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.
`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
#shellcheck disable=SC2086,SC2155
set -e # exit on failure
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() {
APPDIR="/tmp/dwarf_$(basename "$0")$(echo "$0"|md5sum|head -c5)"
export APPDIR APPIMAGE="$(realpath "$0")" ARGV0="$0" OWD="$PWD"
@ -15,18 +21,23 @@ header() {
exit $res
}
printfunc() {
echo '#!/bin/sh'
type "$1" | sed 's/^ *//' | tail -n+4 | head -n-1
}
zzexe() {
[ "$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
zstdmt -cq19 "$@" | ifne sponge "$1"
type zzexe_header | sed 's/^ *//' | tail -n+4 | head -n-1 | cat - "$1" | ifne sponge "$1"
sed -i -e '1i #!/bin/sh' -e "1s/);$/${1##*[./]})/" -e "6s/^/$p /" "$1"
printfunc zzexe_header | cat - "$1" | ifne sponge "$1"
sed -i -e "1s/);$/${1##*[./]})/" -e "6s/^/$p /" "$1"
exit
}
zzexe_header() {
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"
ln -s "$out" "$dir"
trap : 0 1 2 3 6 14 15
@ -37,16 +48,33 @@ zzexe_header() {
}
case "$1" in
-a )
printfunc apprun > "$2"
chmod +x "$2"
exit ;;
-b )
printfunc apprun | sed '4s#/#/bin/#' > "$2"
chmod +x "$2"
exit ;;
-d | -p )
zzexe "$@" ;;
-z)
shift
zzexe "$@" ;;
--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
tput setaf 2
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 " -p zzexe a file with prefix"
echo " -z zzexe a file"
echo
echo " -h, --help Print this help text"
echo " -v, --version Print the appdwarf version"; exit ;;
esac
@ -97,9 +125,8 @@ if [ ! -d "$1" ]; then # directory doesn't exist, see if this is an appimage
fi
head="$(mktemp)"
echo '#!/bin/sh' > $head
type header | tail -n+4 | head -n-1 | sed 's/^ *//' >> $head
printfunc header > "$head"
mkdwarfs -o "$(realpath "$1").sh" -B5 --header $head -i "$@"
rm $head
mkdwarfs -o "$(realpath "$1").sh" -B5 --header "$head" -i "$@"
rm "$head"
chmod +x "$(realpath "$1").sh"

View File

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

View File

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

View File

@ -1,15 +1,12 @@
#!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH
DIR=/tmp/appdwarf/java
mkdir $DIR
APP=${0#./mk}
DIR=/tmp/appdwarf/$APP
mkdir -p "$DIR"
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
appdwarf $DIR "$@"
mv $DIR.sh java
rm -rf $DIR
curl -L "$LINK" | tar xz -C"$DIR"
mv "$DIR"/jdk*/* "$DIR"
appdwarf -b "$DIR"/AppRun
appdwarf "$DIR" "$@"
mv "$DIR".sh "$APP"
rm -rf "$DIR"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,19 +1,15 @@
#!/bin/sh
PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH
DIR=/tmp/appdwarf/wine
mkdir -p $DIR
APP=${0#./mk}
DIR=/tmp/appdwarf/$APP
mkdir -p "$DIR"
VER=Kron4ek/Wine-Builds
[ "$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)
curl -L "$LINK" | bsdtar xf - -C$DIR
mv $DIR/wine*/* $DIR/GE-Proton*/files/* $DIR
cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR
sed -i 4s#/#/bin/# $DIR/AppRun
t=winetricks; wget -O$DIR/bin/$t github.com/$t/$t/raw/master/src/$t
chmod +x $DIR/bin/$t
appdwarf $DIR "$@"
mv $DIR.sh wine
rm -rf $DIR
curl -L "$LINK" | bsdtar xf - -C"$DIR"
mv "$DIR"/wine*/* "$DIR"/GE-Proton*/files/* "$DIR"
t=winetricks; wget -O"$DIR"/bin/$t github.com/$t/$t/raw/master/src/$t
chmod +x "$DIR"/bin/$t
appdwarf -b "$DIR"/AppRun
appdwarf "$DIR" "$@"
mv "$DIR".sh wine
rm -rf "$DIR"

View File

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