#!/usr/bin/perl # # check whether perl part of the package depends on perl-base only # use strict; sub whatsays($) { my $command = shift; local $_ = `$command`; $? and print qq(warning: $command\n\texecuted with $? status\n); my @parts = split; return wantarray ? @parts : $parts[0]; } my %cache; my $n_call = 0; sub whatprovides(@) { my $prov = shift; if ($cache{$prov}) { $n_call++; } else { my @pkgs = whatsays qq(rpm -q --whatprovides '$prov'); $cache{$prov} = \@pkgs; print "warning: $prov is provided by " . join(' AND ' => @pkgs) . "\n" if @pkgs > 1; } return @{$cache{$prov}}; } my @packages = @ARGV; my $base = whatsays qq(rpm -q 'perl-base'); foreach my $package (@packages) { $package = whatsays qq(rpm -q '$package'); my @files = whatsays qq(rpm -ql '$package' '$base' | sort | uniq); my $n = @files; print "checking whether perl part of $package package ($n files)\n\tdepends on $base only\n"; foreach my $file (@files) { my @req = map { /perl\(.+?\)/ ? $& :() } whatsays qq(/usr/lib/rpm/perl.req '$file'); foreach my $req (@req) { my @prov = whatprovides $req; print "file $file requires\n\t$req provided by @prov\n" unless grep { "@prov" =~ /\Q$_/ } ($base, $package); } } } print "whatprovides: " . keys(%cache) . " entries cached ($n_call fork+exec calls saved)\n";