Tips and tricks on package management for RPM based distributions.
In general, I prefer software in this order:
- RPM for my distribution and release.
- RPM for a similar release of my distribution. For example, when I ran Mandriva 2010.2 most of the packages for Mandriva 2010.0 that I tried worked, as did a few for Mandriva 2009.
- RPM for a related distribution contemporaneous with my distribution. For example, Mandriva 2011, Mageia 1, and Rosa 2012 are closely related, and contemporaneous versions of PCLinuxOS, Fedora, Red Hat, and Red Hat clones (in descending order of similarity) are also worth considering. Use DistroWatch or a similar resource to find distro releases contemporary with yours. TODO: Find and link to a distribution genealogy chart.
- Generic RPM.
- Source tarball, made by you into a generic RPM with checkinstall. Even better would be an RPM tailor-made by you for your distribution and release, but that’s overkill for my modest needs.
- .deb package, made by you into a generic RPM with alien.
What you do not want to do is simply compile from source. If you do that, your package management database will no longer be aware of everything you have installed, and all kinds of bad things can (read: will) happen.
I’ve never tried it, but there are reports of unpacking Slackware packages and running that. This too bypasses your package management database and is not recommended.
All RPM based distributions (Red Hat and derivatives)
Sometimes you want to uninstall that last package you tried, along with all those dependencies it dragged in, the names of which you don’t remember. So let’s list all installed packages in order of installation, most recently installed first:
rpm -qa --last | less
To remove a package without dependency checking (use with caution — duh!), as root:
rpm -e --nodeps PACKAGE_NAME
To find out which installed package owns a particular file:
rpm -qf /path/to/FILENAME
URPM based distributions (Mandriva and derivatives)
To list all media:
To remove a medium, as root:
Some earlier versions of Mandriva would under certain circumstances leave RPM lockfiles in place which had to be manually removed. I haven’t seen this problem in a long time, but to remove them, as root:
rm /var/lib/urpmi/.LOCK /var/lib/rpm/.RPMLOCK
To update all registered media and then install all upgradable packages:
To removed orphaned packages — that is, packages that were installed as dependencies of something that has since been removed:
To exclude a package from automatic upgrades, add it to /etc/urpmi/skip.list. The first example excludes a particular version of package foobar; this is useful when a particular version of a package doesn’t work on your system. The second example excludes all packages with foobar in the name, which should be used with caution:
Obviously this is hardly an exhaustive list; it’s just those commands that I most commonly need. For more fun, see the references.
URPM based distributions
A Quick Reference Guide to urpmi
Managing Software with urpm
URPMQ and URPMF
The man pages for urpmi, urpme, urpmi.addmedia, urpmi.update, urpmi.removemedia, urpmf, urpmq, urpmi.files, and urpmi.recover