Integrate example AppRun into main script

This commit is contained in:
Phantop 2022-07-13 00:39:09 -04:00
parent bdd4a0c6e4
commit ac27ba5a32
15 changed files with 146 additions and 167 deletions

4
AppRun
View file

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

9
DirRun
View file

@ -1,9 +0,0 @@
#!/bin/sh
DIR=
if [ ! -d "$DIR" ]; then
mkdir "$DIR"
bindfs --no-allow-other "$APPDIR" "$DIR"
else
fusermount -u "$DIR"
rmdir "$DIR"
fi

View file

@ -45,3 +45,6 @@ created when ran since some programs care about that, such as an emulator only
running games of an expected file extension. running games of an expected file extension.
`zzexe` requires `zstd` for both creating and running files and `moreutils` for creating them. `zzexe` requires `zstd` for both creating and running files and `moreutils` for creating them.
As of June 2022, `zzexe` has been integrated into the main `appdwarf` script. It can
be run either with the `-z` flag or by renaming the `appdwarf` script to `zzexe`.

View file

@ -1,8 +1,14 @@
#!/bin/sh #!/bin/sh
#shellcheck disable=SC2086,SC2155
set -e # exit on failure set -e # exit on failure
IFS=$(printf '\n\t') # smarter ifs IFS=$(printf '\n\t') # smarter ifs
apprun() {
export PATH="$APPDIR"/bin:"$PATH"
export LD_LIBRARY_PATH="$APPDIR"/lib64:"$APPDIR"/lib:"$LD_LIBRARY_PATH"
exec "$APPDIR/$(basename "$ARGV0")" "$@"
}
# shellcheck disable=SC2086,SC2155
header() { header() {
APPDIR="/tmp/dwarf_$(basename "$0")$(echo "$0"|md5sum|head -c5)" APPDIR="/tmp/dwarf_$(basename "$0")$(echo "$0"|md5sum|head -c5)"
export APPDIR APPIMAGE="$(realpath "$0")" ARGV0="$0" OWD="$PWD" export APPDIR APPIMAGE="$(realpath "$0")" ARGV0="$0" OWD="$PWD"
@ -15,18 +21,23 @@ header() {
exit $res exit $res
} }
printfunc() {
echo '#!/bin/sh'
type "$1" | sed 's/^ *//' | tail -n+4 | head -n-1
}
zzexe() { zzexe() {
[ "$1" = "-d" ] && awk 'f;/^exit \$res$/{f=1}' "$2" | head -c-1 | zstd -cd | ifne sponge "$2" && exit [ "$1" = "-d" ] && awk 'f;/^exit \$res$/{f=1}' "$2" | head -c-1 | zstd -cd | ifne sponge "$2" && exit
[ "$1" = "-p" ] && p="$2" && shift 2 # save prefix if present [ "$1" = "-p" ] && p="$2" && shift 2 # save prefix if present
zstdmt -cq19 "$@" | ifne sponge "$1" zstdmt -cq19 "$@" | ifne sponge "$1"
type zzexe_header | sed 's/^ *//' | tail -n+4 | head -n-1 | cat - "$1" | ifne sponge "$1" printfunc zzexe_header | cat - "$1" | ifne sponge "$1"
sed -i -e '1i #!/bin/sh' -e "1s/);$/${1##*[./]})/" -e "6s/^/$p /" "$1" sed -i -e "1s/);$/${1##*[./]})/" -e "6s/^/$p /" "$1"
exit exit
} }
zzexe_header() { zzexe_header() {
dir=$(dirname "$0") out=$(mktemp -t .zzXXXX.) dir=$(dirname "$0") out=$(mktemp -t .zzXXXX.)
awk "f;/^exit \\$res$/{f=1}" "$0" | head -c-1 | zstd -cd > "$out" awk 'f;/^exit \$res$/{f=1}' "$0" | head -c-1 | zstd -cd > "$out"
chmod +x "$out" chmod +x "$out"
ln -s "$out" "$dir" ln -s "$out" "$dir"
trap : 0 1 2 3 6 14 15 trap : 0 1 2 3 6 14 15
@ -37,16 +48,33 @@ zzexe_header() {
} }
case "$1" in case "$1" in
-a )
printfunc apprun > "$2"
chmod +x "$2"
exit ;;
-b )
printfunc apprun | sed '4s#/#/bin/#' > "$2"
chmod +x "$2"
exit ;;
-d | -p ) -d | -p )
zzexe "$@" ;; zzexe "$@" ;;
-z)
shift
zzexe "$@" ;;
--version | -v ) --version | -v )
tput setaf 2; echo appdwarf 2022.06.25 tput setaf 2; echo appdwarf 2022.07.13
tput setaf 6; echo Built by July 🏳️‍🌈; exit ;; tput setaf 6; echo Built by July 🏳️‍🌈; exit ;;
-* | '' ) -* | '' )
tput setaf 6 tput setaf 2
echo "Usage: $(basename "$0") [APP/FILE/FOLDER/URL] [compression options]" echo "Usage: $(basename "$0") [APP/FILE/FOLDER/URL] [compression options]"
tput setaf 3 tput setaf 7
echo " -a [file] Write example AppRun to file and exit"
echo " -b [file] Write example AppRun with bin subdir to file and exit"
echo
echo " -d Decompress a zzexe'd file" echo " -d Decompress a zzexe'd file"
echo " -p zzexe a file with prefix"
echo " -z zzexe a file"
echo
echo " -h, --help Print this help text" echo " -h, --help Print this help text"
echo " -v, --version Print the appdwarf version"; exit ;; echo " -v, --version Print the appdwarf version"; exit ;;
esac esac
@ -97,9 +125,8 @@ if [ ! -d "$1" ]; then # directory doesn't exist, see if this is an appimage
fi fi
head="$(mktemp)" head="$(mktemp)"
echo '#!/bin/sh' > $head printfunc header > "$head"
type header | tail -n+4 | head -n-1 | sed 's/^ *//' >> $head
mkdwarfs -o "$(realpath "$1").sh" -B5 --header $head -i "$@" mkdwarfs -o "$(realpath "$1").sh" -B5 --header "$head" -i "$@"
rm $head rm "$head"
chmod +x "$(realpath "$1").sh" chmod +x "$(realpath "$1").sh"

