appdwarf/mkjava

25 lines
715 B
Bash
Executable file

#!/bin/bash
PATH=$(dirname $(readlink -f "${0}")):$PATH
DIR=/tmp/dwarf-portable-executable/java
mkdir -p $DIR
LINK=$(curl https://api.github.com/repos/adoptium/temurin$1-binaries/releases/latest | jq .assets[].browser_download_url | grep 'jdk_x64_linux_hotspot' | cut -d\" -f2)
curl -L $LINK | tar xz -C$DIR
$DIR/jdk*/bin/jlink --add-modules ALL-MODULE-PATH --output $DIR/jre --strip-debug --no-man-pages --no-header-files --compress=0
JDK=$DIR/jre
ver=$1
cat > $JDK/AppRun << 'EOF'
#!/bin/sh
HERE=$(dirname $(readlink -f "${0}"))
export LD_LIBRARY_PATH="${HERE}":$PATH
"${HERE}"/bin/java $@
rm -r ~/javasharedresources
EOF
chmod +x $JDK/AppRun
shift
appdwarf $JDK $@
mv $(basename $JDK).sh java$ver
rm -rf $DIR