Installing packages from a previously produced list

General support questions
Post Reply
lightman47
Posts: 1522
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Installing packages from a previously produced list

Post by lightman47 » 2018/06/25 17:56:19

I have a laptop that is a little screwy and all my 'tricks' (including reinstalling everything) don't seem to straighten it out. I guess I've finally come to the conclusion that the only option left is a total disk/partition wipe & start over. That having been said:

The laptop's important directories are backed-up regularly. One of the backup initial steps is to produce a list of Installed packages for just such an occasion via "rpm -qa > /mnt/"$DataDrive"/backup/"$Computer"/"$OSVersion"/InstalledPackages.txt". This produces an invaluable list I thought I could use perhaps automatically at a time such as this. The 'automatically' part didn't work the single time I attempted to "yum install < " using that produced list; it didn't like the package names. That list was the my 'saving', despite my failed attempt to automate.

Question:
I thought I remember seeing posts dealing with properly producing an output list of installed packages that could be used as input for a "yum install". How do I do that?

As mentioned, the list gets produced in the backups and it's a small matter to get them manually installed (really). Curiosity is what's driving me. I suspect HOW I derive my list may be one of the issues. I wonder if I should "yum list installed >", but I think I tried that.

There is NOTHING urgent - I've rebuilt CentOS 7 machines before - generally a leisurely Sunday afternoon. I'm only trying to further automate the process.

Thank you.

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Installing packages from a previously produced list

Post by TrevorH » 2018/06/25 19:01:49

echo "yum install " >> /tmp/reinstall; rpm -qa --qf '%{name}.%{arch} ' >> /tmp/reinstall
or
rpm -qa --qf '%{name}.%{arch} ' >> /tmp/reinstall && yum reinstall $(cat /tmp/reinstall) should also work.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mghe
Posts: 766
Joined: 2015/11/24 12:04:43
Location: Katowice, Poland

Re: Installing packages from a previously produced list

Post by mghe » 2018/06/25 19:21:44

Check it:

Code: Select all

$ yum list installed | awk 'NR > 3 { print $1 }' | xargs sudo yum install

Post Reply