appdwarf 3.5: auto detect and handle files and urls

This commit is contained in:
Phantop 2022-06-20 15:13:05 -04:00
parent 478c0ad56a
commit 6774a2d639
9 changed files with 53 additions and 77 deletions

View file

@ -1,52 +1,46 @@
#!/bin/sh
if [ $# -eq 0 ] || [ "$1" = -h ] || [ "$1" = --help ]; then # print help text
tput setaf 6
echo "Usage: $(basename "$0") [options] [FILE/FOLDER/URL] [dwarfs options]"
echo "Compress a given AppDir (default)"
tput setaf 7
echo " -a, --appimage Convert a given AppImage to appdwarf"
echo " -u, --url Fetch and convert AppImage from URL"
echo; tput setaf 5
echo " -h, --help Print this help text"
echo " -v, --version Print the appdwarf version"
exit
fi
set -e # exit on failure
IFS=$(printf '\n\t') # smarter ifs
HEAD="$(dirname "$(readlink -f "${0}")")/header"
while true; do # process args
case "$1" in
--appimage | -a)
app="$2" ;;
--url | -u)
app=$(basename "$2")
aria2c -x16 -s16 "$2" -o "$app" || wget "$2" -O "$app" ;;
--version | -v)
tput setaf 2; echo appdwarf v3.0
tput setaf 4; echo Built by July 🏳️‍🌈
exit ;;
--)
shift; break;;
*)
break;;
esac; shift 2
done
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
if [ -n "$app" ]; then # handle and extract appimage input, if present
[ ! -f "$app" ] && tput setaf 1 && echo "$app" is not a valid file >&2 && exit 1
file -i "$app" | grep -qv x-executable && tput setaf 1 &&
echo "$app" is not an AppImage >&2 && exit 1
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
chmod +x "$app"
chmod +x "$1"
rm -rf squashfs-root
"$(realpath "$app")" --appimage-extract
set -- "$(basename "$app" .AppImage)" "$@"
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" "$@"
mv squashfs-root "$1"
fi
[ ! -d "$1" ] && tput setaf 1 && echo "$1" is not a valid folder >&2 && exit 1
mkdwarfs -o "$(realpath "$1").sh" -B5 --header "$HEAD" -i "$@"
chmod +x "$(realpath "$1").sh"

View file

@ -10,8 +10,7 @@ These scripts are all targeted for using on x86_64 Linux systems with GLIBC.
Script | Function | Source
--- | --- | ---
`appimage ` | Can fetch and convert AppImages by name from AppImageHub if the source repo is hosted on GitHub and linked to | <https://appimage.github.io>
`github ` | Can be given a GitHub URL or repo in the form `user/repo` and will find and convert the latest AppImage release | <https://github.com>
`appimage ` | Can fetch and convert AppImages by name from AppImageHub or from a given GitHub repo| <https://appimage.github.io>
`mkchrome ` | Latest official Chromium build | <https://download-chromium.appspot.com>
`mkgo ` | Latest official Go release | <https://go.dev>
`mkjava ` | Accepts an argument for Java version and obtains that build from Adoptium | <https://adoptium.net>
@ -23,4 +22,3 @@ Script | Function | Source
`mkwine ` | Latest `wine-staging-tkg` release | <https://github.com/Kron4ek/Wine-Builds>
`mkwine proton` | GloriousEggroll Proton Builds | <https://github.com/GloriousEggroll/proton-ge-custom>
`rustsolus` | Latest Rust stable from the Solus repos (requires `eopkg` and may not work on other distros) | <https://getsol.us>
`ungoogled` | Latest submitted `ungoogled-chromium` binary release | <https://ungoogled-software.github.io/ungoogled-chromium-binaries>

View file

@ -1,2 +1,15 @@
#!/bin/sh
./github https://raw.githubusercontent.com/AppImage/appimage.github.io/master/apps/"$1".md
if ! echo "$1" | grep / ; then
"$0" https://raw.githubusercontent.com/AppImage/appimage.github.io/master/apps/"$1".md
exit $?
fi
if ! echo "$1" | grep https ; then
set -- "https://github.com/$1"
fi
LINK2="$(echo "$1"/releases | sed 's|github.com|api.github.com/repos|')"
if ! echo "$1" | grep github.com; then
LINK2="$(curl "$1" | grep -o https.\*releases | sed 's|github.com|api.github.com/repos|')"
fi
LINK3="$(curl "$LINK2" | grep -v arm64 | grep -v armh | grep -om1 https.\*AppImage)"
shift
appdwarf "$LINK3" "$@"

