The following commit has been merged in the master branch:
commit a2286a56712b8da7eb10e817bd933ad981bf834f
Author: James McCoy <[email protected]>
Date:   Sat Jun 30 11:06:34 2012 -0400

    Devscripts/Package{s,Deps}: Make functions Multi-Arch aware.
    
    Closes: #664811
    Signed-off-by: James McCoy <[email protected]>

diff --git a/Devscripts/PackageDeps.pm b/Devscripts/PackageDeps.pm
index 5236d7e..c744eb0 100644
--- a/Devscripts/PackageDeps.pm
+++ b/Devscripts/PackageDeps.pm
@@ -49,8 +49,17 @@ sub new ($$)
     return $self;
 }
 
+# Internal functions
 
-# Internal function
+my $multiarch;
+
+sub multiarch ()
+{
+    if (!defined $multiarch) {
+       $multiarch = (system('dpkg --assert-multi-arch >/dev/null 2>&1') >> 8) 
== 0;
+    }
+    return $multiarch;
+}
 
 sub parse ($$)
 {
@@ -95,6 +104,11 @@ sub parse ($$)
        }
 
        $self->{$pkg} = \@deps;
+       if ($ctrl->{Architecture} ne 'all' && multiarch) {
+           my $arch = $ctrl->{Architecture};
+           @deps = map { "$_:$arch" } @deps;
+           $self->{"$pkg:$arch"} = \@deps;
+       }
        undef $ctrl;
     }
     close PACKAGE_FILE or
diff --git a/Devscripts/Packages.pm b/Devscripts/Packages.pm
index 863ceb3..90ff36d 100644
--- a/Devscripts/Packages.pm
+++ b/Devscripts/Packages.pm
@@ -61,6 +61,16 @@ the corresponding source packages as well in the list.
 
 =cut
 
+my $multiarch;
+
+sub multiarch ()
+{
+    if (!defined $multiarch) {
+       $multiarch = (system('dpkg --assert-multi-arch >/dev/null 2>&1') >> 8) 
== 0;
+    }
+    return $multiarch;
+}
+
 # input: a list of packages names.
 # output: list of files they contain.
 
@@ -148,69 +158,66 @@ sub FilesToPackages (@)
 
 
     my %packages=();
