diff --git a/AppRun b/AppRun index b6c6037..dcbb912 100755 --- a/AppRun +++ b/AppRun @@ -1,5 +1,5 @@ #!/bin/sh HERE=$(dirname "$(readlink -f "${0}")") -#export PATH="${HERE}":"${HERE}"/bin:"$PATH" -#export LD_LIBRARY_PATH="${HERE}"/lib64:"${HERE}"/lib:"$LD_LIBRARY_PATH" +export PATH="${HERE}":"${HERE}"/bin:"$PATH" +export LD_LIBRARY_PATH="${HERE}"/lib64:"${HERE}"/lib:"$LD_LIBRARY_PATH" "${HERE}"/"$APPDWARF_CMD" "$@" diff --git a/appdwarf b/appdwarf index a3787ba..098275e 100755 --- a/appdwarf +++ b/appdwarf @@ -1,61 +1,62 @@ -#!/bin/bash -set -eo pipefail -IFS=$'\n\t' -VER=2 +#!/bin/sh +set -e +IFS=$(printf '\n\t') +VER=2.5 +BACK=5 HERE=$(dirname "$(readlink -f "${0}")") -source "$HERE/headers" +. "$HERE/headers" && header || exit 1 -usage(){ +if test $# -eq 0; then + tput setaf 3 echo "Usage: $(basename "$0") [option] [FILE/FOLDER/URL] [dwarfs option]" echo " Compress a given AppDir (default)" + tput setaf 7 echo " -a, --appimage Convert a given AppImage to appdwarf" echo " -B, --lookback Change dwarfs block lookback amount" echo " -f, --folder Make image mount to a specified folder instead of running AppRun" echo " -s, --separate Use old, separated header format" echo " -u, --url Fetch AppImage from URL and convert to appdwarf" - + echo + tput setaf 4 echo " -h, --help Print this help text" echo " -v, --version Print the appdwarf version" -} + exit 0 +fi dwarf() { - mkdwarfs -i "$1" -o "$(realpath "$1").sh" -B"$back" "${@:2}" --header "$HEAD" + mkdwarfs -i "$@" -o "$(realpath "$1").sh" -B"$BACK" --header "$HEAD" chmod +x "$(realpath "$1").sh" } appimage() { - if [[ -f "$1" ]] - then - chmod +x "$1" - rm -rf squashfs-root - case $1 in - /*) "$1" --appimage-extract || exit 1 ;; - *) ./"$1" --appimage-extract || exit 1 ;; - esac - dwarf squashfs-root "${@:2}" - rm -rf squashfs-root "$1" - mv squashfs-root.sh "$(basename "$1" .AppImage)".sh - else + if [ ! -f "$1" ]; then + tput setaf 1 echo "$1" is not a valid file exit 1 fi + chmod +x "$1" + rm -rf squashfs-root + case $1 in + /*) "$1" --appimage-extract || exit 1 ;; + *) ./"$1" --appimage-extract || exit 1 ;; + esac + file="$1" + shift + dwarf squashfs-root "$@" + rm -rf squashfs-root "$file" + mv squashfs-root.sh "$(basename "$file" .AppImage)".sh + exit 0 } -################################################################ - -header -back=5 - while true do case "$1" in --help | -h) - usage - exit 0 + exec appdwarf ;; --version | -v) - tput setaf 2 + tput setaf 5 echo appdwarf v"$VER" echo Maintained by phantop. exit 0 @@ -65,7 +66,7 @@ do shift 2 ;; --lookback | -B) - back=$2 + BACK=$2 shift 2 ;; --separate | -s) @@ -74,18 +75,19 @@ do ;; --appimage | -a) - appimage "${@:2}" - exit 0 + shift + appimage "$@" ;; --url | -u) - file=$(basename "$2") + shift + file=$(basename "$1") if which aria2c; then - aria2c -x16 -s16 "$2" -o "$file" || exit 1 + aria2c -x16 -s16 "$1" -o "$file" || exit 1 else - wget "$2" -O "$file" || exit 1 + wget "$1" -O "$file" || exit 1 fi - appimage "$file" "${@:3}" - exit 0 + shift + appimage "$file" "$@" ;; --) shift; break;; @@ -94,10 +96,4 @@ do esac done -if test $# -eq 0; then - usage - exit 0 -else - dwarf "$@" - exit 0 -fi +dwarf "$@" diff --git a/apps/appimage b/apps/appimage index ef47cc9..9755c04 100755 --- a/apps/appimage +++ b/apps/appimage @@ -1,2 +1,2 @@ -#!/bin/bash -./github https://raw.githubusercontent.com/AppImage/appimage.github.io/master/apps/$1.md +#!/bin/sh +./github https://raw.githubusercontent.com/AppImage/appimage.github.io/master/apps/"$1".md diff --git a/apps/github b/apps/github index 680e6a6..a3db5a4 100755 --- a/apps/github +++ b/apps/github @@ -1,10 +1,11 @@ -#!/bin/bash -if ! grep https <<< "$1"; then +#!/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 ! grep github.com <<< "$1"; then +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)" -appdwarf "${@:2}" -u "$LINK3" +shift +appdwarf "$@" -u "$LINK3" diff --git a/apps/mkchrome b/apps/mkchrome index bf2d94f..27e47ef 100755 --- a/apps/mkchrome +++ b/apps/mkchrome @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf mkdir -p $DIR diff --git a/apps/mkdotnet b/apps/mkdotnet index 4f64994..e0da79c 100755 --- a/apps/mkdotnet +++ b/apps/mkdotnet @@ -1,10 +1,10 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf/dotnet 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 +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 diff --git a/apps/mkgo b/apps/mkgo index 74cc346..61d9b43 100755 --- a/apps/mkgo +++ b/apps/mkgo @@ -1,18 +1,12 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf mkdir -p $DIR 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 -cat > $DIR/go/AppRun << 'EOF' -#!/bin/sh -HERE=$(dirname $(readlink -f "${0}")) -export LD_LIBRARY_PATH="${HERE}":$PATH -"${HERE}"/bin/go $@ -EOF - -chmod +x $DIR/go/AppRun +cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/go +sed 5s#/#/bin/# $DIR/go/AppRun appdwarf $DIR/go mv $DIR/go.sh go diff --git a/apps/mkjava b/apps/mkjava index 39c9a1b..170982c 100755 --- a/apps/mkjava +++ b/apps/mkjava @@ -1,25 +1,18 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf/java -JRE=$DIR/jre -VER=$1 mkdir -p $DIR - -LINK=https://api.adoptium.net/v3/binary/latest/$1/ga/linux/x64/jdk/hotspot/normal/eclipse -curl -L "$LINK" | tar xz -C$DIR -$DIR/jdk*/bin/jlink --add-modules ALL-MODULE-PATH --output $JRE --strip-debug --no-man-pages --no-header-files --compress=0 - - -cat > $JRE/AppRun << 'EOF' -#!/bin/sh -HERE=$(dirname $(readlink -f "${0}")) -export LD_LIBRARY_PATH="${HERE}":$PATH -"${HERE}"/bin/java $@ -rm -rf ~/javasharedresources -EOF -chmod +x $JRE/AppRun - +VER=$1 shift -appdwarf $JRE $@ -mv $JRE.sh java"$VER" + +LINK=https://api.adoptium.net/v3/binary/latest/$VER/ga/linux/x64/jdk/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 + +cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/jre +sed -i 5s#/#/bin/# $DIR/jre/AppRun + +appdwarf $DIR/jre "$@" +mv $DIR/jre.sh java"$VER" rm -rf $DIR diff --git a/apps/mkmusl b/apps/mkmusl index 995d63e..db90038 100755 --- a/apps/mkmusl +++ b/apps/mkmusl @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf mkdir -p $DIR diff --git a/apps/mknode b/apps/mknode index 0f3b472..471363d 100755 --- a/apps/mknode +++ b/apps/mknode @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf mkdir -p $DIR @@ -8,13 +8,9 @@ curl -L "$LINK" | bsdtar xf - -C$DIR mv $DIR/node* $DIR/node strip $DIR/node/bin/node -cat > $DIR/node/AppRun << 'EOF' -#!/bin/sh -HERE=$(dirname $(readlink -f "${0}")) -export PATH="${HERE}/bin":$PATH -"${HERE}"/bin/$APPDWARF_CMD $@ -EOF -chmod +x $DIR/node/AppRun + +cp "$(dirname "$(readlinjrek -f "${0}")")"/../AppRun $DIR/node +sed -i 5s#/#/bin/# $DIR/node/AppRun appdwarf $DIR/node mv $DIR/node.sh node diff --git a/apps/mkproton b/apps/mkproton index 37be4ac..d82cba9 100755 --- a/apps/mkproton +++ b/apps/mkproton @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf/proton mkdir -p $DIR @@ -12,8 +12,8 @@ wget -O$DIR/winetricks https://raw.githubusercontent.com/Winetricks/winetricks/m chmod +x $DIR/winetricks cat > $DIR/AppRun << 'EOF' -#!/bin/bash -HERE="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +#!/bin/sh +HERE=$(dirname "$(readlink -f "${0}")") export WINE="${HERE}"/bin/wine export WINE64="${HERE}"/bin/wine64 @@ -35,6 +35,6 @@ fi EOF chmod +x $DIR/AppRun -appdwarf $DIR $@ +appdwarf $DIR "$@" rm -rf $DIR mv $DIR.sh proton diff --git a/apps/mkpypy b/apps/mkpypy index b5ce3d5..4d3a6ba 100755 --- a/apps/mkpypy +++ b/apps/mkpypy @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf mkdir -p $DIR diff --git a/apps/mkrust b/apps/mkrust index 6baabb9..9dff0b7 100755 --- a/apps/mkrust +++ b/apps/mkrust @@ -1,21 +1,17 @@ -#!/bin/bash -PATH=$(dirname $(readlink -f "${0}"))/..:$PATH +#!/bin/sh +PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf +ARCH=x86_64-unknown-linux-gnu mkdir -p $DIR -LINK=https://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz +LINK=https://static.rust-lang.org/dist/rust-nightly-$ARCH.tar.gz curl -L $LINK | tar xz -C$DIR mkdir $DIR/rust -cp -r $DIR/rust*/{cargo,rustc,rust-std*}/* $DIR/rust +for i in cargo rustc rust-std-$ARCH/; do + mv "$DIR/rust-nightly-$ARCH/$i"/* $DIR/rust; done -cat > $DIR/rust/AppRun << 'EOF' -#!/bin/sh -HERE=$(dirname $(readlink -f "${0}")) -export PATH="${HERE}/bin":$PATH -"${HERE}"/bin/$APPDWARF_CMD $@ -EOF - -chmod +x $DIR/rust/AppRun +cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/rust +sed -i 5s#/#/bin/# $DIR/rust/AppRun appdwarf $DIR/rust mv $DIR/rust.sh cargo diff --git a/apps/mktex b/apps/mktex index d6c51b0..45b5ef1 100755 --- a/apps/mktex +++ b/apps/mktex @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh PATH="$(dirname "$(readlink -f "${0}")")/..":"$PATH" DIR=/tmp/appdwarf mkdir -p $DIR @@ -42,6 +42,10 @@ 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}")") diff --git a/apps/mkwine b/apps/mkwine index 6255744..b29d810 100755 --- a/apps/mkwine +++ b/apps/mkwine @@ -1,10 +1,10 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf/wine mkdir -p $DIR LINK="$(curl https://api.github.com/repos/Kron4ek/Wine-Builds/releases | grep -om1 http.\*-staging-tkg-amd64.tar.xz)" -curl -L $LINK | tar xJ -C$DIR +curl -L "$LINK" | tar xJ -C$DIR mv $DIR/wine*/* $DIR rmdir $DIR/wine*/ @@ -12,9 +12,8 @@ wget -O$DIR/winetricks https://raw.githubusercontent.com/Winetricks/winetricks/m chmod +x $DIR/winetricks cat > $DIR/AppRun << 'EOF' -#!/bin/bash -HERE="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" - +#!/bin/sh +HERE=$(dirname "$(readlink -f "${0}")") export WINE="${HERE}"/bin/wine export WINE64="${HERE}"/bin/wine64 export WINESERVER="${HERE}"/bin/wineserver @@ -35,6 +34,6 @@ fi EOF chmod +x $DIR/AppRun -appdwarf $DIR $@ +appdwarf $DIR "$@" rm -r $DIR mv $DIR.sh wine diff --git a/apps/rustsolus b/apps/rustsolus index 8971a6d..aa853ca 100755 --- a/apps/rustsolus +++ b/apps/rustsolus @@ -1,25 +1,15 @@ -#!/bin/bash +#!/bin/sh PATH=$(dirname "$(readlink -f "${0}")")/..:$PATH DIR=/tmp/appdwarf/rust mkdir -p $DIR eopkg fc -o $DIR cargo rust -unzip -o $DIR/cargo* -d$DIR -tar xJf $DIR/install.tar.xz -C$DIR -unzip -o $DIR/rust* -d$DIR -tar xJf $DIR/install.tar.xz -C$DIR -rm $DIR/* +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 -cat > $DIR/usr/AppRun << 'EOF' -#!/bin/sh -HERE=$(dirname $(readlink -f "${0}")) -export PATH="${HERE}/bin":$PATH -export LD_LIBRARY_PATH="${HERE}"/lib64:$LD_LIBRARY_PATH -"${HERE}"/bin/$APPDWARF_CMD $@ -EOF - -chmod +x $DIR/usr/AppRun +cp "$(dirname "$(readlink -f "${0}")")"/../AppRun $DIR/usr +sed -i 5s#/#/bin/# $DIR/usr/AppRun appdwarf $DIR/usr mv $DIR/usr.sh cargo diff --git a/headers b/headers index 20b73c0..9290bb4 100755 --- a/headers +++ b/headers @@ -1,11 +1,11 @@ -#!/bin/bash +#!/bin/sh HEAD=/tmp/dwarfhead header_separate() { cat > $HEAD << 'EOF' #!/bin/sh -DIR="$(mktemp -td dwarf_$(basename "$0")XXXXX)" +DIR="$(mktemp -td dwarf_"$(basename "$0")"XXXXX)" ARG="-o offset=auto -o tidy_strategy=swap -o workers=4" -export APPDWARF_CMD=$(basename "$0") +export APPDWARF_CMD="$(basename "$0")" dwarfs $ARG "$0" "$DIR" 2>/dev/null "$DIR/AppRun" "$@" @@ -19,8 +19,8 @@ header() { cat > $HEAD << 'EOF' #!/bin/sh DIR="/tmp/dwarf_$(basename "$0")$(echo "$0" | md5sum | head -c5)" -export APPDWARF_CMD=$(basename "$0") -if [ ! -d $DIR ]; then +export APPDWARF_CMD="$(basename "$0")" +if [ ! -d "$DIR" ]; then mkdir "$DIR" ARG="-o offset=auto -o tidy_strategy=swap -o workers=4" dwarfs $ARG "$0" "$DIR" 2>/dev/null diff --git a/zzexe b/zzexe index 45eb559..2111df5 100755 --- a/zzexe +++ b/zzexe @@ -1,7 +1,9 @@ #!/bin/sh +# shellcheck disable=SC2016,SC2129 + tmp=$(mktemp -u) if [ "$1" = "-d" ]; then - shift + shift #decompress tail -n +11 "$1" | zstd -do "$tmp" && mv "$tmp" "$1" chmod +x "$1" @@ -14,6 +16,7 @@ if [ "$1" = "-p" ]; then shift fi +#file header echo '#!/bin/sh' >> "$tmp" echo 'out=$(mktemp -t .zzXXXX.'"${1##*.}"\) >> "$tmp" cat >> "$tmp" << 'EOF' @@ -29,6 +32,7 @@ rm "$out" "$dir"/$(basename $out) exit $res EOF +#compress zstdmt --ultra -c22 --long "$1" >> "$tmp" || exit 1 mv "$tmp" "$1" chmod +x "$1"