summary refs log tree commit diff
path: root/gnu/packages/java.scm
diff options
context:
space:
mode:
authorBjörn Höfling <bjoern.hoefling@bjoernhoefling.de>2021-02-12 00:20:53 +0100
committerLeo Prikler <leo.prikler@student.tugraz.at>2021-02-12 11:40:10 +0100
commit44425e1f2a96aee39a21dff634abb9b77b44261e (patch)
tree493862028e9c83e2a65bd6e8784535d9d69d6429 /gnu/packages/java.scm
parent84805ef205b7fa12bfaa7b23da06993cab64c40b (diff)
downloadguix-44425e1f2a96aee39a21dff634abb9b77b44261e.tar.gz
gnu: openjdk@11: Add phase to hardcode libraries.
This fixes a NullPointerException related to using fontconfig,
see also <https://bugs.gnu.org/41177>.

* gnu/packages/java.scm (openjdk11)[arguments]: Add patch-jni-libs phase.

Signed-off-by: Leo Prikler <leo.prikler@student.tugraz.at>
Diffstat (limited to 'gnu/packages/java.scm')
-rw-r--r--gnu/packages/java.scm27
1 files changed, 27 insertions, 0 deletions
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index a63dad8755..85ca37d8b6 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -2139,6 +2139,33 @@ new Date();"))
              (substitute* "make/data/blacklistedcertsconverter/blacklisted.certs.pem"
                (("^#!.*") "#! java BlacklistedCertsConverter SHA-256\n"))
              #t))
+         (add-after 'unpack 'patch-jni-libs
+           ;; Hardcode dynamically loaded libraries.
+           (lambda _
+             (let* ((library-path (search-path-as-string->list
+                                   (getenv "LIBRARY_PATH")))
+                    (find-library (lambda (name)
+                                    (search-path
+                                     library-path
+                                     (string-append "lib" name ".so")))))
+               (for-each
+                (lambda (file)
+                  (catch 'decoding-error
+                    (lambda ()
+                      (substitute* file
+                        (("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", \"(.*)\"\\)"
+                          _ name version)
+                         (format #f "\"~a\""  (find-library name)))
+                        (("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name)
+                         (format #f "\"~a\"" (find-library name)))))
+                    (lambda _
+                      ;; Those are safe to skip.
+                      (format (current-error-port)
+                                      "warning: failed to substitute: ~a~%"
+                                      file))))
+                (find-files "."
+                            "\\.c$|\\.h$"))
+               #t)))
          (add-before 'build 'write-source-revision-file
            (lambda _
              (with-output-to-file ".src-rev"