0

How can I go back to the state before the package was installed?

Install:

# apt-get -y install --no-install-recommends build-essential
...
The following additional packages will be installed:
  binutils cpp cpp-5 dpkg-dev g++ g++-5 gcc gcc-5 libasan2 libatomic1
  libc-dev-bin libc6-dev libcilkrts5 libdpkg-perl libgcc-5-dev libgdbm3
  libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpfr4 libmpx0 libperl5.22
  libquadmath0 libstdc++-5-dev libtsan0 libubsan0 linux-libc-dev make patch
  perl perl-modules-5.22 xz-utils
Suggested packages:
  binutils-doc cpp-doc gcc-5-locales debian-keyring g++-multilib
  g++-5-multilib gcc-5-doc libstdc++6-5-dbg gcc-multilib manpages-dev autoconf
  automake libtool flex bison gcc-doc gcc-5-multilib libgcc1-dbg libgomp1-dbg
  libitm1-dbg libatomic1-dbg libasan2-dbg liblsan0-dbg libtsan0-dbg
  libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg glibc-doc
  libstdc++-5-doc make-doc ed diffutils-doc perl-doc libterm-readline-gnu-perl
  | libterm-readline-perl-perl
Recommended packages:
  fakeroot libalgorithm-merge-perl manpages manpages-dev
  libfile-fcntllock-perl rename
The following NEW packages will be installed:
  binutils build-essential cpp cpp-5 dpkg-dev g++ g++-5 gcc gcc-5 libasan2
  libatomic1 libc-dev-bin libc6-dev libcilkrts5 libdpkg-perl libgcc-5-dev
  libgdbm3 libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpfr4 libmpx0
  libperl5.22 libquadmath0 libstdc++-5-dev libtsan0 libubsan0 linux-libc-dev
  make patch perl perl-modules-5.22 xz-utils

Removal:

# apt-get -y --purge --auto-remove remove build-essential
...
The following packages will be REMOVED:
  build-essential*

# apt-get -y --purge autoremove
...
The following packages will be REMOVED:
  g++* g++-5* libstdc++-5-dev*

Why is the other stuff kept?

Velkan
  • 3,616
  • Because build-essential is sort of those apt packages which are called metapackage or virtual package. They are created to pull other packages as a feature set and removing them won't cause removal of pulled packages – Anwar Apr 28 '17 at 11:27
  • @Anwar, there isn't a special notion for that on the dpkg or apt level. The metapackages are just like the others. – Velkan Apr 28 '17 at 11:33
  • No. metapackages are different and see my comment on your answer – Anwar Apr 28 '17 at 11:34

1 Answers1

2

In short:

sudo bash -c 'echo "Apt::AutoRemove::SuggestsImportant false;" > /etc/apt/apt.conf.d/01autoremove-suggested'

This behavior is controlled by the option Apt::AutoRemove::SuggestsImportant.

Option: Apt::AutoRemove::SuggestsImportant

Default: true

Description: If this option is true, then aptitude will not consider packages to be unused (and thus will not automatically remove them) as long as any installed package suggests them. For more information, see the section called “Managing automatically installed packages”.

Source:

Aptitude doesn't remove automatically installed packages

Velkan
  • 3,616
  • You were not using aptitude, you were using apt which is different. And apt always suggest to remove automatically installed packages that are no longer required – Anwar Apr 28 '17 at 11:33
  • @Anwar, the config value is in /etc/apt/apt.conf.d/ and called Apt::, and it works, so it's definitely for apt-get. I do the apt-cacher proxy configs for apt-get in /etc/apt/apt.conf.d/ too... – Velkan Apr 28 '17 at 11:42