[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#170575: dpkg-gencontrol: patch for arch depend Depends line



Package: dpkg-dev
Version: 1.10.9
Severity: wishlist

the following patch makes it possible to use following:
| Depends: test1 [i386] | test2 [!i386], test3 [!s390]

dpkg-gencontrole builds the unified version of this.
the only known problem is, that it doesn't handle Architecture: all
packages well. this needs a further check.

bastian

-- 
Conquest is easy. Control is not.
		-- Kirk, "Mirror, Mirror", stardate unknown
Index: dpkg-gencontrol.pl
===================================================================
RCS file: /cvs/dpkg/dpkg/scripts/dpkg-gencontrol.pl,v
retrieving revision 1.25
diff -u -r1.25 dpkg-gencontrol.pl
--- dpkg-gencontrol.pl	25 May 2002 03:04:04 -0000	1.25
+++ dpkg-gencontrol.pl	24 Nov 2002 19:19:40 -0000
@@ -124,9 +124,13 @@
         else { &unknown('general section of control info file'); }
     } elsif (s/^C$myindex //) {
 #print STDERR "P key >$_< value >$v<\n";
-        if (m/^(Package|Description|Essential|Pre-Depends|Depends)$/ ||
-            m/^(Recommends|Suggests|Enhances|Optional|Conflicts|Provides|Replaces)$/) {
+        if (m/^(Package|Description|Essential)$/) {
             $f{$_}= $v;
+        } elsif (m/^(Pre-Depends|Depends|Recommends|Suggests|Enhances|Optional|Conflicts|Provides|Replaces)$/) {
+            $v = build_dep($v);
+            if (defined $v) {
+                $f{$_}= $v;
+            }
         } elsif (m/^Section$|^Priority$/) {
             $spvalue{$_}= $v;
         } elsif (m/^Architecture$/) {
@@ -252,4 +256,60 @@
     $r= $spvalue{$_[0]};
     $r= '-' if !length($r);
     return $r;
+}
+
+sub build_dep {
+  my $line = shift;
+  my $out;
+  foreach my $dep (split(/,\s*/, $line)) {
+    my $outdep;
+ALTERNATE:
+    foreach my $alternate (split(/\s*\|\s*/, $dep)) {
+      my ($package, $rest) = split(/\s*(?=[[(])/, $alternate, 2);
+      my $seen_arch = 0;
+      my $version;
+      $package =~ s/\s*$//;
+
+      # Check arch specifications.
+      if (defined $rest && $rest =~ m/\[(.*?)\]/) {
+        my $arches = lc($1);
+        foreach my $carch (split(' ', $arches)) {
+          if ($carch eq $arch) {
+            $seen_arch=1;
+            next;
+          }
+          elsif ($carch eq "!$arch") {
+            next ALTERNATE;
+          }
+          elsif ($carch =~ /!/) {
+            # This is equivilant to
+            # having seen the current arch,
+            # unless the current arch
+            # is also listed..
+            $seen_arch = 1;
+          }
+        }
+        if (! $seen_arch) {
+          next;
+        }
+      }
+      if (defined $rest && $rest=~m/\(\s*([<>=]{1,2}\s*.*?)\s*\)/) {
+        $version = $1;
+      }
+      if (defined $outdep) {
+        $outdep .= " | ";
+      }
+      $outdep .= $package;
+      if (defined $version) {
+        $outdep .= " ($version)";
+      }
+    }
+    if (defined $outdep) {
+      if (defined $out) {
+        $out .= ", ";
+      }
+      $out .= $outdep;
+    }
+  }
+  return $out;
 }

Attachment: pgp2WIHK7U7rh.pgp
Description: PGP signature


Reply to: