~ubuntu-branches/ubuntu/utopic/devscripts/utopic

« back to all changes in this revision

Viewing changes to scripts/cowpoke.sh

  • Committer: Package Import Robot
  • Author(s): James McCoy, Benjamin Drung, Guillem Jover, Paul Wise, James McCoy, Christoph Berg, Ron Lee, David Prévot
  • Date: 2014-08-04 22:34:17 UTC
  • mfrom: (10.10.12 sid)
  • Revision ID: package-import@ubuntu.com-20140804223417-jzo8pb55dujbihud
Tags: 2.14.6
[ Benjamin Drung ]
* suspicious-source: Add image/tiff, application/pgp-keys, and image/x-icon
  to whitelisted mime-types. Add .gmo to whitelisted file extensions.
* wrap-and-sort: Add --max-line-length option with a default of 79 characters
  (it was previously hard-coded to 80 characters).  (Closes: #756067)

[ Guillem Jover ]
* nmudiff: Send control messages inline.  (Closes: #752152)

[ Paul Wise ]
* rmadison: bpo madison is dead, remove it
* rmadison: add new to the defaults for Debian
* rmadison: document the defaults in the manual page

[ James McCoy ]
* namecheck: Remove berlios, since it no longer hosts code.  (Closes:
  #752382)
* mk-build-deps:
  + Provide the package name, not file name, to “dpkg --remove” when package
    install fails.
  + Read all of the output from “apt-cache showsrc” to ensure mk-build-deps
    doesn't get stuck waiting for apt-cache to exit.
  + Pass the name of the .deb file out of build_equiv to ensure the correct
    .deb is installed.  (Closes: #753657)

[ Christoph Berg ]
* Update all qa.debian.org URLs to https://.

[ Ron Lee ]
* cowpoke:
  + Allow more flexibility for specialised build chroots.
    It's now possible to specify arbitrary 'dist' names, with arbitrary
    special configurations on top of the real BASE_DIST suite.  This means
    it's easy to have things like a chroot for wheezy-backports which will
    be able to pull other deps from the backports repo, while still having
    a pristine wheezy build chroot on the same build host.  Or to have a
    staging chroot for unstable, with extra build deps pulled in from a
    local repository, or installed manually, while still having a pristine
    sid chroot for building other packages to upload.  And it all works the
    same as normal, you just pass --dist=wheezy_bpo to select the chroot.
  + Allow SIGN_KEYID and UPLOAD_QUEUE to be overridden per arch/dist.
    This makes a lot more sense now that the above is easily possible.
    People can use that for private or work (in progress) builds too, and
    this can reduce the chance of accidentally uploading to the wrong place,
    or signing some package not intended for upload with a key that would
    would let it be accepted by dak.
  + Better handling of --debbuildopts.  There were some corner cases for
    this where the required quoting of options could be rather weird in the
    intersection of all the layers it might get passed through. This should
    make it more forgiving and better able to always DTRT.

[ David Prévot ]
* uscan.1: Use +dfsg suffix in examples

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
# Simple shell script for driving a remote cowbuilder via ssh
3
3
#
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.
6
6
 
7
7
set -e
28
28
 
29
29
get_archdist_vars()
30
30
{
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"
34
34
 
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}[@]}\" )"
 
39
 
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")"
41
 
                    else
42
 
                        echo "   ${arch}_${dist}_${var} = $(eval echo "\$${arch}_${dist}_${var}")"
43
 
                    fi
 
41
                    case $var in
 
42
                        RESULT_DIR | BASE_PATH )
 
43
                            [ ${#val[@]} -gt 0 ] || eval "val=\"$PBUILDER_BASE/$arch/$dist/\$_$var\""
 
44
                            echo "   ${arch}_${dist}_${var} = $val"
 
45
                            ;;
 
46
 
 
47
                        *_OPTS )
 
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[@]}")"
 
52
                            ;;
 
53
 
 
54
                        * )
 
55
                            [ ${#val[@]} -eq 0 ] || echo "   ${arch}_${dist}_${var} = $val"
 
56
                            ;;
 
57
                    esac
44
58
                else
45
 
                    if [ -z "$(eval echo "\$${arch}_${dist}_${var}")" ]; then
46
 
                        echo "${arch}_${dist}_${var}=\"$PBUILDER_BASE/$arch/$dist/$(eval echo "\$_$var")\""
47
 
                    else
48
 
                        echo "${arch}_${dist}_${var}=\"$(eval echo "\$${arch}_${dist}_${var}")\""
49
 
                    fi
 
59
                    case $var in
 
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'"
 
65
                            ;;
 
66
 
 
67
                        *_OPTS )
 
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.
 
70
                            #
 
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[@]}") )"
 
75
                            ;;
 
76
 
 
77
                        SIGN_KEYID | UPLOAD_QUEUE )
 
78
                            # We don't need these in the remote script
 
79
                            ;;
 
80
 
 
81
                        * )
 
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'"
 
85
                            ;;
 
86
                    esac
50
87
                fi
51
88
            done
52
89
        done
53
90
    done
54
91
}
55
92
 
 
93
display_override_vars()
 
