From 8bf99ca809fd9287bbe015523e477109185a4119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Mon, 4 Jan 2010 23:18:45 +0100 Subject: Rewrite get_control_re Replace cat + awk + sed in get_control_re() with a sed script; rename the function to get_source_control_field. --- pbuilder-satisfydepends-funcs | 52 ++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 30 deletions(-) (limited to 'pbuilder-satisfydepends-funcs') diff --git a/pbuilder-satisfydepends-funcs b/pbuilder-satisfydepends-funcs index 58e598c..9beb691 100755 --- a/pbuilder-satisfydepends-funcs +++ b/pbuilder-satisfydepends-funcs @@ -50,45 +50,37 @@ checkbuilddep_versiondeps() { return 1; } -get_control_re() { - # output the field which matches RE of control file in stdout. - re="$1" - - cat "$DEBIAN_CONTROL" | - awk ' - BEGIN { source=1 } - /^$/ { - if (p) { - print s - s="" - } - source=0 - } - /^Source:/ { source=1 } - /^[^ ]*:/ { - if (source && p) { - print s - s="" - } - p=0 - } - /^#/ { next } - tolower($0) ~ /^'"$re"':/ { p=1 } - { if (p && source) { s=s""$0 } }' | - sed 's/^[^: ]*://' +get_source_control_field() { + local field="$1" + + sed -n -e " +s/^$field://i +t store +/^\$/q +d +: store +H +: loop +n +/^#/ b loop +/^[ \\t]/ b store +x +s/\\n//g +p" \ + "$DEBIAN_CONTROL" } get_build_deps() { - get_control_re "build-depends" + get_source_control_field "Build-Depends" if [ "$BINARY_ARCH" = no ]; then - get_control_re "build-depends-indep" + get_source_control_field "Build-Depends-Indep" fi } get_build_conflicts() { - get_control_re "build-conflicts" + get_control_field "Build-Conflicts" if [ "$BINARY_ARCH" = no ]; then - get_control_re "build-conflicts-indep" + get_source_control_field "Build-Conflicts-Indep" fi } -- cgit v1.2.3