aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2012-01-10 12:34:44 +0100
committerGuido Günther <agx@sigxcpu.org>2012-01-13 09:11:49 +0100
commita31c95b5e42a1901867c17a603a150d42bf15e0b (patch)
tree0547939bf4f6f7f3c0b367889ee6bd0d0ae742d9 /bin
parentdc40dc73c5d03d3ee0948ebd618e055d545c7faa (diff)
Update to git-pbuilder 1.27
This adds support for creating backport build environments. Thanks: Russ Allbery
Diffstat (limited to 'bin')
-rw-r--r--[-rwxr-xr-x]bin/git-pbuilder72
1 files changed, 56 insertions, 16 deletions
diff --git a/bin/git-pbuilder b/bin/git-pbuilder
index 86268a12..6bd7e020 100755..100644
--- a/bin/git-pbuilder
+++ b/bin/git-pbuilder
@@ -1,11 +1,11 @@
#!/bin/sh
-# $Id: git-pbuilder,v 1.25 2011/12/25 21:17:51 eagle Exp $
+# $Id: git-pbuilder,v 1.27 2012/01/13 04:12:35 eagle Exp $
#
# git-pbuilder -- Wrapper around pbuilder for git-buildpackage
#
# Written by Russ Allbery <rra@stanford.edu>
# Based on the example in the git-buildpackage documentation
-# Copyright 2008, 2009, 2010, 2011
+# Copyright 2008, 2009, 2010, 2011, 2012
# The Board of Trustees of the Leland Stanford Junior University
#
# Permission to use, copy, modify, and distribute this software and its
@@ -24,6 +24,11 @@
set -e
+# The URL to the Debian backports repository to add to the chroot
+# configuration when created via this script for a distribution ending in
+# -backports.
+BACKPORTS='http://backports.debian.org/debian-backports'
+
# Set default BUILDER, DIST, and ARCH based on the name we were invoked as.
# This allows people to create symlinks like git-pbuilder-squeeze and
# git-qemubuilder-squeeze-amd64 pointing to git-pbuilder and auto-detecting
@@ -55,6 +60,14 @@ esac
: ${DIST:=$default_DIST}
: ${ARCH:=$default_ARCH}
+# If DIST ends in -backports, strip that out of DIST and add it to EXT.
+if expr "$DIST" : '.*-backports$' >/dev/null; then
+ DIST=${DIST%-backports}
+ EXT="-backports"
+else
+ EXT=
+fi
+
# Make sure we have the necessary tools.
if [ ! -x /usr/sbin/"$BUILDER" ]; then
echo "$BUILDER not found; you need to install the $BUILDER package" >&2
@@ -79,7 +92,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
# ARCH is set, use base-$DIST-$ARCH.tgz.
: ${DIST:=sid}
if [ -n "$ARCH" ] ; then
- BASE="$PBUILDER_BASE/base-$DIST-$ARCH.tgz"
+ BASE="$PBUILDER_BASE/base-$DIST$EXT-$ARCH.tgz"
OPTIONS="$OPTIONS --architecture $ARCH"
elif [ "$DIST" = 'sid' ] ; then
if [ -f "$PBUILDER_BASE/base-sid.tgz" ] ; then
@@ -88,7 +101,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
BASE="$PBUILDER_BASE/base.tgz"
fi
else
- BASE="$PBUILDER_BASE/base-$DIST.tgz"
+ BASE="$PBUILDER_BASE/base-$DIST$EXT.tgz"
fi
OPTIONS="$OPTIONS --basetgz $BASE"
@@ -116,7 +129,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
# ARCH is set, use base-$DIST-$ARCH.cow.
: ${DIST:=sid}
if [ -n "$ARCH" ] ; then
- BASE="$COWBUILDER_BASE/base-$DIST-$ARCH.cow"
+ BASE="$COWBUILDER_BASE/base-$DIST$EXT-$ARCH.cow"
OPTIONS="$OPTIONS --architecture $ARCH"
elif [ "$DIST" = 'sid' ] ; then
if [ -d "$COWBUILDER_BASE/base-sid.cow" ] ; then
@@ -125,7 +138,7 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
BASE="$COWBUILDER_BASE/base.cow"
fi
else
- BASE="$COWBUILDER_BASE/base-$DIST.cow"
+ BASE="$COWBUILDER_BASE/base-$DIST$EXT.cow"
fi
OPTIONS="$OPTIONS --basepath $BASE"
@@ -152,12 +165,12 @@ if [ no != "$GIT_PBUILDER_AUTOCONF" ] ; then
# There has to be a configuration file matching our distribution
# and architecture.
- QEMUBUILDER_CONFIG="/var/cache/pbuilder/$BUILDER-$ARCH-$DIST.conf"
- if [ ! -r "$QEMUBUILDER_CONFIG" ]; then
- echo "Cannot read configuration file $QEMUBUILDER_CONFIG" >&2
+ QEMUCONFIG="/var/cache/pbuilder/$BUILDER-$ARCH-$DIST$EXT.conf"
+ if [ ! -r "$CONFIG" ]; then
+ echo "Cannot read configuration file $QEMUCONFIG" >&2
exit 1
fi
- OPTIONS="$OPTIONS --config $QEMUBUILDER_CONFIG"
+ OPTIONS="$OPTIONS --config $QEMUCONFIG"
;;
*)
@@ -173,10 +186,27 @@ case $1 in
update|create|login)
action="$1"
shift
+
+ # Since we're running the builder under sudo, $HOME will change to root's
+ # home directory and the user's .pbuilderrc won't be run. sudo -E would
+ # fix this, but that requires special configuration in sudoers to allow
+ # 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"
+ fi
+
+ # Run the builder.
if [ no = "$GIT_PBUILDER_AUTOCONF" ] ; then
sudo "$BUILDER" --"$action" $OPTIONS "$@"
else
- sudo "$BUILDER" --"$action" --dist "$DIST" $OPTIONS "$@"
+ if [ "$EXT" = '-backports' ] ; then
+ OTHERMIRROR="deb $BACKPORTS $DIST$EXT main"
+ sudo "$BUILDER" --"$action" --dist "$DIST" \
+ --othermirror "$OTHERMIRROR" $OPTIONS "$@"
+ else
+ sudo "$BUILDER" --"$action" --dist "$DIST" $OPTIONS "$@"
+ fi
fi
exit $?
;;
@@ -188,12 +218,13 @@ update|create|login)
esac
# Print out some information about what we're doing.
+building="Building with $BUILDER"
if [ no = "$GIT_PBUILDER_AUTOCONF" ] ; then
- echo "Building with $BUILDER"
+ echo "$building"
elif [ -n "$ARCH" ] ; then
- echo "Building with $BUILDER for distribution $DIST, architecture $ARCH"
+ echo "$building for distribution $DIST$EXT, architecture $ARCH"
else
- echo "Building with $BUILDER for distribution $DIST"
+ echo "$building for distribution $DIST$EXT"
fi
# Source package format 1.0 doesn't automatically exclude Git files, so we
@@ -310,8 +341,17 @@ Alternately, B<git-pbuilder> may be called with an argument of C<update>,
C<create>, or C<login>. In this case, it calls B<cowbuilder> (or the
configured builder as described above) using B<sudo> and passes the
corresponding command to the builder, using the same logic as above to
-determine the base directory and distribution. Any additional arguments
-to B<git-pbuilder> are passed along to the builder.
+determine the base directory and distribution. If the distribution (set
+in DIST) ends in C<-backports>, the following will be added as an
+B<--othermirror> parameter to the builder:
+
+ deb http://backports.debian.org/debian-backports $DIST main
+
+Any additional arguments to B<git-pbuilder> are passed along to the
+builder. Due to how B<sudo> works, invoking the builder with an action
+will not read the user's F<.pbuilderrc> by default, so in this case
+B<git-pbuilder> will add an explicit B<--configfile> option pointing to
+the user's F<.pbuilderrc> if it exists.
=head1 ENVIRONMENT