Package: devscripts
Version: 2.14.2
Severity: normal

Hi.

'mk-build-deps -i' attempts to install the build-deps package this tool
builds. It does this by running

 dpkg --unpack
 apt-get --no-install-recommends just_built.deb

mk-build-deps then looks at the return code of apt-get to determine if
the command succeeded. This apt-get command is interactive, and will ask
the user to confirm. If the user says no, mk-build-deps knows that
apt-get failed. This is fine.

I want to run this non-interactively, so I invoke mk-build-deps with '-t
"apt-get -y --no-install-recommend". With this command, if it's
impossible to install the new package, apt-get will automatically remove
it, and return a SUCCESSFULL error code, even though the action that
mk-build-deps was asked to perform failed.

I'm attaching a patch that explicitly checks if the packages we were
asked to install actually did get installed. If they were not, it
outputs a very explicit error message.


--- /tmp/devscripts/scripts/mk-build-deps.pl	Sat Jul 19 02:24:02 2014
+++ /tmp/ediff29490DaW	Sat Jul 19 17:37:28 2014
@@ -353,11 +353,25 @@
     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 ) {
+    my $err = $? >> 8;
+    if ( !$err ) {
+        # APT succeeded. Did the packages get installed? It's possible that they
+        # didn't because APT may have realized that installation was impossible,
+        # and it could have given up, successfully.
+        for my $deb (@deb_files) {
+            system(qw(dpkg -l $deb 2>/dev/null));
+            if($? >> 8) {
+                $err = 1;
+                last;
+            }
+        }
+    }
+
+    if ( $err ) {
 	# 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");
+	die("ERROR!!! $progname: APT could not install all of these packages: @deb_files\n");
     }
 
     if ($opt_remove) {

Reply via email to