more improvements

- payload now extracts in the right location
- payload checks if the file is already extracted
- etc.
master
Alessandro Mauri 4 years ago
parent 35d955683e
commit 17ab178cdd
  1. 3
      .gitignore
  2. 28
      posix/preload
  3. 2
      posix/prepare

3
.gitignore vendored

@ -1,2 +1 @@
**/pcmi/**
**/badwolf/**
tests/**

@ -1,19 +1,27 @@
#!/bin/sh -e
# TODO: verify checksum before extracting
# SUM
# TODO: extract self without resolving to $0 because it doesn't resolve links
tail -c +"$(expr BYTES + 1)" $0 | lz4 -dc | tar -x
# TODO: remove hardcoded directory
# TODO: use a different extraction path
cd ID
export ORIGIN="$(pwd)"
export LD_LIBRARY_PATH="$ORIGIN/lib"
export PATH="$ORIGIN/bin":$PATH
if [ -z "$XDG_CACHE_HOME" ]; then
destdir=/tmp
else
destdir="$XDG_CACHE_HOME"
fi
if ! [ "$(head -n 1 "$destdir"/ID/checksum 2>/dev/null)" = 'SUM' ]; then
tail -c +BYTES "$0" | lz4 -dc | tar -x -C "$destdir"
echo "SUM" > "$destdir"/ID/checksum
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'
# TODO: use $0 instead
# FIXME: uses the system's basename
exec bin/"$(basename "$1")"
exec "$destdir"/ID/bin/"$(basename "$1")"

@ -148,7 +148,7 @@ awk '!/^ *#/ && NF' > tpp
size="$(wc -c tpp | cut -d " " -f1)"
strsize="$(echo "BYTES" | wc -c)"
numsize="$(echo "$size" | wc -c)"
normsize="$((size - (strsize - numsize)))"
normsize="$((size - (strsize - numsize) + 1))"
sed s/BYTES/"$normsize"/ tpp > tpr
cat tpr "$DIRNAME".tar.lz4 > "$DIRNAME".ti

Loading…
Cancel
Save