forked from fullstaq-ruby/server-edition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-debs
executable file
·117 lines (106 loc) · 2.8 KB
/
upload-debs
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
set -e
SELFDIR=$(dirname "$0")
SELFDIR=$(cd "$SELFDIR" && pwd)
# shellcheck source=../lib/library.sh
source "$SELFDIR/lib/library.sh"
API_USERNAME=
API_KEY_PATH=
CONCURRENCY=4
DRY_RUN=false
REPO_NAME=fullstaq-ruby-apt
REPUBLISH=false
FILES=()
function usage()
{
echo "Usage: ./upload-debs <OPTIONS> <FILES...>"
echo "Upload DEB packages to Fullstaq Ruby's official APT server."
echo
echo "Required options:"
echo " -u Bintray API username"
echo " -k Path to Bintray API key file"
echo
echo "Optional options:"
echo " -j NUM Upload concurrency (default: $CONCURRENCY)"
echo " -R Dry run: don't actually upload"
echo " -n Repository name to upload to (default: fullstaq-ruby-apt)"
echo " -f Re-publish already published package"
echo " -h Show usage"
}
function parse_options()
{
local OPTIND=1
local ORIG_ARGV
local opt
while getopts "u:k:j:Rn:fh" opt; do
case "$opt" in
u)
API_USERNAME="$OPTARG"
;;
k)
API_KEY_PATH=$(absolute_path "$OPTARG")
;;
j)
CONCURRENCY="$OPTARG"
;;
R)
DRY_RUN=true
;;
n)
REPO_NAME="$OPTARG"
;;
f)
REPUBLISH=true
;;
h)
usage
exit
;;
*)
return 1
;;
esac
done
(( OPTIND -= 1 )) || true
shift $OPTIND || true
ORIG_ARGV=("$@")
if [[ "$API_USERNAME" = "" ]]; then
echo 'ERROR: please specify a Bintray API username with -u.' >&2
exit 1
fi
if [[ "$API_KEY_PATH" = "" ]]; then
echo 'ERROR: please specify a Bintray API key file path with -k.' >&2
exit 1
fi
if [[ $# -eq 0 ]]; then
echo 'ERROR: please specify one or more DEB files to upload.' >&2
exit 1
fi
FILES=("$@")
}
parse_options "$@"
if tty -s; then
TTY_ARGS=(-t -i)
else
TTY_ARGS=()
fi
UTILITY_IMAGE_VERSION=$(read_single_value_file "$SELFDIR/environments/utility/image_tag")
MOUNT_ARGS=()
for F in "${FILES[@]}"; do
ABS_PATH=$(absolute_path "$F")
MOUNT_ARGS+=(-v "$ABS_PATH:/input/$ABS_PATH:ro")
done
echo '--- Entering main Docker container ---'
verbose_run docker run --rm --init "${TTY_ARGS[@]}" \
-v "$SELFDIR:/system:ro" \
-v "$API_KEY_PATH:/bintray_api_key.txt:ro" \
"${MOUNT_ARGS[@]}" \
-e "API_USERNAME=$API_USERNAME" \
-e "CONCURRENCY=$CONCURRENCY" \
-e "DRY_RUN=$DRY_RUN" \
-e "REPO_NAME=$REPO_NAME" \
-e "REPUBLISH=$REPUBLISH" \
-e "IGNORE_EXISTING=false" \
--user "$(id -u):$(id -g)" \
"fullstaq/ruby-build-env-utility:$UTILITY_IMAGE_VERSION" \
/system/container-entrypoints/upload-debs