updated on Tue Jan 17 12:00:36 UTC 2012
[aur-mirror.git] / pactools / pt-deptree
blobedb6f538bec5c888b57261969f34f62539b3e337
1 #!/bin/sh
2 # Pacman Dependency Tree
3 # does NOT handle group names -> unexpected results.
4 # Package names using aliases, like x-server, should work.
5 # Breaks on circular dependencies -> you better hit ctrl-c.
7 export LC_ALL=en_US
9 progname=`basename $0`
10 pacexec='pacman'
11 leafnull='None'
12 branch=""
13 vbranch="| "
14 vprune=" "
15 hbranch="+---"
17 _showdep () {
19 # Try to use specific pkg req
20 if $pacexec -Qi $1 &> /dev/null ; then
21 # Grab deps list|from "Depends"|Remove Tag \| specific version req's.
22 deplist=`$pacexec -Qi $1|grep Depends|sed 's/^.*: \|>[^ ]*//g;s/ $//'`
23 else # Oops! Failed on alias, try this...
24 deplist=`$pacexec -Qs $1 | sed '1!d;s/\(^.*\/\)\(.*\)\( .*$\)/\2/'`
27 [ "x$deplist" = "x$leafnull" ] && return
29 while [ -n "$deplist" ]
31 set -- $deplist && echo "$branch$hbranch$1"
32 if [ $# -gt 1 ] ; then
33 branch=${branch}$vbranch
34 else
35 branch=${branch}$vprune
38 _showdep $1
40 deplist=${*:2}
41 branch=${branch:0:${#branch}-${#vprune}}
42 done
45 branch=$vprune
47 for pkg in `$pacexec -Q $1 | sed 's/ .*//'`
49 echo $pkg
50 _showdep $pkg
51 done
53 unset _showdep && set --
54 exit 0