On Thursday 26 March 2009 22:09:28 Paul E Condon wrote: >On 2009-03-26_19:08:32, Douglas A. Tutty wrote: >> On Thu, Mar 26, 2009 at 04:26:12PM -0600, Paul E Condon wrote: >> > But I think I would like to have a record of what packages were >> > actually installed. So I'm thinking of writing a script, to be run >> > nightly, that puts a fresh copy of my selections in /etc/apt, e.g. >> > >> > # dpkg --get-selections >/etc/apt/selections >> Many of those packages will have been installed automatically by your >> package manager. If you use aptitude, you only need to record the >> packages which you manually installed: >> >> aptitude search `~i!~M' >> >> You can then install them, then aptitude will automatically install what >> is needed by them. >Well, I may sound like an orderly person, but writing down a record of >each time I install something is rather more orderly than I think I >can ever be. I'm looking to program the computer to keep track of me. > >Your suggestion does raise in interesting issue: given a set of >installed packages in a --get-selections file, and given that the >dependency information is available in the packages, what is the >minimum set of install commands to aptitude that will reconsturct the >installation from scratch? Does anyone know a way to solve this >problem? It might be a rather difficult search problem, but it might >be there is some neat trick. Does anyone here know?
I don't *know* this works, but it should. To save the state of the Debian packages installed: dpkg --get-selections | \ awk '$2 = "install"' > installed_package_selections aptitude search '~i~M' | awk '{print $3}' > auto_installed_packages debconf-get-selections | grep -Ev '^[[:space:]]*(#|$)' > debconf_settings To restore the state of the Debian packages installed: dpkg --set-selections < installed_package_selections debconf-set-selections < debconf_settings xargs -r -- aptitude markauto < auto_installed_packages aptitude install You may want to throw an aptitude update in there somewhere. You'll still need to restore any configuration settings that aren't managed by debconf.[1] The saving can be mostly done as a non-root user, the only thing that will miss is the "passwords" database, because it is 600 root:root, but running debconf-get-selections as root will get that, too. Of course, all the restoring must be done as root. dpkg says you'll need these packages: dpkg: /usr/bin/dpkg aptitude: /usr/bin/aptitude debconf-utils: /usr/bin/debconf-get-selections grep: /bin/grep debconf: /usr/bin/debconf-set-selections findutils: /usr/bin/xargs plus one of: mawk: /usr/bin/mawk gawk: /usr/bin/gawk -- Boyd Stephen Smith Jr. ,= ,-_-. =. b...@iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/ [1] In particular, you probably want to restore a backup of the /etc/apt directory first, so the aptitude run behaves the way it should.
signature.asc
Description: This is a digitally signed message part.