[SCM] Git repository for devscripts branch, master, updated. v2.11.6-23-g6537756

James McCoy jamessan at debian.org
Sun May 6 18:10:35 UTC 2012


The following commit has been merged in the master branch:
commit bfaab93a0235942e89edf054e309228b42408198
Author: James McCoy <jamessan at debian.org>
Date:   Sun May 6 13:55:55 2012 -0400

    Various small cleanups for mk-build-deps
    
    + Make error messages more explicit about what went wrong.  (Closes:
      #596561)
    + Use Dpkg::IPC to run apt-cache.
    + Don't run equivs if no package information was parsed.
    
    Signed-off-by: James McCoy <jamessan at debian.org>

diff --git a/debian/changelog b/debian/changelog
index 6df5893..5bb20e0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -21,6 +21,11 @@ devscripts (2.11.7) UNRELEASED; urgency=low
     VCSes.
   * svnpath: Always run “svn info” instead of checking for .svn. (Closes:
     #645106)
+  * mk-build-deps:
+    + Make error messages more explicit about what went wrong.  (Closes:
+      #596561)
+    + Use Dpkg::IPC to run apt-cache.
+    + Don't run equivs if no package information was parsed.
 
   [ Benjamin Drung ]
   * Introduce a test suite for the scripts based on shunit2.
diff --git a/scripts/mk-build-deps.pl b/scripts/mk-build-deps.pl
index f9f736b..15fb512 100755
--- a/scripts/mk-build-deps.pl
+++ b/scripts/mk-build-deps.pl
@@ -109,6 +109,8 @@ use File::Basename;
 use Pod::Usage;
 use Dpkg::Control;
 use Dpkg::Version;
+use Dpkg::IPC;
+use FileHandle;
 use Text::ParseWords;
 
 my $progname = basename($0);
@@ -209,27 +211,40 @@ if ($?) {
 }
 
 while ($control = shift) {
-    my ($name, $fh);
+    my ($name, $fh, $descr, $pid);
     if (-r $control and -f $control) {
-	open $fh, $control || do {
+	open $fh, $control;
+	unless (defined $fh) {
 	    warn "Unable to open $control: $!\n";
 	    next;
-        };
+	}
 	$name = 'Source';
+	$descr = "control file `$control'";
     }
     else {
-	open $fh, "apt-cache showsrc $control |" || do {
+	$fh = FileHandle->new();
+	$pid = spawn(exec => ['apt-cache', 'showsrc', $control],
+		     from_file => '/dev/null',
+		     to_pipe => $fh);
+	unless (defined $pid) {
 	    warn "Unable to run apt-cache: $!\n";
 	    next;
-        };
+	}
 	$name = 'Package';
+	$descr = "`apt-cache showsrc $control'";
     }
 
     my (@pkgInfo, @versions);
     until (eof $fh) {
 	my $ctrl = Dpkg::Control->new(allow_pgp => 1, type => CTRL_UNKNOWN);
-	unless ($ctrl->parse($fh, $control)) {
-	    die "$progname: Unable to find package name in '$control'\n";
+	# parse() dies if the file isn't syntactically valid and returns undef
+	# if there simply weren't any fields parsed
+	unless ($ctrl->parse($fh, $descr)) {
+	    die "$progname: Unable to find package name in $descr\n";
+	}
+	if (defined $pid) {
+	    wait_child($pid, no_check => 1);
+	    undef $pid;
 	}
 	unless (exists $ctrl->{$name}) {
 	    next;
@@ -281,6 +296,7 @@ while ($control = shift) {
 		   version => $ctrl->{Version} });
 	}
     }
+    wait_child($pid, no_check => 1) if defined $pid;
     # Only use the newest version.  We'll only have this if processing showsrc
     # output or a dsc file.
     if (@versions) {
@@ -290,9 +306,12 @@ while ($control = shift) {
 	push(@packages, map { build_equiv($_) }
 			grep { $versions[0] eq $_->{version} } @pkgInfo);
     }
-    else {
+    elsif (@pkgInfo) {
 	push(@packages, build_equiv($pkgInfo[0]));
     }
+    else {
+	die "$progname: Unable to find package name in $descr\n";
+    }
 }
 
 if ($opt_install) {

-- 
Git repository for devscripts



More information about the Devscripts-devel mailing list