How to make a list of installed packages

by Hooke

There's a wonderful tool called "remasterme" that lets you build an installable live CD or DVD from your current PCLOS system. However, there are times when you may need something more lightweight, like a list of your installed packages that you can later use to reinstall them using apt-get. Maybe you don't have a DVD burner, or you want to make several slightly different versions, and don't want to spend a DVD for each one. Another reason may be that you want to get a list of installed packages from a PCLOS .93a system and install those packages, (by name, not version), in a PCLOS 2007 system.

Users of distros that have APT with the DPKG packaging system, which handles ".deb" packages (like Debian and Ubuntu) can use the commands:

dpkg --get-selections and dpkg --set-selections

to do the trick. PCLOS has the APT package manager, but not DPKG (it has RPM instead) and RPM seems to lack this feature. But we can do it anyway, as follows:

First, let's save the package names to a file, say, in your desktop. Open a terminal as root and type:

rpm -qa --queryformat '%{name} \n' > ~/Desktop/installed.log

This command tells the RPM program to query the names of installed packages, building a list with the name of each package followed by a carriage return, and then to redirect the output of this query to the file "/home/yourusernameroot/Desktop/installed.log". Of course, you can save it elsewhere. It's a text file, so you can inspect it with

cat ~/Desktop/installed.log

or

kwrite ~/Desktop/installed.log

Then, when you want to use the list, just type (as root):

apt-get -y install $(cat ~/Desktop/installed.log)

This tells apt-get to install the result of reading the package list we just created. You can check the argument passed to apt-get by typing:

echo $(cat ~/Desktop/installed.log)

You will see all the names of the packages, separated by whitespace (the carriage returns go away), which is the way you tell apt-get to install more than one package. The "-y" option is indeed optional. It tells apt-get not to ask questions as long as nothing dangerous happens, such as trying to remove essential packages. If you want to test this command with out actually installing anything, you can use the "simulate" option. Just type:

apt-get --simulate -y install $(cat ~/Desktop/installed.log)

For more information, just type "man apt" and "man rpm". Have fun!

Top