Debian – apt-get autoremove removes important packages

aptdebian

After some failed attempts to install the nvidia binary blob, I returned to debian's nvidia packages. But now aptitude wants to auto-remove many packages:

ant ant-optional apper apper-data fonts-lyx fonts-opensymbol fonts-sil-gentium fonts-sil-gentium-basic hyphen-en-us kaccessible
      kde-icons-mono kdeaccessibility kdesudo kmag kmousetool libapache-pom-java
      libcmis-0.2-0 libcolamd2.7.1 libcommons-beanutils-java
      libcommons-collections3-java libcommons-compress-java
      libcommons-digester-java libcommons-logging-java libcommons-parent-java
      libdb-java libdb-je-java libdb5.1-java libdb5.1-java-jni libexttextcat-data
      libexttextcat0 libfs6 libgraphite2-2.0.0 libhsqldb-java libhyphen0
      libicu4j-java libjline-java libjtidy-java liblucene2-java libmythes-1.2-0
      libnss3-1d libpackagekit-glib2-14 libpackagekit-qt2-2 libregexp-java
      libreoffice libreoffice-base libreoffice-base-core libreoffice-calc
      libreoffice-common libreoffice-core libreoffice-draw libreoffice-emailmerge
      libreoffice-filter-binfilter libreoffice-filter-mobiledev
      libreoffice-help-en-us libreoffice-impress libreoffice-java-common
      libreoffice-kde libreoffice-math libreoffice-report-builder-bin
      libreoffice-style-galaxy libreoffice-style-oxygen libreoffice-writer
      libservlet2.5-java libvisio-0.0-0 libwpd-0.9-9 libwpg-0.2-2 libwps-0.2-2
      libxz-java lp-solve menu-xdg mythes-en-us network-manager-kde packagekit
      packagekit-backend-aptcc packagekit-tools python-packagekit python-uno
      ttf-liberation ttf-sil-gentium-basic uno-libs3 ure x11-apps
      x11-session-utils x11-xfs-utils xfonts-mathml xinit xorg

I understand the lib* packages but, wow hey, xinit and xorg?

Best Answer

apt-get autoremove or the aptitude equivalent removes all packages except the ones that have been installed explicitly (by selecting them in a package manager, or with apt-get install PACKAGENAME) and their dependencies. It doesn't know what packages might be important.

The manual/auto distinction can be very useful but you need to nudge it a bit. Declare key packages as explicitly installed, either with the apt-mark utility, or by running apt-get install (even if the packages is already installed), or by pressing m in the aptitude interface.

Debian and Ubuntu ship a number of metapackages that are there just to depend on certain categories of packages and which it's useful to install explicitly. That way, even if packages are reorganized on an upgrade, the dependencies will be managed automatically and you'll retain the functionality.

For example, in your case, you probably want something like

apt-get install xbase-clients
apt-mark manual ant libreoffice xorg

(and maybe a few more).