فهرست منبع

parse installed dependencies and rely on these to trigger updates to reverse dependencies

Michael van Elst 22 سال پیش
والد
کامیت
d60bfd8179
1فایلهای تغییر یافته به همراه41 افزوده شده و 23 حذف شده
  1. 41 23
      openpkg-tool/openpkg-build.pl

+ 41 - 23
openpkg-tool/openpkg-build.pl

@@ -420,27 +420,28 @@ sub depend_list ($) {
 #
 sub get_installed () {
     my(%map);
-    my(@l) = run("$RPM --provides -qa");
-    my($p);
+    my(@l,$p);
     my($nam,$val,%options);
-    my($vs,$rec,@provides);
+    my($vs,$rec,@list);
     my($name,$version,$release);
+    my($req);
 
-    @provides = ();
+    @l = run("$RPM --provides -qa");
+    @list = ();
     foreach (@l) {
-        $p = parse_provides($_);
+        next unless $p = parse_provides($_);
 
         # is this an option ?
         if (defined $p->{with}) {
             $options{$p->{prefix}}->{$p->{with}} = $p->{version};
-            push @provides, $p;
+            push @list, $p;
             next;
         }
 
         # is this a virtual target ?
         $vs = vs($p);
         if ($vs eq '') {
-            push @provides,$p;
+            push @list,$p;
             next;
         }
 
@@ -448,7 +449,7 @@ sub get_installed () {
         $version = defined $p->{version} ? $p->{version} : '*';
         $release = defined $p->{release} ? $p->{release} : '*';
 
-        push(@provides, {
+        push(@list, {
             name    => $name,
             version => $version,
             release => $release
@@ -459,18 +460,20 @@ sub get_installed () {
             name       => $name,
             version    => $version,
             release    => $release,
-            PROXY      => $p->{proxy}
+            PROXY      => $p->{proxy},
+            depends    => [],
+            keeps      => []
         };
 
-        foreach (@provides) {
+        foreach (@list) {
             push @{$map{$_->{name}}->{vs($_)}}, $rec;
         }
 
-        @provides = ();
+        @list = ();
     }
 
-    if (@provides) {
-        print "# ATTENTION: ",scalar(@provides)," froods found\n"
+    if (@list) {
+        print "# ATTENTION: ",scalar(@list)," froods found\n"
     }
 
     #
@@ -485,6 +488,27 @@ sub get_installed () {
         }
     }
 
+    @l = run("$RPM --qf '%{NAME} %{VERSION} %{RELEASE}[ .%{REQUIRENAME} .%{REQUIREFLAGS:depflags} .%{REQUIREVERSION}]\n' -qa");
+    @list = ();
+    foreach (@l) {
+        ($name,$version,$release,$req) = /^(\S+)\s+(\S+)\s+(\S+)\s*(.*?)\s*$/;
+        while ($req =~ /\.(\S+)\s+\.(\S*)\s+\.(\S*)/g) {
+            $p = parse_depends("$1 $2 $3");
+            next if $p->{name} =~ /^rpmlib\(/;
+
+            $vs = vs({ version => $version, release => $release});
+            $p = { cond => '', value => $p };
+            foreach $rec (@{$map{$name}->{$vs}}) {
+                push @{$rec->{depends}}, $p;
+                push @{$rec->{keeps}}, $p;
+            }
+        }
+    }
+
+    if (@list) {
+        print "# ATTENTION: ",scalar(@list)," fnords found\n"
+    }
+
     return \%map;
 }
 
@@ -496,7 +520,7 @@ sub get_revdep ($$) {
     my($env, $i) = @_;
     my($r) = $env->{'repository'};
     my($pkg, %dep, %dlist, %rev);
-    my(@vers,$t,$t1,$t2,$with,$name);
+    my(@vers,$t,$t1,$with,$name);
     my($d,$k,%d,$old,%name);
 
     print "# computing reverse dependencies\n";
@@ -509,21 +533,15 @@ sub get_revdep ($$) {
         }
 
         #
-        # get forward dependencies from repository packages
-        # but blend in options from installed packages
+        # get forward dependencies from installed packages
         #
         # dep{a}{b} is true if b depends directly on a
         # dlist{a}  is list of packages that depend on a
         #
-        @vers = get_versions($r->{$pkg}, sub { 1; });
+        @vers = get_versions($i->{$pkg}, sub { 1; });
         foreach (@vers) {
-            foreach $t (@{$r->{$pkg}->{$_}}) {
+            foreach $t (@{$i->{$pkg}->{$_}}) {
                 $with = get_with($t);
-                $t2 = find_target($t->{name}, $i);
-                if ($t2) {
-                    $with = { %$with };
-                    override_options($with, get_with($t2), '');
-                }
                 $d = target_attribute($t, $env, 'depends', $with);
                 $k = target_attribute($t, $env, 'keeps', $with);
                 next unless @$d || @$k;