diff options
author | Nicolás Reynolds <fauno@endefensadelsl.org> | 2014-02-18 01:56:34 +0000 |
---|---|---|
committer | Nicolás Reynolds <fauno@endefensadelsl.org> | 2014-02-18 01:56:34 +0000 |
commit | 8185891e28635bdb83fdf4ba4391030912dae596 (patch) | |
tree | 66a946535bdd228514750233b2cc99dd1866ff64 /pcr/pactools/pt-deptree | |
parent | 60a11f87366fdfbd114cdc91ff813518858e5f8d (diff) |
Tue Feb 18 01:56:27 UTC 2014
Diffstat (limited to 'pcr/pactools/pt-deptree')
-rw-r--r-- | pcr/pactools/pt-deptree | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/pcr/pactools/pt-deptree b/pcr/pactools/pt-deptree new file mode 100644 index 000000000..edb6f538b --- /dev/null +++ b/pcr/pactools/pt-deptree @@ -0,0 +1,54 @@ +#!/bin/sh +# Pacman Dependency Tree +# does NOT handle group names -> unexpected results. +# Package names using aliases, like x-server, should work. +# Breaks on circular dependencies -> you better hit ctrl-c. + +export LC_ALL=en_US + +progname=`basename $0` +pacexec='pacman' +leafnull='None' +branch="" +vbranch="| " +vprune=" " +hbranch="+---" + +_showdep () { + + # Try to use specific pkg req + if $pacexec -Qi $1 &> /dev/null ; then + # Grab deps list|from "Depends"|Remove Tag \| specific version req's. + deplist=`$pacexec -Qi $1|grep Depends|sed 's/^.*: \|>[^ ]*//g;s/ $//'` + else # Oops! Failed on alias, try this... + deplist=`$pacexec -Qs $1 | sed '1!d;s/\(^.*\/\)\(.*\)\( .*$\)/\2/'` + fi + + [ "x$deplist" = "x$leafnull" ] && return + + while [ -n "$deplist" ] + do + set -- $deplist && echo "$branch$hbranch$1" + if [ $# -gt 1 ] ; then + branch=${branch}$vbranch + else + branch=${branch}$vprune + fi + + _showdep $1 + + deplist=${*:2} + branch=${branch:0:${#branch}-${#vprune}} + done +} + +branch=$vprune + +for pkg in `$pacexec -Q $1 | sed 's/ .*//'` +do + echo $pkg + _showdep $pkg +done + +unset _showdep && set -- +exit 0 |