]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Status.pm
* fix extraneous semicolon
[debbugs.git] / Debbugs / Status.pm
index 6e21f99cff7ee3de8ec61aa5513cfc2222db1dd6..8b4b9b045164363d14371e5336223ac20f373663 100644 (file)
@@ -40,7 +40,7 @@ use Params::Validate qw(validate_with :types);
 use Debbugs::Common qw(:util :lock :quit :misc);
 use Debbugs::Config qw(:config);
 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
-use Debbugs::Packages qw(makesourceversions make_source_versions getversions get_versions binarytosource);
+use Debbugs::Packages qw(makesourceversions make_source_versions getversions get_versions binary_to_source);
 use Debbugs::Versions;
 use Debbugs::Versions::Dpkg;
 use POSIX qw(ceil);
@@ -232,7 +232,11 @@ sub read_bug{
     for my $line (@lines) {
         if ($line =~ /(\S+?): (.*)/) {
             my ($name, $value) = (lc $1, $2);
-            $data{$namemap{$name}} = $value if exists $namemap{$name};
+           # this is a bit of a hack; we should never, ever have \r
+           # or \n in the fields of status. Kill them off here.
+           # [Eventually, this should be superfluous.]
+           $value =~ s/[\r\n]//g;
+           $data{$namemap{$name}} = $value if exists $namemap{$name};
         }
     }
     for my $field (keys %fields) {
@@ -291,6 +295,10 @@ my %split_fields =
      affects        => \&splitpackages,
      blocks         => $ditch_empty_space,
      blockedby      => $ditch_empty_space,
+     # this isn't strictly correct, but we'll split both of them for
+     # the time being until we ditch all use of keywords everywhere
+     # from the code
+     keywords       => $ditch_empty_space,
      tags           => $ditch_empty_space,
      found_versions => $ditch_empty_space,
      fixed_versions => $ditch_empty_space,
@@ -518,6 +526,13 @@ sub makestatus {
         }
     }
 
+    # this is a bit of a hack; we should never, ever have \r or \n in
+    # the fields of status. Kill them off here. [Eventually, this
+    # should be superfluous.]
+    for my $field (keys %newdata) {
+       $newdata{$field} =~ s/[\r\n]//g if defined $newdata{$field};
+    }
+
     if ($version == 1) {
         for my $field (@v1fieldorder) {
             if (exists $newdata{$field} and defined $newdata{$field}) {
@@ -604,7 +619,7 @@ The following functions are exported with the :versions tag
 
      addfoundversions($status,$package,$version,$isbinary);
 
-
+All use of this should be phased out in favor of Debbugs::Control::fixed/found
 
 =cut
 
@@ -617,9 +632,14 @@ sub addfoundversions {
     return unless defined $version;
     undef $package if $package =~ m[(?:\s|/)];
     my $source = $package;
+    if ($package =~ s/^src://) {
+       $isbinary = 0;
+       $source = $package;
+    }
 
     if (defined $package and $isbinary) {
-        my @srcinfo = binarytosource($package, $version, undef);
+        my @srcinfo = binary_to_source(binary => $package,
+                                      version => $version);
         if (@srcinfo) {
             # We know the source package(s). Use a fully-qualified version.
             addfoundversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
@@ -693,7 +713,8 @@ sub addfixedversions {
     my $source = $package;
 
     if (defined $package and $isbinary) {
-        my @srcinfo = binarytosource($package, $version, undef);
+        my @srcinfo = binary_to_source(binary => $package,
+                                      version => $version);
         if (@srcinfo) {
             # We know the source package(s). Use a fully-qualified version.
             addfixedversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
@@ -1055,25 +1076,10 @@ sub get_bug_status {
 
      $status{package} = '' if not defined $status{package};
      $status{"package"} =~ s/\s*$//;
-     # if we aren't supposed to indicate the source, we'll return
-     # unknown here.
-     $status{source} = 'unknown';
-     if ($param{indicatesource}) {
-        my @packages = split /\s*,\s*/, $status{package};
-        my @source;
-        for my $package (@packages) {
-            next if $package eq '';
-            if ($package =~ /^src\:$/) {
-                push @source,$1;
-            }
-            else {
-                push @source, binarytosource($package);
-            }
-        }
-        if (@source) {
-            $status{source} = join(', ',@source);
-        }
-     }
+
+     $status{source} = binary_to_source(binary=>[split /\s*,\s*/, $status{package}],
+                                       source_only => 1,
+                                      );
 
      $status{"package"} = 'unknown' if ($status{"package"} eq '');
      $status{"severity"} = 'normal' if (not defined $status{severity} or $status{"severity"} eq '');
@@ -1203,8 +1209,10 @@ sub bug_presence {
                       $allowed_distributions{$tag} = 1;
                   }
               }
-              foreach my $arch (make_list(exists $param{arch}?$param{arch}:undef)) {
-                   for my $package (split /\s*,\s*/, $status{package}) {
+              my @archs = make_list(exists $param{arch}?$param{arch}:());
+          GET_SOURCE_VERSIONS:
+              foreach my $arch (@archs) {
+                  for my $package (split /\s*,\s*/, $status{package}) {
                         my @versions = ();
                         my $source = 0;
                         if ($package =~ /^src:(.+)$/) {
@@ -1235,6 +1243,15 @@ sub bug_presence {
                         @sourceversions{@temp} = (1) x @temp;
                    }
               }
+              # this should really be split out into a subroutine,
+              # but it'd touch so many things currently, that we fake
+              # it; it's needed to properly handle bugs which are
+              # erroneously assigned to the binary package, and we'll
+              # probably have it go away eventually.
+              if (not keys %sourceversions and (not @archs or defined $archs[0])) {
+                  @archs = (undef);
+                  goto GET_SOURCE_VERSIONS;
+              }
          }
 
          # TODO: This should probably be handled further out for efficiency and