[Nottingham] Preserving a list of packages installed (Ubuntu but could be general!)

Peter Chang Peter.Chang at nottingham.ac.uk
Thu Sep 28 19:38:42 BST 2006


David,

Sounds very straightforward to do something like this. Get a list of
packages on your old machine:

under rpm distros, run something like

$ rpm -qa | sort > oldrpm.lis

with yum

$ yum list installed | cut -f1 -d' ' > oldyum.lis

with deb distros

$ dpkg -l > olddeb.lis

or

$ dpkg-query -l > olddeb.lis

(you may need to process the deb list as I don't know the format of its
outputs)

Do the same on a newly installed distro on your other machine. Compare
the two lists using diff(1) ($ diff oldrpm.lis newrpm.lis) and grep(1)
for added packages.

So assuming you haven't removed any packages from the base installation of
your old distro,

$ diff -u oldrpm.lis newrpm.lis | \
awk '/^+/ {if (FNR>2) print substr($0,2)}' > add.lis

[
use the following to find removed packages
$ diff -u oldrpm.lis newrpm.lis | \
awk '/^-/ {if (FNR>2) print substr($0,2)}' > sub.lis
]

Finally, add the new packages to your new machine. For example,

$ xargs -a add.lis yum -y install

or if your shell can cope with very long lines

$ yum -y install `cat add.lis`

Hope this helps,
 Peter


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.




More information about the Nottingham mailing list