[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Add ant-build-system.
From: |
Ricardo Wurmus |
Subject: |
Re: [PATCH] Add ant-build-system. |
Date: |
Thu, 10 Mar 2016 11:56:02 +0100 |
Ricardo Wurmus <address@hidden> writes:
> Ludovic Courtès <address@hidden> writes:
>
>>> The build.xml it generates contains a target “touch” which is run before
>>> wrapping up the compiled .class files in a jar archive; this target
>>> ensures that the timestamps of all archived files are reset, so the
>>> produced jars can be (and in case of the above-mentioned packages)
>>> deterministic.
>>
>> Cool.
>>
>> What should we do about packages that do provide a ‘build.xml’? I
>> suppose their jars will most likely include timestamps by default,
>> right?
>>
>> If that is the case, maybe we should instead add an additional phase
>> that would, say, unpack all the installed tarballs, reset timestamps,
>> and repack them?
>
> Yes, I think a generic build phase like that would be better.
I have addressed the other issues with the build system already, so
here’s just an additional patch that adds a generic “repack” build phase
as discussed.
I think it’s easier to review it this way, so I didn’t squash the
patches. If these changes are okay I’ll fold them into the (corrected)
patch adding the ant-build-system and push.
~~ Ricardo
>From ddd1633f12cd53bbe6a8f2ccfbfa02678365f486 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <address@hidden>
Date: Thu, 10 Mar 2016 11:50:52 +0100
Subject: [PATCH] Changes to the ant-build-system.
Do this in a new build phase after "install": Unpack jar, reset
timestamps, repack jar.
---
guix/build-system/ant.scm | 1 +
guix/build/ant-build-system.scm | 37 +++++++++++++++++++++++++++++--------
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/guix/build-system/ant.scm b/guix/build-system/ant.scm
index 5240ff6..ac5546c 100644
--- a/guix/build-system/ant.scm
+++ b/guix/build-system/ant.scm
@@ -39,6 +39,7 @@
(define %ant-build-system-modules
;; Build-side modules imported by default.
`((guix build ant-build-system)
+ (guix build syscalls)
,@%gnu-build-system-modules))
(define (default-jdk)
diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm
index 1e3a1ea..7cb620b 100644
--- a/guix/build/ant-build-system.scm
+++ b/guix/build/ant-build-system.scm
@@ -18,6 +18,7 @@
(define-module (guix build ant-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
+ #:use-module (guix build syscalls)
#:use-module (guix build utils)
#:use-module (sxml simple)
#:use-module (ice-9 match)
@@ -61,14 +62,8 @@
(destdir "${classes.dir}")
(classpath (@ (refid "classpath"))))))
- ;; Reset the ctime/mtime on all files to ensure that the
- ;; jar archive for the same class files is bit-identical.
- (target (@ (name "touch"))
- (exec (@ (executable "find"))
- (arg (@ (line "${classes.dir} -exec touch -d @0
{} ;")))))
-
(target (@ (name "jar")
- (depends "compile,touch"))
+ (depends "compile"))
(mkdir (@ (dir "${jar.dir}")))
;; We cannot use the simpler "jar" task here, because
;; there is no way to disable generation of a
@@ -109,6 +104,31 @@ INPUTS."
#:allow-other-keys)
(zero? (apply system* `("ant" ,build-target ,@make-flags))))
+(define* (repack #:key outputs
+ #:allow-other-keys)
+ "Unpack all jar archives, reset the timestamp of all contained files, and
+repack them. This is necessary to ensure that archives are reproducible."
+ (define (repack-archive jar)
+ (format #t "repacking ~a\n" jar)
+ (let ((dir (mkdtemp! "jar-contents.XXXXXX")))
+ (and (with-directory-excursion dir
+ (zero? (system* "jar" "xf" jar)))
+ ;; The manifest file contains timestamps
+ (for-each delete-file (find-files dir "MANIFEST.MF"))
+ (delete-file jar)
+ (ftw dir (lambda (file stat flag)
+ (utime file 0 0)
+ #t))
+ (format #t "~a\n" (string-join (list "jar" "-Mcf" jar "-C" dir
".")))
+ (zero? (system* "jar" "-Mcf" jar "-C" dir "."))
+ (utime jar 0 0)
+ #t)))
+
+ (every (match-lambda
+ ((output . directory)
+ (every repack-archive (find-files directory "\\.jar$"))))
+ outputs))
+
(define* (check #:key target (make-flags '()) (tests? (not target))
(test-target "check")
#:allow-other-keys)
@@ -126,7 +146,8 @@ INPUTS."
(replace 'configure configure)
(replace 'build build)
(replace 'check check)
- (replace 'install install)))
+ (replace 'install install)
+ (add-after 'install 'repack repack)))
(define* (ant-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
--
2.1.0
- Re: [PATCH] Add ant-build-system.,
Ricardo Wurmus <=