appdwarf: Switch to AppImage standard environmental variables as v3.0

Deprecates $APPDWARF_CMD for $ARGV0, as part of the standard
Also finally removes the separate header, as it seems to
not be needed anymore
This commit is contained in:
Phantop 2022-06-11 15:02:34 -04:00
parent 19b9cd80da
commit 3ebee5f254
12 changed files with 24 additions and 43 deletions

7
AppRun
View file

@ -1,5 +1,4 @@
#!/bin/sh
HERE=$(dirname "$(readlink -f "${0}")")
export PATH="${HERE}":"${HERE}"/bin:"$PATH"
export LD_LIBRARY_PATH="${HERE}"/lib64:"${HERE}"/lib:"$LD_LIBRARY_PATH"
exec "${HERE}"/"$APPDWARF_CMD" "$@"
export PATH="${APPDIR}":"${APPDIR}"/bin:"$PATH"
export LD_LIBRARY_PATH="${APPDIR}"/lib64:"${APPDIR}"/lib:"$LD_LIBRARY_PATH"
exec "$APPDIR/$ARGV0" "$@"

View file

@ -6,7 +6,6 @@ if [ $# -eq 0 ] || [ "$1" = -h ] || [ "$1" = --help ]; then # print help text
tput setaf 7
echo " -a, --appimage Convert a given AppImage to appdwarf"
echo " -f, --folder Make image mount to a given folder (no AppRun)"
echo " -s, --separate Use old, separated header format"
echo " -u, --url Fetch and convert AppImage from URL"
echo; tput setaf 5
echo " -h, --help Print this help text"
@ -28,14 +27,12 @@ while true; do # process args
HEAD=/tmp/dwarfhead
sed -i "2s|$|\"$2\"|" "$HEAD"
shift ;;
--separate | -s)
HEAD="$HEAD"_separate ;;
--url | -u)
app=$(basename "$2")
aria2c -x16 -s16 "$2" -o "$app" || wget "$2" -O "$app"
shift ;;
--version | -v)
tput setaf 2; echo appdwarf v2.9
tput setaf 2; echo appdwarf v3.0
tput setaf 4; echo Built by July 🏳️‍🌈
exit ;;
--)

View file

@ -6,8 +6,8 @@ LINK=$(curl -sL https://go.dev/dl | grep -om1 dl/go.\*linux-amd64.tar.gz)
curl -L https://go.dev/"$LINK" | tar xz -C$DIR
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/go
sed -i 5s#/#/bin/# $DIR/go/AppRun
sed -i '4a export GOPROXY=direct' $DIR/go/AppRun
sed -i '4i export GOPROXY=direct' $DIR/go/AppRun
sed -i 4s#/#/bin/# $DIR/go/AppRun
appdwarf $DIR/go
mv $DIR/go.sh go

View file

@ -11,7 +11,7 @@ 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
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/jre
sed -i 5s#/#/bin/# $DIR/jre/AppRun
sed -i 4s#/#/bin/# $DIR/jre/AppRun
appdwarf $DIR/jre "$@"
mv $DIR/jre.sh java"$VER"

View file

@ -9,7 +9,7 @@ aria2c "$LINK" -d $DIR -o exe
rm $DIR/exe
mv $DIR/Mp3tag.exe $DIR/mp3tag
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR
sed -i '5s/ / wine /' $DIR/AppRun
sed -i '4s/ / wine /' $DIR/AppRun
appdwarf $DIR
mv $DIR.sh mp3tag

View file

@ -10,7 +10,7 @@ mv $DIR/node* $DIR/node
strip $DIR/node/bin/node
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/node
sed -i 5s#/#/bin/# $DIR/node/AppRun
sed -i 4s#/#/bin/# $DIR/node/AppRun
appdwarf $DIR/node
mv $DIR/node.sh node

View file

@ -11,7 +11,7 @@ for i in cargo rustc rust-std-$ARCH/; do
mv "$DIR/rust-nightly-$ARCH/$i"/* $DIR/rust; done
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/rust
sed -i 5s#/#/bin/# $DIR/rust/AppRun
sed -i 4s#/#/bin/# $DIR/rust/AppRun
appdwarf $DIR/rust
mv $DIR/rust.sh cargo

View file

@ -43,15 +43,8 @@ EOF
$DIR/tl/install-tl -profile $DIR/tl/prof
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/tex
sed -i 3s#/bin#/bin/x86_64-linux# $DIR/tex/AppRun
sed -i 5s#/#/bin/x86_64-linux# $DIR/tex/AppRun
cat > $DIR/tex/AppRun << 'EOF'
#!/bin/sh
HERE=$(dirname "$(readlink -f "${0}")")
export PATH="${HERE}"/bin/x86_64-linux:"$PATH"
"${HERE}"/bin/x86_64-linux/"$APPDWARF_CMD" "$@"
EOF
sed -i 2s#/bin#/bin/x86_64-linux# $DIR/tex/AppRun
sed -i 4s#/#/bin/x86_64-linux# $DIR/tex/AppRun
chmod +x $DIR/tex/AppRun

View file

@ -9,7 +9,7 @@ rm $DIR/*.eopkg
rm -r $DIR/usr/lib64/rustlib/i686-unknown-linux-gnu
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/usr
sed -i 5s#/#/bin/# $DIR/usr/AppRun
sed -i 4s#/#/bin/# $DIR/usr/AppRun
appdwarf $DIR/usr
mv $DIR/usr.sh cargo

View file

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

17
header
View file

@ -1,14 +1,17 @@
#!/bin/sh
# shellcheck disable=SC2086,SC2155
DIR="/tmp/dwarf_$(basename "$0")$(echo "$0" | md5sum | head -c5)"
export APPDIR="/tmp/dwarf_$(basename "$0")$(echo "$0" | md5sum | head -c5)"
export APPIMAGE="$0"
export ARGV0="$(basename "$0")"
export OWD="$PWD"
export APPDWARF_CMD="$(basename "$0")"
if [ ! -d "$DIR" ]; then
mkdir "$DIR"
if [ ! -d "$APPDIR" ]; then
mkdir "$APPDIR"
ARG="-o offset=auto -o tidy_strategy=swap -o workers=4"
dwarfs $ARG "$0" "$DIR" 2>/dev/null
dwarfs $ARG "$0" "$APPDIR" 2>/dev/null
fi
"$DIR/AppRun" "$@"
fusermount -quz "$DIR"
rmdir "$DIR" 2> /dev/null
"$APPDIR/AppRun" "$@"
fusermount -quz "$APPDIR"
rmdir "$APPDIR" 2> /dev/null
exit

View file

@ -1,11 +0,0 @@
#!/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