Message ID | 871t0sy206.fsf@member.fsf.org |
---|---|
State | New |
Headers | show |
iyzsong@member.fsf.org (宋文武) skribis: > From 1d0dce6f0c40fa35162ecb441b53b32f77dd5b8d Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com> > Date: Thu, 8 Sep 2016 23:25:23 +0800 > Subject: [PATCH] gnu: icedtea-8: Hardcode dynamically loaded libraries. > > Fixes <https://bugs.gnu.org/24327>. > > * gnu/packages/java.scm (icedtea-8)[arguments]: Add 'patch-jni-libs' phase. I’m a bit late, but thanks for fixing it! > + (lambda (file) > + (catch 'encoding-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)))) What often works in such cases is to force ISO-8859-1 encoding (“Latin-1”), which is a “catch-all” encoding (it’s an 8-bit encoding that covers the 256 values): (with-fluids ((%default-port-encoding "ISO-8859-1")) (substitute* file-in-arbitrary-ascii-compatible-encoding …)) Ludo’.
ludo@gnu.org (Ludovic Courtès) writes: > [...] > >> + (lambda (file) >> + (catch 'encoding-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)))) > > What often works in such cases is to force ISO-8859-1 encoding > (“Latin-1”), which is a “catch-all” encoding (it’s an 8-bit encoding > that covers the 256 values): > > (with-fluids ((%default-port-encoding "ISO-8859-1")) > (substitute* file-in-arbitrary-ascii-compatible-encoding > …)) > Yeah, I tried that, but it was also producing 'encoding-error' in the builder, so I gave up it. It seems that's because the locale is "C" when calling `substitute*', and the files have UTF-8 copyright sign (©). But out of the builder, the `substitute*' works fine even with '(setlocale LC_ALL "C")'. Here is an example: --8<---------------cut here---------------start------------->8--- (use-modules (guix packages) (guix build-system gnu)) (package (name "test") (version "0") (source #f) (build-system gnu-build-system) (arguments '(#:phases (modify-phases %standard-phases (replace 'unpack (lambda _ (setlocale LC_ALL "en_US.utf8") (call-with-output-file "test" (lambda (port) (display "©" port))) (setlocale LC_ALL "C") (with-fluids ((%default-port-encoding #f)) (substitute* "test" (("t") "")))))))) (home-page #f) (synopsis #f) (description #f) (license #f)) --8<---------------cut here---------------end--------------->8---
iyzsong@member.fsf.org (宋文武) skribis: > ludo@gnu.org (Ludovic Courtès) writes: [...] >> What often works in such cases is to force ISO-8859-1 encoding >> (“Latin-1”), which is a “catch-all” encoding (it’s an 8-bit encoding >> that covers the 256 values): >> >> (with-fluids ((%default-port-encoding "ISO-8859-1")) >> (substitute* file-in-arbitrary-ascii-compatible-encoding >> …)) >> > > Yeah, I tried that, but it was also producing 'encoding-error' in the > builder, so I gave up it. > > It seems that's because the locale is "C" when calling `substitute*', Weird; the ‘install-locale’ phase normally installs a UTF-8 locale, and the locale shouldn’t matter once we’re overridden ‘%default-port-encoding’. > and the files have UTF-8 copyright sign (©). But out of the builder, > the `substitute*' works fine even with '(setlocale LC_ALL "C")'. Hmm, OK. Subtle things going on. :-) Thanks, Ludo’.
From 1d0dce6f0c40fa35162ecb441b53b32f77dd5b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com> Date: Thu, 8 Sep 2016 23:25:23 +0800 Subject: [PATCH] gnu: icedtea-8: Hardcode dynamically loaded libraries. Fixes <https://bugs.gnu.org/24327>. * gnu/packages/java.scm (icedtea-8)[arguments]: Add 'patch-jni-libs' phase. --- gnu/packages/java.scm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index 7387235..36c10d0 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -994,6 +994,33 @@ build process and its dependencies, whereas Make uses Makefile format.") (delete 'patch-paths) (delete 'set-additional-paths) (delete 'patch-patches) + (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 'encoding-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 "openjdk.src/jdk/src/solaris/native" + "\\.c|\\.h")) + #t))) ;; FIXME: This phase is needed but fails with this version of ;; IcedTea. (delete 'install-keystore) -- 2.8.4