I was looking through the list of packages with dselect, but pressed Return twice by mistake, thereby making it confirm and quit the [S]elect option.When I go to the [I]nstall option, it's now suggesting to install a number of new packages that I don't want (and that have nothing to do with what I was looking for in the first place).Since I haven't proceeded with the installation itself, is there a way to reset the selection to what it was before I selected new packages, without going through the list one by one and pressing - for each package? (It doesn't matter if it's done via dselect or via another related command.)EDIT: (Adding an example)I've tried on another machine where dselect is installed. Let's assume that package gnugo isn't installed (that's just an example).Launch delect and choose [S]elect to get the list.Search for gnugo in this list (using /, if you're not familiar with dselect).Select it with +.Press Return to validate the suggestions and Return again to validate go back to the main menu (the mistake I made).Go to [I]nstall. It will now say:Reading package lists... DoneBuilding dependency tree       Reading state information... DoneThe following NEW packages will be installed  gnugo:i386 libgpm2:i386 libncurses5:i386 libreadline6:i386 libtinfo5:i3860 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.Need to get 1,926 kB of archives.After this operation, 9,634 kB of additional disk space will be used.Do you want to continue [Y/n]? Here, choose not to continue (n).Quit dselect.dpkg --get-selections | grep gnugo yields nothing at all.Start dselect again, go straight to [I]nstall again, the packages will still be selected for installation.Of course, I can go back into the [S]elect list, search for gnugo, press _ to deselect it, but in a more complex case, you may have to go through the new packages list one by one.[I]nstall in dselect is visibly a front-end to apt-get install, but I'm not sure where it gets its selection from. It appears dpkg --get-selection is not it.As far as dselect is concerned, I'd like to reset it in a state where everything maked with *** stays at it was, but what's now marked with only ** (and not installed yet) goes back to __, without having to go manually through the suggested list from the [I]nstall menu.EDIT 2:This is clearly related to the content of /var/lib/dpkg/status, which contains this entry:Package: gnugoStatus: install ok not-installedPriority: optionalSection: gamesIf I change this manually to Status: deinstall ok not-installed, it disappears from the selection in dselect (which makes sense).What I would like is a general way of turning whatever says Status: install ok not-installed into Status: deinstall ok not-installed (leaving packages saying Status: install ok installed unaffected).
Reset dselect selection before package installation
ubuntu;debian;package management;apt
It turns out dpkg --get-selections doesn't list what's marked for installation and not yet installed, but dpkg -l '*' does, and starts these lines with in.As a result, the following line resets these selections:dpkg -l '*' | grep '^in ' | awk '{ print $2  deinstall }' | dpkg --set-selections