summaryrefslogtreecommitdiffstats
path: root/contrib/pactree
diff options
context:
space:
mode:
authorChristophe Chapuis <chris.chapuis@gmail.com>2010-04-20 08:21:00 +0200
committerDan McGee <dan@archlinux.org>2010-04-27 01:49:11 +0200
commit753599b5046392477449ed550cd99c41631145ed (patch)
tree2f0b9d5aeefc9fe3e72dc76aded26386cb5fb3a0 /contrib/pactree
parent652762488a1fbe70b073588dc5f88412ff952fb7 (diff)
downloadpacman-753599b5046392477449ed550cd99c41631145ed.tar.gz
pacman-753599b5046392477449ed550cd99c41631145ed.tar.xz
contrib/pactree: generate reverse dependency trees
Add an option to show the tree of packages which depend on a given package Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'contrib/pactree')
-rwxr-xr-xcontrib/pactree31
1 files changed, 26 insertions, 5 deletions
diff --git a/contrib/pactree b/contrib/pactree
index df536717..73bece3a 100755
--- a/contrib/pactree
+++ b/contrib/pactree
@@ -41,7 +41,7 @@ arrow1_color="chocolate4" #color of the normal arrow
arrow2_color="grey" #color of the "provided by" headless arrow
readonly prog_name="pactree"
-readonly prog_ver="0.2"
+readonly prog_ver="0.3"
_usage(){
echo "This program generates the dependency tree of an installed package"
@@ -52,13 +52,14 @@ _usage(){
echo " -d, --depth INT Limit the shown dependencies depth"
echo " -g, --graph Use graphviz to make an image of the tree"
echo " -l, --linear Enable linear output"
+ echo " -r, --reversed Show reversed dependancies"
echo " -s, --silent Shh, let me hear those errors!"
echo " -u, --unique Print the dependency list with no duplicates"
echo
echo " -h, --help Print this help message"
echo " -v, --version Print the program name and version"
echo
- echo "Example: $prog_name -c -d 2 readline"
+ echo "Example: $prog_name -c -d2 readline"
}
_version(){
@@ -140,7 +141,16 @@ _tree(){
if [[ ! " ${dep_list[@]} " =~ " $pkg_name " ]] && [ $spaces -ne $max_depth ]; then
dep_list=( "${dep_list[@]}" "$pkg_name" )
- for dep_pkg in $(_grabfield "$pkg_dir/depends" %DEPENDS%); do
+ if [ $reversed_dep -eq 0 ]; then
+ deps_pkg="$(_grabfield "$pkg_dir/depends" %DEPENDS%)"
+ else
+ reqs_pkg_dir="$(_finddep "$pkg_name" %DEPENDS% depends)"
+ unset deps_pkg
+ for req_pkg_dir in $reqs_pkg_dir; do
+ deps_pkg=$(echo "$deps_pkg" "$(_grabfield "$req_pkg_dir/desc" %NAME%)")
+ done
+ fi
+ for dep_pkg in $deps_pkg; do
spaces=$2 #Bash scoping ;_;
if [ $graphviz -eq 1 ]; then
echo "\"$1\" -> \"${dep_pkg%%[<>=]*}\" [color=$arrow1_color];"
@@ -208,6 +218,12 @@ for (( n=0 ; n < $len_options ; n++ )); do
continue
fi
+ if [ "${options[$n]}" = "-r" -o "${options[$n]}" = "--reversed" ]; then
+ unset options[$n]
+ reversed_dep=1
+ continue
+ fi
+
if [[ "${options[$n]}" =~ -d[[:digit:]]+ || "${options[$n]}" == "--depth" ]]; then
if [[ "${options[$n]#-d}" =~ [[:digit:]]+ ]]; then
max_depth="${options[$n]#-d}"
@@ -229,6 +245,7 @@ linear=${linear:-0}
silent=${silent:-0}
nodup=${nodup:-0}
graphviz=${graphviz:-0}
+reversed_dep=${reversed_dep:-0}
if [ $colored -ne 1 ]; then
unset branch1_color
@@ -292,8 +309,12 @@ if [ $graphviz -eq 1 ]; then
root_pkgs="${options[@]}"
# Uncomment for the "generated by pactree" node in graphviz
#advert="xyz [height=0.07, fontsize=8.0, label=\"GENERATED WITH PACTREE\",shape=box,color="black",style=filled,fontcolor="white"];\n"
-
- echo -e "digraph G { START [color=$start_color, style=filled];\n node [style=filled, color=$nodes_color];\n$(_main)\n$advert}" | dot -T$gformat -o "${root_pkgs// /_}.deps.$gformat"
+ if [ $reversed_dep -eq 0 ]; then
+ file_extension="deps.$gformat"
+ else
+ file_extension="reqs.$gformat"
+ fi
+ echo -e "digraph G { START [color=$start_color, style=filled];\n node [style=filled, color=$nodes_color];\n$(_main)\n$advert}" | dot -T$gformat -o "${root_pkgs// /_}.$file_extension"
else _main
fi