[devscripts] 01/01: Allow more flexibility for specialised build chroots

Ron Lee ron at moszumanska.debian.org
Mon Jul 7 03:25:18 UTC 2014


This is an automated email from the git hooks/post-receive script.

ron pushed a commit to branch master
in repository devscripts.

commit 396671470242827a73dc55f71cee9714df00d5d0
Author: Ron <ron at debian.org>
Date:   Mon Jul 7 12:52:42 2014 +0930

    Allow more flexibility for specialised build chroots
    
    Debian now has backports archives as an Official Thing, and sometimes
    packages which are to be built for them depend on other packages that
    are already in them.  But they aren't fully fledged suites in their
    own right, so setting up a cowbuilder chroot for them isn't the same
    as for an ordinary release.  Rather it has more in common with having
    a local repository of extra packages for a given suite.
    
    Since cowpoke has until now required 'dist' to be a real suite that
    debootstrap recognised, that made it a bit awkward to have both a
    pristine chroot for normal package builds intended for upload to one
    of the official suites, and a 'special' chroot with extra packages
    or some other oddball configuration, on the same build host if the
    needed suites overlapped.  So we add the concept of a BASE_DIST now
    and decouple the 'dist' name from the official suites, which means
    you are able to define as many chroots as you please, with whatever
    configuration you please, without having to destroy and remake them
    when you need a pristine one again for some suite.
    
    We also add options to allow arbitrary cowbuilder/pbuilder options
    to be passed through during the --create, --update, and --build
    phases of its operation.  Which makes the otherwise tedious task of
    adding additional repositories or packages, or build options, just
    as trivial as any normal use of cowpoke is.
    
    Allow SIGN_KEYID and UPLOAD_QUEUE to be per arch/dist too
    
    Since now that it's trivial to have multiple chroot flavours, and we
    aren't all that far from people all having their own Probably Putrid
    archives to upload to, and since that's already something many people
    do for private or work (in progress) packages, it makes sense to make
    that easier to not screw up.  We really don't want people uploading
    bogus packages to the distro proper accidentally, or signing packages
    with their distro key that aren't intended for upload to it either
    just because doing something other than that is A Bit Of A Hassle.
    
    We still don't ever offer to upload unsigned packages at all, the game
    here is to make doing The Right Thing easier than not doing it. If you
    really want to be stupid, you're going to have to work for that still.
    
    Better handling of --debbuildopts
    
    By the power of arrays vested in me, we avoid a few of the stranger ways
    which this might choke on the input of an unsuspecting, but otherwise
    well meaning, innocent user.  You'd probably have to try pretty hard to
    hit this directly from the command line, but once we start to get called
    from other layers of automation, all bets were off for sensible input at
    the far end still looking as sensible once it finally got to dpkg-bp.
---
 cowpoke.conf       |  42 +++++++++++++
 debian/changelog   |  23 +++++++
 scripts/cowpoke.1  | 113 +++++++++++++++++++++++++++++++--
 scripts/cowpoke.sh | 179 ++++++++++++++++++++++++++++++++++++++++++-----------
 4 files changed, 314 insertions(+), 43 deletions(-)

diff --git a/cowpoke.conf b/cowpoke.conf
index 2a2a7cc..c11400b 100644
--- a/cowpoke.conf
+++ b/cowpoke.conf
@@ -75,6 +75,45 @@ BUILDD_HOST=
 #
 # $arch_$dist_BASE_PATH   - The directory where the COW master files are found.
 #
