From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: [PATCH] Add ant-build-system. Date: Thu, 10 Mar 2016 11:56:02 +0100 Message-ID: References: <87k2naantw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adyGO-00076Y-K0 for guix-devel@gnu.org; Thu, 10 Mar 2016 05:56:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adyGK-0008SD-Hz for guix-devel@gnu.org; Thu, 10 Mar 2016 05:56:16 -0500 In-Reply-To: List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: "guix-devel@gnu.org" --=-=-= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Ricardo Wurmus writes: > Ludovic Court=C3=A8s writes: > >>> The build.xml it generates contains a target =E2=80=9Ctouch=E2=80=9D = 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 =E2=80=98build.xml=E2= =80=99? 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=E2=80=99s just an additional patch that adds a generic =E2=80=9Crepa= ck=E2=80=9D build phase as discussed. I think it=E2=80=99s easier to review it this way, so I didn=E2=80=99t sq= uash the patches. If these changes are okay I=E2=80=99ll fold them into the (corr= ected) patch adding the ant-build-system and push. ~~ Ricardo --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename="0001-Changes-to-the-ant-build-system.patch" >From ddd1633f12cd53bbe6a8f2ccfbfa02678365f486 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus 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 --=-=-=--