[PLUG] Using YUM to install RPMs from a text file list

Wil Cooley wcooley at nakedape.cc
Sun Jul 19 19:09:15 UTC 2009


On Sun, 2009-07-19 at 02:23 -0700, Matt McKenzie wrote:

> In a nutshell I want to do something like this:
> 
> $ sudo yum install < rpmlist.txt
> 
> But that doesn't work, since yum isn't setup to directly take pipes or
> redirects from command line.
> 
> Also note the package list has full RPM names, including version, so the
> list may need to be trimmed or something to just the package names only.
> (Ex... foo-bar-1.2.3-fc11.i586.rpm, and yum probably wants just foo-bar
> only)


There is, at this point, no way to strip the version from the package
names. Yum will work with the version, though.

In the future, make your list using this:

$ rpm -qa --queryformat '%{NAME}\n'
 
The '--queryformat' is a very powerful option. You can also use
'--querytags' to list tags you can use in addition to 'NAME'. There is a
shorter alias '--qf'. For examples, you might want to look
through /usr/lib/rpm/macros.

Back to your original question, in addition to the highly-portable
'xargs', bash supports a nicer form of command substitution with the
construct '$(< file)'. (Look in the bash man page for 'Command
Substitution'.)

$ sudo yum install $(< rpmlist.txt)

You might need to filter out a few special packages, like 'gpg-pubkey',
since those are created by importing GPG public key signatures and not
actually installed as packages.

Wil
-- 
Wil Cooley <wcooley at nakedape.cc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.pdxlinux.org/pipermail/plug/attachments/20090719/d4496ad9/attachment.asc>


More information about the PLUG mailing list