I am moving from my old Debian development system to a new one, changing architectures from i386 to amd64. So I need to do a fresh install, but basically I want to keep my package selection.
Conventional wisdom is to use dpkg --get-selections and dpkg --set-selections to preserve the package selection. However, this does not keep the information about automatically installed packages.
Instead, I used
aptitude search '?installed?not(?automatic)' -F %p > packages.txt
to dump the packages I installed manually. Installing these was a matter of running:
aptitude install `cat packages.txt`
In fact this was taking so long that I loaded the packages in batches using
cat packages.txt|xargs -n 100 aptitude install --schedule-only; aptitude
While I was at it, it ran
aptitude remove '?obsolete'
on the original system, killing of a few hundred packages that accumulated since 2003.