94
{
 
95
    _OVERRIDE_OPTIONS="CREATE_OPTS UPDATE_OPTS BUILD_OPTS"
 
96
 
 
97
    for var in $_OVERRIDE_OPTIONS; do
 
98
        eval "override=( \"\${OVERRIDE_${var}[@]}\" )"
 
99
        [ ${#override[@]} -eq 0 ] || echo "   $var =$(printf " '%s'" "${override[@]}")"
 
100
    done
 
101
}
 
102
 
 
103
 
56
104
PROGNAME="$(basename $0)"
57
105
version ()
58
106
{
59
107
    echo \
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."
87
135
 
88
136
  The current default configuration is:
89
137
 
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
95
145
 
96
146
  The expected remote paths are:
97
147
 
99
149
   PBUILDER_BASE = ${PBUILDER_BASE:-/}
100
150
 
101
151
$(get_archdist_vars display)
 
152
$(display_override_vars)
102
153
 
103
154
  The cowbuilder image must have already been created on the build host
104
155
  and the expected remote paths must already exist if the --create option
148
199
            ;;
149
200
 
150
201
        --dpkg-opts=*)
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
 
211
            # shell ...
 
212
            #
 
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.
 
219
            #
 
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.
 
224
            val=${arg#*=}
 
225
            [[ $val == \'*\' || $val == \"*\" ]] && val=${val:1:-1}
 
226
            DEBBUILDOPTS+=( "$val" )
 
227
            ;;
 
228
 
 
229
        --create-opts=*)
 
230
            OVERRIDE_CREATE_OPTS+=( "${arg#*=}" )
 
231
            ;;
 
232
 
 
233
        --update-opts=*)
 
234
            OVERRIDE_UPDATE_OPTS+=( "${arg#*=}" )
 
235
            ;;
 
236
 
 
237
        --build-opts=*)
 
238
            OVERRIDE_BUILD_OPTS+=( "${arg#*=}" )
152
239
            ;;
153
240
 
154
241
        *.dsc)
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[@]}\" )"
 
336
 
 
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[*]}")
 
342
 
245
343
 
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"
287
386
                else
288
387
                    echo "SKIPPING \$dist/\$arch build, '\$BASE_PATH' does not exist" | tee "\$LOGFILE"
290
389
                    continue
291
390
                fi
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"
297
398
            fi
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"          \\
302
 
                                       $DEBBUILDOPTS                         \\
 
403
                                       "\${DEBBUILDOPTS[@]}"                 \\
 
404
                                       "\${BUILD_OPTS[@]}"                   \\
303
405
                                       "$INCOMING_DIR/$(basename $DSC)" 2>&1 \\
304
406
            | tee "\$LOGFILE"
305
407
 
337
439
echo
338
440
echo "Build completed."
339
441
 
340
 
if [ -n "$SIGN_KEYID" ]; then
341
 
    for arch in $BUILDD_ARCH; do
342
 
      CHANGES="$arch.changes"
343
 
      for dist in $BUILDD_DIST; do
344
 
 
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
 
445
 
 
446
        eval "sign_keyid=\"\$${arch}_${dist}_SIGN_KEYID\""
 
447
        [ -n "$sign_keyid" ] || sign_keyid="$SIGN_KEYID"
 
448
        [ -n "$sign_keyid" ] || continue
 
449
 
 
450
        eval "RESULT_DIR=\"\$${arch}_${dist}_RESULT_DIR\""
346
451
        [ -n "$RESULT_DIR" ] || RESULT_DIR="$PBUILDER_BASE/$arch/$dist/result"
347
452
 
348
453
        _desc="$dist/$arch"
349
454
        [ "$dist" != "default" ] || _desc="$arch"
350
455
 
351
456
        while true; do
352
 
            echo -n "Sign $_desc $PACKAGE with key '$SIGN_KEYID' (yes/no)? "
 
457
            echo -n "Sign $_desc $PACKAGE with key '$sign_keyid' (yes/no)? "
353
458
            read -e yesno
354
459
            case "$yesno" in
355
460
                YES | yes)
356
 
                    debsign "-k$SIGN_KEYID" -r "$BUILDD_USER$BUILDD_HOST" "$RESULT_DIR/${PACKAGE}_$CHANGES"
357
 
 
358
 
                    if [ -n "$UPLOAD_QUEUE" ]; then
 
461
                    debsign "-k$sign_keyid" -r "$BUILDD_USER$BUILDD_HOST" "$RESULT_DIR/${PACKAGE}_$CHANGES"
 
462
 
 
463
                    eval "upload_queue=\"\$${arch}_${dist}_UPLOAD_QUEUE\""
 
464
                    [ -n "$upload_queue" ] || upload_queue="$UPLOAD_QUEUE"
 
465
 
 
466
                    if [ -n "$upload_queue" ]; then
359
467
                        while true; do
360
 
                            echo -n "Upload $_desc $PACKAGE to '$UPLOAD_QUEUE' (yes/no)? "
 
468
                            echo -n "Upload $_desc $PACKAGE to '$upload_queue' (yes/no)? "
361
469
                            read -e upload
362
470
                            case "$upload" in
363
471
                                YES | yes)
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\""
366
474
                                    break 2
367
475
                                    ;;
368
476
 
388
496
                    ;;
389
497
            esac
390
498
        done
391
 
 
392
 
      done
393
499
    done
394
 
fi
 
500
done
395
501
 
396
502
if [ -n "$RETURN_DIR" ]; then
397
503
    for arch in $BUILDD_ARCH; do
398
504
      CHANGES="$arch.changes"
399
505
      for dist in $BUILDD_DIST; do
400
506
 
401
 
        RESULT_DIR=$(eval echo "\$${arch}_${dist}_RESULT_DIR")
 
507
        eval "RESULT_DIR=\"\$${arch}_${dist}_RESULT_DIR\""
402
508
        [ -n "$RESULT_DIR" ] || RESULT_DIR="$PBUILDER_BASE/$arch/$dist/result"
403
509
 
404
510