mirror of
https://github.com/Phantop/appdwarf.git
synced 2025-01-09 05:37:04 +00:00
appdwarf: split header into multiple files
This commit is contained in:
parent
e2f5be3a75
commit
fc6002e56f
13
appdwarf
13
appdwarf
|
@ -16,7 +16,7 @@ fi
|
|||
|
||||
set -e # exit on failure
|
||||
IFS=$(printf '\n\t') # smarter ifs
|
||||
. "$(dirname "$(readlink -f "${0}")")/headers" && header
|
||||
HEAD="$(dirname "$(readlink -f "${0}")")/header"
|
||||
|
||||
while true; do # process args
|
||||
case "$1" in
|
||||
|
@ -24,10 +24,12 @@ while true; do # process args
|
|||
app="$2"
|
||||
shift ;;
|
||||
--folder | -f)
|
||||
header_folder "$(realpath "$2")"
|
||||
"$HEAD"_folder
|
||||
HEAD=/tmp/dwarfhead
|
||||
sed -i "2s|$|\"$2\"|" "$HEAD"
|
||||
shift ;;
|
||||
--separate | -s)
|
||||
header_separate ;;
|
||||
HEAD="$HEAD"_separate ;;
|
||||
--url | -u)
|
||||
app=$(basename "$2")
|
||||
aria2c -x16 -s16 "$2" -o "$app" || wget "$2" -O "$app"
|
||||
|
@ -48,10 +50,7 @@ if [ -n "$app" ]; then # handle and extract appimage input, if present
|
|||
[ ! -f "$app" ] && tput setaf 1 && echo "$app" is not a valid file && exit 1
|
||||
chmod +x "$app"
|
||||
rm -rf squashfs-root
|
||||
case "$app" in
|
||||
/*) "$app" --appimage-extract || exit 1 ;;
|
||||
*) ./"$app" --appimage-extract || exit 1 ;;
|
||||
esac
|
||||
"$(realpath "$app")" --appimage-extract || exit 1
|
||||
rm "$app"
|
||||
set -- "$(basename "$app" .AppImage)" "$@"
|
||||
mv squashfs-root "$1"
|
||||
|
|
14
header
Executable file
14
header
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
# shellcheck disable=SC2086,SC2155
|
||||
DIR="/tmp/dwarf_$(basename "$0")$(echo "$0" | md5sum | head -c5)"
|
||||
export APPDWARF_CMD="$(basename "$0")"
|
||||
if [ ! -d "$DIR" ]; then
|
||||
mkdir "$DIR"
|
||||
ARG="-o offset=auto -o tidy_strategy=swap -o workers=4"
|
||||
dwarfs $ARG "$0" "$DIR" 2>/dev/null
|
||||
fi
|
||||
|
||||
"$DIR/AppRun" "$@"
|
||||
fusermount -quz "$DIR"
|
||||
rmdir "$DIR" 2> /dev/null
|
||||
exit
|
14
header_folder
Executable file
14
header_folder
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
cat > /tmp/dwarfhead << 'EOF'
|
||||
#!/bin/sh
|
||||
DIR=
|
||||
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
|
||||
exit
|
||||
EOF
|
11
header_separate
Executable file
11
header_separate
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
# shellcheck disable=SC2086,SC2155
|
||||
DIR="$(mktemp -td dwarf_"$(basename "$0")"XXXXX)"
|
||||
ARG="-o offset=auto -o tidy_strategy=swap -o workers=4"
|
||||
export APPDWARF_CMD="$(basename "$0")"
|
||||
dwarfs $ARG "$0" "$DIR" 2>/dev/null
|
||||
|
||||
"$DIR/AppRun" "$@"
|
||||
fusermount -uz "$DIR"
|
||||
rmdir "$DIR"
|
||||
exit
|
50
headers
50
headers
|
@ -1,50 +0,0 @@
|
|||
#!/bin/sh
|
||||
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"
|
||||
export APPDWARF_CMD="$(basename "$0")"
|
||||
dwarfs $ARG "$0" "$DIR" 2>/dev/null
|
||||
|
||||
"$DIR/AppRun" "$@"
|
||||
fusermount -uz "$DIR"
|
||||
rmdir "$DIR"
|
||||
exit
|
||||
EOF
|
||||
}
|
||||
|
||||
header() {
|
||||
cat > $HEAD << 'EOF'
|
||||
#!/bin/sh
|
||||
DIR="/tmp/dwarf_$(basename "$0")$(echo "$0" | md5sum | head -c5)"
|
||||
export APPDWARF_CMD="$(basename "$0")"
|
||||
if [ ! -d "$DIR" ]; then
|
||||
mkdir "$DIR"
|
||||
ARG="-o offset=auto -o tidy_strategy=swap -o workers=4"
|
||||
dwarfs $ARG "$0" "$DIR" 2>/dev/null
|
||||
fi
|
||||
|
||||
"$DIR/AppRun" "$@"
|
||||
fusermount -quz "$DIR"
|
||||
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
|
||||
exit
|
||||
EOF
|
||||
}
|
Loading…
Reference in a new issue