[devscripts] 04/06: Remove manual parsing of dpkg-buildpackage's output

James McCoy jamessan at debian.org
Mon Jul 27 06:28:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit 7c250fa9d0b31aad0a3ad53d2aeb33ee140dd6dc
Author: James McCoy <jamessan at debian.org>
Date:   Mon Jul 27 00:54:02 2015 -0400

    Remove manual parsing of dpkg-buildpackage's output
    
    Use its -S switch or, for perl scripts, the Dpkg::Changelog::Parse
    module instead.
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 Makefile                          |  3 +--
 debian/changelog                  |  3 +++
 debian/control                    |  3 ++-
 scripts/cvs-debi.sh               | 14 ++++++------
 scripts/cvs-debrelease.sh         | 14 ++++++------
 scripts/debchange.bash_completion |  2 +-
 scripts/debchange.pl              | 17 +++++---------
 scripts/debclean.sh               |  2 +-
 scripts/debi.pl                   |  2 +-
 scripts/debrelease.sh             |  6 ++---
 scripts/debrsign.sh               |  6 ++---
 scripts/debsign.sh                |  6 ++---
 scripts/debuild.pl                | 14 +++---------
 scripts/nmudiff.sh                |  8 +++----
 scripts/tagpending.pl             | 48 ++++++++++-----------------------------
 scripts/uscan.pl                  | 21 +++++++++--------
 scripts/uupdate.sh                |  6 ++---
 scripts/what-patch.sh             |  2 +-
 test/test_debchange               |  4 ++--
 19 files changed, 70 insertions(+), 111 deletions(-)

diff --git a/Makefile b/Makefile
index fd96376..d693c41 100644
--- a/Makefile
+++ b/Makefile
@@ -10,8 +10,7 @@ all: version make_scripts $(EXAMPLES) translated_manpages
 
 version:
 	rm -f version
-	dpkg-parsechangelog | perl -ne '/^Version: (.*)/ && print $$1' \
-	    > version
+	dpkg-parsechangelog -SVersion > version
 
 conf.default: conf.default.in version
 	rm -f $@ $@.tmp
