[pacman-dev] [PATCH] added pactree

Carlo Bersani carlocci at gmail.com
Wed Jul 23 12:09:55 EDT 2008


I fixed the ugly comments layout as well as the awk long long line

---
 contrib/pactree |   51 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/contrib/pactree b/contrib/pactree
index c186595..96ca06a 100755
--- a/contrib/pactree
+++ b/contrib/pactree
@@ -44,9 +44,9 @@ arrow2_color="grey"           #color of the "provided by" 
headless arrow
 # Original http://carlocci.ngi.it/arch/pactree
 # Credit to scj for the graphviz idea
 
-#######################################################################
-# User friendly part                                                  #
-#######################################################################
+#
+# User friendly part
+#
 readonly prog_name="pactree"
 readonly prog_ver="0.2"
 
@@ -75,9 +75,9 @@ _version(){
 # end of the friendliness
 
 
-#######################################################################
-# grab a field from the database: $1=path/to/file, $2=field to grab   #
-#######################################################################
+#
+# grab a field from the database: $1=path/to/file, $2=field to grab
+#
 _grabfield(){
 	for line in $(cat "$1" 2>/dev/null ); do
 		if [ -z "$line" ]; then
@@ -94,19 +94,27 @@ _grabfield(){
 }
 
 
-#######################################################################
-# find a dep in the db: $1=dep, $2=field, $3=dbfile, ret=file list    #
-#######################################################################
+#
+# find a dep in the db: $1=dep, $2=field, $3=dbfile, ret=file list
+#
 _finddep(){
-	for line in $(awk 'BEGIN{RS=""} {if ($1=="'"$2"'") {for (i=2 ; i<=NF ; ++i){ 
if ($i ~ /^'"$1"'([<>=]+.*|)$/ ) {print FILENAME}}}}' $(find $pac_db -name 
$3)); do
+	for line in $(awk 'BEGIN{RS=""}
+	                   {
+	                   if ($1=="'"$2"'"){
+	                     for (i=2 ; i<=NF ; ++i){
+	                       if ($i ~ /^'"$1"'([<>=]+.*|)$/ ){
+	                         print FILENAME}
+	                       }
+	                     }
+	                   }' $(find $pac_db -name $3)); do
 		echo "${line%/*}"
 	done
 }
 
 
-#######################################################################
+#
 # Recursive function: does all of the work, pays all of the taxes     #
-#######################################################################
+#
 _tree(){
 	pkg_name="$1"
 	pkg_dirs="$(echo $pac_db/$pkg_name-[0-9]*)"
@@ -158,12 +166,11 @@ _tree(){
 }
 
 
-#######################################################################
-# Main program: gets all of the money, pays none of the taxes         #
-#######################################################################
+#
+# Main program: gets all of the money, pays none of the taxes
+#
 
-# Command line parameters parser --------------------------------------
-# ---------------------------------------------------------------------
+# Command line parameters parser
 if [ $# -eq 0 ]; then
 	_usage
 	exit 1
@@ -230,11 +237,10 @@ for (( n=0 ; n < $len_options ; n++ )); do
 		continue
 	fi
 done
-# End of the dumb command line parser ---------------------------------
+# End of the dumb command line parser
 
 
-# Env -----------------------------------------------------------------
-# ---------------------------------------------------------------------
+# Env
 colored=${colored:-0}
 max_depth=${max_depth:--10}
 linear=${linear:-0}
@@ -279,11 +285,10 @@ if [ ! -d "$pac_db" ] ; then
 	echo "ERROR: pacman database directory ${pac_db} not found"
 	exit 1
 fi
-# Env End -------------------------------------------------------------
+# Env End
 
-# Program starts ------------------------------------------------------
-# ---------------------------------------------------------------------
 
+# Program starts
 _main(){
 	for pkg_name in ${options[@]} ; do
 		[ $graphviz -eq 1 ] && echo -e "\"START\" -> \"$pkg_name\" ;"
-- 
1.5.6.4




More information about the pacman-dev mailing list