Debian packages: distinguish “requested install” from “installed to satisfy dependencies”

半腔热情 提交于 2019-12-24 05:42:07

问题


How can I determine which packages where installed because I requested the installation and which packages where automatically installed in order to satisfy dependencies?

In aptitude, this information is shown as "A":

i A fam         ...
i   grub        ...
i A grub-common ...

This shows that I requested the package grub and that grub-common was installed as a result of this. However, aptitude is an interactive program, I cannot extract this information automatically to process it with a script.

With the debian package management tool 'dpkg -l' or 'dpkg --get-selections', I can get a list of installed package with additional information. E.g.

> dpkg -l
...
ii  grub                                 0.97-47lenny2              GRand Unified Bootloader (Legacy version)
ii  grub-common                          1.96+20080724-16           GRand Unified Bootloader, version 2 (common files)
ii  gs-common                            8.62.dfsg.1-3.2lenny1      Dummy package depending on ghostscript
...

This list can easily be processed with scripts, but it only shows that the packages are installed --- not whether by request or for dependencies.


回答1:


indeed one can call aptitude search with the so-called search patterns; see reference at http://algebraicthunk.net/~dburrows/projects/aptitude/doc/en/ch02s03s05.html#tableSearchTermQuickGuide search ~i yields installed packages. Using grep to discard packages with A gives packages not automatically installed, so it almost answers the original question.

But it includes packages that belong to the original distribution, so its not completely sorted out. In my case, its still 1500 packages, a set I can deal with.

Its probably possible to do it by search combination, I didnt dig, here is my command:

aptitude search ~i|grep -v '^i A'|

the grep -v discards dependent packages




回答2:


Aptitude runs as a commandline-only, gui-less program too. Try:

aptitude search grub

The information will be there.




回答3:


Apt supports an 'auto' flag which describes precisely this.

Look at http://man.he.net/man8/apt-mark and dig deeper if needed.



来源:https://stackoverflow.com/questions/1686386/debian-packages-distinguish-requested-install-from-installed-to-satisfy-depe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!