为什么“apt-get autoremove sendmail”将依赖放在后面?

我注意到使用apt-get来安装sendmail,然后卸载它会留下许多不必要的文件。

sudo apt-get install sendmail Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: liblockfile-bin liblockfile1 make procmail sendmail-base sendmail-bin sendmail-cf sensible-mda Suggested packages: make-doc sendmail-doc rmail logcheck resolvconf sasl2-bin Recommended packages: default-mta mail-transport-agent fetchmail The following NEW packages will be installed: liblockfile-bin liblockfile1 make procmail sendmail sendmail-base sendmail-bin sendmail-cf sensible-mda 0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Need to get 2256 kB of archives. After this operation, 5263 kB of additional disk space will be used. Do you want to continue? [Y/n] y 

所以我们安装了sendmail – 9个新包和5.2MB。
几分钟后,我改变了主意,想卸载它。 没问题,apt-get让我覆盖,对吧? 我清除(删除包和包configuration文件):

 sudo apt-get purge sendmail Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: procmail sensible-mda Use 'apt-get autoremove' to remove them. The following packages will be REMOVED: sendmail* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 219 kB disk space will be freed. Do you want to continue? [Y/n] y 

然后autoremove(删除自动安装的软件包依赖项)

 sudo apt-get autoremove sendmail Reading package lists... Done Building dependency tree Reading state information... Done Package 'sendmail' is not installed, so not removed The following packages will be REMOVED: procmail sensible-mda 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. After this operation, 550 kB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 24702 files and directories currently installed.) Removing sensible-mda (8.14.4-8+deb8u1) ... Removing procmail (3.22-24) ... Processing triggers for man-db (2.7.0.2-5) ... 

这是219 + 550 = 769KB恢复! 我有没有空间? 为了什么?

仔细查看输出,看来apt-get只删除了以前自动安装的软件包中的3个。 例如,sendmail-base包仍然是:

 sudo apt-get remove sendmail-base Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: sendmail-base sendmail-bin 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. After this operation, 2464 kB disk space will be freed. Do you want to continue? [Y/n] 

所以有一些我的浪费空间。 但为什么这些自动安装的依赖关系仍然安装?

sendmail是一个由一组依赖关系组成的元程序包。 当你安装sendmail元包时,它会安装sendmail-bin等等。 例如,这为cron提供了一个推荐的软件包,但是我相信也有一些其他软件包可以在sendmail依赖链中推荐软件包。

Autoremove不会删除其他软件包推荐的自动软件包。 您可以通过在/etc/apt/apt.conf.d/99_norec添加aptconfiguration来改变这种行为

APT::AutoRemove::RecommendsImportant "false"; APT::AutoRemove::SuggestsImportant "false";

然后运行apt-get remove --auto-remove sendmail ,你应该看到所有的sendmail相关软件包被标记为删除,还有一些其他不相关的东西,因为aptconfiguration的整体变化,现在是删除候选软件。

虽然,我相信这不是build议(没有双关语意)。 你应该手动处理这些,如果你需要摆脱它们。