added template for bash scripts; added dependency-graph.sh to get project dependencies
This commit is contained in:
		@@ -138,6 +138,8 @@ GENERATED FILES
 | 
				
			|||||||
    * build-resource-file.sh - build resource.qrc file from a resource directory
 | 
					    * build-resource-file.sh - build resource.qrc file from a resource directory
 | 
				
			||||||
    * sql-to-dot.sed - script to convert SQL schema files to graphviz dot in doxygen
 | 
					    * sql-to-dot.sed - script to convert SQL schema files to graphviz dot in doxygen
 | 
				
			||||||
    * mac-create-app-bundle.sh - script to create apple mac os-x app-bundle
 | 
					    * mac-create-app-bundle.sh - script to create apple mac os-x app-bundle
 | 
				
			||||||
 | 
					    * dependency-graph.sh - script to draw project dependencies
 | 
				
			||||||
 | 
					    * template.sh - generic template for bash scripts
 | 
				
			||||||
    * test/runtests.sh - template file to run test scripts, i.e. docker based
 | 
					    * test/runtests.sh - template file to run test scripts, i.e. docker based
 | 
				
			||||||
    * AUTHORS - replace your name in AUTHORS before first run
 | 
					    * AUTHORS - replace your name in AUTHORS before first run
 | 
				
			||||||
    * NEWS - empty file add your project's news
 | 
					    * NEWS - empty file add your project's news
 | 
				
			||||||
@@ -549,6 +551,8 @@ copy rpmsign.exp
 | 
				
			|||||||
copy build-resource-file.sh
 | 
					copy build-resource-file.sh
 | 
				
			||||||
copy sql-to-dot.sed
 | 
					copy sql-to-dot.sed
 | 
				
			||||||
copy mac-create-app-bundle.sh
 | 
					copy mac-create-app-bundle.sh
 | 
				
			||||||
 | 
					copy dependency-graph.sh
 | 
				
			||||||
 | 
					copy template.sh
 | 
				
			||||||
AUTHOR=$(gpg -K 2>/dev/null | sed -n 's,uid *\(\[ultimate\] *\)\?,,p' | head -1)
 | 
					AUTHOR=$(gpg -K 2>/dev/null | sed -n 's,uid *\(\[ultimate\] *\)\?,,p' | head -1)
 | 
				
			||||||
if test -z "${AUTHOR}"; then
 | 
					if test -z "${AUTHOR}"; then
 | 
				
			||||||
    AUTHOR="FIRSTNAME LASTNAME (URL) <EMAIL>"
 | 
					    AUTHOR="FIRSTNAME LASTNAME (URL) <EMAIL>"
 | 
				
			||||||
@@ -1785,6 +1789,7 @@ dist_pkgdata_DATA = @PACKAGE_ICON@ ax_check_qt.m4 bootstrap.sh		\\
 | 
				
			|||||||
                    build-resource-file.sh				\\
 | 
					                    build-resource-file.sh				\\
 | 
				
			||||||
                    ax_init_standard_project.m4				\\
 | 
					                    ax_init_standard_project.m4				\\
 | 
				
			||||||
                    mac-create-app-bundle.sh resolve-debbuilddeps.sh    \\
 | 
					                    mac-create-app-bundle.sh resolve-debbuilddeps.sh    \\
 | 
				
			||||||
 | 
					                    dependency-graph.sh template.sh                     \\
 | 
				
			||||||
                    sql-to-dot.sed
 | 
					                    sql-to-dot.sed
 | 
				
			||||||
