1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-15 19:40:46 +02:00

gnu: opendjk11: Remove trailing #t and use gexps.

* gnu/packages/java.scm (openjdk11): Properly punctuate comments.
[source]: Remove trailing #t in snippet.
[configure-flags]: Use gexps and this-package-input.
[phases]: Delete trailing #t and use gexps to refer to outputs.
This commit is contained in:
Maxim Cournoyer 2022-09-26 16:37:45 -04:00
parent 79b8e52e64
commit e33ab2dd9e
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -1781,234 +1781,224 @@ new Date();"))
"0di91nnms2iq1svgq72r5y17am17r4vh2lq43k0bkcwpc84d6nd8")) "0di91nnms2iq1svgq72r5y17am17r4vh2lq43k0bkcwpc84d6nd8"))
(modules '((guix build utils))) (modules '((guix build utils)))
(snippet (snippet
`(begin '(for-each delete-file (find-files "." ".*.(bin|exe|jar)$")))))
(for-each delete-file (find-files "." ".*.(bin|exe|jar)$"))
#t))))
(build-system gnu-build-system) (build-system gnu-build-system)
(outputs '("out" "jdk" "doc")) (outputs '("out" "jdk" "doc"))
(arguments (arguments
`(#:imported-modules ((guix build syscalls) (list
#:imported-modules `((guix build syscalls)
,@%gnu-build-system-modules) ,@%gnu-build-system-modules)
#:disallowed-references ,(list (gexp-input openjdk10) #:disallowed-references (list (gexp-input openjdk10)
(gexp-input openjdk10 "jdk")) (gexp-input openjdk10 "jdk"))
#:tests? #f; requires jtreg #:tests? #f ; requires jtreg
;; TODO package jtreg ;; TODO package jtreg
#:configure-flags #:configure-flags
`(;; Add flags for compilation with gcc >= 10 #~(list
,(string-append "--with-extra-cflags=-fcommon" ;; Add flags for compilation with gcc >= 10.
" -fno-delete-null-pointer-checks" #$(string-append "--with-extra-cflags=-fcommon"
" -fno-lifetime-dse") " -fno-delete-null-pointer-checks"
"--disable-option-checking" ; --enable-fast-install default flag errors otherwise " -fno-lifetime-dse")
;; Otherwise, the '--enable-fast-install' causes an error.
"--disable-option-checking"
"--disable-warnings-as-errors" "--disable-warnings-as-errors"
;; make validate-runpath pass, see: http://issues.guix.info/issue/32894 ;; Make validate-runpath pass (see:
;; http://issues.guix.info/issue/32894).
"--with-native-debug-symbols=zipped" "--with-native-debug-symbols=zipped"
;; do not use the bundled libraries ;; Do not use the bundled libraries.
"--with-giflib=system" "--with-giflib=system"
"--with-lcms=system" "--with-lcms=system"
"--with-libjpeg=system" "--with-libjpeg=system"
"--with-libpng=system" "--with-libpng=system"
"--with-version-pre=" "--with-version-pre="
;; allow the build system to locate the system freetype ;; Allow the build system to locate the system freetype.
,(string-append "--with-freetype-include=" (string-append "--with-freetype-include="
(assoc-ref %build-inputs "freetype") "/include") #$(this-package-input "freetype") "/include")
,(string-append "--with-freetype-lib=" (string-append "--with-freetype-lib="
(assoc-ref %build-inputs "freetype") "/lib")) #$(this-package-input "freetype") "/lib"))
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'patch-source-shebangs 'fix-java-shebangs (add-after 'patch-source-shebangs 'fix-java-shebangs
(lambda _ (lambda _
;; This file was "fixed" by patch-source-shebangs, but it requires ;; This file was "fixed" by patch-source-shebangs, but it requires
;; this exact first line. ;; this exact first line.
(substitute* "make/data/blockedcertsconverter/blocked.certs.pem" (substitute* "make/data/blockedcertsconverter/blocked.certs.pem"
(("^#!.*") "#! java BlockedCertsConverter SHA-256\n")) (("^#!.*") "#! java BlockedCertsConverter SHA-256\n"))))
#t)) (add-after 'unpack 'patch-jni-libs
(add-after 'unpack 'patch-jni-libs ;; Hardcode dynamically loaded libraries.
;; Hardcode dynamically loaded libraries. (lambda _
(lambda _ (define remove
(define remove (@ (srfi srfi-1) remove))
(@ (srfi srfi-1) remove))
(define (icedtea-or-openjdk? path) (define (icedtea-or-openjdk? path)
(or (string-contains path "openjdk") (or (string-contains path "openjdk")
(string-contains path "icedtea"))) (string-contains path "icedtea")))
(let* ((library-path (remove icedtea-or-openjdk? (let* ((library-path (remove icedtea-or-openjdk?
(search-path-as-string->list (search-path-as-string->list
(getenv "LIBRARY_PATH")))) (getenv "LIBRARY_PATH"))))
(find-library (lambda (name) (find-library (lambda (name)
(or (search-path (or (search-path
library-path library-path
(string-append "lib" name ".so")) (string-append "lib" name ".so"))
(string-append "lib" name ".so"))))) (string-append "lib" name ".so")))))
(for-each (for-each
(lambda (file) (lambda (file)
(catch 'decoding-error (catch 'decoding-error
(lambda () (lambda ()
(substitute* file (substitute* file
(("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", \"(.*)\"\\)" (("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", \"(.*)\"\\)"
_ name version) _ name version)
(string-append "\"" (find-library name) "\"")) (string-append "\"" (find-library name) "\""))
(("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name) (("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name)
(string-append "\"" (find-library name) "\"")))) (string-append "\"" (find-library name) "\""))))
(lambda _ (lambda _
;; Those are safe to skip. ;; Those are safe to skip.
(format (current-error-port) (format (current-error-port)
"warning: failed to substitute: ~a~%" "warning: failed to substitute: ~a~%"
file)))) file))))
(find-files "." (find-files "."
"\\.c$|\\.h$")) "\\.c$|\\.h$")))))
#t))) (add-before 'build 'write-source-revision-file
(add-before 'build 'write-source-revision-file (lambda _
(lambda _ (with-output-to-file ".src-rev"
(with-output-to-file ".src-rev" (lambda _
(lambda _ (display #$version)))))
(display ,version))) (replace 'build
#t)) (lambda* (#:key parallel-build? make-flags #:allow-other-keys)
(replace 'build (apply invoke "make" "all"
(lambda* (#:key parallel-build? make-flags #:allow-other-keys) `(,@(if parallel-build?
(apply invoke "make" "all" (list (string-append "JOBS="
`(,@(if parallel-build? (number->string (parallel-job-count))))
(list (string-append "JOBS=" '())
(number->string (parallel-job-count)))) ,@make-flags))))
'()) ;; jdk 11 does not build jre by default any more; so explicitly build
,@make-flags)))) ;; it (see:
;; jdk 11 does not build jre by default any more ;; https://github.com/AdoptOpenJDK/openjdk-build/issues/356).
;; building it anyways (add-after 'build 'build-jre
;; for further information see: (lambda* (#:key parallel-build? make-flags #:allow-other-keys)
;; https://github.com/AdoptOpenJDK/openjdk-build/issues/356 (apply invoke "make" "legacy-jre-image"
(add-after 'build 'build-jre `(,@(if parallel-build?
(lambda* (#:key parallel-build? make-flags #:allow-other-keys) (list (string-append "JOBS="
(apply invoke "make" "legacy-jre-image" (number->string (parallel-job-count))))
`(,@(if parallel-build? '())
(list (string-append "JOBS=" ,@make-flags))))
(number->string (parallel-job-count)))) (replace 'install
'()) (lambda _
,@make-flags)))) (let ((images (car (find-files "build" ".*-server-release"
(replace 'install #:directories? #t))))
(lambda* (#:key outputs #:allow-other-keys) (copy-recursively (string-append images "/images/jdk")
(let ((out (assoc-ref outputs "out")) #$output:jdk)
(jdk (assoc-ref outputs "jdk")) (copy-recursively (string-append images "/images/jre")
(doc (assoc-ref outputs "doc")) #$output)
(images (car (find-files "build" ".*-server-release" (copy-recursively (string-append images "/images/docs")
#:directories? #t)))) #$output:doc))))
(copy-recursively (string-append images "/images/jdk") jdk) ;; Some of the libraries in the lib/ folder link to libjvm.so.
(copy-recursively (string-append images "/images/jre") out) ;; But that shared object is located in the server/ folder, so it
(copy-recursively (string-append images "/images/docs") doc)) ;; cannot be found. This phase creates a symbolic link in the
#t)) ;; lib/ folder so that the other libraries can find it.
;; Some of the libraries in the lib/ folder link to libjvm.so. ;;
;; But that shared object is located in the server/ folder, so it ;; See:
;; cannot be found. This phase creates a symbolic link in the ;; https://lists.gnu.org/archive/html/guix-devel/2017-10/msg00169.html
;; lib/ folder so that the other libraries can find it. ;;
;; ;; FIXME: Find the bug in the build system, so that this symlink is
;; See: ;; not needed.
;; https://lists.gnu.org/archive/html/guix-devel/2017-10/msg00169.html (add-after 'install 'install-libjvm
;; (lambda _
;; FIXME: Find the bug in the build system, so that this symlink is (let ((lib-out (string-append #$output "/lib"))
;; not needed. (lib-jdk (string-append #$output:jdk "/lib")))
(add-after 'install 'install-libjvm (symlink (string-append lib-jdk "/server/libjvm.so")
(lambda* (#:key inputs outputs #:allow-other-keys) (string-append lib-jdk "/libjvm.so"))
(let* ((lib-out (string-append (assoc-ref outputs "out") (symlink (string-append lib-out "/server/libjvm.so")
"/lib")) (string-append lib-out "/libjvm.so")))))
(lib-jdk (string-append (assoc-ref outputs "jdk") (add-after 'install 'strip-character-data-timestamps
"/lib"))) (lambda _
(symlink (string-append lib-jdk "/server/libjvm.so") (use-modules (guix build syscalls))
(string-append lib-jdk "/libjvm.so")) (let ((archive (string-append #$output:jdk "/lib/src.zip"))
(symlink (string-append lib-out "/server/libjvm.so") (dir (mkdtemp! "zip-contents.XXXXXX")))
(string-append lib-out "/libjvm.so"))) (with-directory-excursion dir
#t)) (invoke "unzip" archive))
(add-after 'install 'strip-character-data-timestamps (delete-file archive)
(lambda* (#:key outputs #:allow-other-keys) (with-directory-excursion dir
(use-modules (guix build syscalls)) (let ((char-data-files (find-files "." "CharacterData.*")))
(let ((archive (string-append (for-each (lambda (file)
(assoc-ref outputs "jdk") "/lib/src.zip")) (substitute* file
(dir (mkdtemp! "zip-contents.XXXXXX"))) (((string-append "This file was generated "
(with-directory-excursion dir "AUTOMATICALLY from a template "
(invoke "unzip" archive)) "file.*"))
(delete-file archive) (string-append "This file was generated "
(with-directory-excursion dir
(let ((char-data-files (find-files "." "CharacterData.*")))
(for-each (lambda (file)
(substitute* file
(((string-append "This file was generated "
"AUTOMATICALLY from a template " "AUTOMATICALLY from a template "
"file.*")) "file"))))
(string-append "This file was generated " char-data-files)))
"AUTOMATICALLY from a template " (with-directory-excursion dir
"file")))) (let ((files (find-files "." ".*" #:directories? #t)))
char-data-files))) (apply invoke "zip" "-0" "-X" archive files))))))
(with-directory-excursion dir (add-after 'strip-character-data-timestamps 'strip-archive-timestamps
(let ((files (find-files "." ".*" #:directories? #t))) (lambda _
(apply invoke "zip" "-0" "-X" archive files)))))) (use-modules (guix build syscalls)
(add-after 'strip-character-data-timestamps 'strip-archive-timestamps (ice-9 binary-ports)
(lambda* (#:key outputs #:allow-other-keys) (rnrs bytevectors))
(use-modules (guix build syscalls) (letrec ((repack-archive
(ice-9 binary-ports) (lambda (archive)
(rnrs bytevectors)) (let ((dir (mkdtemp! "zip-contents.XXXXXX")))
(letrec ((repack-archive (with-directory-excursion dir
(lambda (archive) (invoke "unzip" archive))
(let ((dir (mkdtemp! "zip-contents.XXXXXX"))) (delete-file archive)
(with-directory-excursion dir (for-each (compose repack-archive canonicalize-path)
(invoke "unzip" archive)) (find-files dir "(ct.sym|.*.jar)$"))
(delete-file archive) (let ((reset-file-timestamp
(for-each (compose repack-archive canonicalize-path) (lambda (file)
(find-files dir "(ct.sym|.*.jar)$")) (let ((s (lstat file)))
(let ((reset-file-timestamp (unless (eq? (stat:type s) 'symlink)
(lambda (file) (format #t "reset ~a~%" file)
(let ((s (lstat file))) (utime file 0 0 0 0))))))
(unless (eq? (stat:type s) 'symlink) (for-each reset-file-timestamp
(format #t "reset ~a~%" file) (find-files dir #:directories? #t)))
(utime file 0 0 0 0)))))) (with-directory-excursion dir
(for-each reset-file-timestamp (let ((files (find-files "." ".*" #:directories? #t)))
(find-files dir #:directories? #t))) (apply invoke "zip" "-0" "-X" archive files)))))))
(with-directory-excursion dir (for-each repack-archive
(let ((files (find-files "." ".*" #:directories? #t))) (find-files #$output:doc ".*.zip$"))
(apply invoke "zip" "-0" "-X" archive files))))))) (for-each repack-archive
(for-each repack-archive (find-files #$output:jdk ".*.(zip|jar|diz)$"))
(find-files (assoc-ref outputs "doc") ".*.zip$")) (repack-archive (string-append #$output:jdk "/lib/ct.sym"))
(for-each repack-archive (let ((repack-jmod
(find-files (assoc-ref outputs "jdk") (lambda (file-name)
".*.(zip|jar|diz)$")) (call-with-input-file file-name
(repack-archive (string-append (assoc-ref outputs "jdk") "/lib/ct.sym")) (lambda (file)
(let ((repack-jmod (let ((header #vu8(#x4a #x4d #x01 #x00)))
(lambda (file-name) (if (equal? (get-bytevector-n
(call-with-input-file file-name file (bytevector-length header))
(lambda (file) header)
(let ((header #vu8(#x4a #x4d #x01 #x00))) (let* ((header-length (bytevector-length header))
(if (equal? (get-bytevector-n (temp-file (mkstemp!
file (bytevector-length header)) (string-copy
header) "temp-file.XXXXXX")))
(let* ((header-length (bytevector-length header)) (temp-filename (port-filename temp-file))
(temp-file (mkstemp! (content-length
(string-copy (- (stat:size (stat file))
"temp-file.XXXXXX"))) header-length)))
(temp-filename (port-filename temp-file)) (sendfile temp-file file content-length header-length)
(content-length (delete-file file-name)
(- (stat:size (stat file)) (close-port temp-file)
header-length))) (repack-archive (canonicalize-path temp-filename))
(sendfile temp-file file content-length header-length) (call-with-output-file file-name
(delete-file file-name) (lambda (file)
(close-port temp-file) (put-bytevector file header)
(repack-archive (canonicalize-path temp-filename)) (call-with-input-file temp-filename
(call-with-output-file file-name (lambda (temp-file)
(lambda (file) (sendfile
(put-bytevector file header) file temp-file
(call-with-input-file temp-filename (stat:size (stat temp-file)) 0)))))))))))))
(lambda (temp-file) (for-each repack-jmod
(sendfile (find-files #$output:jdk ".*.jmod$"))))))
file temp-file (add-after 'install 'remove-timestamp-from-api-summary
(stat:size (stat temp-file)) 0))))))))))))) (lambda _
(for-each repack-jmod (substitute* (string-append #$output:doc
(find-files (assoc-ref outputs "jdk") ".*.jmod$"))) "/api/overview-summary.html")
#t))) (("Generated by javadoc \\(11-internal\\).*$")
(add-after 'install 'remove-timestamp-from-api-summary "Generated by javadoc (11-internal) -->\n")))))))
(lambda* (#:key outputs #:allow-other-keys)
(substitute* (string-append (assoc-ref outputs "doc")
"/api/overview-summary.html")
(("Generated by javadoc \\(11-internal\\).*$")
"Generated by javadoc (11-internal) -->\n"))
#t)))))
(inputs (inputs
`(("alsa-lib" ,alsa-lib) `(("alsa-lib" ,alsa-lib)
("cups" ,cups) ("cups" ,cups)