summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMadeline Mewmews2024-04-07 15:51:13 -0500
committerMadeline Mewmews2024-04-07 15:51:13 -0500
commit3c0f067d8957671d24171ce2875e7f07f9a7317b (patch)
tree47d37b9cd76fa0a1997d3698fcca6391e0bd4db0
downloadaur-jdk22-graalvm-bin.tar.gz
inital commit
-rw-r--r--.SRCINFO23
-rw-r--r--.gitignore9
-rw-r--r--PKGBUILD37
-rw-r--r--graalvm-rebuild-libpolyglot.hook11
-rw-r--r--jdk22-graalvm-bin.install47
-rwxr-xr-xtest.sh80
6 files changed, 207 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..6e94358286cc
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,23 @@
+pkgbase = jdk22-graalvm-bin
+ pkgdesc = Universal virtual machine for running applications written in a variety of languages (JVM-based, LLVM-based, or other), Java 22 version
+ pkgver = 22.0.0
+ pkgrel = 1
+ url = https://www.graalvm.org/
+ install = jdk22-graalvm-bin.install
+ arch = x86_64
+ arch = aarch64
+ license = custom
+ depends = java-runtime-common
+ depends = java-environment-common
+ provides = java-runtime=22
+ provides = java-environment=22
+ replaces = native-image-jdk22-bin
+ options = staticlibs
+ source = graalvm-rebuild-libpolyglot.hook
+ sha256sums = eae72b5a2a2826eed7e4be5710d33f82934622a390ab6a9f009ed7753359e02e
+ source_x86_64 = https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-22.0.0/graalvm-community-jdk-22.0.0_linux-x64_bin.tar.gz
+ sha256sums_x86_64 = e5eeb486a23101753f18181d002c3ede9da13c463fb61d3ea448abe774db0657
+ source_aarch64 = https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-22.0.0/graalvm-community-jdk-22.0.0_linux-aarch64_bin.tar.gz
+ sha256sums_aarch64 = da9a0e11b110ebccff33ade502516d00f574ec3247868007e452cef4143e0904
+
+pkgname = jdk22-graalvm-bin
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..3372492e0b3b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+# source
+/*.tar.gz
+
+# build
+/src/
+/pkg/
+
+# package
+/*.pkg.tar*
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..2bc811f14124
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,37 @@
+# Maintainer: Madeline Mewmews <maddie at mewmews dot gay>
+# Contributor: Lucas Werkmeister <mail@lucaswerkmeister.de>
+# Contributor: <asamk(at)gmx.de>
+
+pkgver=22.0.0
+java_=${pkgver%%.*}
+graal_=${java_}+36.1
+pkgname="jdk${java_}-graalvm-bin"
+pkgrel=1
+pkgdesc="Universal virtual machine for running applications written in a variety of languages (JVM-based, LLVM-based, or other), Java ${java_} version"
+arch=('x86_64'
+ 'aarch64')
+url='https://www.graalvm.org/'
+license=('custom')
+depends=('java-runtime-common'
+ 'java-environment-common')
+makedepends=()
+provides=("java-runtime=${java_}"
+ "java-environment=${java_}")
+replaces=("native-image-jdk${java_}-bin")
+options=('staticlibs')
+install="$pkgname.install"
+source=('graalvm-rebuild-libpolyglot.hook')
+sha256sums=('eae72b5a2a2826eed7e4be5710d33f82934622a390ab6a9f009ed7753359e02e')
+sha256sums_x86_64=('e5eeb486a23101753f18181d002c3ede9da13c463fb61d3ea448abe774db0657')
+sha256sums_aarch64=('da9a0e11b110ebccff33ade502516d00f574ec3247868007e452cef4143e0904')
+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")
+
+package() {
+ cd "graalvm-community-openjdk-${graal_}"
+ mkdir -p "$pkgdir/usr/lib/jvm/java-${java_}-graalvm/"
+ cp -a -t "$pkgdir/usr/lib/jvm/java-${java_}-graalvm/" *
+ install -DTm644 LICENSE_NATIVEIMAGE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+ sed "s/JAVA/${java_}/g" < "../graalvm-rebuild-libpolyglot.hook" > "graalvm-jdk${java_}-rebuild-libpolyglot.hook"
+ install -DTm644 "graalvm-jdk${java_}-rebuild-libpolyglot.hook" "$pkgdir/usr/share/libalpm/hooks/graalvm-jdk${java_}-rebuild-libpolyglot.hook"
+}
diff --git a/graalvm-rebuild-libpolyglot.hook b/graalvm-rebuild-libpolyglot.hook
new file mode 100644
index 000000000000..9f35151d15ab
--- /dev/null
+++ b/graalvm-rebuild-libpolyglot.hook
@@ -0,0 +1,11 @@
+[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."
diff --git a/jdk22-graalvm-bin.install b/jdk22-graalvm-bin.install
new file mode 100644
index 000000000000..e9be22c978f3
--- /dev/null
+++ b/jdk22-graalvm-bin.install
@@ -0,0 +1,47 @@
+THIS_JDK='java-22-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
+ /usr/bin/archlinux-java unset
+ fi
+}
diff --git a/test.sh b/test.sh
new file mode 100755
index 000000000000..053484fda0e7
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+java_=$(source PKGBUILD && echo $java_)
+
+if ! tmpdir=$(mktemp --directory --tmpdir graalvm-test.XXXX); then
+ exit
+fi
+cd -- "$tmpdir" || exit
+function cleanup {
+ cd / || exit
+ rm -rf -- "$tmpdir"
+}
+trap cleanup EXIT
+PATH=/usr/lib/jvm/java-${java_}-graalvm/bin/:$(systemd-path search-binaries-default)
+
+printf '%s\n' 'Testing Node with polyglot R, Python, Ruby, JavaScript, and Java...'
+
+jsThree=$(node --polyglot --jvm << 'EOF'
+rPlus = Polyglot.eval('R', '(function(s1, s2) s1 + s2)');
+pythonPlus = Polyglot.eval('python', 'lambda s1, s2: s1 + s2');
+rubyOne = Polyglot.eval('ruby', '1')
+pythonOne = Polyglot.eval('python', '1')
+jsOne = 1
+jvmPrint = Java.type('java.lang.System').out.println
+jvmPrint(pythonPlus(rPlus(rubyOne, pythonOne), jsOne))
+EOF
+) || exit
+if [[ $jsThree != 3 ]]; then
+ printf 'expected 3, got %q\n' "$rThree"
+ exit 1
+fi
+
+printf '%s\n' 'Testing native image...'
+
+cat > Test.java << 'EOF'
+public class Test {
+ public static void main(String[] args) {
+ System.out.println("Hello, world!");
+ }
+}
+EOF
+javac Test.java || exit
+native-image Test > /dev/null || exit
+
+helloWorld=$(./test) || exit
+if [[ $helloWorld != 'Hello, world!' ]]; then
+ printf 'expected "Hello, world!", got %q\n' "$helloWorld"
+ exit 1
+fi
+
+printf '%s\n' 'Testing Espresso...'
+
+# reusing the same Test.java / Test.class
+helloWorld=$(java -truffle Test) || exit
+if [[ $helloWorld != 'Hello, world!' ]]; then
+ printf 'expected "Hello, world!", got %q\n' "$helloWorld"
+ exit 1
+fi
+
+printf '%s\n' 'Testing GraalWASM...'
+
+PATH=$PATH:/usr/lib/emscripten
+
+cat > hello.c << 'EOF'
+#include <stdio.h>
+
+int main() {
+ printf("Hello, WASM!\n");
+ return 0;
+}
+EOF
+nice -n19 emcc -o hello.wasm hello.c 2>/dev/null || exit
+
+helloWorld=$(wasm --Builtins=wasi_snapshot_preview1 hello.wasm) || exit
+if [[ $helloWorld != 'Hello, WASM!' ]]; then
+ printf 'expected "Hello, WASM!", got %q\n' "$helloWorld"
+ exit 1
+fi
+
+printf '%s\n' 'Done.'