aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-09-17 18:28:10 +0200
committerGuido Günther <agx@sigxcpu.org>2013-09-17 18:28:10 +0200
commita86ccb7d17e4a49df93f02b44cae99182ac4c0ab (patch)
tree94296134313f7bf4713dafcde0948918461ba930 /bin
parent820100d702c3a2bed084061892f49bcb43a87b38 (diff)
Update to git-pbuilder 1.29
Diffstat (limited to 'bin')
-rw-r--r--bin/git-pbuilder71
1 files changed, 47 insertions, 24 deletions
diff --git a/bin/git-pbuilder b/bin/git-pbuilder
index fc0f48c6..99164baf 100644
--- a/bin/git-pbuilder
+++ b/bin/git-pbuilder
@@ -1,8 +1,13 @@
-#!/bin/sh
-# $Id: git-pbuilder,v 1.27 2012/01/13 04:12:35 eagle Exp $
+#!/bin/bash
+# $Id: git-pbuilder,v 1.29 2012/12/26 00:10:52 eagle Exp $
#
# git-pbuilder -- Wrapper around pbuilder for git-buildpackage
#
+# Note that this script requires bash, not a POSIX shell, because it uses bash
+# arrays to handle GIT_PBUILDER_OPTIONS. It's otherwise quite difficult to
+# get the contents of that environment variable to undergo the correct amount
+# of shell expansion.
+#
# Written by Russ Allbery <rra@stanford.edu>
# Based on the example in the git-buildpackage documentation
# Copyright 2008, 2009, 2010, 2011, 2012
@@ -24,6 +29,13 @@
set -e
+# Helper function to quote an argument so that it's protected from the shell.
+# This is used when passing arguments through in --debbuildopts, since they'll
+# undergo another round of shell expansion.
+shell_quote () {
+ echo "$1" | sed -e "s/'/'\"'\"'/g" -e "1 s/^/'/" -e "\$ s/\$/'/"
+}
+
# The URL to the Debian backports repository to add to the chroot
# configuration when created via this script for a distribution ending in
# -backports.
@@ -74,8 +86,9 @@ if [ ! -x /usr/sbin/"$BUILDER" ]; then
exit 1
fi
-# Default options come from the environment.
-OPTIONS="$GIT_PBUILDER_OPTIONS"
+# Default options come from the environment. Use eval to parse
+# GIT_PBUILDER_OPTIONS into an array since some arguments may have quoting.
+eval "OPTIONS=( $GIT_PBUILDER_OPTIONS )"
OUTPUT_DIR="${GIT_PBUILDER_OUTPUT_DIR:-../}"
# How we handle options depends on what type of builder we're using. Ignore
@@ -94,7 +107,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
: ${DIST:=sid}
if [ -n "$ARCH" ] ; then
BASE="$PBUILDER_BASE/base-$DIST$EXT-$ARCH.tgz"
- OPTIONS="$OPTIONS --architecture $ARCH"
+ OPTIONS+=( --architecture "$ARCH" )
elif [ "$DIST" = 'sid' ] ; then
if [ -f "$PBUILDER_BASE/base-sid.tgz" ] ; then
BASE="$PBUILDER_BASE/base-sid.tgz"
@@ -104,7 +117,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
else
BASE="$PBUILDER_BASE/base-$DIST$EXT.tgz"
fi
- OPTIONS="$OPTIONS --basetgz $BASE"
+ OPTIONS+=( --basetgz "$BASE" )
# Make sure the base tarball exists.
if [ ! -f "$BASE" ] && [ "$1" != "create" ]; then
@@ -115,7 +128,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
# Set --debian-etch-workaround if DIST is etch. Assume that
# everything else is new enough that it will be fine.
if [ "$DIST" = 'etch' ] || [ "$DIST" = 'ebo' ] ; then
- OPTIONS="$OPTIONS --debian-etch-workaround"
+ OPTIONS+=( --debian-etch-workaround )
fi
;;
@@ -131,7 +144,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
: ${DIST:=sid}
if [ -n "$ARCH" ] ; then
BASE="$COWBUILDER_BASE/base-$DIST$EXT-$ARCH.cow"
- OPTIONS="$OPTIONS --architecture $ARCH"
+ OPTIONS+=( --architecture "$ARCH" )
elif [ "$DIST" = 'sid' ] ; then
if [ -d "$COWBUILDER_BASE/base-sid.cow" ] ; then
BASE="$COWBUILDER_BASE/base-sid.cow"
@@ -141,7 +154,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
else
BASE="$COWBUILDER_BASE/base-$DIST$EXT.cow"
fi
- OPTIONS="$OPTIONS --basepath $BASE"
+ OPTIONS+=( --basepath "$BASE" )
# Make sure the base directory exists.
if [ ! -d "$BASE" ] && [ "$1" != "create" ]; then
@@ -152,7 +165,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
# Set --debian-etch-workaround if DIST is etch. Assume that
# everything else is new enough that it will be fine.
if [ "$DIST" = 'etch' ] || [ "$DIST" = 'ebo' ] ; then
- OPTIONS="$OPTIONS --debian-etch-workaround"
+ OPTIONS+=( --debian-etch-workaround )
fi
;;
@@ -171,7 +184,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
echo "Cannot read configuration file $QEMUCONFIG" >&2
exit 1
fi
- OPTIONS="$OPTIONS --config $QEMUCONFIG"
+ OPTIONS+=( --config "$QEMUCONFIG" )
;;
*)
@@ -194,19 +207,19 @@ update|create|login)
# it. Instead, check if the user has a .pbuilderrc and, if so, explicitly
# add it as a configuration file.
if [ -f "$HOME/.pbuilderrc" ] ; then
- OPTIONS="$OPTIONS --configfile $HOME/.pbuilderrc"
+ OPTIONS+=( --configfile "$HOME/.pbuilderrc" )
fi
# Run the builder.
if [ no = "$GIT_PBUILDER_AUTOCONF" ] ; then
- sudo "$BUILDER" --"$action" $OPTIONS "$@"
+ sudo "$BUILDER" --"$action" "${OPTIONS[@]}" "$@"
else
if [ "$EXT" = '-backports' ] ; then
OTHERMIRROR="deb $BACKPORTS $DIST$EXT main"
sudo "$BUILDER" --"$action" --dist "$DIST" \
- --othermirror "$OTHERMIRROR" $OPTIONS "$@"
+ --othermirror "$OTHERMIRROR" "${OPTIONS[@]}" "$@"
else
- sudo "$BUILDER" --"$action" --dist "$DIST" $OPTIONS "$@"
+ sudo "$BUILDER" --"$action" --dist "$DIST" "${OPTIONS[@]}" "$@"
fi
fi
exit $?
@@ -235,18 +248,26 @@ fi
# or -I flags unless we're using source format 1.0.
if [ ! -f debian/source/format ] || grep -qs '^1.0' debian/source/format ; then
echo 'Source format 1.0 detected, adding exclude flags'
- DEBBUILDOPTS="-i'(?:^|/)\\.git(attributes)?(?:\$|/.*\$)' -I.git $*"
+ DEBBUILDOPTS="-i'(?:^|/)\\.git(attributes)?(?:\$|/.*\$)' -I.git"
else
- DEBBUILDOPTS="$*"
+ DEBBUILDOPTS=''
fi
+# Add all of the additional arguments we got on the command line, but quote
+# them from the shell since they'll undergo another round of shell expansion
+# when the pbuilder runs debbuild.
+for arg in "$@" ; do
+ DEBBUILDOPTS+=" $(shell_quote "$arg")"
+done
+
# Now we can finally run pdebuild. The quoting here is tricky, but this
# seems to pass everything through properly.
if [ no = "$GIT_PBUILDER_AUTOCONF" ] ; then
- pdebuild --pbuilder "$BUILDER" --debbuildopts "$DEBBUILDOPTS" -- $OPTIONS
+ pdebuild --pbuilder "$BUILDER" --debbuildopts "$DEBBUILDOPTS" \
+ -- "${OPTIONS[@]}"
else
- pdebuild --buildresult $OUTPUT_DIR --pbuilder "$BUILDER" \
- --debbuildopts "$DEBBUILDOPTS" -- $OPTIONS
+ pdebuild --buildresult "$OUTPUT_DIR" --pbuilder "$BUILDER" \
+ --debbuildopts "$DEBBUILDOPTS" -- "${OPTIONS[@]}"
fi
status="$?"
if [ -n "`ls ../*_source.changes`" ] ; then
@@ -388,9 +409,9 @@ If set to C<no>, disable the logic that constructs the base path, tarball,
or configuration file and all other logic to determine the options to pass
to the builder. Instead, just run the configured builder and assume its
configuration is handled elsewhere (such as in F<.pbuilderrc>). This also
-suppresses setting C<--buildresult ..>, so the user will need to ensure
-that the configuration still puts packages where B<git-buildpackage>
-expects them.
+suppresses setting B<--buildresult>, so the user will need to ensure that
+the configuration still puts packages where B<git-buildpackage> expects
+them.
=item GIT_PBUILDER_OPTIONS
@@ -402,7 +423,9 @@ value of the environment variable.
=item GIT_PBUILDER_OUTPUT_DIR
-Where pbuilder puts the build result. Default is '..'.
+Where to put the result of the build. The default is C<..> (the parent
+directory). This setting is ignored if GIT_PBUILDER_AUTOCONF is set to
+C<no>.
=item PBUILDER_BASE