Mark Weyer wrote at 2013-04-23 16:12 -0500: > The title is imprecise. Actually, the question is: How do I list > installed packages except those automatically installed to satisfy > dependencies. In aptitude that would be packages marked as "i " but > not as "i A". And if there is no command to list this, where in /etc > (or whereever) is the information hidden?
If the generated list may be used to restore the package selection, then you may want to save a list of *all* packages installed ("i"), then a list of packages *manually* installed (not "i" but not "i A"). If you restore a list containing only packages *manually* installed, the result will be a different package selection because of variations in dependency resolution. This happens because of packages that depend on "foo OR bar", or packages with recommends which were or were not fulfilled in the original package set. Following are the commands I use for backup and restore of the package selection. Please note that I have not needed to use these commands for some time. In fact, aptitude-create-state-bundle arrived some time after I implemented this; I have not researched the possibility of using the state bundle to restore the package state. It is quite likely that it will do the job better than these commands. For saving the package state, I use these commands: # Save aptitude state bundle aptitude-create-state-bundle state.tar.bz2 # Save a list of all installed packages aptitude -F "%?p" --disable-columns search \~i >| installed-all # Save a list of all installed packages with their versions aptitude -F "%?p=%?V" --disable-columns search \~i >| installed-all-ver # Save a list of all automatically installed packages aptitude -F "%?p" --disable-columns search \~i\~M >| installed-auto For restoring the package state, I use these commands: # Install all essential, important, required, or standard packages aptitude -R --schedule-only install $( aptitude -F "%?p" search \ \!\~i?or(\~E,\~pimportant,\~prequired,\~pstandard) ) # Mark as manually installed all essential, important, required, or standard priority packages aptitude -R --schedule-only unmarkauto $( aptitude -F "%?p" search \ \~i?or(\~E,\~pimportant,\~prequired,\~pstandard) ) # Mark as automatically installed all packages that are not essential, # important, required, or standard priority aptitude --schedule-only markauto $( aptitude -F "%?p" search \ \~i\!\~E\!\~pimportant\!\~prequired\!\~pstandard ) # Install all the packages in the installed package list (manual + automatic) aptitude -R --schedule-only install $( cat installed-all ) # Select specific versions of packages (you may want to skip this step) aptitude -R --schedule-only install $( cat installed-all-ver ) # Mark as automatically installed all packages in that list aptitude --schedule-only markauto $( cat installed-auto ) # Run aptitude, check scheduled actions, and apply aptitude
signature.asc
Description: Digital signature