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

Matt McKenzie lnxknight at gmail.com
Sun Jul 19 22:27:21 UTC 2009


On Sun, Jul 19, 2009 at 12:09 PM, Wil Cooley <wcooley at nakedape.cc> wrote:

> 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>
>
> _________________________________



Thanks for all the replies everyone!

It is too late at this point to do the rpm query, though I will definitely
save that one for next time.
I had F11 installed in a VM, but since I messed up and gave the VM a virtual
HDD that was too small, I had to wipe and redo it.  I did a regular rpm -qa
> rpmlist.txt, emailed that to myself, and then wiped it.

I ended up just doing a copy/paste on the command line (using the list with
the version numbers), and yum chugged through it all, saying package xyz
already installed for a bunch of them (the list was a complete list, and the
new install already had a bunch of them obviously), but it did finally get
to the new packages, and installed them, about 600 or so.  It took a while,
but it did work.  I was concerned that bash would have crapped out (command
line too long), but it didn't.

These solutions here are much more streamlined though, I will save them for
next time for sure. :)

Using backticks ` or $() to surround the command so bash will expand the
file is what I was thinking of but couldn't remember how to do it.  Thanks!



More information about the PLUG mailing list