View file

@ -1,11 +0,0 @@
#!/bin/sh
if ! echo "$1" | grep https ; then
set -- "https://github.com/$1"
fi
LINK2="$(echo "$1"/releases | sed 's|github.com|api.github.com/repos|')"
if ! echo "$1" | grep github.com; then
LINK2="$(curl "$1" | grep -o https.\*releases | sed 's|github.com|api.github.com/repos|')"
fi
LINK3="$(curl "$LINK2" | grep -v arm64 | grep -v armh | grep -om1 https.\*AppImage)"
shift
appdwarf "$@" -u "$LINK3"

View file

@ -5,10 +5,9 @@ mkdir -p $DIR
VER=$1
shift
LINK=https://api.adoptium.net/v3/binary/latest/$VER/ga/linux/x64/jdk/hotspot/normal/eclipse
LINK=https://api.adoptium.net/v3/binary/latest/$VER/ga/linux/x64/jre/hotspot/normal/eclipse
curl -L "$LINK" | tar xz -C$DIR
mv $DIR/jdk* $DIR/jdk
$DIR/jdk/bin/jlink --add-modules ALL-MODULE-PATH --output $DIR/jre --strip-debug --no-man-pages --no-header-files --compress=0
mv $DIR/jdk* $DIR/jre
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/jre
sed -i 4s#/#/bin/# $DIR/jre/AppRun

View file

@ -6,13 +6,8 @@ curl http://musl.cc/x86_64-linux-musl-native.tgz | tar xz -C$DIR
mv $DIR/x86_64-linux-musl-native $DIR/musl
ln -s gcc $DIR/musl/bin/cc
cat > $DIR/musl/AppRun << 'EOF'
#!/bin/sh
HERE=$(dirname $(readlink -f "${0}"))
export PATH="${HERE}/bin":$PATH
"$@"
EOF
chmod +x $DIR/musl/AppRun
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/musl
sed -i '4s#"$APPDIR/$ARGV0" ##' $DIR/musl/AppRun
appdwarf $DIR/musl
mv $DIR/musl.sh musl

View file

@ -1,9 +0,0 @@
#!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH
DIR=/tmp/appdwarf
mkdir -p $DIR
LINK=https://releases.hashicorp.com/vagrant
VER=$(curl -L $LINK | grep -m1 'href.*[0-9]' | cut -d/ -f3)
LINK2=https://releases.hashicorp.com/vagrant/$VER/vagrant_"$VER"_linux_amd64.zip
curl "$LINK2" | bsdtar xf - -C$DIR
appdwarf -a $DIR/vagrant

View file

@ -1,3 +0,0 @@
#!/bin/sh
ID="$(curl -L https://ungoogled-software.github.io/ungoogled-chromium-binaries | grep -m7 href | tail -n 1 | awk -F'[<>]' '{print $5}')"
appdwarf -u "https://github.com/clickot/ungoogled-chromium-binaries/releases/download/$ID/ungoogled-chromium_$ID.AppImage"

4
header
View file

@ -2,10 +2,10 @@
ARGV0="$(basename "$0")"; APPDIR="/tmp/dwarf_$ARGV0$(echo "$0"|md5sum|head -c5)"
export APPIMAGE="$0" OWD="$PWD" ARGV0 APPDIR
[ ! -d "$APPDIR" ] && mkdir "$APPDIR" &&
dwarfs -o offset=auto -o tidy_strategy=swap -o workers=4 "$0" "$APPDIR" 2>&1|:
dwarfs -o offset=auto -o tidy_strategy=swap -o workers=4 "$0" "$APPDIR" 2>/dev/null
"$APPDIR/AppRun" "$@"
res=$?
fusermount -quz "$APPDIR"
rmdir "$APPDIR" /dev/null
rmdir "$APPDIR" > /dev/null
exit $res