-    my ($curfile, $pkgfrom);
-    undef $pkgfrom;
-    $curfile = shift;
-
-    foreach (@dpkg_out) {
-       # We want to handle diversions nicely.
-       # Ignore local diversions
-       if (/^local diversion from: /) {
-           # Do nothing
-       }
-       elsif (/^local diversion to: (.+)$/) {
-           if ($curfile eq $1) {
-               $curfile = shift;
+    foreach my $curfile (@_) {
+       my $pkgfrom;
+       foreach my $line (@dpkg_out) {
+           # We want to handle diversions nicely.
+           # Ignore local diversions
+           if ($line =~ /^local diversion from: /) {
+               # Do nothing
            }
-       }
-       elsif (/^diversion by (\S+) from: (.+)$/) {
-           if ($curfile eq $2) {
-               # So the file we're looking has been diverted
-               $pkgfrom=$1;
+           elsif ($line =~ /^local diversion to: (.+)$/) {
+               if ($curfile eq $1) {
+                   last;
+               }
            }
-       }
-       elsif (/^diversion by (\S+) to: (.+)$/) {
-           if ($curfile eq $2) {
-               # So the file we're looking is a diverted file
-               # We shouldn't see it again
-               $packages{$1} = 1;
-               $curfile = shift;
+           elsif ($line =~ /^diversion by (\S+) from: (.+)$/) {
+               if ($curfile eq $2) {
+                   # So the file we're looking has been diverted
+                   $pkgfrom=$1;
+               }
            }
-       }
-       elsif (/^dpkg: \Q$curfile\E not found\.$/) {
-           $curfile = shift;
-       }
-       elsif (/^dpkg-query: no path found matching pattern \Q$curfile\E\.$/) {
-           $curfile = shift;
-       }
-       elsif (/^(.*): \Q$curfile\E$/) {
-           my @pkgs = split /,\s+/, $1;
-           if (@pkgs == 1 || !grep /:/, @pkgs) {
-               # Only one package, or all Multi-Arch packages
-               map { $packages{$_} = 1 } @pkgs;
+           elsif ($line =~ /^diversion by (\S+) to: (.+)$/) {
+               if ($curfile eq $2) {
+                   # So the file we're looking is a diverted file
+                   # We shouldn't see it again
+                   $packages{$1} = 1;
+                   last;
+               }
            }
-           else {
-               # We've got a file which has been diverted by some package
-               # or is Multi-Arch and so is listed in two packages.  If it
-               # was diverted, the *diverting* package is the one with the
-               # file that was actually used.
-               my $found=0;
-               foreach my $pkg (@pkgs) {
-                   if ($pkg eq $pkgfrom) {
-                       $packages{$pkgfrom} = 1;
-                       $found=1;
-                       last;
-                   }
+           elsif ($line =~ /^dpkg: \Q$curfile\E not found\.$/) {
+               last;
+           }
+           elsif ($line =~ /^dpkg-query: no path found matching pattern 
\Q$curfile\E\.$/) {
+               last;
+           }
+           elsif ($line =~ /^(.*): \Q$curfile\E$/) {
+               my @pkgs = split /,\s+/, $1;
+               if (@pkgs == 1 || !grep /:/, @pkgs) {
+                   # Only one package, or all Multi-Arch packages
+                   map { $packages{$_} = 1 } @pkgs;
                }
-               if (! $found) {
-                   carp("Something wicked happened to the output of dpkg -S 
$curfile");
+               else {
+                   # We've got a file which has been diverted by some package
+                   # or is Multi-Arch and so is listed in two packages.  If it
+                   # was diverted, the *diverting* package is the one with the
+                   # file that was actually used.
+                   my $found=0;
+                   foreach my $pkg (@pkgs) {
+                       if ($pkg eq $pkgfrom) {
+                           $packages{$pkgfrom} = 1;
+                           $found=1;
+                           last;
+                       }
+                   }
+                   if (! $found) {
+                       carp("Something wicked happened to the output of dpkg 
-S $curfile");
+                   }
                }
+               # Prepare for the next round
+               last;
            }
-           # Prepare for the next round
-           $curfile = shift;
-           undef $pkgfrom;
        }
-
     }
 
     return keys %packages;
@@ -232,6 +239,9 @@ sub PackagesMatch ($)
           && $ctrl->parse(\*STATUS, '/var/lib/dpkg/status')) {
        if ("$ctrl" =~ m/$match/m) {
            my $package = $ctrl->{Package};
+           if ($ctrl->{Architecture} ne 'all' && multiarch) {
+               $package .= ":$ctrl->{Architecture}";
+           }
            push @matches, $package;
        }
        undef $ctrl;
@@ -264,6 +274,9 @@ sub InstalledPackages ($)
        }
        if (exists $ctrl->{Package}) {
            $matches{$ctrl->{Package}} = 1;
+           if ($ctrl->{Architecture} ne 'all' && multiarch) {
+               $matches{"$ctrl->{Package}:$ctrl->{Architecture}"} = 1;
+           }
        }
        undef $ctrl;
     }
diff --git a/debian/changelog b/debian/changelog
index 88d1212..ae1e141 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,8 +17,10 @@ devscripts (2.11.10) UNRELEASED; urgency=low
     + Unset wget's continue option to ensure the bug list is properly
       downloaded.  (Closes: #677229)
     + Handle rc bugs assigned to source packages.  (Closes: #576853)
-  * Devscripts/Packages.pm, Devscripts/PackageDeps.pm: Parse dpkg's status
-    file using Dpkg::Control.
+  * Devscripts/Packages.pm, Devscripts/PackageDeps.pm:
+    + Parse dpkg's status file using Dpkg::Control.
+    + Make functions Multi-Arch aware so they can handle $pkg:$arch naming.
+      (Closes: #664811)
 
  -- Benjamin Drung <[email protected]>  Sun, 17 Jun 2012 23:33:41 +0200
 

-- 
Git repository for devscripts

_______________________________________________
devscripts-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel

Reply via email to