[plug] Reinstalling debian

Anthony J. Breeds-Taurima tony at cantech.net.au
Tue Jul 9 15:22:00 WST 2002


On Tue, 9 Jul 2002, Trevor Phillips wrote:

> Anthony J. Breeds-Taurima wrote:
> >
> > apt-get update
> > dpkg --set-selections < /path/to/your/backup/dpkg.selections
> > apt-get dselect-upgrade
> 
> Out of curiosity, if this is done on an existing system with extra junk, 
> will it cull the packages down to the selections? ie; remove things NOT in 
> the selections?

No you will be given a list of packages that are either in  
"install/deinstall/hold" .... Any package that is on the current running
system, that wasn't installed on the "-get-selections" machine will be
unaltered.  So you can't use that methedology to do what you want BUT you
could do;

!!!!!!!!!! Extremly untested code !!!!!!!!!!
----------
#!perl

open OLD, "/path/to/your/backup/dpkg.selections" or die
while (<OLD>) {
	($name,$state) = split/\s+/;
	$packages{$name}=$state;
}

close OLD:

open NEW, "dpkg --get-selections" or die
while (<NEW>) {
	($name,$state) = split/\s+/;
	if (exists $packages{$name}) {
		if ($packages{$name} ne $state) {
			print "$name is $state was $packages{$name}\n";
		}
	} else {
		print "You have $name installed remove it\n";
	}
}
----------

That will compare the current "selections" to an archived state file.
If a package is on the current system and is in the same state then you won't
see any messages about it.  If it is on the current system and in the archive
file BUT they differn in their state then you'll be told.  If a package is on
the current machine BUT not in thr archive file you'll be told to remove it.

I think?

Yours Tony

   Jan 22-25 2003           Linux.Conf.AU            http://linux.conf.au/
		  The Australian Linux Technical Conference!



More information about the plug mailing list