From bb15b3f34a9e70360972b3c58beaed5e34e45f1b Mon Sep 17 00:00:00 2001 From: Andrew Lorimer Date: Sun, 15 Jul 2018 21:28:25 +1000 Subject: [PATCH 1/1] add pacdep.sh --- pacdep.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 pacdep.sh diff --git a/pacdep.sh b/pacdep.sh new file mode 100755 index 0000000..df6466e --- /dev/null +++ b/pacdep.sh @@ -0,0 +1,52 @@ +#!/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. + +progname=`basename $0` +pacexec=`which 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 -- 2.43.2