summaryrefslogtreecommitdiff
path: root/appstore
diff options
context:
space:
mode:
Diffstat (limited to 'appstore')
-rwxr-xr-xappstore58
1 files changed, 58 insertions, 0 deletions
diff --git a/appstore b/appstore
new file mode 100755
index 0000000..eee4774
--- /dev/null
+++ b/appstore
@@ -0,0 +1,58 @@
+#!/bin/bash -e
+
+PRG="$0"
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+done
+
+APPSTORE_HOME=`dirname "$PRG"`
+APPSTORE_HOME=`cd "$APPSTORE_HOME" && pwd`
+
+. $APPSTORE_HOME/lib/common
+
+usage_text() {
+ echo "usage: $usage_app <command>"
+ echo ""
+ echo "Available porcelain commands:"
+ grep_path "/appstore-.*$" "$APPSTORE_HOME/bin" | \
+ sed "s,^.*/appstore-, ," | \
+ sort -n
+ echo ""
+ echo "Available plumbing commands:"
+ grep_path "/appstore-.*$" "$APPSTORE_HOME/libexec" | \
+ sed "s,^.*/appstore-, ," | \
+ sort -n
+}
+
+if [ $# -eq 0 ]
+then
+ usage
+fi
+
+command=$1; shift
+
+bin=`grep_path "/appstore-$command$" "$APPSTORE_HOME/bin"`
+
+if [ ! -x "$bin" ]
+then
+ bin=`grep_path "/appstore-$command$" "$APPSTORE_HOME/libexec"`
+ if [ ! -x "$bin" ]
+ then
+ echo "Unknown command: $command" 2>&1
+ exit 1
+ fi
+fi
+
+PATH=$APPSTORE_HOME/bin:$PATH
+
+# TODO: this is probably a good place to clean up the environment
+exec env \
+ "APPSTORE_HOME=$APPSTORE_HOME" \
+ "echo_debug=$echo_debug" \
+ "$bin" "$@"