On Thu, May 28, 2020 at 09:34:51PM +0700, Victor Sudakov wrote: > > > > dpkg --get-selections > /root/initial-packages > > > > > > > > Just hold on to that file, and it will allow you to return to this > > > > state on the same machine, or conceivably even a different machine. > > > > > > Out of itself, this file will not allow me anything. But Charles Curley > > > has named the debfoster utility which seems to do the closest thing to > > > what I wanted to achieve. > > > > What?! > > > > It does PRECISELY WHAT YOU STATED you wanted to do! > > Well, I wanted a degree of automation, not just a > "dpkg --get-selections | diff /root/initial-packages -" for visual > analysis and manual removal.
The reverse of dpkg --get-selections is dpkg --set-selections, which you run using the saved file as input instead of output. Then you follow this with something like "apt-get dselect-upgrade" to install the packages necessary to make the new system match the old system. Now, I've never used this to *remove* packages -- only to install new packages after a (re)install. I'm not sure how it handles removal of packages. Maybe there's an additional step required. Or maybe it just works as is. The fact that you just ASSUMED that it would require "manual removal" instead of thinking, "Hey, what is this --get-selections thing, maybe I should read some documentation about it, or ask more questions about it", is part of the problem here.