[pbuilder] 01/01: pbuilder-satisfydepends-funcs: Make get_source_control_field more robust
James Clarke
jrtc27-guest at moszumanska.debian.org
Mon Jan 2 16:55:11 UTC 2017
This is an automated email from the git hooks/post-receive script.
jrtc27-guest pushed a commit to branch sed-fix
in repository pbuilder.
commit d490a9f1ca4e4fa5cca0b9ab0d5a71d21bb5efd0
Author: James Clarke <jrtc27 at jrtc27.com>
Date: Mon Jan 2 16:54:33 2017 +0000
pbuilder-satisfydepends-funcs: Make get_source_control_field more robust
Closes: #847944
---
pbuilder-satisfydepends-funcs | 26 +++++++++++++++++++-------
t/test_pbuilder-satisfydepends-funcs | 31 +++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/pbuilder-satisfydepends-funcs b/pbuilder-satisfydepends-funcs
index 60f8eca..23de753 100755
--- a/pbuilder-satisfydepends-funcs
+++ b/pbuilder-satisfydepends-funcs
@@ -56,26 +56,36 @@ get_source_control_field() {
local field="$1"
sed -n -e "s/^$field://i" -e '
-t store
+# Skip PGP header
/^-----BEGIN PGP SIGNED MESSAGE-----$/ {
: pgploop
n
- /^$/ d
+ /^$/ b leadloop
b pgploop
}
+
+# Skip empty lines/comments
: leadloop
/^[ \t]*$/ {
n
- /^$/ d
b leadloop
}
/^#/ {
n
- /^$/ d
b leadloop
}
-/^$/q
-d
+
+# First line of source paragraph
+: sourceloop
+# Strip field name from line if present
+s/^'"$field"'://i
+# If field present, print normalised contents
+t store
+# Otherwise, check for end of paragraph or ignore
+/^[ \t]*$/q
+n
+b sourceloop
+
: store
H
: loop
@@ -106,7 +116,9 @@ s/(\(>>\|>=\|>\|==\|=\|<=\|<<\|<\|!=\) *\([^)]*\))/(\1 \2)/g
# normalize space at beginning and end of line
s/^ *//
s/ *$//
-p' \
+p
+n
+b sourceloop' \
"$DEBIAN_CONTROL"
}
diff --git a/t/test_pbuilder-satisfydepends-funcs b/t/test_pbuilder-satisfydepends-funcs
index cced2d1..b921e81 100755
--- a/t/test_pbuilder-satisfydepends-funcs
+++ b/t/test_pbuilder-satisfydepends-funcs
@@ -57,6 +57,25 @@ EOF
get_build_deps
}
+test_get_build_deps_comment_between_lines() {
+ local BINARY_ARCH="$1"
+ cat <<EOF >"$DEBIAN_CONTROL"
+Source: foo
+# foo
+Build-Depends: bar
+EOF
+ get_build_deps
+}
+
+test_get_build_deps_one_line_preceding_comment() {
+ local BINARY_ARCH="all"
+ cat << EOF >"$DEBIAN_CONTROL"
+# Preceding comment
+Build-Depends: blabla
+EOF
+ get_build_deps
+}
+
test_get_build_deps_one_line_trailing_comment() {
local BINARY_ARCH="all"
cat << EOF >"$DEBIAN_CONTROL"
@@ -66,6 +85,15 @@ EOF
get_build_deps
}
+test_get_build_deps_one_line_preceding_blank() {
+ local BINARY_ARCH="all"
+ cat << EOF >"$DEBIAN_CONTROL"
+
+Build-Depends: blabla
+EOF
+ get_build_deps
+}
+
test_get_build_deps_dsc() {
cat <<EOF >"$DEBIAN_CONTROL"
-----BEGIN PGP SIGNED MESSAGE-----
@@ -123,7 +151,10 @@ 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 [amd64 i386], test1, test2 [!i386 !amd64], test3 | test4, test5" \
test_get_build_deps "all"
expect_output "bar" test_get_build_deps_source_para_only "any"
+expect_output "bar" test_get_build_deps_comment_between_lines "any"
+expect_output "blabla" test_get_build_deps_one_line_preceding_comment
expect_output "blabla" test_get_build_deps_one_line_trailing_comment
+expect_output "blabla" test_get_build_deps_one_line_preceding_blank
expect_fail checkbuilddep_archdeps "foo [amd64]" "amd64"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/pbuilder.git
More information about the Pbuilder-maint
mailing list