Skip to content

Instantly share code, notes, and snippets.

@lucaswerkmeister
Created September 30, 2023 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucaswerkmeister/c4a8f5f1f5bcd46852d1c028c01ae2f2 to your computer and use it in GitHub Desktop.
Save lucaswerkmeister/c4a8f5f1f5bcd46852d1c028c01ae2f2 to your computer and use it in GitHub Desktop.
Provisional jdk-graalvm-bin AUR package
# source
/*.tar.gz
# build
/src/
/pkg/
# package
/*.pkg.tar*
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Operation = Remove
Target = usr/lib/jvm/java-JAVA-graalvm/*
[Action]
Description = Suggest rebuilding GraalVM libpolyglot component
When = PostTransaction
Exec = /usr/bin/printf '%s\n' 'Changes to GraalVM detected.' 'You may need to rebuild libpolyglot (and possibly other components) with the following command:' ' /usr/lib/jvm/java-JAVA-graalvm/bin/gu rebuild libpolyglot' "Note that this will take a while (which is why it's not done automatically):" 'the package maintainer has experienced CPU times upwards of _four hours_.' '(However, it parallelizes fairly well, so wall-clock time will depend on your CPU.)' "If you don't rebuild libpolyglot, then --polyglot without --jvm probably won't work right."
THIS_JDK='java-21-graalvm'
fix_default() {
if [ ! -x /usr/bin/java ]; then
/usr/bin/archlinux-java unset
echo ""
else
/usr/bin/archlinux-java get
fi
}
post_install() {
default=$(fix_default)
case ${default} in
"")
/usr/bin/archlinux-java set ${THIS_JDK}
;;
${THIS_JDK})
# Nothing
;;
*)
echo "Default Java environment is already set to '${default}'"
echo "See 'archlinux-java help' to change it"
;;
esac
if [ ! -f /etc/ssl/certs/java/cacerts ]; then
/usr/bin/update-ca-trust
fi
}
post_upgrade() {
default=$(fix_default)
if [ -z "${default}" ]; then
/usr/bin/archlinux-java set ${THIS_JDK}
fi
if [ ! -f /etc/ssl/certs/java/cacerts ]; then
/usr/bin/update-ca-trust
fi
}
pre_remove() {
if [ "x$(fix_default)" = "x${THIS_JDK}" ]; then
# Check JRE is still available
if [ -x /usr/lib/jvm/${THIS_JDK}/bin/java ]; then
/usr/bin/archlinux-java unset
fi
fi
}
# Maintainer: Lucas Werkmeister <mail@lucaswerkmeister.de>
pkgname=jdk-graalvm-bin
pkgver=21.0.0
java_=${pkgver%%.*}
plusver_=35.1
pkgrel=1
pkgdesc='Universal virtual machine for running applications written in a variety of languages (JVM-based, LLVM-based, or other)'
arch=('x86_64'
'aarch64')
url='https://www.graalvm.org/'
license=('custom')
depends=('java-runtime-common'
'java-environment-common'
'ca-certificates-utils')
makedepends=()
provides=("java-runtime=${java_}"
"java-environment=${java_}")
backup=('etc/java-graalvm/jaxp.properties'
'etc/java-graalvm/logging.properties'
'etc/java-graalvm/management/jmxremote.access'
'etc/java-graalvm/management/jmxremote.password.template'
'etc/java-graalvm/management/management.properties'
'etc/java-graalvm/net.properties'
'etc/java-graalvm/sdp/sdp.conf.template'
'etc/java-graalvm/security/java.policy'
'etc/java-graalvm/security/java.security'
'etc/java-graalvm/security/policy/README.txt'
'etc/java-graalvm/security/policy/limited/default_US_export.policy'
'etc/java-graalvm/security/policy/limited/default_local.policy'
'etc/java-graalvm/security/policy/limited/exempt_local.policy'
'etc/java-graalvm/security/policy/unlimited/default_US_export.policy'
'etc/java-graalvm/security/policy/unlimited/default_local.policy'
'etc/java-graalvm/sound.properties')
options=('staticlibs')
install="$pkgname.install"
source=('graalvm-rebuild-libpolyglot.hook')
sha256sums=('SKIP')
source_x86_64=("https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${pkgver}/graalvm-community-jdk-${pkgver}_linux-x64_bin.tar.gz")
source_aarch64=("https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${pkgver}/graalvm-community-jdk-${pkgver}_linux-aarch64_bin.tar.gz")
sha256sums_x86_64=('6c422941ccc58be5b891bb6499feeb72cd2b74d6729a29bf1fb8cc1a7d58b319')
sha256sums_aarch64=('bb4e92cf7eae91e474061aeae5ae75053a65cd558dbee76947827bf54d1b30a5')
package() {
cd "graalvm-community-openjdk-${java_}+${plusver_}"
mkdir -p "$pkgdir/usr/lib/jvm/java-${java_}-graalvm/"
cp -a -t "$pkgdir/usr/lib/jvm/java-${java_}-graalvm/" bin/ include/ jmods/ lib/ release
# conf (installed + symlinked in /etc)
install -dm 755 "${pkgdir}/etc"
cp -r conf "${pkgdir}/etc/java-graalvm"
ln -s /etc/java-graalvm "${pkgdir}/usr/lib/jvm/java-${java_}-graalvm/conf"
# legal (installed + symlinked in /usr/share/licenses)
install -dm 755 "${pkgdir}/usr/share/licenses"
cp -r legal "${pkgdir}/usr/share/licenses/${pkgname}"
ln -s "/usr/share/licenses/${pkgname}" "${pkgdir}/usr/lib/jvm/java-${java_}-graalvm/legal"
# link JKS keystore from ca-certificates-utils
ln -sfT /etc/ssl/certs/java/cacerts "${pkgdir}/usr/lib/jvm/java-${java_}-graalvm/lib/security/cacerts"
install -Dm644 lib/svm/LICENSE_NATIVEIMAGE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE_NATIVEIMAGE.txt"
sed "s/JAVA/${java_}/g" < '../graalvm-rebuild-libpolyglot.hook' > 'graalvm-rebuild-libpolyglot.hook'
install -Dm644 'graalvm-rebuild-libpolyglot.hook' "$pkgdir/usr/share/libalpm/hooks/graalvm-rebuild-libpolyglot.hook"
}
@lucaswerkmeister
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment