[PATCH] Check correct architecture for checkarchitecture, and make it more testable

Matt Palmer mpalmer at hezmatt.org
Wed Dec 15 20:37:34 UTC 2010


The checkarchitecture function was examining and reporting against the main
host architecture, instead of the chroot architecture.  Whilst this isn't
usually a problem, an i386 chroot on an amd64 machine might give odd
results.

I also took the liberty of moving the arch detection out of the function, so
that we can more easily test it by just passing in an arch of our choosing,
rather than having to rely on the kindness of strangers.
---
 pbuilder-buildpackage       |    7 ++++---
 pbuilder-buildpackage-funcs |    2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/pbuilder-buildpackage b/pbuilder-buildpackage
index 8b42b6d..4671c0d 100755
--- a/pbuilder-buildpackage
+++ b/pbuilder-buildpackage
@@ -31,9 +31,6 @@ if [ ! -f "$PACKAGENAME" ]; then
     exit 1;
 fi;
 
-# check if this package should be built at all
-checkarchitecture "$PACKAGENAME"
-
 if [ -n "$BUILDUSERNAME" -a -n "$BUILDUSERID" ]; then
     SUTOUSER="env LOGNAME=$BUILDUSERNAME su -p $BUILDUSERNAME"
     DEBBUILDOPTS="${DEBBUILDOPTS:+$DEBBUILDOPTS }-rfakeroot"
@@ -56,6 +53,10 @@ export HOME="/tmp/buildd"
 echobacktime
 extractbuildplace 
 trap umountproc_cleanbuildplace_trap exit sighup sigpipe
+
+# check if this package should be built at all
+checkarchitecture "$PACKAGENAME" "$($CHROOTEXEC dpkg-architecture -qDEB_HOST_ARCH)"
+
 loadhooks
 
 if [ ! -d "${BUILDRESULT}" ]; then
diff --git a/pbuilder-buildpackage-funcs b/pbuilder-buildpackage-funcs
index fedbfc4..5ac393f 100644
--- a/pbuilder-buildpackage-funcs
+++ b/pbuilder-buildpackage-funcs
@@ -32,8 +32,8 @@ function copydsc () {
 
 function checkarchitecture () {
     local DSCFILE="$1"
+    local ARCH="$2"
     local ARCHES="$(cat $DSCFILE | grep Architecture | sed 's/^[^:]\+:\s*//')"
-    local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH)
     local VALID_ARCH
     for d in $ARCHES; do
         if dpkg-architecture -a$ARCH -i$d; then
-- 
1.5.6.5


--qjNfmADvan18RZcF
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0008-Make-checkarchitecture-even-more-testable.patch"



More information about the Pbuilder-maint mailing list