2021-12-31 18:27:01 +00:00
|
|
|
#!/bin/bash
|
|
|
|
HEAD=/tmp/dwarfhead
|
|
|
|
header_separate() {
|
|
|
|
cat > $HEAD << 'EOF'
|
|
|
|
#!/bin/sh
|
|
|
|
DIR="$(mktemp -td dwarf_$(basename "$0")XXXXX)"
|
|
|
|
ARG="-o offset=auto -o tidy_strategy=swap -o workers=4"
|
|
|
|
dwarfs $ARG "$0" "$DIR" 2>/dev/null
|
|
|
|
export APPDWARF_CMD=$(basename "$0")
|
|
|
|
"$DIR/AppRun" "$@"
|
|
|
|
fusermount -u "$DIR"
|
|
|
|
rmdir "$DIR"
|
|
|
|
exit
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
header() {
|
|
|
|
cat > $HEAD << 'EOF'
|
|
|
|
#!/bin/sh
|
2021-12-31 19:24:04 +00:00
|
|
|
DIR="/tmp/dwarf_$(basename "$0")$(echo "$0" | md5sum | head -c5)"
|
2021-12-31 18:27:01 +00:00
|
|
|
export APPDWARF_CMD=$(basename "$0")
|
|
|
|
|
2021-12-31 19:24:04 +00:00
|
|
|
if [[ ! -d $DIR ]]; then
|
2021-12-31 18:27:01 +00:00
|
|
|
mkdir "$DIR"
|
|
|
|
ARG="-o offset=auto -o tidy_strategy=swap -o workers=4"
|
|
|
|
dwarfs $ARG "$0" "$DIR" 2>/dev/null
|
|
|
|
fi
|
2021-12-31 19:24:04 +00:00
|
|
|
"$DIR/AppRun" "$@"
|
2021-12-31 18:27:01 +00:00
|
|
|
fusermount -qu "$DIR"
|
2021-12-31 19:24:04 +00:00
|
|
|
rmdir "$DIR" 2> /dev/null
|
|
|
|
exit
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
header_folder() {
|
|
|
|
echo '#!/bin/sh' > $HEAD
|
|
|
|
echo DIR=\"$1\" >> $HEAD
|
|
|
|
cat >> $HEAD << 'EOF'
|
|
|
|
if [ ! -d "$DIR" ]; then
|
|
|
|
mkdir "$DIR"
|
|
|
|
ARG="-o offset=auto -o tidy_strategy=swap -o workers=4"
|
|
|
|
dwarfs $ARG "$0" "$DIR" 2>/dev/null
|
|
|
|
else
|
|
|
|
fusermount -u "$DIR"
|
|
|
|
rmdir "$DIR"
|
|
|
|
fi
|
2021-12-31 18:27:01 +00:00
|
|
|
exit
|
|
|
|
EOF
|
|
|
|
}
|