Compare commits
2 Commits
7fc4f775ac
...
bcb18dc478
Author | SHA1 | Date | |
---|---|---|---|
bcb18dc478 | |||
dd4a26da22 |
@ -143,7 +143,10 @@ lz4 --rm -9 -c "$DIRNAME.tar" > "$DIRNAME".tar.lz4
|
||||
echo "Injecting payload..."
|
||||
sed s/SUM/"$(cat "$SUMFILE")"/ "$PAYLOAD_SCRIPT" |
|
||||
sed s/ID/"$(basename "$DIRNAME")"/ |
|
||||
awk '!/^ *#/ && NF' > tpp
|
||||
#awk '!/^ *#/ && NF' > tpp
|
||||
sed -e '1{/^#!/ {p}}; /^[\t\ ]*#/d;/\.*#.*/ {/[\x22\x27].*#.*[\x22\x27]/ !{:regular_loop s/\(.*\)*[^\]#.*/\1/;t regular_loop}; /[\x22\x27].*#.*[\x22\x27]/ {:special_loop s/\([\x22\x27].*#.*[^\x22\x27]\)#.*/\1/;t special_loop}; /\\#/ {:second_special_loop s/\(.*\\#.*[^\]\)#.*/\1/;t second_special_loop}}' |
|
||||
sed '/^$/d' > tpp
|
||||
|
||||
|
||||
size="$(wc -c tpp | cut -d " " -f1)"
|
||||
strsize="$(echo "BYTES" | wc -c)"
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh -e
|
||||
#!/bin/sh -ex
|
||||
|
||||
# TODO: extract self without resolving to $0 because it doesn't resolve links
|
||||
|
||||
@ -12,15 +12,53 @@ if ! [ -d "$destdir" ]; then
|
||||
mkdir -p "$destdir"
|
||||
fi
|
||||
|
||||
|
||||
# If the file does not contain the .tin extension it was either renamed or
|
||||
# linked somewhere, so if it was called as $ <exe> then try to find it in the
|
||||
# current directory else try to find it in path. When found evaluate if it is
|
||||
# a link, if it is traverse it and then set the archive variable
|
||||
# TODO: for each match check if the file si really a tarinstall with a header
|
||||
|
||||
archive="$0"
|
||||
if ! echo "$archive" | grep -q \.tin$; then
|
||||
if [ "$(dirname "$archive")" = '.' ]; then
|
||||
if [ -e "$archive" ]; then
|
||||
if [ -L "$archive" ]; then
|
||||
archive="$(readlink "$0")"
|
||||
fi
|
||||
else
|
||||
: > "$destdir"/paths
|
||||
( IFS=:
|
||||
for p in $PATH; do
|
||||
find -L "$p" -name "$archive" >> "$destdir"/paths
|
||||
done
|
||||
)
|
||||
while read -r l; do
|
||||
if [ -L "$l" ]; then
|
||||
archive="$(readlink "$l")"
|
||||
break
|
||||
elif [ -x "$l" ]; then
|
||||
archive="$l"
|
||||
break
|
||||
fi
|
||||
done < "$destdir"/paths
|
||||
fi
|
||||
fi
|
||||
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
|
||||
|
||||
if [ "$(find "$destdir"/ID/bin -maxdepth 1 -type f | wc -l)" = '1' ]; then
|
||||
binname="$(find "$destdir"/ID/bin -maxdepth 1 -type f)"
|
||||
else
|
||||
binname="$(basename "$0")"
|
||||
if echo "$binname" | grep -q \.tin$; then
|
||||
binname="$(echo "$binname" | sed s/\.tin//)"
|
||||
binname="$destdir"/ID/bin/"$(echo "$binname" | sed s/\.tin//)"
|
||||
fi
|
||||
fi
|
||||
|
||||
ORIGIN="$destdir"/ID
|
||||
@ -32,4 +70,4 @@ export PATH
|
||||
|
||||
# export LD_DEBUG='libs'
|
||||
|
||||
exec "$destdir"/ID/bin/"$binname" "$@"
|
||||
exec "$binname" "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user