[devscripts] 04/04: debsnap: Error when version or architecture aren't found

James McCoy jamessan at debian.org
Sat Jan 3 14:49:43 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 81c4d4da5bbcbbda3dad4e510df5261f31095893
Author: James McCoy <jamessan at debian.org>
Date:   Sat Jan 3 02:20:06 2015 -0500

    debsnap: Error when version or architecture aren't found
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog   |  4 ++++
 scripts/debsnap.pl | 41 ++++++++++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index e36f634..2b9e08f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,10 @@ devscripts (2.15.1+exp1) UNRELEASED; urgency=medium
   * uscan: explicitly dearmor, rather than --import upstream signing key
     (Closes: #768345)
 
+  [ James McCoy ]
+  * debsnap: When specified version or architectures aren't available, warn
+    and exit with error code 2.  (Closes: #774276)
+
  -- James McCoy <jamessan at debian.org>  Sat, 03 Jan 2015 00:47:36 -0500
 
 devscripts (2.15.1) unstable; urgency=medium
diff --git a/scripts/debsnap.pl b/scripts/debsnap.pl
index 48c3832..8800e37 100755
--- a/scripts/debsnap.pl
+++ b/scripts/debsnap.pl
@@ -54,7 +54,7 @@ if ($@) {
 my $modified_conf_msg = '';
 my %config_vars = ();
 
-my %opt;
+my %opt = (architecture => []);
 my $package = '';
 my $pkgversion = '';
 my $warnings = 0;
@@ -215,7 +215,7 @@ if (@ARGV) {
 
 $package eq '' && usage(1);
 
-$opt{binary} ||= $opt{architecture};
+$opt{binary} ||= @{$opt{architecture}};
 
 my $baseurl;
 if ($opt{binary}) {
@@ -238,23 +238,37 @@ unless ($json_text && @{$json_text->{result}}) {
     fatal "Unable to retrieve information for $package from $baseurl.";
 }
 
+my @versions = @{$json_text->{result}};
+if ($pkgversion) {
+    @versions = $opt{binary} ? grep { !($_->{binary_version} <=> $pkgversion) } @versions
+                             : grep { !($_->{version} <=> $pkgversion) } @versions;
+    unless (@versions) {
+	warn "$progname: No matching versions found for $package\n";
+	$warnings++;
+    }
+}
 if ($opt{binary}) {
-    foreach my $version (@{$json_text->{result}}) {
-	if ($pkgversion) {
-	    next if ($version->{binary_version} <=> $pkgversion);
-	}
-
+    foreach my $version (@versions) {
 	my $src_json = fetch_json_page("$opt{baseurl}/mr/package/$version->{source}/$version->{version}/binfiles/$version->{name}/$version->{binary_version}?fileinfo=1");
 
 	unless ($src_json) {
 	    warn "$progname: No binary packages found for $package version $version->{binary_version}\n";
 	    $warnings++;
+	    next;
 	}
 
-	foreach my $result (@{$src_json->{result}}) {
-	    if ($opt{architecture} && @{$opt{architecture}}) {
-		next unless (grep { $_ eq $result->{architecture} } @{$opt{architecture}});
+	my @results = @{$src_json->{result}};
+	if (@{$opt{architecture}})
+	{
+	    my %archs = map { ($_ => 1) } @{$opt{architecture}};
+	    @results = grep { $archs{$_->{architecture}}-- } @results;
+	    my @missing = grep { $archs{$_} == 1 } sort keys %archs;
+	    if (@missing) {
+		warn "$progname: No binary packages found for $package version $version->{binary_version} on " . join(', ', @missing) . "\n";
+		$warnings++;
 	    }
+	}
+	foreach my $result (@results) {
 	    my $hash = $result->{hash};
 	    my $fileinfo = @{$src_json->{fileinfo}{$hash}}[0];
 	    my $file_url = "$opt{baseurl}/file/$hash";
@@ -267,15 +281,12 @@ if ($opt{binary}) {
     }
 }
 else {
-    foreach my $version (@{$json_text->{result}}) {
-	if ($pkgversion) {
-	    next if ($version->{version} <=> $pkgversion);
-	}
-
+    foreach my $version (@versions) {
 	my $src_json = fetch_json_page("$baseurl/$version->{version}/srcfiles?fileinfo=1");
 	unless ($src_json) {
 	    warn "$progname: No source files found for $package version $version->{version}\n";
 	    $warnings++;
+	    next;
 	}
 
 	foreach my $hash (keys %{$src_json->{fileinfo}}) {

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