[devscripts] 02/05: mk-build-deps: Verify build-dep packages are actually installed

James McCoy jamessan at debian.org
Wed Jun 10 03:34:07 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 32731f6a41e69740bbbaa86f372059d44cf85605
Author: James McCoy <jamessan at debian.org>
Date:   Tue Jun 9 21:13:59 2015 -0400

    mk-build-deps: Verify build-dep packages are actually installed
    
    Closes: #755371
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog         |  4 ++++
 scripts/mk-build-deps.pl | 45 +++++++++++++++++++++++++++++++++++++--------
 2 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index fb1d716..58bfd69 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -39,6 +39,10 @@ devscripts (2.15.5) UNRELEASED; urgency=medium
       relevant sites.  (Closes: #736063)
   * Devscripts::Debbugs: Retrieve bug status in chunks to avoid building large
     responses on bugs.d.o.
+  * mk-build-deps:
+    + Verify build-dep package was installed since the install tool may exit
+      successfully even if the package couldn't be installed.  Based on a
+      patch by Dima Kogan.  (Closes: #755371)
 
   [ Dominique Dumont ]
   * licensecheck:
diff --git a/scripts/mk-build-deps.pl b/scripts/mk-build-deps.pl
index 012c814..a17be2b 100755
--- a/scripts/mk-build-deps.pl
+++ b/scripts/mk-build-deps.pl
@@ -353,16 +353,45 @@ if ($opt_install) {
     system @root, 'dpkg', '--unpack', @deb_files;
     die("$progname: dpkg --unpack failed\n") if ( ($?>>8) != 0 );
     system @root, shellwords($install_tool), '-f', 'install';
-    if ( ($?>>8) != 0 ) {
-	# Restore system to previous state, since apt wasn't able to resolve a
-	# proper way to get the build-dep packages installed
-	system @root, 'dpkg', '--remove', @pkg_names;
-	die("$progname: apt-get install call failed\n");
+    my $err = $? >> 8;
+    if (!$err) {
+	# $install_tool succeeded. Did the packages get installed? It's
+	# possible that they didn't because $install_tool may have realized
+	# that installation was impossible, and it could have given up,
+	# successfully.
+	for (my $i = 0; $i < @pkg_names; $i++) {
+	    my $pkg = $pkg_names[$i];
+	    my $status;
+	    spawn(exec => ['dpkg-query', '-W', '-f', '${db:Status-Status}', $pkg],
+	          to_string => \$status,
+	          error_to_file => '/dev/null',
+	          nocheck => 1,
+	          wait_child => 1);
+	    if ($status ne 'installed' || ($? >> 8)) {
+		# Restore system to previous state, since $install_tool wasn't
+		# able to resolve a proper way to get the build-dep packages
+		# installed
+		warn "$progname: Unable to install $pkg";
+		$err = 1;
+	    }
+	    else {
+		unlink $deb_files[$i];
+	    }
+	}
+	if ($err) {
+	    die "$progname: Unable to install all build-dep packages\n";
+	}
     }
+    else {
+	# Restore system to previous state, since $install_tool wasn't able to
+	# resolve a proper way to get the build-dep packages installed
+	system @root, 'dpkg', '--remove', @pkg_names;
+	die("$progname: Unable to install all build-dep packages\n");
 
-    if ($opt_remove) {
-	foreach my $file (@deb_files) {
-	    unlink $file;
+	if ($opt_remove) {
+	    foreach my $file (@deb_files) {
+		unlink $file;
+	    }
 	}
     }
 }

-- 
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