summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Werkmeister2021-07-31 19:07:13 +0200
committerLucas Werkmeister2021-07-31 19:18:10 +0200
commite647c333799df416782f9686ca64eb0dbff0f94b (patch)
tree5684895871c3b3440b1c0e6bf1f2616011037d0d
parent56986527709ca30d38ba000083492ec6f686af73 (diff)
downloadaur-e647c333799df416782f9686ca64eb0dbff0f94b.tar.gz
Install alpm hook recommending `gu rebuild libpolyglot`
Apparently the only reason that the `node --polyglot` added to test.sh in the previous commit worked on my system is that it silently fell back to `node --polyglot --jvm`; however, it’s *supposed* to run polyglot Node + everything else as a native image, without a JVM. And apparently, R can’t be built as a native image (for engineering reasons, I’ve been told), so if it doesn’t fall back to --jvm mode, then our test doesn’t work. Consequently, we should actually specify --polyglot --jvm. The fallback happens when libpolyglot.so is missing. It’s supposed to be built by `gu rebuild libpolyglot`, and apparently `gu` prints a message recommending that you run this command when you use it to install a new language; since we bypass gu, we should print a similar message in our package installation process. We don’t directly run the command for the same reason that gu doesn’t: it’s way too expensive, requiring over four hours of CPU time on my system. Even as a hook, rather than a post-install script (i.e. only running once at the end of all package installs, not once per package), I can’t justify this expenditure for everyone installing the package, especially since most people probably won’t need this (evidently I’ve been using GraalVM for years without ever having built libpolyglot.so). So we just make the hook print a message for users, and they can hopefully decide for themselves if they want to run the command or not. (If people ask about the message in the AUR comments, we can probably iterate on the phrasing a bit.)
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD6
-rw-r--r--graalvm-rebuild-libpolyglot.hook11
-rwxr-xr-xtest.sh2
4 files changed, 20 insertions, 3 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 62ece52c9de9..a95371a9a816 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = jdk11-graalvm-bin
pkgdesc = Universal virtual machine for running applications written in a variety of languages (JVM-based, LLVM-based, or other), Java 11 version
pkgver = 21.2.0
- pkgrel = 1
+ pkgrel = 2
url = https://www.graalvm.org/
install = jdk11-graalvm-bin.install
arch = x86_64
@@ -13,6 +13,8 @@ pkgbase = jdk11-graalvm-bin
provides = java-runtime=11
provides = java-environment=11
options = staticlibs
+ source = graalvm-rebuild-libpolyglot.hook
+ sha256sums = SKIP
source_x86_64 = https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.2.0/graalvm-ce-java11-linux-amd64-21.2.0.tar.gz
sha256sums_x86_64 = bbd3e03025168172a76c2a29e6a14c1c37e3476b30774259c3ef5952fb86f470
source_aarch64 = https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.2.0/graalvm-ce-java11-linux-aarch64-21.2.0.tar.gz
diff --git a/PKGBUILD b/PKGBUILD
index 0ba5f0a340df..35bcf9a05944 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,7 +3,7 @@
java_=11
pkgname="jdk${java_}-graalvm-bin"
pkgver=21.2.0
-pkgrel=1
+pkgrel=2
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')
@@ -17,6 +17,8 @@ provides=("java-runtime=${java_}"
"java-environment=${java_}")
options=('staticlibs')
install="$pkgname.install"
+source=('graalvm-rebuild-libpolyglot.hook')
+sha256sums=('SKIP')
source_x86_64=("https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${pkgver}/graalvm-ce-java${java_}-linux-amd64-${pkgver}.tar.gz")
source_aarch64=("https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${pkgver}/graalvm-ce-java${java_}-linux-aarch64-${pkgver}.tar.gz")
sha256sums_x86_64=('bbd3e03025168172a76c2a29e6a14c1c37e3476b30774259c3ef5952fb86f470')
@@ -27,4 +29,6 @@ package() {
mkdir -p "$pkgdir/usr/lib/jvm/java-${java_}-graalvm/"
cp -a -t "$pkgdir/usr/lib/jvm/java-${java_}-graalvm/" *
install -DTm644 LICENSE.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/test.sh b/test.sh
index 0b6209c3adcf..08bddea83689 100755
--- a/test.sh
+++ b/test.sh
@@ -15,7 +15,7 @@ PATH=/usr/lib/jvm/java-${java_}-graalvm/bin/:$(systemd-path search-binaries-defa
printf '%s\n' 'Testing Node with polyglot R, Python, Ruby, JavaScript, and Java...'
-jsThree=$(node --polyglot << 'EOF'
+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')