Syncing the set of installed packages on two computers

Debian makes an enormous number of packages available. Installation of a new program is simple, any additional packages that the packges depends on is automatically installed. But deinstalling a program does not necessarily deinstall the packages that was installed solely to satisfy this programs dependencies.

aptitude does automatically remove packages that was only installed to satisfy dependencies. However, if you really want to get rid of packages that you don't need this might not be what you want.

Maybe it comes down to what you is used to and I am used to apt-get rather than aptitude.

With apt-get you specify what you would like to de-install, and those packages will be de-installed. With aptitude you must instead specify the packages you want to have installed.

I know what programs I want and am willing to spend some effort to not have unused packages installed. So on one of my two computers at home a used synaptic to remove packages that I didn't need. The problem with the way aptitude works is that if you deinstall a meta-package which depends on packages you don't want, it will want to deinstall the packages that you do want also.

So how do you get from the list of the set of packages installed on computer A to having the same packages installed on computer B which from the beginning have a larger set of packages installed?

The technique given in the debian reference http://www.debian.org/doc/manuals/reference/ch-package.en.html#s-record is not usable here, since it will not remove packages that were installed on B but not on A.

Synaptics "save/read markings" does not work.

Here is how to do it (host "a" has the correct set of packages while host "b" has too many)

a: $ dpkg --get-selections > packages.a
a: $ scp packages.a b:
b: $ dpkg --get-selections > packages.b
# Now list all packages that is marked "install" in packages.b but is # not marked "install" in packages.a
b: $ diff packages.a packages.b | grep \> | grep -v deinstall | cut -d" " -f2 | cut -f1
Inspect that list and ensure it seems OK and use it to feed apt-get with.
b: # apt-get --purge remove `diff packages.a packages.b | grep \> | grep -v deinstall | cut -d" " -f2 | cut -f1`

Install the packages that was installed on a, but not on b

b: # dpkg --set-selections < packages.a
b: # apt-get dselect-upgrade

comments powered by Disqus


Back to the index

Blog roll

R-bloggers, Debian Weekly
Valid XHTML 1.0 Strict [Valid RSS] Valid CSS! Emacs Muse Last modified: 2007-01-18