On Wed, Apr 14, 2010 at 12:59 PM, Christophe Chapuis < chris.chapuis@gmail.com> wrote:
On Wed, Apr 14, 2010 at 12:28 PM, Allan McRae <allan@archlinux.org> wrote:
On 14/04/10 19:23, Christophe Chapuis wrote:
Here it comes (output of a simple diff command):
Any chance of a git patch, or at least a unified diff?
Allan
Sure, but you'll have to wait some hours, I'm not at home right now.
Sorry for the delay, here is a unified diff: ------------------------snip------------------- --- /usr/bin/pactree 2009-11-20 06:12:20.000000000 +0100 +++ pactree 2010-04-11 17:44:41.000000000 +0200 @@ -41,7 +41,7 @@ arrow2_color="grey" #color of the "provided by" headless arrow readonly prog_name="pactree" -readonly prog_ver="0.2" +readonly prog_ver="0.2.1" _usage(){ echo "This program generates the dependency tree of an installed package" @@ -54,11 +54,12 @@ echo " -l, --linear Enable linear output" echo " -s, --silent Shh, let me hear those errors!" echo " -u, --unique Print the dependency list with no duplicates" + echo " -r, --reversed Show reversed dependancies" 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 @@ 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 1 ]; then + 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 + else + deps_pkg="$(_grabfield "$pkg_dir/depends" %DEPENDS%)" + 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 @@ 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 @@ silent=${silent:-0} nodup=${nodup:-0} graphviz=${graphviz:-0} +reversed_dep=${reversed_dep:-0} if [ $colored -ne 1 ]; then unset branch1_color @@ -293,7 +310,13 @@ # 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 1 ]; then + file_extension="reqs.$gformat" + else + file_extension="deps.$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