]> git.pld-linux.org Git - projects/cleanbuild.git/blobdiff - findunusedbr
findbr: check errors from mkmf.log as well
[projects/cleanbuild.git] / findunusedbr
index 06499214843952ead79cbd811f57282694aff7a5..daf4c3784c010b0dc436abdb055ba9d8ca67417b 100755 (executable)
@@ -18,7 +18,7 @@ my $spec = shift @ARGV or die "Spec file not specified\n";
 my @rpms;
 open F_IN, "<", $spec or die "Cannot open '$spec'\n";
 while ( <F_IN> ) {
-       if ( /^\s*(?:%{.*)?BuildRequires:\s*(\S+)/i ) {
+       if ( /^\s*(?:%\{.*)?BuildRequires:\s*(\S+)/i ) {
                local $_ = $1;
                s/}$//;
                push @rpms, $_;
@@ -36,6 +36,14 @@ sub clear_files
                chop $file;
                my $f = $chroot.$file;
 
+               local $_;
+               while ( $_ = readlink $f and m#^/# ) {
+                        $f = $chroot.$_;
+               }
+
+               # skip missing files, like "%_excludedocs 0" being active
+               next unless stat $f;
+
                # XXX: this truncates mtime to its low resolution value
                my $mtime = (stat $f)[9];
                warn "Mtime failed on $f" unless $mtime;
@@ -52,8 +60,15 @@ sub check_files
                chop $file;
                my $f = $chroot.$file;
 
+               local $_;
+               while ( $_ = readlink $f and m#^/# ) {
+                        $f = $chroot.$_;
+               }
+
                my $atime = (stat $f)[8];
-               if ( $atime > 0 ) {
+               if ( not defined $atime ) {
+                       print "$rpm: $f no atime\n";
+               } elsif ( $atime > 0 ) {
                        #print "$rpm: $file accessed\n";
                        #$used = 1;
                        return;
@@ -64,9 +79,17 @@ sub check_files
        print "$rpm may be superfluous !\n";# unless $used;
 }
 
+sub rpm {
+       my @cmd = ("rpm", "--root=$chroot", @_);
+       open my $fh, '-|', @cmd or die "$!: @cmd";
+       my @data = <$fh>;
+       close $fh;
+       warn $! if $!;
+       return @data;
+}
 
 foreach my $rpm ( @rpms ) {
-       my @files = qx/rpm --root=$chroot -ql --what-provides "$rpm"/;
+       my @files = rpm("-ql", "--what-provides", "$rpm");
        next if $files[0] =~ /^no package provides/;
        #print "*** $rpm ***\n";
        if ( $clear ) {
This page took 0.087738 seconds and 4 git commands to generate.