summaryrefslogtreecommitdiffhomepage
path: root/standalone
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-05-05 14:27:39 -0400
committerJoey Hess <joeyh@joeyh.name>2017-05-05 14:30:46 -0400
commit2f5315b3c32fbd23ebce05da80712183dc259b7c (patch)
tree48de39738910859cb0eaaf15cbfe9529b44e4272 /standalone
parent4a2a01a7eaa8945d063468d7d1c24f095a3ae2a4 (diff)
downloaddebug-me-2f5315b3c32fbd23ebce05da80712183dc259b7c.tar.gz
standalone tarball
Adapted the standalone tarball building code from git-annex.
Diffstat (limited to 'standalone')
-rw-r--r--standalone/linux/skel/README6
-rwxr-xr-xstandalone/linux/skel/runshell80
2 files changed, 86 insertions, 0 deletions
diff --git a/standalone/linux/skel/README b/standalone/linux/skel/README
new file mode 100644
index 0000000..0126d8e
--- /dev/null
+++ b/standalone/linux/skel/README
@@ -0,0 +1,6 @@
+You can put this directory into your PATH, or symlink the programs in this
+directory to anyplace already in your PATH, and use debug-me the same
+as if you'd installed it using a package manager.
+
+This should work on any Linux system of the appropriate architecture.
+More or less.
diff --git a/standalone/linux/skel/runshell b/standalone/linux/skel/runshell
new file mode 100755
index 0000000..ca7dbe5
--- /dev/null
+++ b/standalone/linux/skel/runshell
@@ -0,0 +1,80 @@
+#!/bin/sh
+# Runs a shell command (or interactive shell) using the binaries and
+# libraries bundled with this app.
+
+set -e
+
+base="$(dirname "$0")"
+
+if [ ! -d "$base" ]; then
+ echo "** cannot find base directory (I seem to be $0)" >&2
+ exit 1
+fi
+
+if [ ! -e "$base/bin/debug-me" ]; then
+ echo "** base directory $base does not contain bin/debug-me" >&2
+ exit 1
+fi
+
+# Get absolute path to base, to avoid breakage when things change directories.
+orig="$(pwd)"
+cd "$base"
+base="$(pwd)"
+cd "$orig"
+
+# --library-path won't work if $base contains : or ;
+# Detect this problem, and work around it by using a temp directory.
+if echo "$base" | grep -q '[:;]'; then
+ tbase=$(mktemp -d -p /tmp debugmeshimXXXXXXXXX 2>/dev/null || true)
+ if [ -z "$tbase" ]; then
+ tbase="/tmp/debugmeshim.$$"
+ mkdir "$tbase"
+ fi
+ ln -s "$base" "$tbase/link"
+ base="$tbase/link"
+ cleanuptbase () {
+ rm -rf "$tbase"
+ }
+ trap cleanuptbase EXIT
+fi
+
+# Put our binaries first, to avoid issues with out of date or incompatible
+# system binaries. Extra binaries come after system path.
+ORIG_PATH="$PATH"
+export ORIG_PATH
+PATH="$base/bin:$PATH:$base/extra"
+export PATH
+
+# These env vars are used by the shim wrapper around each binary.
+for lib in $(cat "$base/libdirs"); do
+ DEBUG_ME_LD_LIBRARY_PATH="$base/$lib:$DEBUG_ME_LD_LIBRARY_PATH"
+done
+export DEBUG_ME_LD_LIBRARY_PATH
+DEBUG_ME_DIR="$base"
+export DEBUG_ME_DIR
+
+ORIG_GCONV_PATH="$GCONV_PATH"
+export ORIG_GCONV_PATH
+GCONV_PATH="$base/$(cat "$base/gconvdir")"
+export GCONV_PATH
+
+ORIG_MANPATH="$MANPATH"
+export ORIG_MANPATH
+MANPATH="$base/usr/share/man:$MANPATH"
+export MANPATH
+
+DEBUG_ME_EXE="$base/debug-me"
+export DEBUG_ME_EXE
+
+if [ "$1" ]; then
+ cmd="$1"
+ shift 1
+ if [ -z "$tbase" ]; then
+ exec "$cmd" "$@"
+ else
+ # allow EXIT trap to cleanup
+ "$cmd" "$@"
+ fi
+else
+ sh
+fi