From 19152b3f7db286f75de1b551010eb472260e0749 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Date: Thu, 28 May 2015 12:29:25 +0200 Subject: build profile parsing support --- pbuilder-satisfydepends-aptitude | 6 ++-- pbuilder-satisfydepends-funcs | 73 ++++++++++++++++++++++++++++++++++++++ test_pbuilder-satisfydepends-funcs | 50 ++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 2 deletions(-) diff --git a/pbuilder-satisfydepends-aptitude b/pbuilder-satisfydepends-aptitude index 31f5353..f96486e 100755 --- a/pbuilder-satisfydepends-aptitude +++ b/pbuilder-satisfydepends-aptitude @@ -33,8 +33,10 @@ function checkbuilddep_internal () { local DEPENDS local CONFLICTS echo " -> Attempting to satisfy build-dependencies" - DEPENDS="$(get_build_deps | filter_arch_deps "$ARCH")" - CONFLICTS="$(get_build_conflicts | filter_arch_deps "$ARCH")" + DEPENDS="$(get_build_deps | filter_arch_deps "$ARCH" | + filter_restriction_deps \"$DEB_BUILD_PROFILES\" )" + CONFLICTS="$(get_build_conflicts | filter_arch_deps "$ARCH" | + filter_restriction_deps \"$DEB_BUILD_PROFILES\" )" echo " -> Creating pbuilder-satisfydepends-dummy package" BUILD_DEP_DEB_DIR="/tmp/satisfydepends-aptitude" BUILD_DEP_DEB_CONTROL="$BUILD_DEP_DEB_DIR/pbuilder-satisfydepends-dummy/DEBIAN/control" diff --git a/pbuilder-satisfydepends-funcs b/pbuilder-satisfydepends-funcs index e028fa2..30d487b 100755 --- a/pbuilder-satisfydepends-funcs +++ b/pbuilder-satisfydepends-funcs @@ -148,6 +148,37 @@ filter_arch_deps() { xargs --no-run-if-empty } +# filter out dependencies sent on input not for selected build profiles; deps +# can have multiple lines; output is on a single line or "" if empty +filter_restriction_deps() { + local profiles="$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_restrictiondeps "$INSTALLPKG" "$profiles"; then + continue + fi + fi + # output the selected package + echo "$INSTALLPKG" + done | + # remove the restriction 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" @@ -182,6 +213,48 @@ checkbuilddep_archdeps() { return 1 } +checkbuilddep_restrictiondeps() { + # returns FALSE on INSTALL + local INSTALLPKG="$1" + local PROFILES="$2" + # restrictions listed between < and > for this dep + local DEP_RESTRICTIONS="$(echo "$INSTALLPKG" | sed -e 's/[^<]*<\(.*\)>.*/\1/' -e 's/>\s\+" "" +expect_success checkbuilddep_restrictiondeps "foo " "stage1" +expect_fail checkbuilddep_restrictiondeps "foo " "notest" +expect_success checkbuilddep_restrictiondeps "foo " "stage1 notest" + +expect_success checkbuilddep_restrictiondeps "foo " "" +expect_fail checkbuilddep_restrictiondeps "foo " "stage1" +expect_success checkbuilddep_restrictiondeps "foo " "notest" +expect_fail checkbuilddep_restrictiondeps "foo " "stage1 notest" + +expect_fail checkbuilddep_restrictiondeps "foo " "" +expect_success checkbuilddep_restrictiondeps "foo " "stage1" +expect_success checkbuilddep_restrictiondeps "foo " "notest" +expect_success checkbuilddep_restrictiondeps "foo " "stage1 notest" + +expect_success checkbuilddep_restrictiondeps "foo " "" +expect_success checkbuilddep_restrictiondeps "foo " "stage1" +expect_success checkbuilddep_restrictiondeps "foo " "notest" +expect_fail checkbuilddep_restrictiondeps "foo " "stage1 notest" + +expect_success checkbuilddep_restrictiondeps "foo " "" +expect_success checkbuilddep_restrictiondeps "foo " "stage1" +expect_fail checkbuilddep_restrictiondeps "foo " "notest" +expect_success checkbuilddep_restrictiondeps "foo " "stage1 notest" + +expect_success checkbuilddep_restrictiondeps "foo " "" +expect_fail checkbuilddep_restrictiondeps "foo " "stage1" +expect_success checkbuilddep_restrictiondeps "foo " "notest" +expect_success checkbuilddep_restrictiondeps "foo " "stage1 notest" + +test_filter_restriction_deps() { + echo "$1" | filter_restriction_deps "$2" +} + +expect_output "foo" test_filter_restriction_deps "foo " "" +expect_output "" test_filter_restriction_deps "foo " "stage1" +expect_output "foo" test_filter_restriction_deps "foo " "stage1" +expect_output "bar, foo" test_filter_restriction_deps "bar, foo " "stage1" +expect_output "bar | foo" test_filter_restriction_deps "bar | foo " "stage1" +expect_output "bar" test_filter_restriction_deps "bar | foo " "stage1" + +test_filter_arch_restriction_deps() { + echo "$1" | filter_arch_deps "$2" | filter_restriction_deps "$3" +} + +expect_output "foo" test_filter_arch_restriction_deps "foo [amd64] " "amd64" "" +expect_output "" test_filter_arch_restriction_deps "foo [amd64] " "amd64" "" +expect_output "foo" test_filter_arch_restriction_deps "foo [amd64] " "amd64" "" +expect_output "" test_filter_arch_restriction_deps "foo [i386] " "amd64" "stage1" + expect_output "debhelper (>= 7)" test_get_build_deps_dsc testlib_summary -- cgit v1.2.3