alexk / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
dac7c0
--- rpm-4.11.3/scripts/perl.req.old	2019-05-26 15:41:33.316395021 +0200
dac7c0
+++ rpm-4.11.3/scripts/perl.req	2019-05-26 14:08:38.248028422 +0200
dac7c0
@@ -90,10 +90,10 @@
dac7c0
 
dac7c0
 sub compute_global_requires {
dac7c0
  
dac7c0
-# restrict require to all non provided by the file
dac7c0
-  foreach my $moduler (sort keys %require) {
dac7c0
-    if (exists $provide{$moduler} && length($require{$moduler}) == 0) {
dac7c0
-      $require = delete $require{$moduler};
dac7c0
+# restrict require_removable to all non provided by the file
dac7c0
+  foreach my $moduler (sort keys %require_removable) {
dac7c0
+    if (exists $provide{$moduler} && length($require_removable{$moduler}) == 0) {
dac7c0
+      $require_removable = delete $require_removable{$moduler};
dac7c0
     } 
dac7c0
   }
dac7c0
 # store requires to global_requires
dac7c0
@@ -107,8 +107,21 @@
dac7c0
       $global_require{$module} = $newver;
dac7c0
     }
dac7c0
   }
dac7c0
+
dac7c0
+# store requires_removable to global_requires
dac7c0
+  foreach my $module (sort keys %require_removable) {
dac7c0
+    my $oldver = $global_require{$module};
dac7c0
+    my $newver = $require_removable{$module};
dac7c0
+    if ($oldver) {
dac7c0
+      $global_require{$module} = $newver
dac7c0
+        if ($HAVE_VERSION && $newver && version->new($oldver) < $newver);
dac7c0
+    } else {
dac7c0
+      $global_require{$module} = $newver;
dac7c0
+    }
dac7c0
+  }
dac7c0
 # remove all local requires and provides
dac7c0
   undef %require;
dac7c0
+  undef %require_removable;
dac7c0
   undef %provide;
dac7c0
 }
dac7c0
 
dac7c0
@@ -124,6 +137,18 @@
dac7c0
   }
dac7c0
 }
dac7c0
 
dac7c0
+sub add_require_removable {
dac7c0
+  my ($module, $newver) = @_;
dac7c0
+  my $oldver = $require_removable{$module};
dac7c0
+  if ($oldver) {
dac7c0
+    $require_removable{$module} = $newver
dac7c0
+      if ($HAVE_VERSION && $newver && version->new($oldver) < $newver);
dac7c0
+  }
dac7c0
+  else {
dac7c0
+    $require_removable{$module} = $newver;
dac7c0
+  }
dac7c0
+}
dac7c0
+
dac7c0
 sub process_file {
dac7c0
 
dac7c0
   my ($file) = @_;
dac7c0
@@ -286,7 +311,6 @@
dac7c0
 
dac7c0
       # if the module starts with /, it is an absolute path to a file
dac7c0
       if ($module =~ m(^/)) {
dac7c0
-        print "$module\n";
dac7c0
         next;
dac7c0
       }
dac7c0
 
dac7c0
@@ -346,7 +370,13 @@
dac7c0
           add_require($_, undef) for split(' ', $1);
dac7c0
         }
dac7c0
         elsif ($version =~ /(["'])([^"']+)\1/) {
dac7c0
-          add_require($2, undef);
dac7c0
+          # requires like "use base name" can be removed if they are 
dac7c0
+          # provided in the same file
dac7c0
+          if (($whitespace eq "") && ($statement eq "use") && ($module eq "base"))  {
dac7c0
+            add_require_removable($2, undef);
dac7c0
+          } else {
dac7c0
+            add_require($2, undef);
dac7c0
+          }
dac7c0
         }
dac7c0
         next;
dac7c0
       }