forked from fullstaq-ruby/server-edition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-common-rpm
executable file
·95 lines (82 loc) · 2.09 KB
/
build-common-rpm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
set -e
SELFDIR=$(dirname "$0")
SELFDIR=$(cd "$SELFDIR" && pwd)
# shellcheck source=lib/library.sh
source "$SELFDIR/lib/library.sh"
OUTPUT_PATH=
VERSION=1.0
REVISION=0
function usage()
{
echo "Usage: ./build-rbenv-rpm <OPTIONS>"
echo "Build the fullstaq-ruby-common RPM package."
echo
echo "Required options:"
echo " -o PATH Path to output package file"
echo
echo "Optional options:"
echo " -v REVISION Package version number (default: $VERSION)"
echo " -r REVISION Package revision number (default: $REVISION)"
echo " -h Show usage"
}
function parse_options()
{
local OPTIND=1
local ORIG_ARGV
local opt
while getopts "o:v:r:h" opt; do
case "$opt" in
o)
OUTPUT_PATH=$(absolute_path "$OPTARG")
;;
v)
VERSION="$OPTARG"
;;
r)
REVISION="$OPTARG"
;;
h)
usage
exit
;;
*)
return 1
;;
esac
done
(( OPTIND -= 1 )) || true
shift $OPTIND || true
ORIG_ARGV=("$@")
if [[ "$OUTPUT_PATH" = "" ]]; then
echo 'ERROR: please specify an output package path with -o.' >&2
exit 1
fi
}
parse_options "$@"
if tty -s; then
TTY_ARGS=(-t -i)
else
TTY_ARGS=()
fi
IMAGE_VERSION=$(read_single_value_file "$SELFDIR/environments/utility/image_tag")
OUTPUT_TEMP_PATH=$(mktemp "$OUTPUT_PATH.XXXXXX")
create_file_if_missing "$OUTPUT_TEMP_PATH"
echo '--- Entering Docker container ---'
function _cleanup() {
echo
echo '--- Exited Docker container ---'
run rm -f "$OUTPUT_TEMP_PATH"
}
verbose_run docker run --rm --init "${TTY_ARGS[@]}" \
-v "$SELFDIR:/system:ro" \
-v "$OUTPUT_TEMP_PATH:/output/common.rpm" \
-e "VERSION=$VERSION" \
-e "REVISION=$REVISION" \
--user "$(id -u):$(id -g)" \
"fullstaq/ruby-build-env-utility:$IMAGE_VERSION" \
/system/container-entrypoints/build-common-rpm
function _cleanup() {
echo '--- Exited Docker container ---'
run mv "$OUTPUT_TEMP_PATH" "$OUTPUT_PATH"
}