From b068c8d3289423f7d74a7f8d5886830777d71c27 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Date: Thu, 28 May 2015 12:25:06 +0200 Subject: move filter_arch_deps from pbuilder-satisfydepends-aptitude to pbuilder-satisfydepends-funcs and add tests --- pbuilder-satisfydepends-funcs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'pbuilder-satisfydepends-funcs') 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" -- cgit v1.2.3