RPM package management tips

Tips and tricks on package management for RPM based distributions.

SOFTWARE PREFERENCES
In general, I prefer software in this order:

  1. RPM for my distribution and release.
  2. 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.
  3. 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.
  4. Generic RPM.
  5. 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.
  6. .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.

USEFUL COMMANDS
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:

urpmq --list-url

To remove a medium, as root:

urpmi.removemedia MEDIA_NAME

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:

urpmi --auto-update

To removed orphaned packages — that is, packages that were installed as dependencies of something that has since been removed:

urpme --auto-orphans

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:

/^foobar-10.2.153.1/
/^foobar/

Obviously this is hardly an exhaustive list; it’s just those commands that I most commonly need. For more fun, see the references.

REFERENCES
RPM based distributions
Maximum RPM
Fedora RPM Guide
Installing Source RPM (SRPM) package
man rpm

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

Advertisements

About Warren Post

So far: Customer support guy, jungle guide, IT consultant, beach bum, entrepreneur, teacher, diplomat, over-enthusiastic cyclist. Tomorrow: who knows?
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

2 Responses to RPM package management tips

  1. whoknows2012 says:

    Nice.

  2. Pingback: Security and stability tuning on Linux | A maze of twisty little passages

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s