diff options
-rwxr-xr-x | pbuilder-satisfydepends-aptitude | 32 | ||||
-rwxr-xr-x | pbuilder-satisfydepends-funcs | 31 | ||||
-rwxr-xr-x | test_pbuilder-satisfydepends-funcs | 16 |
3 files changed, 47 insertions, 32 deletions
diff --git a/pbuilder-satisfydepends-aptitude b/pbuilder-satisfydepends-aptitude index 97c58e5..31f5353 100755 --- a/pbuilder-satisfydepends-aptitude +++ b/pbuilder-satisfydepends-aptitude @@ -25,38 +25,6 @@ export PBUILDER_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder . "$PBUILDER_PKGLIBDIR"/pbuilder-satisfydepends-funcs - -# filter out dependencies sent on input not for this arch; deps can have -# multiple lines; output is on a single line or "" if empty -function filter_arch_deps() { - local arch="$1" - local INSTALLPKGMULTI - local INSTALLPKG - - # split on "," - sed 's/[[:space:]]*,[[:space:]]*/\n/g' | - while read INSTALLPKGMULTI; do - echo "$INSTALLPKGMULTI" | - # split on "|" - sed 's/[[:space:]]*|[[:space:]]*/\n/g' | - while read INSTALLPKG; do - if echo "$INSTALLPKG" | grep -q '\['; then - if checkbuilddep_archdeps "$INSTALLPKG" "$ARCH"; then - continue - fi - fi - # output the selected package - echo "$INSTALLPKG" - done | - # remove the arch list and add " | " between entries - sed 's/\[.*\]//; $,$! s/$/ |/' | - xargs --no-run-if-empty - done | - # add ", " between entries - sed '$,$! s/$/,/' | - xargs --no-run-if-empty -} - function checkbuilddep_internal () { # Use this function to fulfill the dependency (almost) local ARCH=$($CHROOTEXEC dpkg-architecture -qDEB_HOST_ARCH) diff --git a/pbuilder-satisfydepends-funcs b/pbuilder-satisfydepends-funcs index 6c8dc28..e028fa2 100755 --- a/pbuilder-satisfydepends-funcs +++ b/pbuilder-satisfydepends-funcs @@ -117,6 +117,37 @@ get_build_conflicts() { echo "$output" } +# filter out dependencies sent on input not for this arch; deps can have +# multiple lines; output is on a single line or "" if empty +filter_arch_deps() { + local arch="$1" + local INSTALLPKGMULTI + local INSTALLPKG + + # split on "," + sed 's/[[:space:]]*,[[:space:]]*/\n/g' | + while read INSTALLPKGMULTI; do + echo "$INSTALLPKGMULTI" | + # split on "|" + sed 's/[[:space:]]*|[[:space:]]*/\n/g' | + while read INSTALLPKG; do + if echo "$INSTALLPKG" | grep -q '\['; then + if checkbuilddep_archdeps "$INSTALLPKG" "$arch"; then + continue + fi + fi + # output the selected package + echo "$INSTALLPKG" + done | + # remove the arch list and add " | " between entries + sed 's/\[.*\]//; $,$! s/$/ |/' | + xargs --no-run-if-empty + done | + # add ", " between entries + sed '$,$! s/$/,/' | + xargs --no-run-if-empty +} + checkbuilddep_archdeps() { # returns FALSE on INSTALL local INSTALLPKG="$1" diff --git a/test_pbuilder-satisfydepends-funcs b/test_pbuilder-satisfydepends-funcs index 4eaa665..aafef2b 100755 --- a/test_pbuilder-satisfydepends-funcs +++ b/test_pbuilder-satisfydepends-funcs @@ -84,6 +84,22 @@ expect_output "autotools-dev (>= 1.2), debhelper, quilt (<< 12:0), libwxgtk2.8-d expect_output "autotools-dev (>= 1.2), debhelper, quilt (<< 12:0), libwxgtk2.8-dev" \ test_get_build_deps "yes" +expect_fail checkbuilddep_archdeps "foo [amd64]" "amd64" +expect_success checkbuilddep_archdeps "foo [i386]" "amd64" +expect_fail checkbuilddep_archdeps "foo [i386 amd64]" "amd64" +expect_success checkbuilddep_archdeps "foo [!amd64]" "amd64" +expect_success checkbuilddep_archdeps "foo [!i386 !amd64]" "amd64" + +test_filter_arch_deps() { + echo "$1" | filter_arch_deps "$2" +} + +expect_output "foo" test_filter_arch_deps "foo" "amd64" +expect_output "foo" test_filter_arch_deps "foo [amd64]" "amd64" +expect_output "bar, foo" test_filter_arch_deps "bar, foo [amd64]" "amd64" +expect_output "bar | foo" test_filter_arch_deps "bar | foo [amd64]" "amd64" +expect_output "bar" test_filter_arch_deps "bar | foo [amd64]" "i386" + expect_output "debhelper (>= 7)" test_get_build_deps_dsc testlib_summary |