20101222 yum install from a list - plembo/onemoretech GitHub Wiki

title: yum install from a list link: https://onemoretech.wordpress.com/2010/12/22/yum-install-from-a-list/ author: lembobro description: post_id: 94 created: 2010/12/22 19:40:58 created_gmt: 2010/12/22 19:40:58 comment_status: open post_name: yum-install-from-a-list status: publish post_type: post

yum install from a list

I recently re-installed CentOS 5.5 on a machine at work to move it up to 64 from 32 bit. Although I was able to just tar up my data beforehand and then restore it later, I basically did a fresh install of the system to get the 64-bit versions of things. That left me with a raft of additional packages, including a couple of dozen perl modules, that needed to be reinstalled. To do this I decided to try yum installing them from lists. Following is what I did to get the perl stuff back in place as an example.

First I made a list of all the perl packages on a reference system (this is a machine that closely matched my workstations package set).

rpm -qa | grep '^perl-' >perl-pkgs.lst

This gave me a list formatted like this:

perl-DBI-1.52-2.el5 perl-ExtUtils-CBuilder-0.18-1.el5 perl-Net-SSLeay-1.30-4.fc6 perl-Gtk2-1.221-1.el5.rf perl-BSD-Resource-1.28-1.fc6.1 perl-Image-Xpm-1.09-6.el5 perl-MailTools-1.77-1.el5.centos perl-Net-UPnP-1.41-3.el5 perl-Text-Iconv-1.4-5.el5 perl-GSSAPI-0.24-2.el5

Problem here were the version numbers. They could be a problem if the package versions had changed since they were last installed/updated on my reference system.

Here’s a better way I came up with.

yum list installed | grep '^perl-' | cut -d " " -f 1 > perl-pkgs.lst

This produces a nice, alphabetically sorted, list without any version numbers (but with the architecture label, something that might come in handy later on).

perl-Authen-SASL.noarch perl-BSD-Resource.x86_64 perl-Bit-Vector.x86_64 perl-Carp-Clan.noarch perl-Compress-Raw-Bzip2.x86_64 perl-Compress-Raw-Zlib.x86_64 perl-Config-Simple.noarch perl-Convert-ASN1.noarch perl-Crypt-DES.x86_64

Armed with this list I could theoretically issue a command like this:

yum -y install $(cat install.lst)

But what about prerequisites! The above will try to install each package one at a time.

Maybe submit the whole list to yum install and let it decide what to try installing first?

To do that I’d need to replace the linefeeds between each package with spaces:

perl -pi -e 's/n/ /g' perl-pkgs.lst

There’d be no guarantees of success here because sometimes (often) yum will make the wrong decision about what to try first. In addition, depending on how many packages were in the list, you could also run into the old “line too long” issue.

I’m thinking the best (and most efficient) strategy would be to make up a series of lists, organized by subject are (database, network, web related, etc.), and try installing from them one at a time.

P.S. In the end I went with the full linefeed-delimited list, and to my surprise things worked out really well. There were a couple of packages that had apparently been installed when my yum priorities were set up differently, so the names of the available corresponding packages were cased slightly differently (perl-DBD-MySQL rather than perl-dbd-mysql, for example) but for the most part everything came over without a hitch. I’m also experimenting with doing an rsync from /usr/lib/perl5/site_perl and vendor_perl (and /usr/lib64/perl5/site_perl and vendor_perl) for some of the handbuilt modules. We’ll see how that works out.

Copyright 2004-2019 Phil Lembo