Synaptic 软件包管理器有一个自定义过滤器“缺失推荐”。有没有办法找出我系统上安装的哪些软件包推荐了此过滤器中列出的软件包?
答案1
Aptitude 可以执行一些相当花哨的搜索
这将显示所有具有不满足的推荐的软件包:
aptitude search '?installed?broken-recommends'
要将其限制为特定的推荐包:
aptitude search '?installed?broken-recommends(PACKAGE)'
答案2
据我所知,没有简单的方法可以找出哪个包推荐了特定的其他包。
这是一个粗略的脚本,用于构建软件包推荐或建议其他软件包的列表:
dpkg --get-selections | cut -f 1 | while read pkgname
do
apt-cache depends "$pkgname" | \
grep -E "Recommends|Suggests" | \
cut -b 3- | \
while read recommends
do
echo "$pkgname" "$recommends"
done
done | sort -k 3 -k 2 | column -t
注意:脚本需要一些时间才能运行。此外,输出非常长,因此您很可能希望将输出捕获到文件中:
$ whatrecommends.sh > whatrecommends.txt
输出示例:
...
ubuntu-desktop Recommends: avahi-autoipd
avahi-daemon Suggests: avahi-autoipd
dhcp3-client Suggests: avahi-autoipd
libnss-mdns Suggests: avahi-autoipd
hplip Recommends: avahi-daemon
rhythmbox Recommends: avahi-daemon
ubuntu-desktop Recommends: avahi-daemon
libsane Suggests: avahi-daemon
pulseaudio-utils Suggests: avahi-daemon
sane-utils Suggests: avahi-daemon
system-config-printer-common Recommends: avahi-utils
bash Recommends: bash-completion
ubuntu-standard Recommends: bash-completion
ack-grep Suggests: bash-completion
bash Suggests: bash-doc
...
sort
通过更改脚本末尾的参数,您可以更改输出的排序顺序。
答案3
根据 tumbleweed 的回答,我编写了一个脚本,使用 aptitude 搜索来提出推荐缺少的软件包的软件包。
但是它没有提供与突触相同的完整列表。不知道为什么。
剧本
#!/usr/bin/php
<?php
$list = shell_exec("aptitude search '?broken-reverse-recommends(?installed)'");
preg_match_all("|^.{4}(.*) - (.*)$|mU", $list, $matches);
foreach ($matches[1] as $prog) {
$prog = trim($prog);
echo "$prog:\n";
$missing = shell_exec("aptitude search '?installed?broken-recommends($prog)'");
preg_match_all("|^.{4}(.*) - (.*)$|mU", $missing, $mismatch);
foreach ($mismatch[1] as $missoft) {
echo "\tRecommended by: ".trim($missoft)."\n";
}
}
示例输出
ecryptfs-utils:
Recommended by: adduser
firefox:
Recommended by: xubuntu-desktop
Recommended by: xul-ext-ubufox
firefox-gnome-support:
Recommended by: xubuntu-desktop
libatm1:
Recommended by: iproute
答案4
获取缺少推荐包的已安装包列表:
aptitude search '?installed?broken-recommends'
获取已安装软件包推荐的未安装、缺失软件包列表 - “缺失推荐”:
aptitude search '?broken-reverse-recommends(?installed)'
获取哪个包正在推荐特定的“缺失推荐”:
aptitude search '?installed?broken-recommends(MISSING_PKG_NAME)'
一句话:对于所有“缺少的推荐”,获取推荐的软件包:
for p in $(aptitude search -F%p '?broken-reverse-recommends(?installed)'); do echo $p; aptitude search "?installed?broken-recommends($p)"; done
您可以在 Synaptic 软件包管理器中找到“缺少的推荐”。 (据我所知,Synaptic 还显示缺少的建议软件包。)
您可以使用一个命令安装所有“缺少的推荐”,但我不推荐这样做!首先,在安装之前查看软件包列表。(例如,新安装的 debian buster 显示缺少“default-mta”,这是一个虚拟软件包。)
apt install $(aptitude search -F%p '?broken-reverse-recommends(?installed)')
(这是从几个类似的问题和答案中总结出来的。希望它能对其他人有所帮助。)