例如,我想找出为什么monodevelop
依赖于systemd
.
apt-rdepends -r systemd
显示所有直接或间接依赖于 systemd 的包:
$ apt-rdepends --dotty -r systemd | grep monodevelop
"monodevelop" -> "libgnome2.24-cil";
...
debtree monodevelop
显示monodevelop
直接或间接依赖的所有包:
$ debtree monodevelop | grep -- '-> "systemd"'
"libpam-systemd" -> "systemd" [color=blue,label="(= 215-6)"];
...
但是我如何轻松地显示从monodevelop
到 的链systemd
?
其中一条链的示例:
monodevelop -> libgnome2.24-cil -> libgnome2-0 -> gvfs -> gvfs-daemons -> udisks2 -> libpam-systemd -> systemd
答案1
为此开发了一个oneliner:
$ apt-rdepends --dot -r systemd | perl -ne 'our %chains; if(m!"([^"]+)" -> "([^"]+)"[^"]*;!) { my $c="$2 $chains{$2}"; $chains{$1}=$c; print "$1 $c\n" }' | grep '^monodevelop '
Reading package lists... Done
Building dependency tree
Reading state information... Done
monodevelop libgnome2.24-cil libgnomeui-0 libbonoboui2-0 libgnome2-0 gvfs gvfs-daemons udisks2 libpam-systemd systemd
答案2
awk
相当于你的perl
一句:
apt-rdepends -dr systemd |
awk -F\" '/->/{print $2,c[$2]=$4" "c[$4]}' |
grep '^monodevelop'