Here's new patches to support architecture wildcards in pbuilder. The first patch provides changes to how package interrelationships are handled. The second patch adds support for checking the 'Architecture' field to see whether or not to build a package. This kind of check is supported in sbuild.
Both patches are modeled closely to how architecture wildcard support is implemented in sbuild. See bug #501230. -- Regards, Andres
diff --git a/pbuilder-satisfydepends-funcs b/pbuilder-satisfydepends-funcs index 5c16269..8d86c81 100755 --- a/pbuilder-satisfydepends-funcs +++ b/pbuilder-satisfydepends-funcs @@ -85,19 +85,32 @@ function checkbuilddep_archdeps () { local ARCH="$2" # architectures listed between [ and ] for this dep local DEP_ARCHES="$(echo "$INSTALLPKG" | sed 's/.*\[\(.*\)\].*/\1/')" - # check for !$ARCH in DEP_ARCHES - if echo "$DEP_ARCHES" | egrep -q "(^|[[:space:]/]+)\![[:space:]/]*$ARCH($|[[:space:]/]+)"; then - return 0; + local PKG="$(echo "$INSTALLPKG" | cut -d ' ' -f 1)" + local USE_IT + local IGNORE_IT + local INCLUDE + # Use 'dpkg-architecture' to support architecture wildcards. + for d in $DEP_ARCHES; do + if echo "$d" | grep -q '!'; then + d="$(echo $d | sed 's/!//')" + if dpkg-architecture -a$ARCH -i$d; then + IGNORE_IT="yes" + fi + else + if dpkg-architecture -a$ARCH -i$d; then + USE_IT="yes" + fi + INCLUDE="yes" + fi + done + if [ $IGNORE_IT ] && [ $USE_IT ]; then + printf "W: inconsistent arch restriction on $PKG: " >&2 + printf "$DEP_ARCHES depedency\n" >&2 fi - # check for a "!" which would mean there's a !<otherarch> and hence $ARCH - # is included - if ! echo "$DEP_ARCHES" | grep -q '!'; then - # check for $ARCH in DEP_ARCHES - if ! echo "$DEP_ARCHES" | egrep -q "(^|[[:space:]/]+)$ARCH($|[[:space:]/]+)"; then - return 0; - fi + if [ $IGNORE_IT ] || ( [ $INCLUDE ] && [ ! $USE_IT ] ); then + return 0 fi - return 1; + return 1 } function checkbuilddep_provides () {
diff --git a/pbuilder-buildpackage b/pbuilder-buildpackage index 0fbaf2e..cde3551 100755 --- a/pbuilder-buildpackage +++ b/pbuilder-buildpackage @@ -31,6 +31,9 @@ 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 -rfakeroot" diff --git a/pbuilder-buildpackage-funcs b/pbuilder-buildpackage-funcs index 370c799..2dfaa14 100644 --- a/pbuilder-buildpackage-funcs +++ b/pbuilder-buildpackage-funcs @@ -30,6 +30,25 @@ function copydsc () { done } +function checkarchitecture () { + local DSCFILE="$1" + local ARCHES="$(cat $DSCFILE | grep Architecture | sed 's/^[^:]\+://')" + local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH) + local VALID_ARCH + for d in $ARCHES; do + if dpkg-architecture -a$ARCH -i$d; then + VALID_ARCH="yes" + break + fi + done + if [ ! $VALID_ARCH ]; then + local msg="E: $ARCH not in arch list or does not match any " + msg="$msg arch wildcards: $ARCHES" + log $msg + exit 2 + fi +} + function checkbuilddep () { # call satisfydepends local BUILDOPT="--binary-all"