root rpm package list?

Tom Horsley horsley1953 at gmail.com
Thu Nov 4 01:36:43 UTC 2010


On Wed, 3 Nov 2010 20:58:05 -0400
Tom Horsley wrote:

> deplist is looking the most promising so far.

It isn't fast, but it seems to work. I whipped out a
little "find-roots" perl script to do the job:

#!/usr/bin/perl -w
#
# Long running script to find all the deps of all the packages
# then find all the installed rpms that are not deps of anything.
#
use strict;

my %rpms;
my $fh;

# This is the bit that takes forever to run, and it also (apparently)
# describes every package in every repo that might provide a dependency,
# so the list this generates is about 10 times larger than the actual
# installed base.

open($fh, '-|', 'yum', 'deplist', '*');
while (<$fh>) {
   if (/^\s*provider:\s*(\S+)\s*\S+\s*$/) {
      $rpms{$1} = 1;
   }
}
close($fh);
undef($fh);

# Getting the list of actual installed rpms is much less time consuming.

my %installed;
open($fh, '-|', 'rpm', '-q', '--qf', '%{NAME}.%{ARCH}\n', '-a');
while (<$fh>) {
   chomp;
   $installed{$_} = 1;
}
close($fh);
undef($fh);

# Now we print all the rpms that are installed, but which do not show
# up as a provider of any dependency.

foreach $_ (sort(keys(%installed))) {
   if (! exists($rpms{$_})) {
      print "$_\n";
   }
}


More information about the users mailing list