如何显示从一个包到另一个包的依赖关系链?

如何显示从一个包到另一个包的依赖关系链?

例如,我想找出为什么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'

相关内容