diff --git a/debian/changelog b/debian/changelog
index c4a8de4..3847bb2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,9 @@ devscripts (2.15.6) UNRELEASED; urgency=medium
     + Use getopt to handle argument parsing.
     + Add --exact switch to match the exact package name instead of a
       substring.  Thanks to Balasankar C.  (Closes: #791918)
+  * Replace manual parsing of dpkg-buildpackage's output with the use of its
+    -S switch or the Dpkg::Changelog::Parse Perl module.
+    + Bump minimum required version of dpkg-dev to 1.17.0
 
   [ Dominique Dumont ]
   * licensecheck:
diff --git a/debian/control b/debian/control
index f0b1d07..b913203 100644
--- a/debian/control
+++ b/debian/control
@@ -11,6 +11,7 @@ Standards-Version: 3.9.6
 Build-Depends: bash-completion,
                debhelper (>= 9),
                docbook-xsl,
+               dpkg-dev (>= 1.17.0),
                file,
                libdistro-info-perl,
                libfile-desktopentry-perl,
@@ -39,7 +40,7 @@ Vcs-Git: git://anonscm.debian.org/collab-maint/devscripts.git
 Package: devscripts
 Architecture: any
 Multi-Arch: foreign
-Depends: dpkg-dev (>= 1.16.4),
+Depends: dpkg-dev (>= 1.17.0),
          ${misc:Depends},
          ${perl:Depends},
          ${python3:Depends},
diff --git a/scripts/cvs-debi.sh b/scripts/cvs-debi.sh
index ec8daa5..307ef8a 100755
--- a/scripts/cvs-debi.sh
+++ b/scripts/cvs-debi.sh
@@ -220,20 +220,20 @@ if [ "x$opt_package" = "x" ]; then
     if [ -f debian/changelog ]; then
 	# Ok, changelog exists
 	 setq "package" \
-	    "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
+	    "`dpkg-parsechangelog -SSource`" \
 		"source package"
 	setq "version" \
-	    "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
+	    "`dpkg-parsechangelog -SVersion`" \
 		"source version"
     elif [ "x$opt_cvsmodule" != "x" ]; then
 	# Hmm. Well, see if we can checkout the changelog file
 	rm -f $TEMPFILE
 	cvs -q co -p $TAGOPT $opt_cvsmodule/debian/changelog > $TEMPFILE
         setq "package" \
-	    "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Source: //p'`" \
+	    "`dpkg-parsechangelog -l$TEMPFILE -SSource`" \
           "source package"
         setq "version" \
-          "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Version: //p'`" \
+          "`dpkg-parsechangelog -l$TEMPFILE -SVersion`" \
           "source version"
         rm -f "$TEMPFILE"
     else
@@ -256,14 +256,14 @@ else
     elif [ -f debian/changelog ]; then
 	# Fine, see what the changelog says
 	setq "version" \
-	    "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
+	    "`dpkg-parsechangelog -SVersion`" \
 		"source version"
     elif [ "x$opt_cvsmodule" != "x" ]; then
 	# Hmm. The CVS module name is known, so lets us try exporting changelog
 	rm -f $TEMPFILE
 	cvs -q co -p $TAGOPT $opt_cvsmodule/debian/changelog > $TEMPFILE
         setq "version" \
-          "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Version: //p'`" \
+          "`dpkg-parsechangelog -l$TEMPFILE -SVersion`" \
           "source version"
         rm -f "$TEMPFILE"
     else
@@ -272,7 +272,7 @@ else
 	cvsmodule="${prefix}$package"
 	cvs -q co -p $TAGOPT $cvsmodule/debian/changelog > $TEMPFILE
         setq "version" \
-          "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Version: //p'`" \
+          "`dpkg-parsechangelog -l$TEMPFILE -SVersion`" \
           "source version"
         rm -f "$TEMPFILE"
     fi
diff --git a/scripts/cvs-debrelease.sh b/scripts/cvs-debrelease.sh
index 46aaf2e..54fac93 100755
--- a/scripts/cvs-debrelease.sh
+++ b/scripts/cvs-debrelease.sh
@@ -227,20 +227,20 @@ if [ "x$opt_package" = "x" ]; then
     if [ -f debian/changelog ]; then
 	# Ok, changelog exists
 	 setq "package" \
-	    "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
+	    "`dpkg-parsechangelog -SSource`" \
 		"source package"
 	setq "version" \
-	    "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
+	    "`dpkg-parsechangelog -SVersion`" \
 		"source version"
     elif [ "x$opt_cvsmodule" != "x" ]; then
 	# Hmm. Well, see if we can checkout the changelog file
 	rm -f $TEMPFILE
 	cvs -q co -p $TAGOPT $opt_cvsmodule/debian/changelog > $TEMPFILE
         setq "package" \
-	    "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Source: //p'`" \
+	    "`dpkg-parsechangelog -l$TEMPFILE -SSource`" \
           "source package"
         setq "version" \
-          "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Version: //p'`" \
+          "`dpkg-parsechangelog -l$TEMPFILE -SVersion`" \
           "source version"
         rm -f "$TEMPFILE"
     else
@@ -263,14 +263,14 @@ else
     elif [ -f debian/changelog ]; then
 	# Fine, see what the changelog says
 	setq "version" \
-	    "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
+	    "`dpkg-parsechangelog -SVersion`" \
 		"source version"
     elif [ "x$opt_cvsmodule" != "x" ]; then
 	# Hmm. The CVS module name is known, so lets us try exporting changelog
 	rm -f $TEMPFILE
 	cvs -q co -p $TAGOPT $opt_cvsmodule/debian/changelog > $TEMPFILE
         setq "version" \
-          "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Version: //p'`" \
+          "`dpkg-parsechangelog -l$TEMPFILE -SVersion`" \
           "source version"
         rm -f "$TEMPFILE"
     else
@@ -279,7 +279,7 @@ else
 	cvsmodule="${prefix}$package"
 	cvs -q co -p $TAGOPT $cvsmodule/debian/changelog > $TEMPFILE
         setq "version" \
-          "`dpkg-parsechangelog -l$TEMPFILE | sed -n 's/^Version: //p'`" \
+          "`dpkg-parsechangelog -l$TEMPFILE -SVersion`" \
           "source version"
         rm -f "$TEMPFILE"
     fi
diff --git a/scripts/debchange.bash_completion b/scripts/debchange.bash_completion
index 555b3b6..2fa1c66 100644
--- a/scripts/debchange.bash_completion
+++ b/scripts/debchange.bash_completion
@@ -51,7 +51,7 @@ _debchange()
 	    ;;
 #FIXME: we need "querybts --list" option with no verbose output
 #	--closes)
-#	     package=`dpkg-parsechangelog |grep ^Source|cut -d':' -f2|sed -e s/\ //`
+#	     package=`dpkg-parsechangelog -SSource`
 #	     bugnumber=`querybts --list -b $package|grep ^#|cut -d' ' -f1`
 #	     COMPREPLY=( $( compgen -W "$bugnumber" ) )
 #	    ;;
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index 2bad684..4348813 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -40,7 +40,7 @@ use File::Copy;
 use File::Basename;
 use Cwd;
 use Dpkg::Vendor qw(get_current_vendor);
-use Dpkg::Changelog::Parse;
+use Dpkg::Changelog::Parse qw(changelog_parse);
 use Dpkg::Control;
 use Devscripts::Compression;
 use Devscripts::Debbugs;
@@ -613,7 +613,7 @@ my $CL_URGENCY = '';
 
 if (! $opt_create || ($opt_create && $opt_news)) {
     my $file = $opt_create ? 'debian/changelog' : $changelog_path;
-    $changelog = Dpkg::Changelog::Parse::changelog_parse(file => $file);
+    $changelog = changelog_parse(file => $file);
 
     # Now we've read the changelog, set some variables and then
     # let's check the directory name is sensible
@@ -644,7 +644,7 @@ if (! $opt_create || ($opt_create && $opt_news)) {
     if ($opt_news) {
 	my $found_version = 0;
 	my $found_urgency = 0;
-	my $clog = Dpkg::Changelog::Parse::changelog_parse(file => $real_changelog_path);
+	my $clog = changelog_parse(file => $real_changelog_path);
 	$VERSION = $clog->{Version};
 	$VERSION =~ s/~$//;
 
@@ -1555,16 +1555,11 @@ if ((basename(cwd()) =~ m%^\Q$PACKAGE\E-\Q$UVERSION\E$%) &&
     !$opt_p && !$opt_create) {
     # Find the current version number etc.
     my ($new_version, $new_sversion, $new_uversion);
-    open PARSED, "dpkg-parsechangelog |"
-	or fatal "Cannot execute dpkg-parsechangelog: $!";
-    while (<PARSED>) {
-	if (/^Version:\s(.+?)\s*$/) { $new_version=$1; }
+    my $changelog = changelog_parse();
+    if (exists $changelog->{Version}) {
+	$new_version = $changelog->{Version};
     }
 
-    close PARSED
-	or fatal "Problem executing dpkg-parsechangelog: $!";
-    if ($?) { fatal "dpkg-parsechangelog failed!" }
-
     fatal "No version number in debian/changelog!"
 	unless defined $new_version;
 
diff --git a/scripts/debclean.sh b/scripts/debclean.sh
index f17a63b..45510a9 100755
--- a/scripts/debclean.sh
+++ b/scripts/debclean.sh
@@ -172,7 +172,7 @@ for i in `find . -type d -name "debian"`; do
 	echo "Directory $DIR: contains no debian/changelog, skipping" >&2
 	exit
     fi
-    package="`dpkg-parsechangelog | sed -n 's/^Source: //p'`"
+    package="`dpkg-parsechangelog -SSource`"
     if [ -z "$package" ]; then
 	echo "Directory $DIR: unable to determine package name, skipping" >&2
 	exit
diff --git a/scripts/debi.pl b/scripts/debi.pl
index 6e6fe13..d911748 100755
--- a/scripts/debi.pl
+++ b/scripts/debi.pl
@@ -31,7 +31,7 @@ use File::Basename;
 use filetest 'access';
 use Cwd;
 use Dpkg::Control;
-use Dpkg::Changelog::Parse;
+use Dpkg::Changelog::Parse qw(changelog_parse);
 
 my $progname = basename($0,'.pl');  # the '.pl' is for when we're debugging
 my $modified_conf_msg;
diff --git a/scripts/debrelease.sh b/scripts/debrelease.sh
index c25418e..a9647d4 100755
--- a/scripts/debrelease.sh
+++ b/scripts/debrelease.sh
@@ -258,10 +258,8 @@ if ! [ -d "$debsdir" ]; then
     fi
 fi
 
-mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
-    "source package"
-mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
-    "source version"
+mustsetvar package "`dpkg-parsechangelog -SSource`" "source package"
+mustsetvar version "`dpkg-parsechangelog -SVersion`" "source version"
 
 if [ $CHECK_DIRNAME_LEVEL -eq 2 -o \
     \( $CHECK_DIRNAME_LEVEL -eq 1 -a "$CHDIR" = yes \) ]; then
diff --git a/scripts/debrsign.sh b/scripts/debrsign.sh
index f21536c..0c7917b 100755
--- a/scripts/debrsign.sh
+++ b/scripts/debrsign.sh
@@ -155,10 +155,8 @@ case $# in
 	esac
 
 
-	mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
-	    "source package"
-	mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
-	    "source version"
+	mustsetvar package "`dpkg-parsechangelog -SSource`" "source package"
+	mustsetvar version "`dpkg-parsechangelog -SVersion`" "source version"
 
 	if [ "x$sourceonly" = x ]
 	then
diff --git a/scripts/debsign.sh b/scripts/debsign.sh
index b129e8a..8bd5559 100755
--- a/scripts/debsign.sh
+++ b/scripts/debsign.sh
@@ -630,10 +630,8 @@ case $# in
 	    exit 1
 	fi
 
-	mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
-	    "source package"
-	mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
-	    "source version"
+	mustsetvar package "`dpkg-parsechangelog -SSource`" "source package"
+	mustsetvar version "`dpkg-parsechangelog -SVersion`" "source version"
 
 	if [ "x$sourceonly" = x ]
 	then
diff --git a/scripts/debuild.pl b/scripts/debuild.pl
index 28f4f34..4227d2d 100755
--- a/scripts/debuild.pl
+++ b/scripts/debuild.pl
@@ -54,6 +54,7 @@ use File::Basename;
 use filetest 'access';
 use Cwd;
 use Devscripts::Compression;
+use Dpkg::Changelog::Parse qw(changelog_parse);
 use Dpkg::IPC;
 use IO::Handle;  # for flushing
 use vars qw(*BUILD *OLDOUT *OLDERR);  # prevent a warning
@@ -636,17 +637,8 @@ until (-r 'debian/changelog') {
 
 # Find the source package name and version number
 my %changelog;
-my @parsed = grep {/^(Source|Version):/} `dpkg-parsechangelog`
-    or fatal "cannot execute dpkg-parsechangelog | grep: $!";
-foreach (@parsed) {
-    chomp;
-    if (/^(\S+):\s(.+?)\s*$/) { $changelog{$1}=$2; }
-    else {
-	fatal "don't understand dpkg-parsechangelog output: $_";
-    }
-}
-
-if ($?) { fatal "dpkg-parsechangelog | grep failed!" }
+my $c = changelog_parse();
+ at changelog{'Source', 'Version'} = @{$c}{'Source', 'Version'};
 
 fatal "no package name in changelog!"
     unless exists $changelog{'Source'};
diff --git a/scripts/nmudiff.sh b/scripts/nmudiff.sh
index 29a6d81..e925fa0 100755
--- a/scripts/nmudiff.sh
+++ b/scripts/nmudiff.sh
@@ -247,19 +247,19 @@ if ! [ -f debian/changelog ]; then
     exit 1
 fi
 
-SOURCE=$(dpkg-parsechangelog | grep ^Source: | cut -d" " -f2)
+SOURCE=$(dpkg-parsechangelog -SSource)
 if [ -z "$SOURCE" ]; then
     echo "nmudiff: could not determine source package name from changelog!" >&2
     exit 1
 fi
 
-VERSION=$(dpkg-parsechangelog | grep ^Version: | cut -d" " -f2)
+VERSION=$(dpkg-parsechangelog -SVersion)
 if [ -z "$VERSION" ]; then
     echo "nmudiff: could not determine source package version from changelog!" >&2
     exit 1
 fi
 
-CLOSES=$(dpkg-parsechangelog | grep ^Closes: | cut -d" " -f2-)
+CLOSES=$(dpkg-parsechangelog -SCloses)
 
 if [ -z "$CLOSES" ]; then
     # no bug reports, so make a new report in any event
@@ -275,7 +275,7 @@ if [ "$NMUDIFF_NEWREPORT" = "maybe" ]; then
     fi
 fi
 
-OLDVERSION=$(dpkg-parsechangelog -o1 -c1 | grep ^Version: | cut -d" " -f2)
+OLDVERSION=$(dpkg-parsechangelog -o1 -c1 -SVersion)
 if [ -z "$OLDVERSION" ]; then
     echo "nmudiff: could not determine previous package version from changelog!" >&2
     exit 1
diff --git a/scripts/tagpending.pl b/scripts/tagpending.pl
index 9db77f5..fde1a04 100755
--- a/scripts/tagpending.pl
+++ b/scripts/tagpending.pl
@@ -28,6 +28,7 @@ use strict;
 use warnings;
 use Getopt::Long qw(:config gnu_getopt);
 use File::Basename;
+use Dpkg::Changelog::Parse qw(changelog_parse);
 use Devscripts::Debbugs;
 
 sub bugs_info;
@@ -35,7 +36,7 @@ sub bugs_info;
 my $progname = basename($0);
 
 my ($opt_help, $opt_version, $opt_verbose, $opt_noact, $opt_silent);
-my ($opt_online, $opt_confirm, $opt_to, $opt_wnpp, $opt_comments);
+my ($opt_online, $opt_confirm, %opt_to, $opt_wnpp, $opt_comments);
 my $opt_interactive;
 
 # Default options
@@ -45,7 +46,7 @@ $opt_online = 1;
 $opt_noact = 0;
 $opt_confirm = 0;
 $opt_wnpp = 0;
-$opt_to = '';
+%opt_to = ();
 $opt_comments = 1;
 $opt_interactive = 0;
 
@@ -57,14 +58,12 @@ GetOptions("help|h" => \$opt_help,
 	   "silent|s" => \$opt_silent,
 	   "force|f" => sub { $opt_online = 0; },
 	   "confirm|c" => \$opt_confirm,
-	   "to|t=s" => \$opt_to,
+	   "to|t=s" => sub { $opt_to{'-v'} = $_[1] },
 	   "wnpp|w" => \$opt_wnpp,
 	   "interactive|i" => \$opt_interactive,
            )
     or die "Usage: $progname [options]\nRun $progname --help for more details\n";
 
-$opt_to = "-v$opt_to" if $opt_to;
-
 if ($opt_help) {
     help(); exit 0;
 } elsif ($opt_version) {
@@ -150,39 +149,16 @@ B<bts>(1) and B<dpkg-parsechangelog>(1)
 
 =cut
 
-my $source;
-my @closes;
-my $in_changes=0;
-my $changes='';
-my $header='';
-
-foreach my $file ("debian/changelog") {
-    if (! -f $file) {
-	die "$progname error: $file does not exist!\n";
-    }
-}
-
-open PARSED, "dpkg-parsechangelog $opt_to |";
-
-while (<PARSED>) {
-    if (/^Source: (.*)/) {
-	$source = $1;
-    } elsif (/^Closes: (.*)$/) {
-	@closes = split ' ', $1;
-    } elsif (/^Changes: /) {
-	$in_changes = 1;
-    } elsif ($in_changes) {
-	if ($header) {
-	    next unless /^ {3}[^[]/;
-	    $changes .= "\n" if $changes;
-	    $changes .= $_;
-	} else {
-	    $header = $_;
-	}
-    }
+if (! -f 'debian/changelog') {
+  die "$progname error: debian/changelog does not exist!\n";
 }
 
-close PARSED;
+my $changelog = changelog_parse(%opt_to);
+my $source = $changelog->{Source};
+my @closes = split ' ', $changelog->{Closes};
+my @lines = split /\n/, $changelog->{Changes};
+my $header = $lines[1];
+my $changes = join "\n", grep /^ {3}[^[]/, @lines;
 
 # Add a fake entry to the end of the recorded changes
 # This makes the parsing of the changes simpler
diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 119a741..b64122d 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -27,6 +27,7 @@ use strict;
 use warnings;
 use Cwd;
 use Cwd 'abs_path';
+use Dpkg::Changelog::Parse qw(changelog_parse);
 use Dpkg::IPC;
 use File::Basename;
 use File::Copy;
@@ -463,14 +464,14 @@ if (defined $opt_watchfile) {
 	}
 
 	# Figure out package info we need
-	my $changelog = `dpkg-parsechangelog`;
-	unless ($? == 0) {
-	    uscan_die "$progname: Problems running dpkg-parsechangelog\n";
+	my $changelog = eval { changelog_parse(); };
+	if ($@) {
+	    uscan_die "$progname: Problems parsing debian/changelog: $@\n";
 	}
 
 	my ($package, $debversion, $uversion);
-	$changelog =~ /^Source: (.*?)$/m and $package=$1;
-	$changelog =~ /^Version: (.*?)$/m and $debversion=$1;
+	$package = $changelog->{Source};
+	$debversion = $changelog->{Version};
 	if (! defined $package || ! defined $debversion) {
 	    uscan_die "$progname: Problems determining package name and/or version from\n  debian/changelog\n";
 	}
@@ -546,15 +547,15 @@ for my $dir (@dirs) {
     # Check for debian/watch file
     if (-r 'debian/watch' and -r 'debian/changelog') {
 	# Figure out package info we need
-	my $changelog = `dpkg-parsechangelog`;
-	unless ($? == 0) {
-	    uscan_warn "$progname warning: Problems running dpkg-parsechangelog in $dir, skipping\n";
+	my $changelog = eval { changelog_parse(); };
+	if ($@) {
+	    uscan_warn "$progname warning: Problems parse debian/changelog in $dir, skipping\n";
 	    next;
 	}
 
 	my ($package, $debversion, $uversion);
-	$changelog =~ /^Source: (.*?)$/m and $package=$1;
-	$changelog =~ /^Version: (.*?)$/m and $debversion=$1;
+	$packages = $changelog->{Source};
+	$debversion = $changelog->{Version};
 	if (! defined $package || ! defined $debversion) {
 	    uscan_warn "$progname warning: Problems determining package name and/or version from\n  $dir/debian/changelog, skipping\n";
 	    next;
diff --git a/scripts/uupdate.sh b/scripts/uupdate.sh
index 97314da..e037327 100755
--- a/scripts/uupdate.sh
+++ b/scripts/uupdate.sh
@@ -231,10 +231,8 @@ if [ ! -f debian/changelog ]; then
 fi
 
 # Figure out package info we need
-mustsetvar PACKAGE "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" \
-    "source package"
-mustsetvar VERSION "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" \
-    "source version"
+mustsetvar PACKAGE "`dpkg-parsechangelog -SSource`" "source package"
+mustsetvar VERSION "`dpkg-parsechangelog -SVersion`" "source version"
 
 # Get epoch and upstream version
 eval `echo "$VERSION" | perl -ne '/^(?:(\d+):)?(.*)/; print "SVERSION=$2\nEPOCH=$1\n";'`
diff --git a/scripts/what-patch.sh b/scripts/what-patch.sh
index dc5c173..edabcdf 100755
--- a/scripts/what-patch.sh
+++ b/scripts/what-patch.sh
@@ -55,7 +55,7 @@ then
 fi
 
 if [ "$VERBOSE" -gt 0 ]; then
-	files=`lsdiff -z ../$(dpkg-parsechangelog | grep ^Source: | sed -e "s/^Source: //")_$(dpkg-parsechangelog | grep ^Version: | sed -e "s/^Version: //").diff.gz 2>/dev/null | grep -v 'debian/'`
+	files=`lsdiff -z ../$(dpkg-parsechangelog -SSource)_$(dpkg-parsechangelog -SVersion).diff.gz 2>/dev/null | grep -v 'debian/'`
 	if [ -n "$files" ]
 	then
 		echo "Following files were modified outside of the debian/ directory:"
diff --git a/test/test_debchange b/test/test_debchange
index 810d3f1..867a38c 100755
--- a/test/test_debchange
+++ b/test/test_debchange
@@ -65,7 +65,7 @@ checkVersion() {
     rm -f "$CHANGELOG"
     success "--create $start_param --package test-package -v $start_version \"Devscripts Test Suite.\""
     success "$param \"Version test.\""
-    local version=$(dpkg-parsechangelog -l"$CHANGELOG" | sed -n 's/^Version: //p')
+    local version=$(dpkg-parsechangelog -l"$CHANGELOG" -SVersion)
     assertEquals "\"dch $param\" from version $start_version" "$expected_version" "$version"
 }
 
@@ -122,7 +122,7 @@ testUbuntuRebuild() {
 }
 
 verifyMaintainer() {
-    local maintainer="$(dpkg-parsechangelog -l"$CHANGELOG" | sed -n 's/^Maintainer: //p')"
+    local maintainer="$(dpkg-parsechangelog -l"$CHANGELOG" -SMaintainer)"
     assertEquals "\"$1\"" "$DEBFULLNAME <$DEBEMAIL>" "$maintainer"
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list