[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] hrmib cache for dpkg

Hi all,

I made a quick port of the "HR-MIB cache" for net-snmp of rpm,
so that it can be used with the dpkg packaging system as well.

What it does is that it keeps a simple directory of files in
/var/cache/hrmib with one entry for each package, that has a
timestamp of when the package was installed. So this directory
can be used to get a package list, without needing db or grep.

This is different from a normal cache dumped from cron or so,
in that the package manager itself keeps it up-to-date at all
times by adding and removing files as packages are modified.
The initial cache can easilly be populated by e.g. touch(1).

The files are named in a simple N-V-R.A style, without epochs.
And for rpm, those "gpg-pubkey" packages aren't listed either.

That is, the file list of the hrmib cache directory should be
the same as the output of one of the following shell scriptlets:

rpm -qa --queryformat="%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" |
grep -v ^gpg-pubkey- # remove public keys

dpkg-query -W --showformat='${Package}-${Version}.${Architecture}\n' |
sed -e 's/[0-9]\{1,\}://' # remove epochs

The cache must first be populated with the currently installed
packages, the code only makes sure that it is kept up-to-date.

To get the installation date of each package, one can loop over
the installed package names and touch the files with a date of:

rpm -q --queryformat="%{INSTALLTIME:date}" $package

ls -l --time-style="+%a %b %e %H:%M:%S %Y" /var/lib/dpkg/info/ $package.list | cut -d\ -f6-10

Attaching patch from the git repository, tried with a similar
version for the dpkg 1.14 version present in Ubuntu 9.04...

It is available in rpm since version 4.4.7, by uncommenting
the %_hrmib_path macro in the /usr/lib/rpm/macros config...


PS. It can also be used for doing bash-completion of packages.
    There are patches for this available elsewhere on the net.

Attachment: 0001-hrmib-cache-proof-of-concept.patch
Description: Binary data

Attachment: 0002-also-remove-upgraded-oldversions.patch
Description: Binary data

Reply to: