rpmsafereduce: Fix missing: /usr/local
[nethome.git] / bin / rpmsafereduce
index 5a7922c..71d2685 100755 (executable)
@@ -23,13 +23,14 @@ while (<>) {
   carp "sort -u: $l >= $_" if $l && $l ge $_;
   $l=$_;
   my $sl=slashes $_;
-  $d{$_}=$sl if -d;
+  $t{$_}=1,$d{$_}=$sl if -d;
   $f{$_}=$sl if -f;
   s{/[^/]*$}{} or carp $_;
   $d{$_}=$sl-1 if $IGNORE_D && $_ ne "";
   $t{$_}=1 if $d{$_};
 }
 my $time;
+my(%b);
 while (%t) {
   my @t=keys(%t);
   %t=();
@@ -41,6 +42,7 @@ while (%t) {
       print STDERR (@t+0)."    \r";
     }
     my $t=shift @t;
+    next if $b{$t};
     next if !$d{$t}&&!$f{$t};
     opendir DIR,$t or carp "$t: $!";
     my $ok=1;
@@ -56,10 +58,12 @@ while (%t) {
       last;
     }
     closedir DIR or carp "$t: $!";
-    next if !$ok;
+    if (!$ok) {
+      do { $b{$t}=1; } while $t=~s{/[^/]*$}{};
+      next;
+    }
     for my $d (@d) {
-      delete $f{"$t/$d"};
-      delete $t{"$t/$d"};
+      $b{"$t/$d"}=1;
     }
     $f{$t}=slashes $t;
     $t=~s{/[^/]*$}{} or carp $t;
@@ -68,5 +72,5 @@ while (%t) {
   }
 }
 for my $f (sort keys(%f)) {
-  print "$f\n";
+  print "$f\n" if !$b{$f};
 }