[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Creating a new machine with the same set of packages as an existing one?

On Sun, 2003-10-12 at 18:45, stan wrote:
> How cna I do this?
> The machine I want to match is a "testting" machine, that I quit updating
> about a month agao. Still has Gnome 1.4 for instance.
> Will this ne a problem?

One approach is to create a list of all of the packages currently
installed on your system, for instance with dpkg --get-selections or
with apt-show-packages. You can parse the output and save into a file to
get the names of all of the installed packages, for instance:

dpkg --get-selections | cut -f 1 >package-listing-from-dpkg
apt-show-versions | cut -f 1 -d / >package-listing-from-apt

Now, install a base woody system on the new machine. Modify your
/etc/apt/sources.list for testing, and do apt-get update; apt-get
dist-upgrade to bring you up to testing since that is what your current
machine is.

Now, using either of the above package lists, you can do:
	for pkg in $(cat package-listing-from-xxx);
		apt-get install $pkg;
which will work although not be the most efficient way (because you will
have to run apt-get for each package, and hence dependences are
re-resolved over and over, or:
	cat package-listing-from-xxx | xargs apt-get install
will also work and let apt-get do all the resolving at one time,
PROVIDED the total listing of your packages does not exceed the maximum
line length of bash. Since it is likely that it WILL do so, you might
want to stick to the first approach of installing each package one by
one. Slower, but of course later packages that have already been
installed won't need to happen again.

I haven't testing this in practice, and note that there isn't any error
handling here, but you can always give it a shot.


Reply to: