guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: gnu: ant-bootstrap: Make build reproducible.


From: Gábor Boskovits
Subject: 01/01: gnu: ant-bootstrap: Make build reproducible.
Date: Sat, 16 Jun 2018 14:40:58 -0400 (EDT)

boskovits pushed a commit to branch staging
in repository guix.

commit cded3a759356ff66b7df668bcdbdfa0daf96f4c5
Author: Gábor Boskovits <address@hidden>
Date:   Mon Jun 11 13:40:31 2018 +0200

    gnu: ant-bootstrap: Make build reproducible.
    
    * gnu/packages/java.scm 
(ant-bootstrap)[arguments]<#:phases>[strip-jar-timestamps]:
    New phase to reset jar file timestamps.
    <#:imported-modules>: Import guix build syscalls, gnu-build-system-modules.
    <#:modules>: Import guix build: gnu-build-system, utils, syscalls.
    [native-inputs]: Add unzip, zip.
---
 gnu/packages/java.scm | 42 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 678cbee..8390016 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -212,7 +212,13 @@ JNI.")
                 "1cg0lga887qz5iizh6mlkxp01lciymrhmp7wzxpl6zpnldxmzrjx"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:tests? #f ; no "check" target
+     `(#:imported-modules ((guix build syscalls)
+                           ,@%gnu-build-system-modules)
+       #:modules ((srfi srfi-1)
+                  (guix build gnu-build-system)
+                  (guix build utils)
+                  (guix build syscalls))
+       #:tests? #f ; no "check" target
        #:phases
        (modify-phases %standard-phases
          (delete 'bootstrap)
@@ -254,10 +260,42 @@ JNI.")
              (zero? (system* "bash" "bootstrap.sh"
                              (string-append "-Ddist.dir="
                                             (assoc-ref %outputs "out"))))))
+         (add-after 'build 'strip-jar-timestamps ;based on ant-build-system
+           (lambda* (#:key outputs #:allow-other-keys)
+             (define (repack-archive jar)
+               (let* ((dir (mkdtemp! "jar-contents.XXXXXX"))
+                      (manifest (string-append dir "/META-INF/MANIFESTS.MF")))
+                 (with-directory-excursion dir
+                   (invoke "unzip" jar))
+                 (delete-file jar)
+                 ;; XXX: copied from (gnu build install)
+                 (for-each (lambda (file)
+                             (let ((s (lstat file)))
+                               (unless (eq? (stat:type s) 'symlink)
+                                 (utime file  0 0 0 0))))
+                           (find-files dir #:directories? #t))
+                 ;; It is important that the manifest appears first.
+                 (with-directory-excursion dir
+                   (let* ((files (find-files "." ".*" #:directories? #t))
+                          ;; To ensure that the reference scanner can
+                          ;; detect all store references in the jars
+                          ;; we disable compression with the "-0" option.
+                          (command (if (file-exists? manifest)
+                                       `("zip" "-0" "-X" ,jar ,manifest
+                                         ,@files)
+                                       `("zip" "-0" "-X" ,jar ,@files))))
+                     (apply invoke command)))))
+             (for-each repack-archive
+                    (find-files
+                     (string-append (assoc-ref %outputs "out") "/lib")
+                     "\\.jar$"))
+             #t))
          (delete 'install))))
     (native-inputs
      `(("jikes" ,jikes)
-       ("jamvm" ,jamvm-1-bootstrap)))
+       ("jamvm" ,jamvm-1-bootstrap)
+       ("unzip" ,unzip)
+       ("zip", zip)))
     (home-page "http://ant.apache.org";)
     (synopsis "Build tool for Java")
     (description



reply via email to

[Prev in Thread] Current Thread [Next in Thread]