2
2
# Simple shell script for driving a remote cowbuilder via ssh
4
# Copyright(C) 2007, 2008, 2009, Ron <ron@debian.org>
4
# Copyright(C) 2007, 2008, 2009, 2011, 2012, 2014, Ron <ron@debian.org>
5
5
# This script is distributed according to the terms of the GNU GPL.
29
29
get_archdist_vars()
31
_ARCHDIST_OPTIONS="RESULT_DIR BASE_PATH"
31
_ARCHDIST_OPTIONS="RESULT_DIR BASE_PATH BASE_DIST CREATE_OPTS UPDATE_OPTS BUILD_OPTS SIGN_KEYID UPLOAD_QUEUE"
32
32
_RESULT_DIR="result"
33
33
_BASE_PATH="base.cow"
35
35
for arch in $BUILDD_ARCH; do
36
36
for dist in $BUILDD_DIST; do
37
37
for var in $_ARCHDIST_OPTIONS; do
38
eval "val=( \"\${${arch}_${dist}_${var}[@]}\" )"
38
40
if [ "$1" = "display" ]; then
39
if [ -z "$(eval echo "\$${arch}_${dist}_${var}")" ]; then
40
echo " ${arch}_${dist}_${var} = $PBUILDER_BASE/$arch/$dist/$(eval echo "\$_$var")"
42
echo " ${arch}_${dist}_${var} = $(eval echo "\$${arch}_${dist}_${var}")"
42
RESULT_DIR | BASE_PATH )
43
[ ${#val[@]} -gt 0 ] || eval "val=\"$PBUILDER_BASE/$arch/$dist/\$_$var\""
44
echo " ${arch}_${dist}_${var} = $val"
48
# Don't display these if they are overridden on the command line.
49
eval "override=( \"\${OVERRIDE_${var}[@]}\" )"
50
[ ${#override[@]} -gt 0 ] || [ ${#val[@]} -eq 0 ] ||
51
echo " ${arch}_${dist}_${var} =$(printf " '%s'" "${val[@]}")"
55
[ ${#val[@]} -eq 0 ] || echo " ${arch}_${dist}_${var} = $val"
45
if [ -z "$(eval echo "\$${arch}_${dist}_${var}")" ]; then
46
echo "${arch}_${dist}_${var}=\"$PBUILDER_BASE/$arch/$dist/$(eval echo "\$_$var")\""
48
echo "${arch}_${dist}_${var}=\"$(eval echo "\$${arch}_${dist}_${var}")\""
60
RESULT_DIR | BASE_PATH )
61
# These are always a single value, and must always be set,
62
# either by the user or to their default value.
63
[ ${#val[@]} -gt 0 ] || eval "val=\"$PBUILDER_BASE/$arch/$dist/\$_$var\""
64
echo "${arch}_${dist}_${var}='$val'"
68
# These may have zero, one, or many values which we must not word-split.
69
# They can safely remain unset if there are no values.
71
# We don't need to worry about the command line overrides here,
72
# they will be taken care of in the remote script.
73
[ ${#val[@]} -eq 0 ] ||
74
echo "${arch}_${dist}_${var}=($(printf " %q" "${val[@]}") )"
77
SIGN_KEYID | UPLOAD_QUEUE )
78
# We don't need these in the remote script
82
# These may have zero or one value.
83
# They can safely remain unset if there are no values.
84
[ ${#val[@]} -eq 0 ] || echo "${arch}_${dist}_${var}='$val'"
93
display_override_vars()
95
_OVERRIDE_OPTIONS="CREATE_OPTS UPDATE_OPTS BUILD_OPTS"
97
for var in $_OVERRIDE_OPTIONS; do
98
eval "override=( \"\${OVERRIDE_${var}[@]}\" )"
99
[ ${#override[@]} -eq 0 ] || echo " $var =$(printf " '%s'" "${override[@]}")"
56
104
PROGNAME="$(basename $0)"
60
108
"This is $PROGNAME, from the Debian devscripts package, version ###VERSION###
61
This code is copyright 2007-9 by Ron <ron@debian.org>, all rights reserved.
109
This code is Copyright 2007-2014, Ron <ron@debian.org>.
62
110
This program comes with ABSOLUTELY NO WARRANTY.
63
111
You are free to redistribute this code under the terms of the
64
112
GNU General Public License."
88
136
The current default configuration is:
90
BUILDD_HOST = $BUILDD_HOST
91
BUILDD_USER = $BUILDD_USER
92
BUILDD_ARCH = $BUILDD_ARCH
93
BUILDD_DIST = $BUILDD_DIST
94
RETURN_DIR = $RETURN_DIR
138
BUILDD_HOST = $BUILDD_HOST
139
BUILDD_USER = $BUILDD_USER
140
BUILDD_ARCH = $BUILDD_ARCH
141
BUILDD_DIST = $BUILDD_DIST
142
RETURN_DIR = $RETURN_DIR
143
SIGN_KEYID = $SIGN_KEYID
144
UPLOAD_QUEUE = $UPLOAD_QUEUE
96
146
The expected remote paths are:
151
DEBBUILDOPTS="--debbuildopts \"${arg#*=}\""
202
# This one is a bit tricky, given the combination of the calling convention here,
203
# the calling convention for cowbuilder, and the behaviour of things that might
204
# pass this option to us. Some things, like when we are called from the gitpkg
205
# hook using options from git-config, will preserve any quoting that was used in
206
# the .gitconfig file, which is natural for anyone to want to use in a construct
207
# like: options = --dpkg-opts='-uc -us -j6'. People are going to cringe if we
208
# tell them they must not use quotes there no matter how much it may 'make sense'
209
# if you know too much about the internals. And it will only get worse when we
210
# then tell them they must quote it like that if they type it directly in their
213
# So we do the only thing that seems sensible, and try to Deal With It here.
214
# If the outermost characters are paired quotes, we manually strip them off.
215
# We don't want to let the shell do quote removal, since that might change a
216
# part of this which we don't want modified.
217
# We collect however many sets of those we are passed in an array, which we'll
218
# then combine back into a single argument at the final point of use.
220
# Which _should_ DTRT for anyone who isn't trying to blow this up deliberately
221
# any maybe will still do it for them too in spite of their efforts. But unless
222
# someone finds a sensible case this fails on, I'm not going to cry over people
223
# who want to stuff up their own system with input they created themselves.
225
[[ $val == \'*\' || $val == \"*\" ]] && val=${val:1:-1}
226
DEBBUILDOPTS+=( "$val" )
230
OVERRIDE_CREATE_OPTS+=( "${arg#*=}" )
234
OVERRIDE_UPDATE_OPTS+=( "${arg#*=}" )
238
OVERRIDE_BUILD_OPTS+=( "${arg#*=}" )
240
327
CHANGES="\$arch.changes"
241
328
LOGFILE="$INCOMING_DIR/build.${PACKAGE}_\$arch.\$dist.log"
242
329
UPDATELOG="$INCOMING_DIR/cowbuilder-\${arch}-\${dist}-update-log-$DATE"
243
RESULT_DIR="\$(eval echo "\\\$\${arch}_\${dist}_RESULT_DIR")"
244
BASE_PATH="\$(eval echo "\\\$\${arch}_\${dist}_BASE_PATH")"
330
eval "RESULT_DIR=\"\\\$\${arch}_\${dist}_RESULT_DIR\""
331
eval "BASE_PATH=\"\\\$\${arch}_\${dist}_BASE_PATH\""
332
eval "BASE_DIST=\"\\\$\${arch}_\${dist}_BASE_DIST\""
333
eval "CREATE_OPTS=( \"\\\${\${arch}_\${dist}_CREATE_OPTS[@]}\" )"
334
eval "UPDATE_OPTS=( \"\\\${\${arch}_\${dist}_UPDATE_OPTS[@]}\" )"
335
eval "BUILD_OPTS=( \"\\\${\${arch}_\${dist}_BUILD_OPTS[@]}\" )"
337
[ -n "\$BASE_DIST" ] || BASE_DIST=\$dist
338
[ ${#OVERRIDE_CREATE_OPTS[@]} -eq 0 ] || CREATE_OPTS=("${OVERRIDE_CREATE_OPTS[@]}")
339
[ ${#OVERRIDE_UPDATE_OPTS[@]} -eq 0 ] || UPDATE_OPTS=("${OVERRIDE_UPDATE_OPTS[@]}")
340
[ ${#OVERRIDE_BUILD_OPTS[@]} -eq 0 ] || BUILD_OPTS=("${OVERRIDE_BUILD_OPTS[@]}")
341
[ ${#DEBBUILDOPTS[*]} -eq 0 ] || DEBBUILDOPTS=("--debbuildopts" "${DEBBUILDOPTS[*]}")
246
344
# Sort the list of old changes files for this package to try and
247
345
# determine the most recent one preceding this version. We will
278
376
mkdir -p "\$RESULT_DIR"
279
377
mkdir -p "\$(dirname \$BASE_PATH)"
280
378
mkdir -p "$PBUILDER_BASE/aptcache"
281
$BUILDD_ROOTCMD cowbuilder --create --distribution \$dist \\
379
$BUILDD_ROOTCMD cowbuilder --create --distribution \$BASE_DIST \\
282
380
--basepath "\$BASE_PATH" \\
283
381
--aptcache "$PBUILDER_BASE/aptcache" \\
284
382
--debootstrap "$DEBOOTSTRAP" \\
285
383
--debootstrapopts --arch="\$arch" \\
384
"\${CREATE_OPTS[@]}" \\
286
385
2>&1 | tee "\$UPDATELOG"
288
387
echo "SKIPPING \$dist/\$arch build, '\$BASE_PATH' does not exist" | tee "\$LOGFILE"
292
391
elif ! [ -e "\$UPDATELOG" ]; then
293
$BUILDD_ROOTCMD cowbuilder --update --basepath "\$BASE_PATH" \\
392
$BUILDD_ROOTCMD cowbuilder --update --distribution \$BASE_DIST \\
393
--basepath "\$BASE_PATH" \\
294
394
--aptcache "$PBUILDER_BASE/aptcache" \\
295
395
--autocleanaptcache \\
396
"\${UPDATE_OPTS[@]}" \\
296
397
2>&1 | tee "\$UPDATELOG"
298
399
$BUILDD_ROOTCMD cowbuilder --build --basepath "\$BASE_PATH" \\
299
400
--aptcache "$PBUILDER_BASE/aptcache" \\
300
401
--buildplace "$PBUILDER_BASE/build" \\
301
402
--buildresult "\$RESULT_DIR" \\
403
"\${DEBBUILDOPTS[@]}" \\
404
"\${BUILD_OPTS[@]}" \\
303
405
"$INCOMING_DIR/$(basename $DSC)" 2>&1 \\
304
406
| tee "\$LOGFILE"
338
440
echo "Build completed."
340
if [ -n "$SIGN_KEYID" ]; then
341
for arch in $BUILDD_ARCH; do
342
CHANGES="$arch.changes"
343
for dist in $BUILDD_DIST; do
345
RESULT_DIR="$(eval echo "\$${arch}_${dist}_RESULT_DIR")"
442
for arch in $BUILDD_ARCH; do
443
CHANGES="$arch.changes"
444
for dist in $BUILDD_DIST; do
446
eval "sign_keyid=\"\$${arch}_${dist}_SIGN_KEYID\""
447
[ -n "$sign_keyid" ] || sign_keyid="$SIGN_KEYID"
448
[ -n "$sign_keyid" ] || continue
450
eval "RESULT_DIR=\"\$${arch}_${dist}_RESULT_DIR\""
346
451
[ -n "$RESULT_DIR" ] || RESULT_DIR="$PBUILDER_BASE/$arch/$dist/result"
348
453
_desc="$dist/$arch"
349
454
[ "$dist" != "default" ] || _desc="$arch"
352
echo -n "Sign $_desc $PACKAGE with key '$SIGN_KEYID' (yes/no)? "
457
echo -n "Sign $_desc $PACKAGE with key '$sign_keyid' (yes/no)? "
356
debsign "-k$SIGN_KEYID" -r "$BUILDD_USER$BUILDD_HOST" "$RESULT_DIR/${PACKAGE}_$CHANGES"
358
if [ -n "$UPLOAD_QUEUE" ]; then
461
debsign "-k$sign_keyid" -r "$BUILDD_USER$BUILDD_HOST" "$RESULT_DIR/${PACKAGE}_$CHANGES"
463
eval "upload_queue=\"\$${arch}_${dist}_UPLOAD_QUEUE\""
464
[ -n "$upload_queue" ] || upload_queue="$UPLOAD_QUEUE"
466
if [ -n "$upload_queue" ]; then
360
echo -n "Upload $_desc $PACKAGE to '$UPLOAD_QUEUE' (yes/no)? "
468
echo -n "Upload $_desc $PACKAGE to '$upload_queue' (yes/no)? "
362
470
case "$upload" in
364
472
ssh "$BUILDD_USER$BUILDD_HOST" \
365
"cd \"$RESULT_DIR/\" && dput \"$UPLOAD_QUEUE\" \"${PACKAGE}_$CHANGES\""
473
"cd \"$RESULT_DIR/\" && dput \"$upload_queue\" \"${PACKAGE}_$CHANGES\""