[Rpm-maint] How to get RPM requires quickly
Panu Matilainen
pmatilai at laiskiainen.org
Mon Sep 15 12:42:37 UTC 2014
On 09/13/2014 04:13 PM, Richard W.M. Jones wrote:
>
> We have a program[1] that needs to take a list of installed RPM
> package names, and quickly generate all of the installed dependencies
> (recursively).
>
> *Note* this is NOT a question about yum/dnf/zypper/etc depsolving.
> It's about doing 'rpm -qR' quickly on installed packages only.
>
> At the moment we run the following command:
>
> rpm -qR <current set of packages> |
> awk '{print $1}' |
> xargs rpm -q --qf '%%{name}\n' --whatprovides |
> grep -v 'no package provides' |
> sort -u
>
> The output is added to the current set, and we repeat the process
> until the set of packages reaches a fixpoint.
>
> To give you an idea, on a typical starting set this takes around 20 seconds,
> which is over half the total running time of the program.
>
> Does anyone have any suggestions about how to do this more quickly
> and/or cleverly? Maybe using rpmlib (which unfortunately seems to
> lack any documentation)?
That kind of usage is pretty much worst case behavior for rpm as it
defies almost all caching etc. For immediate speed gain with no other
changes, add --nosignature to stop rpm from re-re-re-re-revalidating
header signatures over and over again. In the average 'rpm -qa' time
--nodigest doesn't help much but the cumulative effect might be worth it
here.
To get rpm do a bit more work for you, use 'rpm -e --test' to make rpm
resolve the deps. Basically
rpm -e --test <current set of packages> 2>&1 |
awk '/needed by/{print $NF}' |
sort -u
...and feed the output to the next cycle. --nosignature and --nodigest
will help here too, but to lesser degree.
For more speed, you'd need to use the rpmlib API, pointers to
documentation can be found at http://rpm.org/wiki/Docs
- Panu -
More information about the Rpm-maint
mailing list