df6466ee0f8db071366798113feb06f5c3b3b2db
   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.
   6
   7progname=`basename $0`
   8pacexec=`which pacman`
   9leafnull='None'
  10branch=""
  11vbranch="|   "
  12vprune="    "
  13hbranch="+---"
  14
  15_showdep () {
  16
  17    # Try to use specific pkg req
  18    if $pacexec -Qi $1 &> /dev/null ; then
  19         # Grab deps list|from "Depends"|Remove Tag | specific version req's.
  20        deplist=`$pacexec -Qi $1|grep Depends|sed 's/^.*: |>[^ ]*//g;s/ $//'`
  21    else # Oops! Failed on alias, try this...
  22        deplist=`$pacexec -Qs $1 | sed '1!d;s/(^.*/)(.*)( .*$)/2/'`
  23    fi
  24
  25    [ "x$deplist" = "x$leafnull" ] && return
  26
  27    while [ -n "$deplist" ]
  28    do
  29        set -- $deplist && echo "$branch$hbranch$1"
  30        if [ $# -gt 1 ] ; then
  31            branch=${branch}$vbranch
  32        else
  33            branch=${branch}$vprune
  34        fi
  35
  36        _showdep $1
  37
  38        deplist=${*:2}
  39        branch=${branch:0:${#branch}-${#vprune}}
  40    done
  41}
  42
  43branch=$vprune
  44
  45for pkg in `$pacexec -Q $1 | sed 's/ .*//'`
  46do
  47    echo $pkg
  48    _showdep $pkg
  49done
  50
  51unset _showdep && set --
  52exit 0