+# $arch_$dist_BASE_DIST   - The code name to pass as the --distribution option
+#                           for cowbuilder instead of $dist. This is necessary
+#                           when $dist is a locally significant name assigned
+#                           to some specially configured build chroot, such as
+#                           'wheezy_backports', and not the formal suite name
+#                           of a distro release known to debootstrap.
+#
+# $arch_$dist_CREATE_OPTS - A bash array containing additional options to pass
+#                           verbatim to cowbuilder when this chroot is created
+#                           for the first time (using the --create option).
+#                           This is useful when options like --othermirror are
+#                           wanted to create specialised chroot configurations
+#                           such as 'wheezy_backports'.
+#
+# $arch_$dist_UPDATE_OPTS - A bash array containing additional options to pass
+#                           verbatim to cowbuilder each time the base of this
+#                           chroot is updated.
+#
+# $arch_$dist_BUILD_OPTS  - A bash array containing additional options to pass
+#                           verbatim to cowbuilder each time a package build is
+#                           performed in this chroot.  This is useful when you
+#                           want to use some option like --twice which cowpoke
+#                           does not directly need to care about.
+#
+# Each element in these arrays corresponds to a single argument (in the ARGV
+# sense) that will be passed to cowbuilder.  This ensures that arguments which
+# may contain whitespace or have strange quoting requirements or other special
+# characters will not be mangled before they get to cowbuilder.
+#
+# Bash arrays are initialised using the following form:
+#    VARIABLE=( "arg1" "arg 2" "--option" "value" "--opt=val" "etc. etc." )
+#
+#
+# $arch_$dist_SIGN_KEYID      - An optional arch and dist specific override for
+#                               the global SIGN_KEYID option.
+#
+# $arch_$dist_UPLOAD_QUEUE    - An optional arch and dist specific override for
+#                               the global UPLOAD_QUEUE option.
+#
 # -----------------------------------------------------------------------------
 
 #amd64_unstable_RESULT_DIR="$PBUILDER_BASE/amd64/unstable/result"
@@ -89,3 +128,6 @@ BUILDD_HOST=
 #i386_experimental_RESULT_DIR="$PBUILDER_BASE/i386/experimental/result"
 #i386_experimental_BASE_PATH="$PBUILDER_BASE/i386/experimental/base.cow"
 
