]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Packages.pm
properly support src: packages in make_source_versions
[debbugs.git] / Debbugs / Packages.pm
index 307e1f98005042c17b5ee4a793cfa3b369e617b5..47c37f9f7bbd6bb0dba0bd4d9e5e72f497452962 100644 (file)
@@ -144,6 +144,9 @@ sub binarytosource {
     # need an extra cache for speed here.
     return () unless defined $gBinarySourceMap;
 
+    if ($binname =~ m/^src:(.+)$/) {
+       return $1;
+    }
     if (not tied %_binarytosource) {
         tie %_binarytosource, MLDBM => $gBinarySourceMap, O_RDONLY or
              die "Unable to open $gBinarySourceMap for reading";
@@ -167,6 +170,9 @@ sub binarytosource {
     elsif (exists $binary{$binver}) {
         if (defined $binarch) {
              my $src = $binary{$binver}{$binarch};
+             if (not defined $src and exists $binary{$binver}{all}) {
+                 $src = $binary{$binver}{all};
+             }
              return () unless defined $src; # not on this arch
              # Copy the data to avoid tiedness problems.
              return dclone($src);
@@ -219,9 +225,8 @@ sub sourcetobinary {
     # avoid autovivification
     my $source = $_sourcetobinary{$srcname};
     return () unless defined $source;
-    my %source = %{$source};
-    if (exists $source{$srcver}) {
-        my $bin = $source{$srcver};
+    if (exists $source->{$srcver}) {
+        my $bin = $source->{$srcver};
         return () unless defined $bin;
         return @$bin;
     }
@@ -340,8 +345,8 @@ sub get_versions{
               for my $arch (exists $param{arch}?
                             make_list($param{arch}):
                             (grep {not $param{no_source_arch} or
-                                        $_ ne 'source'
-                              } keys %{$version->{$dist}})) {
+                                       $_ ne 'source'
+                                   } keys %{$version->{$dist}})) {
                    next unless defined $version->{$dist}{$arch};
                    for my $ver (ref $version->{$dist}{$arch} ?
                                 keys %{$version->{$dist}{$arch}} :
@@ -421,7 +426,7 @@ sub make_source_versions {
     my %param = validate_with(params => \@_,
                              spec   => {package => {type => SCALAR|ARRAYREF,
                                                    },
-                                        arch    => {type => SCALAR|ARRAYREF,
+                                        arch    => {type => SCALAR|ARRAYREF|UNDEF,
                                                     default => ''
                                                    },
                                         versions => {type => SCALAR|ARRAYREF,
@@ -444,9 +449,8 @@ sub make_source_versions {
     my ($warnings) = globify_scalar(exists $param{warnings}?$param{warnings}:undef);
     my ($debug)    = globify_scalar(exists $param{debug}   ?$param{debug}   :undef);
 
-
     my @packages = grep {defined $_ and length $_ } make_list($param{package});
-    my @archs    = grep {defined $_ } make_list ($param{archs});
+    my @archs    = grep {defined $_ } make_list ($param{arch});
     if (not @archs) {
        push @archs, '';
     }
@@ -459,19 +463,31 @@ sub make_source_versions {
     my %sourceversions;
     for my $version (make_list($param{versions})) {
         if ($version =~ m{(.+)/([^/]+)$}) {
+           # Already a source version.
+            $sourceversions{$version} = 1;
+           next unless exists $param{warnings};
            # check to see if this source version is even possible
            my @bin_versions = sourcetobinary($1,$2);
            if (not @bin_versions or
                @{$bin_versions[0]} != 3) {
                print {$warnings} "The source $1 and version $2 do not appear to match any binary packages\n";
            }
-            # Already a source version.
-            $sourceversions{$version} = 1;
         } else {
            if (not @packages) {
                croak "You must provide at least one package if the versions are not fully qualified";
            }
            for my $pkg (@packages) {
+               if ($pkg =~ /^src:(.+)/) {
+                   $sourceversions{"$1/$version"} = 1;
+                   next unless exists $param{warnings};
+                   # check to see if this source version is even possible
+                   my @bin_versions = sourcetobinary($1,$version);
+                   if (not @bin_versions or
+                       @{$bin_versions[0]} != 3) {
+                       print {$warnings} "The source $1 and version $2 do not appear to match any binary packages\n";
+                   }
+                   next;
+               }
                for my $arch (@archs) {
                    my $cachearch = (defined $arch) ? $arch : '';
                    my $cachekey = "$pkg/$cachearch/$version";
@@ -483,7 +499,7 @@ sub make_source_versions {
                    }
                    elsif ($param{guess_source} and
                           exists$param{source_version_cache}{$cachekey.'/guess'}) {
-                       for my $v (@{$param{source_version_cache}{$cachekey}}) {
+                       for my $v (@{$param{source_version_cache}{$cachekey.'/guess'}}) {
                            $sourceversions{$v} = 1;
                        }
                        next;