I'm in a situation where apt shows 1000+ packages on my system marked as auto-removable. Amongst those are many that I know I need. I've resolved the situation by setting those to manually installed. But that results in almost half the packages in my system showing up as 'manually installed'. I ran into trouble when upgrading my system to the current stable version of Debian (apt-get dist-upgrade), and none of the 'manually installed' packages were upgraded. Again, I resolved the situation by setting all the 'manually installed' packages to automatically installed. That made the upgrade possible. But now all the upgraded, formerly 'manually installed' packages are again auto-removable. I tried finding not installed meta-packages that through their dependencies would at least reduce the auto-removable list. But without success. - Is there no way to get back to a situation where the packages marked as auto-removable are really those I don't need?
Finally I was thinking: what do I do when I install a new system? - Install a minimal system and then add what I need in addition. So I tried this:
aptitude install ~pstandard ~pimportant ~prequired
which should make sure at least a minimal functioning system would not be 'autremoved', containing all packages of priorities Required, Important and Standard.
However the command returned an error code: "Unable to apply some actions, aborting" Not very informative, but I then replaced the command whith a longer version:
required=$(aptitude search ~prequired -F"%p"); apt-get install $required;
important=$(aptitude search ~pimportant -F"%p"); apt-get install $important;
standard=$(aptitude search ~pstandard -F"%p"); apt-get install $standard;
That also threw a couple of errors which were, however, easily resolved. Then I listed the still autoremovable packages with:
apt-get --dry-run autoremove | grep -Po 'Remv K[^ ]+' | sort > autoremovable.txt
one name per line and found & additionally installed those I knew I needed. Having done that there were still 757 packages in my 'autoremovable' list. Those I then removed with
Then I rebooted and the system came back up fine.
Possibly you are misunderstanding "auto-removable". If a packet is installed automatically as a dependency of other packages, it is marked as "automatically installed" or "auto-removable" (as opposed to "manually installed").
This only means that if all other packages that need a particular are removed, then this automatically installed package is considered as a candidate for auto-removal, which you have to do explicitly. It does not mean that these packages are somehow in danger of being removed while they are still needed.
On the other hand, marking a package as "manual" means "the user has explicitly chosen to install this package, with this particular version, and the user is responsible for upgrading it".
So the usual way to handle things is to install those packages you need (which will mark them "manual"), upgrade them manually or let them semi-manually upgrade with dist-upgrade, and let the library packages etc. be marked as "auto", so the package system can remove those at will, and re-install variants or different versions as needed.
TL;DR: Don't worry about auto-removable packages, keep them that way.