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, $_;
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;
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;
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 ) {