Re: tip: automated way to delete duplicate rpms

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kim Lux wrote:
> I recently updated a server from fc3 to fc6.  All seemed to go well
> except the first yum attempt to update the machine failed and when I
> entered synaptic I received a ton of errors about duplicate rpms
> installed on the machine.  I've run into this issue before.
> Unfortunately neither yum nor synaptic has a way to deal with it, as far
> as I can tell.   
> 
> Rather than manually go through the list of offending rpms and delete
> them, I did things semi automatically.  There were 120 duplicate rpms on
> my machine, so manually typing the full package names would have taken a
> while.
> 
> Here is what I did instead.
> 
> 1) Generate a list of all the rpm packages installed.
> 
> $rpm -qa --queryformat '%{name}\n' > pkglist
> 
> This generates an unsorted list that looks like this.
> libavc1394
> libmusicbrainz
> ethtool
> desktop-file-utils
> less
> time
> libXrandr
> rmt
> 
> 2) Sort the list and find the duplicates
> 
> $sort -g pkglist | uniq -d > duplicates
> 
> This list will look like 
> 
> a2ps
> anacron
> at
> audit
> ...
> 
> 3) Generate a list of the packages with versions to look at and edit
> 
> I created a small script file called dupWithVersions with this in it
> 
> for pkg in `cat duplicates`; do
>   rpm -q $pkg
> done
> 
> Redirect the output to another file like this.  $dupWithVersions
>> removeList
> 
> The remove list will look like this:
> 
> a2ps-4.13b-57
> a2ps-4.13b-57.fc6.3
> anacron-2.3-41.fc6
> anacron-2.3-44.fc6
> at-3.1.8-82.fc6
> at-3.1.8-84.fc6
> audit-1.2.8-1.fc6
> audit-1.3-2.fc6
> 
> Go through the remove list and manually remove the versions you want to
> KEEP !  Remember this is a list of rpms you want to remove !
> 
> 4) Remove the rpms in the remove list.
> 
> To do this I generated a little script as follows:
> 
> for pkg in `cat removelist`; do
>   rpm -e $pkg
> done
> 
> This process quickly and correctly removed the duplicate rpms from my
> machine. 
> 
> I hope this helps someone. 
> 
	This worries me a little bit.  If you remove a package aren't you
likely to remove identically named files from the newer package as well?

	I ask because I usually do a rpm -e --justdb <pkgname> as I once found
myself without some services after deleting an old package.

Scott

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFFlsSm5mBKdb7VQEcRAnDTAKCxEod2+NmlvLXAofs0VYwCe0YM2ACgl3j9
+fFHeQpUi5ZzrDFpbraXH5E=
=vGO8
-----END PGP SIGNATURE-----


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux