diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-10-22 20:40:50 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-10-22 20:40:50 +0200 |
commit | 34e60841a44ee688792e87863aa67db469d39fa8 (patch) | |
tree | d4ec57728121d87b029d8b729c98494356015061 /lib | |
parent | 4452df33f080c314f9b4c6a6504f254edc500282 (diff) | |
download | appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.gz appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.bz2 appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.xz appstore-34e60841a44ee688792e87863aa67db469d39fa8.zip |
wip
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/common | 64 | ||||
-rw-r--r-- | lib/header | 8 | ||||
-rw-r--r-- | lib/header-hook | 8 |
3 files changed, 80 insertions, 0 deletions
diff --git a/lib/common b/lib/common new file mode 100755 index 0000000..473c8b1 --- /dev/null +++ b/lib/common @@ -0,0 +1,64 @@ +#!/bin/bash + +# Sanity check to make sure that app.sh is installed +APPSH_HOME="`cd $APPSTORE_HOME/../app.sh; pwd`" + +if [ ! -d "$APPSH_HOME" ] +then + echo "app.sh has to be installed at $APPSH_HOME" + exit 1 +fi + +PATH=$APPSH_HOME:$PATH + +show_help() { + message=${1-} + + if [[ $message != "" ]] + then + echo $message + fi + + if [ "`declare -f usage_text >/dev/null; echo $?`" = 0 ] + then + usage_text + else + echo "The command $usage_app does not have any usage info." + fi + exit 1 +} + +usage() { + message=${1-} + + if [[ $message != "" ]] + then + echo $message >&2 + fi + + if [ "`declare -f usage_text >/dev/null; echo $?`" = 0 ] + then + usage_text >&2 + fi + exit 1 +} + +debug() { + [[ $echo_debug == no ]] || echo "D: $usage_app: $@" 2>&1 +} + +info() { + echo "I: $usage_app: $@" 2>&1 +} + +fatal() { + echo "$usage_app: fatal: $@" 2>&1 + exit 1 +} + +grep_path() { + local regex="$1"; shift + local path="$1"; shift + + find `echo $path | tr : " "` -type f -executable 2>/dev/null | (egrep "$regex" || exit 0) +} diff --git a/lib/header b/lib/header new file mode 100644 index 0000000..ccd343e --- /dev/null +++ b/lib/header @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e +set -u + +APPSTORE_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSTORE_HOME/lib/common diff --git a/lib/header-hook b/lib/header-hook new file mode 100644 index 0000000..ccd343e --- /dev/null +++ b/lib/header-hook @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e +set -u + +APPSTORE_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSTORE_HOME/lib/common |