[devscripts] 03/03: mk-build-deps: Return name of built .deb from build_equiv

James McCoy jamessan at debian.org
Mon Jul 7 03:35:46 UTC 2014


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

jamessan pushed a commit to branch master
in repository devscripts.

commit ed03c060a90baca7d086f916c0f6fe8b05246049
Author: James McCoy <jamessan at debian.org>
Date:   Sun Jul 6 23:05:16 2014 -0400

    mk-build-deps: Return name of built .deb from build_equiv
    
    The previous approach of globbing the working directory for the name of
    the deb was prone to error when apt-cache emitted multiple source
    stanzas or previous .deb files had not been removed.
    
    Closes: #753657
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog         |  2 ++
 scripts/mk-build-deps.pl | 47 +++++++++++++++++++++++++++++++----------------
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 6518d53..2a8e468 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,6 +19,8 @@ devscripts (2.14.6) UNRELEASED; urgency=medium
       install fails.
     + Read all of the output from “apt-cache showsrc” to ensure mk-build-deps
       doesn't get stuck waiting for apt-cache to exit.
+    + Pass the name of the .deb file out of build_equiv to ensure the correct
+      .deb is installed.  (Closes: #753657)
 
   [ Christoph Berg ]
   * Update all qa.debian.org URLs to https://.
diff --git a/scripts/mk-build-deps.pl b/scripts/mk-build-deps.pl
index c1be28f..c84dc38 100755
--- a/scripts/mk-build-deps.pl
+++ b/scripts/mk-build-deps.pl
@@ -121,7 +121,6 @@ my $control;
 my $install_tool;
 my $root_cmd;
 my @packages;
-my @deb_files;
 
 my @config_files = ('/etc/devscripts.conf', '~/.devscripts');
 my %config_vars = (
@@ -338,27 +337,31 @@ while ($control = shift) {
 }
 
 if ($opt_install) {
-    for my $package (@packages) {
-	my $file = glob "${package}_*.deb";
-	push @deb_files, $file;
-    }
-
     my @root;
     if ($root_cmd) {
 	push(@root, shellwords($root_cmd));
     }
+
+    my (@pkg_names, @deb_files, %uniq);
+    for my $package (@packages) {
+	if ($uniq{$package->{deb_file}}++ == 0) {
+	    push @pkg_names, $package->{package};
+	    push @deb_files, $package->{deb_file};
+	}
+    }
+
     system @root, 'dpkg', '--unpack', @deb_files;
-    die("dpkg call failed\n") if ( ($?>>8) != 0 );
+    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', @packages;
-	die("install call failed\n");
+	system @root, 'dpkg', '--remove', @pkg_names;
+	die("$progname: apt-get install call failed\n");
     }
 
     if ($opt_remove) {
-	foreach my $file (@deb_files) {
+	foreach my $file (map { $_->{package} } @packages) {
 	    unlink $file;
 	}
     }
@@ -382,14 +385,16 @@ sub build_equiv
     my $args = '';
     my $arch = 'all';
 
-    if ($opts->{depends} =~ /\[|\]/) {
-	$arch = 'any';
-
-    }
     if (defined $opt_arch) {
 	$args = "--arch=$opt_arch ";
 	$arch = $opt_arch;
     }
+    elsif ($opts->{depends} =~ m/\[|\]/) {
+	spawn(exec => ['dpkg-architecture', '-qDEB_HOST_ARCH'],
+	      to_string => \$arch,
+	      wait_child => 1);
+	chomp($arch);
+    }
 
     my $readme = '/usr/share/devscripts/README.mk-build-deps';
     open EQUIVS, "| equivs-build $args-"
@@ -406,11 +411,21 @@ sub build_equiv
     # Allow the file not to exist to ease testing
     print EQUIVS "Readme: $readme\n" if -r $readme;
 
-    print EQUIVS "Version: $opts->{version}\n" if $opts->{version};
+    my $version = $opts->{version} || '1.0';
+    print EQUIVS "Version: $version\n";
 
     print EQUIVS "Description: build-dependencies for $opts->{name}\n" .
     " Depencency package to build the '$opts->{name}' package\n";
 
     close EQUIVS;
-    return "$opts->{name}-$opts->{type}";
+
+    my $v = Dpkg::Version->new($version);
+    # The version in the .deb filename will not contain the epoch
+    $version = $v->as_string(omit_epoch => 1);
+    my $package = "$opts->{name}-$opts->{type}";
+    my $deb_file = "${package}_${version}_${arch}.deb";
+    return {
+	package => $package,
+	deb_file => $deb_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