2022-04-13 21:10:51 +00:00
|
|
|
#!/bin/sh
|
2022-04-15 18:05:20 +00:00
|
|
|
set -e # exit on failure
|
|
|
|
IFS=$(printf '\n\t') # smarter ifs
|
2022-04-17 19:39:52 +00:00
|
|
|
HEAD="$(dirname "$(readlink -f "${0}")")/header"
|
2021-12-31 19:24:04 +00:00
|
|
|
|
2022-06-20 19:13:05 +00:00
|
|
|
case "$1" in
|
|
|
|
-h | --help | '')
|
|
|
|
tput setaf 6
|
|
|
|
echo "Usage: $(basename "$0") [FILE/FOLDER/URL] [dwarfs options]"
|
|
|
|
tput setaf 3
|
|
|
|
echo " -h, --help Print this help text"
|
|
|
|
echo " -v, --version Print the appdwarf version"; exit ;;
|
|
|
|
--version | -v)
|
|
|
|
tput setaf 2; echo appdwarf v3.5
|
|
|
|
tput setaf 6; echo Built by July 🏳️🌈; exit ;;
|
|
|
|
-* )
|
|
|
|
tput setaf 1; echo Invalid argument; exit 1
|
|
|
|
esac
|
2021-05-29 20:13:12 +00:00
|
|
|
|
2022-06-20 19:13:05 +00:00
|
|
|
if [ ! -d "$1" ]; then # directory doesn't exist, see if this is an appimage
|
|
|
|
if [ ! -f "$1" ]; then # file doesn't exist, see if this is a url
|
|
|
|
app=$(basename "$1")
|
|
|
|
if aria2c -x16 -s16 "$1" -o "$app" || wget "$1" -O "$app"; then
|
|
|
|
shift
|
|
|
|
set -- "$app" "$@"
|
|
|
|
else
|
|
|
|
tput setaf 1; echo "$1" is not a valid file, folder, or url >&2
|
|
|
|
rm "$app" 2> /dev/null; exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2022-05-13 00:32:37 +00:00
|
|
|
|
2022-06-20 19:13:05 +00:00
|
|
|
chmod +x "$1"
|
2022-04-15 18:05:20 +00:00
|
|
|
rm -rf squashfs-root
|
2022-05-13 00:32:37 +00:00
|
|
|
|
2022-06-20 19:13:05 +00:00
|
|
|
if ! "$(realpath "$1")" --appimage-extract 2> /dev/null; then
|
|
|
|
tput setaf 4; echo "$1 is not an AppImage, it will be zzexe'd"
|
|
|
|
exec "$(dirname "$(readlink -f "${0}")")/zzexe" "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
app="$(basename "$1" .AppImage)" shift
|
|
|
|
set -- "$app" "$@"
|
2022-04-15 18:05:20 +00:00
|
|
|
mv squashfs-root "$1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdwarfs -o "$(realpath "$1").sh" -B5 --header "$HEAD" -i "$@"
|
|
|
|
chmod +x "$(realpath "$1").sh"
|