dist_doc_DATA = AUTHORS NEWS README COPYING INSTALL ChangeLog
 | 
					dist_doc_DATA = AUTHORS NEWS README COPYING INSTALL ChangeLog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										153
									
								
								scripts/dependency-graph.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										153
									
								
								scripts/dependency-graph.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,153 @@
 | 
				
			|||||||
 | 
					#!/bin/bash -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# template for bash scripts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# internal use only
 | 
				
			||||||
 | 
					append_msg() {
 | 
				
			||||||
 | 
					    if test $# -ne 0; then
 | 
				
			||||||
 | 
					        echo -en ":\e[0m \e[1m$*"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    echo -e "\e[0m"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# write a notice
 | 
				
			||||||
 | 
					notice() {
 | 
				
			||||||
 | 
					    if test $# -eq 0; then
 | 
				
			||||||
 | 
					        return
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    echo -e "\e[1m$*\e[0m" 1>&3
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# write error message
 | 
				
			||||||
 | 
					error() {
 | 
				
			||||||
 | 
					    echo -en "\e[1;31merror" 1>&2
 | 
				
			||||||
 | 
					    append_msg $* 1>&2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# write a warning message
 | 
				
			||||||
 | 
					warning() {
 | 
				
			||||||
 | 
					    echo -en "\e[1;33mwarning" 1>&2
 | 
				
			||||||
 | 
					    append_msg $* 1>&2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# write a success message
 | 
				
			||||||
 | 
					success() {
 | 
				
			||||||
 | 
					    echo -en "\e[1;32msuccess" 1>&2
 | 
				
			||||||
 | 
					    append_msg $* 1>&2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# commandline parameter evaluation
 | 
				
			||||||
 | 
					files=${0%/*}/configure.ac
 | 
				
			||||||
 | 
					while test $# -gt 0; do
 | 
				
			||||||
 | 
					    case "$1" in
 | 
				
			||||||
 | 
					        (--help|-h) less <<EOF
 | 
				
			||||||
 | 
					SYNOPSIS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  $0 [OPTIONS] <files>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OPTIONS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  --help, -h                 show this help
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <files>                    list of zero or more configure.ac files
 | 
				
			||||||
 | 
					                             (default: ${files})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DESCRIPTION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Evaluates dependencies of all the given configure.ac file. By
 | 
				
			||||||
 | 
					  default takes the local configure.ac. Outputs a graphwiz dot file
 | 
				
			||||||
 | 
					  with the dependencies. Solid lines are required dependencies, dotted
 | 
				
			||||||
 | 
					  lines are optional dependencies.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EXAMPLE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Evaluate all dependencies between all local subversion and git
 | 
				
			||||||
 | 
					  projects, if they are in the path ~/svn and ~/git:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $0 ~/svn/*/configure.ac ~/git/*/configure.ac 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					            exit;;
 | 
				
			||||||
 | 
					        (*) files=$*; break;;
 | 
				
			||||||
 | 
					    esac
 | 
				
			||||||
 | 
					    if test $# -eq 0; then
 | 
				
			||||||
 | 
					        error "missing parameter, try $0 --help"; exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    shift;
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# run a command, print the result and abort in case of error
 | 
				
			||||||
 | 
					# option: --no-check: ignore the result, continue in case of error
 | 
				
			||||||
 | 
					run() {
 | 
				
			||||||
 | 
					    check=1
 | 
				
			||||||
 | 
					    while test $# -gt 0; do
 | 
				
			||||||
 | 
					        case "$1" in
 | 
				
			||||||
 | 
					            (--no-check) check=0;;
 | 
				
			||||||
 | 
					            (*) break;;
 | 
				
			||||||
 | 
					        esac
 | 
				
			||||||
 | 
					        shift;
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					    echo -en "\e[1m-> running:\e[0m $* ..."
 | 
				
			||||||
 | 
					    result=$($* 2>&1)
 | 
				
			||||||
 | 
					    res=$?
 | 
				
			||||||
 | 
					    if test $res -ne 0; then
 | 
				
			||||||
 | 
					        if test $check -eq 1; then
 | 
				
			||||||
 | 
					            error "failed with return code: $res"
 | 
				
			||||||
 | 
					            if test -n "$result"; then
 | 
				
			||||||
 | 
					                echo "$result"
 | 
				
			||||||
 | 
					            fi
 | 
				
			||||||
 | 
					            exit 1
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            warning "ignored return code: $res"
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        success
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# error handler
 | 
				
			||||||
 | 
					function traperror() {
 | 
				
			||||||
 | 
					    set +x
 | 
				
			||||||
 | 
					    local err=($1) # error status
 | 
				
			||||||
 | 
					    local line="$2" # LINENO
 | 
				
			||||||
 | 
					    local linecallfunc="$3"
 | 
				
			||||||
 | 
					    local command="$4"
 | 
				
			||||||
 | 
					    local funcstack="$5"
 | 
				
			||||||
 | 
					    for e in ${err[@]}; do
 | 
				
			||||||
 | 
					        if test -n "$e" -a "$e" != "0"; then
 | 
				
			||||||
 | 
					            error "line $line - command '$command' exited with status: $e (${err[@]})"
 | 
				
			||||||
 | 
					            if [ "${funcstack}" != "main" -o "$linecallfunc" != "0" ]; then
 | 
				
			||||||
 | 
					                echo -n "   ... error at ${funcstack} "
 | 
				
			||||||
 | 
					                if [ "$linecallfunc" != "" ]; then
 | 
				
			||||||
 | 
					                    echo -n "called at line $linecallfunc"
 | 
				
			||||||
 | 
					                fi
 | 
				
			||||||
 | 
					                echo
 | 
				
			||||||
 | 
					            fi
 | 
				
			||||||
 | 
					            exit $e
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					    success
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# catch errors
 | 
				
			||||||
 | 
					trap 'traperror "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' ERR SIGINT INT TERM EXIT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					##########################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "digraph G {"
 | 
				
			||||||
 | 
					for file in $files; do
 | 
				
			||||||
 | 
					    if ! test -e $file; then
 | 
				
			||||||
 | 
					        error "file $file not found"; exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    sed -n '
 | 
				
			||||||
 | 
					      /^ *m4_define(x_package_name, */ {s///;s/ *).*//;h;s/.*/& [shape=doublecircle];/p}
 | 
				
			||||||
 | 
					      /^ *AX_REQUIRE_QT/ {s/.*/qt -> /;G;s/\n//;s/.*/&;/p}
 | 
				
			||||||
 | 
					      /^ *AX_PKG_REQUIRE(\[\?\([^],]\+\)\]\?, \[\?\([^],]\+\)\]\?.*/ {s//\2 -> /;G;s/\n//;s/.*/&;/p}
 | 
				
			||||||
 | 
					      /^ *AX_PKG_REQUIRE(\[\?\([^],]\+\)\]\?.*/ {s//\1 -> /;G;s/\n//;s/.*/&;/p}
 | 
				
			||||||
 | 
					      /^ *AX_CHECK_QT/ {s/.*/qt -> /;G;s/\n//;s/.*/& [style=dotted];/p}
 | 
				
			||||||
 | 
					      /^ *AX_PKG_CHECK(\[\?\([^],]\+\)\]\?, \[\?\([^],]\+\)\]\?.*/ {s//\2 -> /;G;s/\n//;s/.*/& [style=dotted];/p}
 | 
				
			||||||
 | 
					      /^ *AX_PKG_CHECK(\[\?\([^],]\+\)\]\?.*/ {s//\1 -> /;G;s/\n//;s/.*/& [style=dotted];/p}
 | 
				
			||||||
 | 
					    ' $file
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					echo "}"
 | 
				
			||||||
							
								
								
									
										121
									
								
								scripts/template.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										121
									
								
								scripts/template.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,121 @@
 | 
				
			|||||||
 | 
					#!/bin/bash -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# template for bash scripts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# internal use only
 | 
				
			||||||
 | 
					append_msg() {
 | 
				
			||||||
 | 
					    if test $# -ne 0; then
 | 
				
			||||||
 | 
					        echo -en ":\e[0m \e[1m$*"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    echo -e "\e[0m"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# write a notice
 | 
				
			||||||
 | 
					notice() {
 | 
				
			||||||
 | 
					    if test $# -eq 0; then
 | 
				
			||||||
 | 
					        return
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    echo -e "\e[1m$*\e[0m" 1>&3
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# write error message
 | 
				
			||||||
 | 
					error() {
 | 
				
			||||||
 | 
					    echo -en "\e[1;31merror" 1>&2
 | 
				
			||||||
 | 
					    append_msg $* 1>&2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# write a warning message
 | 
				
			||||||
 | 
					warning() {
 | 
				
			||||||
 | 
					    echo -en "\e[1;33mwarning" 1>&2
 | 
				
			||||||
 | 
					    append_msg $* 1>&2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# write a success message
 | 
				
			||||||
 | 
					success() {
 | 
				
			||||||
 | 
					    echo -en "\e[1;32msuccess" 1>&2
 | 
				
			||||||
 | 
					    append_msg $* 1>&2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# commandline parameter evaluation
 | 
				
			||||||
 | 
					while test $# -gt 0; do
 | 
				
			||||||
 | 
					    case "$1" in
 | 
				
			||||||
 | 
					        (--help|-h) less <<EOF
 | 
				
			||||||
 | 
					SYNOPSIS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  $0 [OPTIONS]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OPTIONS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  --help, -h                 show this help
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DESCRIPTION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					            exit;;
 | 
				
			||||||
 | 
					        (*) error "unknow option $1, try $0 --help"; exit 1;;
 | 
				
			||||||
 | 
					    esac
 | 
				
			||||||
 | 
					    if test $# -eq 0; then
 | 
				
			||||||
 | 
					        error "missing parameter, try $0 --help"; exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    shift;
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# run a command, print the result and abort in case of error
 | 
				
			||||||
 | 
					# option: --no-check: ignore the result, continue in case of error
 | 
				
			||||||
 | 
					run() {
 | 
				
			||||||
 | 
					    check=1
 | 
				
			||||||
 | 
					    while test $# -gt 0; do
 | 
				
			||||||
 | 
					        case "$1" in
 | 
				
			||||||
 | 
					            (--no-check) check=0;;
 | 
				
			||||||
 | 
					            (*) break;;
 | 
				
			||||||
 | 
					        esac
 | 
				
			||||||
 | 
					        shift;
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					    echo -en "\e[1m-> running:\e[0m $* ..."
 | 
				
			||||||
 | 
					    result=$($* 2>&1)
 | 
				
			||||||
 | 
					    res=$?
 | 
				
			||||||
 | 
					    if test $res -ne 0; then
 | 
				
			||||||
 | 
					        if test $check -eq 1; then
 | 
				
			||||||
 | 
					            error "failed with return code: $res"
 | 
				
			||||||
 | 
					            if test -n "$result"; then
 | 
				
			||||||
 | 
					                echo "$result"
 | 
				
			||||||
 | 
					            fi
 | 
				
			||||||
 | 
					            exit 1
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            warning "ignored return code: $res"
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        success
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# error handler
 | 
				
			||||||
 | 
					function traperror() {
 | 
				
			||||||
 | 
					    set +x
 | 
				
			||||||
 | 
					    local err=($1) # error status
 | 
				
			||||||
 | 
					    local line="$2" # LINENO
 | 
				
			||||||
 | 
					    local linecallfunc="$3"
 | 
				
			||||||
 | 
					    local command="$4"
 | 
				
			||||||
 | 
					    local funcstack="$5"
 | 
				
			||||||
 | 
					    for e in ${err[@]}; do
 | 
				
			||||||
 | 
					        if test -n "$e" -a "$e" != "0"; then
 | 
				
			||||||
 | 
					            error "line $line - command '$command' exited with status: $e (${err[@]})"
 | 
				
			||||||
 | 
					            if [ "${funcstack}" != "main" -o "$linecallfunc" != "0" ]; then
 | 
				
			||||||
 | 
					                echo -n "   ... error at ${funcstack} "
 | 
				
			||||||
 | 
					                if [ "$linecallfunc" != "" ]; then
 | 
				
			||||||
 | 
					                    echo -n "called at line $linecallfunc"
 | 
				
			||||||
 | 
					                fi
 | 
				
			||||||
 | 
					                echo
 | 
				
			||||||
 | 
					            fi
 | 
				
			||||||
 | 
					            exit $e
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					    success
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# catch errors
 | 
				
			||||||
 | 
					trap 'traperror "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' ERR SIGINT INT TERM EXIT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					##########################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Reference in New Issue
	
	Block a user