From 2f5315b3c32fbd23ebce05da80712183dc259b7c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 5 May 2017 14:27:39 -0400 Subject: standalone tarball Adapted the standalone tarball building code from git-annex. --- standalone/linux/skel/README | 6 ++++ standalone/linux/skel/runshell | 80 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 standalone/linux/skel/README create mode 100755 standalone/linux/skel/runshell (limited to 'standalone/linux/skel') 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 -- cgit v1.2.3