+#amd64_wheezy_bpo_BASE_DIST="wheezy"
+#amd64_wheezy_bpo_CREATE_OPTS=(--othermirror "deb http://ftp.debian.org/debian wheezy-backports main")
+
diff --git a/debian/changelog b/debian/changelog
index e466c1d..7de081f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,29 @@ devscripts (2.14.6) UNRELEASED; urgency=medium
   [ 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.
+
  -- Christoph Berg <christoph.berg at credativ.de>  Thu, 03 Jul 2014 11:32:00 +0200
 
 devscripts (2.14.5) unstable; urgency=medium
diff --git a/scripts/cowpoke.1 b/scripts/cowpoke.1
index 2b825d4..df7fcda 100644
--- a/scripts/cowpoke.1
+++ b/scripts/cowpoke.1
@@ -45,6 +45,14 @@ codenames (such as \fBsid\fP, or \fBsqueeze\fP) or distribution names (such as
 to using one or the other consistently as this name may be used in file paths
 and to locate old packages for comparison reporting.
 
+It is now also possible to use locally defined names with this option, when
+used in conjunction with the \fBBASE_DIST\fP option in a configuration file.
+This permits the maintenance and use of specially configured build chroots,
+which can source package dependencies from the backports archives or a local
+repository, or have other unusual configuration options set, without polluting
+the chroots you use for clean package builds intended for upload to the main
+repositories.  See the description of \fBBASE_DIST\fP below.
+
 .TP
 .BI \-\-buildd= host
 Specify the remote host to build on.
@@ -59,6 +67,11 @@ Create the remote \fBcowbuilder\fR root if it does not already exist.  If this o
 is not passed it is an error for the specified \fB\-\-dist\fP or \fB\-\-arch\fP
 to not have an existing \fBcowbuilder\fR root in the expected location.
 
+The \fB\-\-buildd\-user\fP must have permission to create the \fBRESULT_DIR\fP
+on the build host, or an admin with the necessary permission must first create
+it and give that user (or some group they are in) write access to it, for this
+option to succeed.
+
 .TP
 .BR \-\-return= [ \fIpath ]
 Copy results of the build to \fIpath\fP.  If \fIpath\fP is not specified, then return
@@ -76,6 +89,36 @@ options are delimited with spaces.  This will override any options specified in
 \fBDEBBUILDOPTS\fP in the build host's \fIpbuilderrc\fP.
 
 .TP
+.BI \-\-create\-opts= "'cowbuilder option'"
+Specify additional arguments to be passed verbatim to \fBcowbuilder\fR when a
+chroot is first created (using the \fB\-\-create\fP option above). If multiple
+arguments need to be passed, this option should be specified separately for
+each of them.
+
+eg. \fB\-\-create\-opts "--othermirror" \-\-create\-opts "deb http:// ..."\fP
+
+This option will override any \fBCREATE_OPTS\fP specified for a chroot in the
+cowpoke configuration files.
+
+.TP
+.BI \-\-update\-opts= "'cowbuilder option'"
+Specify additional arguments to be passed verbatim to \fBcowbuilder\fR if the
+base of the chroot is updated.  If multiple arguments need to be passed, this
+option should be specified separately for each of them.
+
+This option will override any \fBUPDATE_OPTS\fP specified for a chroot in the
+cowpoke configuration files.
+
+.TP
+.BI \-\-build\-opts= "'cowbuilder option'"
+Specify additional arguments to be passed verbatim to \fBcowbuilder\fR when
+a package build is performed.  If multiple arguments need to be passed, this
+option should be specified separately for each of them.
+
+This option will override any \fBBUILD_OPTS\fP specified for a chroot in the
+cowpoke configuration files.
+
+.TP
 .B \-\-help
 Display a brief summary of the available options and current configuration.
 
@@ -92,7 +135,7 @@ home directory.  Since the paths are typically quoted when used, tilde expansion
 will \fBnot\fP be performed on them.
 
 .SS Global defaults
-These apply to every arch and dist in a single cowpoke invocation.
+These apply to every \fIarch\fP and \fIdist\fP in a single cowpoke invocation.
 
 .TP
 .B BUILDD_HOST
@@ -123,17 +166,21 @@ The directory path on the build machine where the source package will initially
 be placed.  This must be writable by the \fBBUILDD_USER\fP.
 .TP
 .B PBUILDER_BASE
-The filesystem root for all pbuilder COW and result files.  Arch and dist
+The filesystem root for all pbuilder CoW and result files.  \fIArch\fP and \fIdist\fP
 specific subdirectories will normally be created under this.  The apt cache
 and temporary build directory will also be located under this path.
 
 .TP
 .B SIGN_KEYID
-If this option is set, it is expected to contain the gpg key id to pass to
+If this option is set, it is expected to contain the gpg key ID to pass to
 \fBdebsign\fP(1) if the packages are to be remotely signed.  You will be prompted
 to confirm whether you wish to sign the packages after all builds are complete.
 If this option is unset or an empty string, no attempt to sign packages will be
-made.
+made.  It may be overridden on an \fIarch\fP and \fIdist\fP specific basis using
+the
+.IB arch _ dist _SIGN_KEYID
+option described below.
+
 .TP
 .B UPLOAD_QUEUE
 If this option is set, it is expected to contain a 'host' specification for
@@ -141,6 +188,10 @@ If this option is set, it is expected to contain a 'host' specification for
 be prompted to confirm whether you wish to upload the packages after they are
 signed.  If this option is unset or an empty string, no attempt to upload packages
 will be made.  If \fBSIGN_KEYID\fP is not set, this option will be ignored entirely.
+It may be overridden on an \fIarch\fP and \fIdist\fP specific basis using the
+.IB arch _ dist _UPLOAD_QUEUE
+option described below.
+
 
 .TP
 .B BUILDD_ROOTCMD
@@ -190,15 +241,65 @@ readable by the \fBBUILDD_USER\fP for sanity checking with \fBlintian\fP(1) and
 \fBdebdiff\fP(1), and for upload with \fBdput\fP(1).  If this option is not
 specified for some arch and dist combination then it will default to
 .I $PBUILDER_BASE/$arch/$dist/result
-.
 
 .TP
 .IB arch _ dist _BASE_PATH
-The directory where the COW master files are to be found (or created if the
+The directory where the CoW master files are to be found (or created if the
 \fB\-\-create\fP command line option was passed).  If this option is not specified
 for some arch or dist then it will default to
 .I $PBUILDER_BASE/$arch/$dist/base.cow
 
+.TP
+.IB arch _ dist _BASE_DIST
+The code name to pass as the \fB\-\-distribution\fP option for cowbuilder instead
+of \fIdist\fP.  This is necessary when \fIdist\fP is a locally significant name
+assigned to some specially configured build chroot, such as 'wheezy_backports',
+and not the formal suite name of a distro release known to debootstrap.  This
+option cannot be overridden on the command line, since it would rarely, if ever,
+make any sense to change it for individual invocations of \fBcowpoke\fP. If this
+option is not specified for an arch and dist combination then it will default to
+.IR dist .
+
+.TP
+.IB arch _ dist _CREATE_OPTS
+A bash array containing additional options to pass verbatim to \fBcowbuilder\fP
+when this chroot is created for the first time (using the \fB\-\-create\fP option).
+This is useful when options like \fB\-\-othermirror\fP are wanted to create
+specialised chroot configurations such as 'wheezy_backports'.  By default this
+is unset.  All values set in it will be overridden if the \fB\-\-create\-opts\fP
+option is passed on the command line.
+
+Each element in this array corresponds to a single argument (in the ARGV sense)
+that will be passed to cowbuilder.  This ensures that arguments which may contain
+whitespace or have strange quoting requirements or other special characters will
+not be mangled before they get to cowbuilder.
+
+Bash arrays are initialised using the following form:
+
+    OPTS=( "arg1" "arg 2" "--option" "value" "--opt=val" "etc. etc." )
+
+.TP
+.IB arch _ dist _UPDATE_OPTS
+A bash array containing additional options to pass verbatim to \fBcowbuilder\fP
+each time the base of this chroot is updated.  It behaves similarly to the
+\fBCREATE_OPTS\fP option above, except for acting when the chroot is updated.
+
+.TP
+.IB arch _ dist _BUILD_OPTS
+A bash array containing additional options to pass verbatim to \fBcowbuilder\fP
+each time a package build is performed in this chroot.  This is useful when you
+want to use some option like \fB\-\-twice\fP which cowpoke does not directly
+need to care about.  It otherwise behaves similarly to \fBUPDATE_OPTS\fP above
+except that it acts during the build phase of \fBcowbuilder\fP.
+
+.TP
+.IB arch _ dist _SIGN_KEYID
+An optional arch and dist specific override for the global SIGN_KEYID option.
+
+.TP
+.IB arch _ dist _UPLOAD_QUEUE
+An optional arch and dist specific override for the global UPLOAD_QUEUE option.
+
 
 .SH CONFIGURATION FILES
 .TP
diff --git a/scripts/cowpoke.sh b/scripts/cowpoke.sh
index 303d74d..e1d2422 100755
--- a/scripts/cowpoke.sh
+++ b/scripts/cowpoke.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 # Simple shell script for driving a remote cowbuilder via ssh
 #
-# Copyright(C) 2007, 2008, 2009, Ron <ron at debian.org>
+# Copyright(C) 2007, 2008, 2009, 2011, 2012, 2014, Ron <ron at debian.org>
 # This script is distributed according to the terms of the GNU GPL.
 
 set -e
@@ -28,37 +28,85 @@ for f in /etc/cowpoke.conf ~/.cowpoke .cowpoke "$COWPOKE_CONF"; do [ -r "$f" ] &
 
 get_archdist_vars()
 {
-    _ARCHDIST_OPTIONS="RESULT_DIR BASE_PATH"
+    _ARCHDIST_OPTIONS="RESULT_DIR BASE_PATH BASE_DIST CREATE_OPTS UPDATE_OPTS BUILD_OPTS SIGN_KEYID UPLOAD_QUEUE"
     _RESULT_DIR="result"
     _BASE_PATH="base.cow"
 
     for arch in $BUILDD_ARCH; do
 	for dist in $BUILDD_DIST; do
 	    for var in $_ARCHDIST_OPTIONS; do
+		eval "val=( \"\${${arch}_${dist}_${var}[@]}\" )"
+
 		if [ "$1" = "display" ]; then
-		    if [ -z "$(eval echo "\$${arch}_${dist}_${var}")" ]; then
-			echo "   ${arch}_${dist}_${var} = $PBUILDER_BASE/$arch/$dist/$(eval echo "\$_$var")"
-		    else
-			echo "   ${arch}_${dist}_${var} = $(eval echo "\$${arch}_${dist}_${var}")"
-		    fi
+		    case $var in
+			RESULT_DIR | BASE_PATH )
+			    [ ${#val[@]} -gt 0 ] || eval "val=\"$PBUILDER_BASE/$arch/$dist/\$_$var\""
+			    echo "   ${arch}_${dist}_${var} = $val"
+			    ;;
+
+			*_OPTS )
+			    # Don't display these if they are overridden on the command line.
+			    eval "override=( \"\${OVERRIDE_${var}[@]}\" )"
+			    [ ${#override[@]} -gt 0 ] || [ ${#val[@]} -eq 0 ] ||
+				echo "   ${arch}_${dist}_${var} =$(printf " '%s'" "${val[@]}")"
+			    ;;
+
+			* )
+			    [ ${#val[@]} -eq 0 ] || echo "   ${arch}_${dist}_${var} = $val"
+			    ;;
+		    esac
 		else
-		    if [ -z "$(eval echo "\$${arch}_${dist}_${var}")" ]; then
-			echo "${arch}_${dist}_${var}=\"$PBUILDER_BASE/$arch/$dist/$(eval echo "\$_$var")\""
-		    else
-			echo "${arch}_${dist}_${var}=\"$(eval echo "\$${arch}_${dist}_${var}")\""
-		    fi
+		    case $var in
+			RESULT_DIR | BASE_PATH )
+			    # These are always a single value, and must always be set,
+			    # either by the user or to their default value.
+			    [ ${#val[@]} -gt 0 ] || eval "val=\"$PBUILDER_BASE/$arch/$dist/\$_$var\""
+			    echo "${arch}_${dist}_${var}='$val'"
+			    ;;
+
+			*_OPTS )
+			    # These may have zero, one, or many values which we must not word-split.
+			    # They can safely remain unset if there are no values.
+			    #
+			    # We don't need to worry about the command line overrides here,
+			    # they will be taken care of in the remote script.
+			    [ ${#val[@]} -eq 0 ] ||
+				echo "${arch}_${dist}_${var}=($(printf " %q" "${val[@]}") )"
+			    ;;
+
+			SIGN_KEYID | UPLOAD_QUEUE )
+			    # We don't need these in the remote script
+			    ;;
+
+			* )
+			    # These may have zero or one value.
+			    # They can safely remain unset if there are no values.
+			    [ ${#val[@]} -eq 0 ] || echo "${arch}_${dist}_${var}='$val'"
+			    ;;
+		    esac
 		fi
 	    done
 	done
     done
 }
 
+display_override_vars()
+{
+    _OVERRIDE_OPTIONS="CREATE_OPTS UPDATE_OPTS BUILD_OPTS"
+
+    for var in $_OVERRIDE_OPTIONS; do
+	eval "override=( \"\${OVERRIDE_${var}[@]}\" )"
+	[ ${#override[@]} -eq 0 ] || echo "   $var =$(printf " '%s'" "${override[@]}")"
+    done
+}
+
+
 PROGNAME="$(basename $0)"
 version ()
 {
     echo \
 "This is $PROGNAME, from the Debian devscripts package, version ###VERSION###
-This code is copyright 2007-9 by Ron <ron at debian.org>, all rights reserved.
+This code is Copyright 2007-2014, Ron <ron at debian.org>.
 This program comes with ABSOLUTELY NO WARRANTY.
 You are free to redistribute this code under the terms of the
 GNU General Public License."
@@ -87,11 +135,13 @@ cowpoke [options] package.dsc
 
   The current default configuration is:
 
-   BUILDD_HOST = $BUILDD_HOST
-   BUILDD_USER = $BUILDD_USER
-   BUILDD_ARCH = $BUILDD_ARCH
-   BUILDD_DIST = $BUILDD_DIST
-   RETURN_DIR  = $RETURN_DIR
+   BUILDD_HOST   = $BUILDD_HOST
+   BUILDD_USER   = $BUILDD_USER
+   BUILDD_ARCH   = $BUILDD_ARCH
+   BUILDD_DIST   = $BUILDD_DIST
+   RETURN_DIR    = $RETURN_DIR
+   SIGN_KEYID    = $SIGN_KEYID
+   UPLOAD_QUEUE  = $UPLOAD_QUEUE
 
   The expected remote paths are:
 
@@ -99,6 +149,7 @@ cowpoke [options] package.dsc
    PBUILDER_BASE = ${PBUILDER_BASE:-/}
 
 $(get_archdist_vars display)
+$(display_override_vars)
 
   The cowbuilder image must have already been created on the build host
   and the expected remote paths must already exist if the --create option
@@ -148,7 +199,43 @@ for arg; do
 	    ;;
 
 	--dpkg-opts=*)
-	    DEBBUILDOPTS="--debbuildopts \"${arg#*=}\""
+	    # This one is a bit tricky, given the combination of the calling convention here,
+	    # the calling convention for cowbuilder, and the behaviour of things that might
+	    # pass this option to us.  Some things, like when we are called from the gitpkg
+	    # hook using options from git-config, will preserve any quoting that was used in
+	    # the .gitconfig file, which is natural for anyone to want to use in a construct
+	    # like: options = --dpkg-opts='-uc -us -j6'.  People are going to cringe if we
+	    # tell them they must not use quotes there no matter how much it may 'make sense'
+	    # if you know too much about the internals.  And it will only get worse when we
+	    # then tell them they must quote it like that if they type it directly in their
+	    # shell ...
+	    #
+	    # So we do the only thing that seems sensible, and try to Deal With It here.
+	    # If the outermost characters are paired quotes, we manually strip them off.
+	    # We don't want to let the shell do quote removal, since that might change a
+	    # part of this which we don't want modified.
+	    # We collect however many sets of those we are passed in an array, which we'll
+	    # then combine back into a single argument at the final point of use.
+	    #
+	    # Which _should_ DTRT for anyone who isn't trying to blow this up deliberately
+	    # any maybe will still do it for them too in spite of their efforts. But unless
+	    # someone finds a sensible case this fails on, I'm not going to cry over people
+	    # who want to stuff up their own system with input they created themselves.
+	    val=${arg#*=}
+	    [[ $val == \'*\' || $val == \"*\" ]] && val=${val:1:-1}
+	    DEBBUILDOPTS[${#DEBBUILDOPTS[@]}]=$val
+	    ;;
+
+	--create-opts=*)
+	    OVERRIDE_CREATE_OPTS[${#OVERRIDE_CREATE_OPTS[@]}]="${arg#*=}"
+	    ;;
+
+	--update-opts=*)
+	    OVERRIDE_UPDATE_OPTS[${#OVERRIDE_UPDATE_OPTS[@]}]="${arg#*=}"
+	    ;;
+
+	--build-opts=*)
+	    OVERRIDE_BUILD_OPTS[${#OVERRIDE_BUILD_OPTS[@]}]="${arg#*=}"
 	    ;;
 
 	*.dsc)
@@ -240,8 +327,19 @@ cat > "$REMOTE_SCRIPT" <<-EOF
 	    CHANGES="\$arch.changes"
 	    LOGFILE="$INCOMING_DIR/build.${PACKAGE}_\$arch.\$dist.log"
 	    UPDATELOG="$INCOMING_DIR/cowbuilder-\${arch}-\${dist}-update-log-$DATE"
-	    RESULT_DIR="\$(eval echo "\\\$\${arch}_\${dist}_RESULT_DIR")"
-	    BASE_PATH="\$(eval echo "\\\$\${arch}_\${dist}_BASE_PATH")"
+	    eval "RESULT_DIR=\"\\\$\${arch}_\${dist}_RESULT_DIR\""
+	    eval "BASE_PATH=\"\\\$\${arch}_\${dist}_BASE_PATH\""
+	    eval "BASE_DIST=\"\\\$\${arch}_\${dist}_BASE_DIST\""
+	    eval "CREATE_OPTS=( \"\\\${\${arch}_\${dist}_CREATE_OPTS[@]}\" )"
+	    eval "UPDATE_OPTS=( \"\\\${\${arch}_\${dist}_UPDATE_OPTS[@]}\" )"
+	    eval "BUILD_OPTS=( \"\\\${\${arch}_\${dist}_BUILD_OPTS[@]}\" )"
+
+	    [ -n "\$BASE_DIST" ]                  || BASE_DIST=\$dist
+	    [ ${#OVERRIDE_CREATE_OPTS[@]} -eq 0 ] || CREATE_OPTS=("${OVERRIDE_CREATE_OPTS[@]}")
+	    [ ${#OVERRIDE_UPDATE_OPTS[@]} -eq 0 ] || UPDATE_OPTS=("${OVERRIDE_UPDATE_OPTS[@]}")
+	    [ ${#OVERRIDE_BUILD_OPTS[@]}  -eq 0 ] || BUILD_OPTS=("${OVERRIDE_BUILD_OPTS[@]}")
+	    [ ${#DEBBUILDOPTS[*]} -eq 0 ]         || DEBBUILDOPTS=("--debbuildopts" "${DEBBUILDOPTS[*]}")
+
 
 	    # Sort the list of old changes files for this package to try and
 	    # determine the most recent one preceding this version.  We will
@@ -278,11 +376,12 @@ cat > "$REMOTE_SCRIPT" <<-EOF
 	            mkdir -p "\$RESULT_DIR"
 	            mkdir -p "\$(dirname \$BASE_PATH)"
 	            mkdir -p "$PBUILDER_BASE/aptcache"
-	            $BUILDD_ROOTCMD cowbuilder --create --distribution \$dist       \\
+	            $BUILDD_ROOTCMD cowbuilder --create --distribution \$BASE_DIST  \\
 	                                       --basepath "\$BASE_PATH"             \\
 	                                       --aptcache "$PBUILDER_BASE/aptcache" \\
 	                                       --debootstrap "$DEBOOTSTRAP"         \\
 	                                       --debootstrapopts --arch="\$arch"    \\
+	                                       "\${CREATE_OPTS[@]}"                 \\
 	            2>&1 | tee "\$UPDATELOG"
 	        else
 	            echo "SKIPPING \$dist/\$arch build, '\$BASE_PATH' does not exist" | tee "\$LOGFILE"
@@ -293,13 +392,15 @@ cat > "$REMOTE_SCRIPT" <<-EOF
 	        $BUILDD_ROOTCMD cowbuilder --update --basepath "\$BASE_PATH"    \\
 	                                   --aptcache "$PBUILDER_BASE/aptcache" \\
 	                                   --autocleanaptcache                  \\
+	                                   "\${UPDATE_OPTS[@]}"                 \\
 	        2>&1 | tee "\$UPDATELOG"
 	    fi
 	    $BUILDD_ROOTCMD cowbuilder --build --basepath "\$BASE_PATH"      \\
 	                               --aptcache "$PBUILDER_BASE/aptcache"  \\
 	                               --buildplace "$PBUILDER_BASE/build"   \\
 	                               --buildresult "\$RESULT_DIR"          \\
-	                               $DEBBUILDOPTS                         \\
+	                               "\${DEBBUILDOPTS[@]}"                 \\
+	                               "\${BUILD_OPTS[@]}"                   \\
 	                               "$INCOMING_DIR/$(basename $DSC)" 2>&1 \\
 	    | tee "\$LOGFILE"
 
@@ -337,32 +438,38 @@ ssh -t "$BUILDD_USER$BUILDD_HOST" "\"$INCOMING_DIR/$REMOTE_SCRIPT\" && rm -f \"$
 echo
 echo "Build completed."
 
-if [ -n "$SIGN_KEYID" ]; then
-    for arch in $BUILDD_ARCH; do
-      CHANGES="$arch.changes"
-      for dist in $BUILDD_DIST; do
+for arch in $BUILDD_ARCH; do
+    CHANGES="$arch.changes"
+    for dist in $BUILDD_DIST; do
 
-	RESULT_DIR="$(eval echo "\$${arch}_${dist}_RESULT_DIR")"
+	eval "sign_keyid=\"\$${arch}_${dist}_SIGN_KEYID\""
+	[ -n "$sign_keyid" ] || sign_keyid="$SIGN_KEYID"
+	[ -n "$sign_keyid" ] || continue
+
+	eval "RESULT_DIR=\"\$${arch}_${dist}_RESULT_DIR\""
 	[ -n "$RESULT_DIR" ] || RESULT_DIR="$PBUILDER_BASE/$arch/$dist/result"
 
 	_desc="$dist/$arch"
 	[ "$dist" != "default" ] || _desc="$arch"
 
 	while true; do
-	    echo -n "Sign $_desc $PACKAGE with key '$SIGN_KEYID' (yes/no)? "
+	    echo -n "Sign $_desc $PACKAGE with key '$sign_keyid' (yes/no)? "
 	    read -e yesno
 	    case "$yesno" in
 		YES | yes)
-		    debsign "-k$SIGN_KEYID" -r "$BUILDD_USER$BUILDD_HOST" "$RESULT_DIR/${PACKAGE}_$CHANGES"
+		    debsign "-k$sign_keyid" -r "$BUILDD_USER$BUILDD_HOST" "$RESULT_DIR/${PACKAGE}_$CHANGES"
+
+		    eval "upload_queue=\"\$${arch}_${dist}_UPLOAD_QUEUE\""
+		    [ -n "$upload_queue" ] || upload_queue="$UPLOAD_QUEUE"
 
-		    if [ -n "$UPLOAD_QUEUE" ]; then
+		    if [ -n "$upload_queue" ]; then
 			while true; do
-			    echo -n "Upload $_desc $PACKAGE to '$UPLOAD_QUEUE' (yes/no)? "
+			    echo -n "Upload $_desc $PACKAGE to '$upload_queue' (yes/no)? "
 			    read -e upload
 			    case "$upload" in
 				YES | yes)
 				    ssh "$BUILDD_USER$BUILDD_HOST" \
-					"cd \"$RESULT_DIR/\" && dput \"$UPLOAD_QUEUE\" \"${PACKAGE}_$CHANGES\""
+					"cd \"$RESULT_DIR/\" && dput \"$upload_queue\" \"${PACKAGE}_$CHANGES\""
 				    break 2
 				    ;;
 
@@ -388,17 +495,15 @@ if [ -n "$SIGN_KEYID" ]; then
 		    ;;
 	    esac
 	done
-
-      done
     done
-fi
+done
 
 if [ -n "$RETURN_DIR" ]; then
     for arch in $BUILDD_ARCH; do
       CHANGES="$arch.changes"
       for dist in $BUILDD_DIST; do
 
-	RESULT_DIR=$(eval echo "\$${arch}_${dist}_RESULT_DIR")
+	eval "RESULT_DIR=\"\$${arch}_${dist}_RESULT_DIR\""
 	[ -n "$RESULT_DIR" ] || RESULT_DIR="$PBUILDER_BASE/$arch/$dist/result"
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list