Dependencies
如何顯示從一個包到另一個包的依賴鏈?
例如,我想找出為什麼
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
monodevelop
tosystemd
?其中一個鏈的範例:
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'