View file

@ -1,13 +1,11 @@
#!/bin/sh #!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH APP=${0#./mk}
DIR=/tmp/appdwarf/dotnet DIR=/tmp/appdwarf/$APP
mkdir -p $DIR mkdir -p "$DIR"
LINK=https://dotnetcli.azureedge.net/dotnet/Runtime LINK=https://dotnetcli.azureedge.net/dotnet/Runtime
VER=$(curl $LINK/LTS/latest.version) VER=$(curl $LINK/LTS/latest.version)
curl "$LINK/$VER/dotnet-runtime-$VER-linux-x64.tar.gz" | tar xz -C$DIR curl "$LINK/$VER/dotnet-runtime-$VER-linux-x64.tar.gz" | tar xz -C"$DIR"
ln -s dotnet "$DIR"/AppRun
ln -s dotnet $DIR/AppRun appdwarf "$DIR" "$@"
mv "$DIR".sh "$APP"
appdwarf $DIR "$@" rm -rf "$DIR"
mv $DIR.sh dotnet
rm -rf $DIR

View file

@ -4,11 +4,8 @@ DIR=/tmp/appdwarf/go
mkdir -p $DIR mkdir -p $DIR
LINK=$(curl -sL https://go.dev/dl | grep -m1 linux | cut -d\" -f4) LINK=$(curl -sL https://go.dev/dl | grep -m1 linux | cut -d\" -f4)
curl -L https://go.dev/"$LINK" | tar xz -C$DIR/.. curl -L https://go.dev/"$LINK" | tar xz -C$DIR/..
appdwarf -b $DIR/AppRun
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR
sed -i '4i export GOPROXY=direct' $DIR/AppRun sed -i '4i export GOPROXY=direct' $DIR/AppRun
sed -i 5s#/#/bin/# $DIR/AppRun
appdwarf $DIR "$@" appdwarf $DIR "$@"
mv $DIR.sh go mv $DIR.sh go
rm -rf $DIR rm -rf $DIR

View file

@ -1,15 +1,12 @@
#!/bin/sh #!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH APP=${0#./mk}
DIR=/tmp/appdwarf/java DIR=/tmp/appdwarf/$APP
mkdir $DIR mkdir -p "$DIR"
LINK=https://api.adoptium.net/v3/binary/latest/$1/ga/linux/x64/jre/hotspot/normal/eclipse LINK=https://api.adoptium.net/v3/binary/latest/$1/ga/linux/x64/jre/hotspot/normal/eclipse
curl -L "$LINK" | tar xz -C$DIR
mv $DIR/jdk*/* $DIR
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR
sed -i 4s#/#/bin/# $DIR/AppRun
shift shift
appdwarf $DIR "$@" curl -L "$LINK" | tar xz -C"$DIR"
mv $DIR.sh java mv "$DIR"/jdk*/* "$DIR"
rm -rf $DIR appdwarf -b "$DIR"/AppRun
appdwarf "$DIR" "$@"
mv "$DIR".sh "$APP"
rm -rf "$DIR"

View file

@ -1,15 +1,13 @@
#!/bin/sh #!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH APP=${0#./mk}
DIR=/tmp/appdwarf/mp3tag DIR=/tmp/appdwarf/$APP
mkdir -p $DIR mkdir -p "$DIR"
LINK=$(curl -L mp3tag.de/dodownload64.html | awk -F'[="]' /URL/'{print $7}') LINK=$(curl -L mp3tag.de/dodownload64.html | awk -F'[="]' /URL/'{print $7}')
aria2c "$LINK" -d $DIR -o mp3tag aria2c "$LINK" -d "$DIR" -o mp3tag
7z x -y -o$DIR $DIR/mp3tag 7z x -y -o"$DIR" "$DIR"/mp3tag
mv "$DIR"/Mp3tag.exe "$DIR"/mp3tag
mv $DIR/Mp3tag.exe $DIR/mp3tag appdwarf -a "$DIR"/AppRun
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR sed -i '4s/ / wine /' "$DIR"/AppRun
sed -i '4s/ / wine /' $DIR/AppRun appdwarf "$DIR" "$@"
mv "$DIR".sh "$APP"
appdwarf $DIR "$@" rm -rf "$DIR"
mv $DIR.sh mp3tag
rm -rf $DIR

View file

@ -1,14 +1,12 @@
#!/bin/sh #!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH APP=${0#./mk}
DIR=/tmp/appdwarf/musl DIR=/tmp/appdwarf/$APP
mkdir $DIR mkdir "$DIR"
curl http://musl.cc/x86_64-linux-musl-native.tgz | tar xz -C$DIR curl http://musl.cc/x86_64-linux-musl-native.tgz | tar xz -C"$DIR"
mv "$DIR"/x86_64-linux-musl-native/* "$DIR"
mv $DIR/x86_64-linux-musl-native/* $DIR ln -s gcc "$DIR"/bin/cc
ln -s gcc $DIR/bin/cc appdwarf -a "$DIR"/AppRun
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR sed -i '4d;3a exec "$@"' "$DIR"/AppRun
sed -i '4d;3a exec "$@"' $DIR/AppRun appdwarf "$DIR" "$@"
mv "$DIR".sh "$APP"
appdwarf $DIR "$@" rm -rf "$DIR"
mv $DIR.sh musl
rm -rf $DIR

View file

@ -1,15 +1,12 @@
#!/bin/sh #!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH APP=${0#./mk}
DIR=/tmp/appdwarf/node DIR=/tmp/appdwarf/$APP
mkdir -p $DIR mkdir -p "$DIR"
LINK=$(curl https://nodejs.org/en/download/current/ | grep -m1 linux | cut -d\" -f4) LINK=$(curl https://nodejs.org/en/download/current/ | grep -m1 linux | cut -d\" -f4)
curl -L "$LINK" | bsdtar xf - -C$DIR curl -L "$LINK" | tar xJ -C"$DIR"
mv "$DIR"/node*/* "$DIR"
mv $DIR/node*/* $DIR strip "$DIR"/bin/node
strip $DIR/bin/node appdwarf -b "$DIR"/AppRun
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR appdwarf "$DIR"
sed -i 4s#/#/bin/# $DIR/AppRun mv "$DIR".sh node
rm -rf "$DIR"
appdwarf $DIR
mv $DIR.sh node
rm -rf $DIR

View file

@ -1,17 +1,14 @@
#!/bin/sh #!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH APP=${0#./mk}
DIR=/tmp/appdwarf/pypy DIR=/tmp/appdwarf/$APP
mkdir -p $DIR mkdir -p "$DIR"
LINK="https://buildbot.pypy.org/nightly/py3.9/pypy-c-jit-latest-linux64.tar.bz2" LINK="https://buildbot.pypy.org/nightly/py3.9/pypy-c-jit-latest-linux64.tar.bz2"
curl -L "$LINK" | tar xj -C$DIR curl -L "$LINK" | tar xj -C"$DIR"
ln -s bin/pypy "$DIR"/AppRun
mv $DIR/pypy*/* $DIR mv "$DIR"/pypy*/* "$DIR"
rm $DIR/bin/*.debug rm "$DIR"/bin/*.debug
ln -s bin/pypy $DIR/AppRun "$DIR"/AppRun -m ensurepip
"$DIR"/AppRun -m pip install pipx
$DIR/AppRun -m ensurepip appdwarf "$DIR"
$DIR/AppRun -m pip install pipx mv "$DIR".sh "$APP"
rm -rf "$DIR"
appdwarf $DIR
mv $DIR.sh pypy
rm -rf $DIR

View file

@ -1,17 +1,13 @@
#!/bin/sh #!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH APP=${0#./mk}
DIR=/tmp/appdwarf/rust DIR=/tmp/appdwarf/$APP
ARCH=x86_64-unknown-linux-gnu ARCH=x86_64-unknown-linux-gnu
mkdir -p $DIR mkdir -p "$DIR"
LINK=https://static.rust-lang.org/dist/rust-beta-$ARCH.tar.gz LINK=https://static.rust-lang.org/dist/rust-beta-$ARCH.tar.gz
curl -L $LINK | tar xz -C$DIR curl -L $LINK | tar xz -C"$DIR"
"$DIR"/rust-beta-$ARCH/install.sh --prefix="$DIR" --components=cargo,rustc,rust-std-$ARCH
$DIR/rust-beta-$ARCH/install.sh --prefix=$DIR --components=cargo,rustc,rust-std-$ARCH rm -rf "$DIR"/rust-beta-$ARCH
rm -rf $DIR/rust-beta-$ARCH appdwarf -b "$DIR"/AppRun
appdwarf "$DIR"
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR mv "$DIR".sh "$APP"
sed -i 4s#/#/bin/# $DIR/AppRun rm -rf "$DIR"
appdwarf $DIR
mv $DIR.sh cargo
rm -rf $DIR

View file

@ -1,12 +1,11 @@
#!/bin/sh #!/bin/sh
PATH="$(dirname "$(readlink -f "${0}")")/..":"$PATH" APP=${0#./mk}
DIR=/tmp/appdwarf/tex DIR=/tmp/appdwarf/$APP
mkdir -p $DIR mkdir -p "$DIR"
LINK=https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz LINK=https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
curl -L $LINK | tar xz -C$DIR curl -L $LINK | tar xz -C"$DIR"
mv $DIR/install-tl-* $DIR/tl mv "$DIR"/install-tl-* "$DIR"/tl
cat > "$DIR"/tl/prof << 'EOF'
cat > $DIR/tl/prof << 'EOF'
selected_scheme scheme-custom selected_scheme scheme-custom
TEXDIR /tmp/appdwarf/tex TEXDIR /tmp/appdwarf/tex
TEXMFCONFIG $TEXMFSYSCONFIG TEXMFCONFIG $TEXMFSYSCONFIG
@ -39,15 +38,9 @@ tlpdbopt_sys_info /usr/local/share/info
tlpdbopt_sys_man /usr/local/share/man tlpdbopt_sys_man /usr/local/share/man
tlpdbopt_w32_multi_user 1 tlpdbopt_w32_multi_user 1
EOF EOF
"$DIR"/tl/install-tl -profile "$DIR"/tl/prof
$DIR/tl/install-tl -profile $DIR/tl/prof appdwarf -b "$DIR"/AppRun
sed -i s#/bin#/bin/x86_64-linux# "$DIR"/AppRun
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR appdwarf "$DIR"
sed -i 2s#/bin#/bin/x86_64-linux# $DIR/AppRun mv "$DIR".sh "$APP"
sed -i 4s#/#/bin/x86_64-linux# $DIR/AppRun rm -rf "$DIR"
chmod +x $DIR/AppRun
appdwarf $DIR
mv $DIR.sh tex
rm -rf $DIR

View file

@ -1,19 +1,15 @@
#!/bin/sh #!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH APP=${0#./mk}
DIR=/tmp/appdwarf/wine DIR=/tmp/appdwarf/$APP
mkdir -p $DIR mkdir -p "$DIR"
VER=Kron4ek/Wine-Builds VER=Kron4ek/Wine-Builds
[ "$1" = "proton" ] && VER=GloriousEggroll/proton-ge-custom && shift [ "$1" = "proton" ] && VER=GloriousEggroll/proton-ge-custom && shift
LINK=$(curl -L api.github.com/repos/$VER/releases | jq .[0].assets[1] | grep -om1 g.\*tar..z) LINK=$(curl -L api.github.com/repos/$VER/releases | jq .[0].assets[1] | grep -om1 g.\*tar..z)
curl -L "$LINK" | bsdtar xf - -C$DIR curl -L "$LINK" | bsdtar xf - -C"$DIR"
mv "$DIR"/wine*/* "$DIR"/GE-Proton*/files/* "$DIR"
mv $DIR/wine*/* $DIR/GE-Proton*/files/* $DIR t=winetricks; wget -O"$DIR"/bin/$t github.com/$t/$t/raw/master/src/$t
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR chmod +x "$DIR"/bin/$t
sed -i 4s#/#/bin/# $DIR/AppRun appdwarf -b "$DIR"/AppRun
appdwarf "$DIR" "$@"
t=winetricks; wget -O$DIR/bin/$t github.com/$t/$t/raw/master/src/$t mv "$DIR".sh wine
chmod +x $DIR/bin/$t rm -rf "$DIR"
appdwarf $DIR "$@"
mv $DIR.sh wine
rm -rf $DIR

View file

@ -1,16 +1,11 @@
#!/bin/sh #!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH APP=${0#./}
DIR=/tmp/appdwarf/rust DIR=/tmp/appdwarf/$APP
mkdir -p $DIR mkdir -p "$DIR"
eopkg fc -o "$DIR" cargo rust
eopkg fc -o $DIR cargo rust parallel "unzip -op {} install.tar.xz | tar xJf - -C"$DIR"" ::: "$DIR"/*.eopkg
parallel "unzip -op {} install.tar.xz | tar xJf - -C$DIR" ::: $DIR/*.eopkg rm -r "$DIR"/usr/lib64/rustlib/i686-unknown-linux-gnu "$DIR"/*.eopkg
rm $DIR/*.eopkg appdwarf -b "$DIR"/usr/AppRun
rm -r $DIR/usr/lib64/rustlib/i686-unknown-linux-gnu appdwarf "$DIR"/usr
mv "$DIR"/usr.sh cargo
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/usr rm -rf "$DIR"
sed -i 4s#/#/bin/# $DIR/usr/AppRun
appdwarf $DIR/usr
mv $DIR/usr.sh cargo
rm -rf $DIR