#!/bin/sh -e # TODO: extract self without resolving to $0 because it doesn't resolve links if [ -z "$XDG_CACHE_HOME" ]; then destdir=/tmp/tarinstall else destdir="$XDG_CACHE_HOME"/tarinstall fi if ! [ -d "$destdir" ]; then mkdir -p "$destdir" fi if ! [ "$(head -n 1 "$destdir"/ID/checksum 2>/dev/null)" = 'SUM' ]; then rm -rf "$destdir"/ID tail -c +BYTES "$0" | lz4 -dc | tar -x -C "$destdir" echo "SUM" > "$destdir"/ID/checksum fi binname="$(basename "$0")" if echo "$binname" | grep -q \.tin$; then binname="$(echo "$binname" | sed s/\.tin//)" fi ORIGIN="$destdir"/ID LD_LIBRARY_PATH="$ORIGIN/lib" PATH="$ORIGIN/bin":$PATH export ORIGIN export LD_LIBRARY_PATH export PATH # export LD_DEBUG='libs' exec "$destdir"/ID/bin/"$binname" "$@"