Script to deal with duplicated packages in RPM database
Andy Green
andy at warmcat.com
Sat Apr 23 20:53:54 UTC 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi folks -
Over time RPM seems to collect duplicate packages for one reason or
another (interrupted installs, hoarding, who knows), causing
unpleasantness at update time. Here is a short script that issues a
list of packages which are not only duplicated, but are older (by
install date) than the newest duped package (which is not printed).
rpm -qa --last >/tmp/timeorderedpackagelist ; olddupes=;
allpackages=`rpm -qa --queryformat "%-30{NAME}\n" | sort`; baddies="`q=
; for i in $allpackages ; do if [ "$i" = "$q" ] ; then echo $i ; q=xxx
; else q=$i; fi ; done`"; baddiesnokernel=`echo "$baddies" | grep -v
kernel | grep -v gpg-pubkey`; for i in $baddiesnokernel ; do echo $i;
grep ^"$i"-[0-9] /tmp/timeorderedpackagelist | cut -d' ' -f1
|/tmp/dupelist; first=1; for j in `cat /tmp/dupelist` ; do if [ -z
$first ] ; then olddupes="$olddupes $j"; fi; first=; done ; done ;
echo $olddupes;
(The script needs to be all one line, despite what thunderbird has done
to it)
The issued list is suitable for feeding into rpm -e to give your
constipated package database a serious colonic irrigation, without
actually removing any packages. I suggest you review the output against
rpm -q packagename and satisfy yourself that the list is looking good
before hitting it with rpm -e, but it has worked great on a couple of
machines here and I hope it is useful to others bedevilled by the
package duplication problem.
If there's a better way to do this, by all means reply with it since I
couldn't find another way to do this without using apt-get.
- -Andy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFCarXijKeDCxMJCTIRAs48AJ9ScnL7CIEgnVQYiln4ACwPL8NGBACeOBky
lID1wD78pymlZ89HdWUXGu4=
=bSPo
-----END PGP SIGNATURE-----
More information about the fedora-list
mailing list