15 January 2010

Advanced Dependency Management with Yum Shell

Many years ago, Red Hat had a (rather unfair) reputation of being a Linux distrubution forever crippled by a painful and clumsy package management system. “Dependency Hell” was the name used to describe the situation one could get into where circular dependencies arose, and the user became stuck. Dependency hell (which was always a bit of a myth) is a thing of the past now, especially since RHEL 5 where Red Hat adopted the powerful Yellowdog Updater, Modified (yum) which CentOS and Fedora had used for some time. However, just occasionally, problems arise which require some black-belt dependency solving.

For example, last week, a Linux user was attempting to replace the default sysklogd with rsyslog. He had a package which provided a newer version than the one provided in the distro, and was trying to install it. Yum wouldn’t allow this, owing to a conflict of ownership of the logrotate syslog entry. He was going to try uninstalling syklogd, but a quick check suggested this might not be a good idea:

[root@yarg ~]# rpm -e --test sysklogd
error: Failed dependencies:
    	syslog is needed by (installed) initscripts-8.45.30-2.el5.centos.x86_64
        syslog is needed by (installed) vixie-cron-4.1-76.el5.x86_64

Aha - yum will remove initscripts, upon which most of the system depends, so that’s not a great idea.

So - we have a catch 22. We want to install rsyslog, but we can’t because of a conflict with sysklogd. We can’t uninstall sysklogd, because that will remove most of the system. Now, one could trust that rsyslog is a drop in replacement for rsysklogd, and remove sysklogd with rpm -e –nodeps, but that feels a bit hacky. No, this is exactly the sort of situation in which we can use yum shell.

Yum shell is a very nifty feature of yum which allows the user to stack commands to resolve various types of packaging issues. This is exactly what we need to do with our rsyslog / sysklogd issue, and was a godsend on earlier versions of Redhat when replacing sendmail with exim or postfix provided similar challenges.

So, we fire up yum shell:

[root@yarg stephen]# yum shell
Loaded plugins: fastestmirror
Setting up Yum Shell
> install rsyslog
> remove sysklogd
> run 
> exit
Leaving Shell

You’ll see some feedback during the process - but what’s basically happening is that all the operations are being run in a single transaction (and, incidentally with only one call of python, and the yum libraries, repo checks etc). This means that we get around the issues yum was complaining about, because the operations are carried out in a single shot.

I think yum shell is a powerful feature, and it’s great to have the capability to script sets of commands and bundle them up into a single operation, and one I think you’ll find will be a potententially valuable addition to your toolkit.