Dependencies

如何顯示從一個包到另一個包的依賴鏈?

  • November 21, 2014

例如,我想找出為什麼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)"];
...

但是我如何輕鬆地顯示鏈 from monodevelopto systemd

其中一個鏈的範例:

monodevelop -> libgnome2.24-cil -> libgnome2-0 -> gvfs -> gvfs-daemons ->  udisks2 -> libpam-systemd -> systemd

為此開發了一個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 

awk相當於你perl的單線:

apt-rdepends -dr systemd |
 awk -F\" '/->/{print $2,c[$2]=$4" "c[$4]}' |
 grep '^monodevelop'

引用自:https://unix.stackexchange.com/questions/169031