From ed9db022d4e2ea9b6f1151fbc2785014b2a1bd8e Mon Sep 17 00:00:00 2001 From: Tim Gesthuizen Date: Thu, 17 Jan 2019 22:49:46 +0100 Subject: [PATCH 04/11] guix: ant: Use repack * guix/build-system/ant.scm (default-zip): Deleted. * guix/build-system/ant.scm (lower): Change zip to repack. * guix/build/ant-build-system.scm (strip-jar-timestamps): Use repack for repack-archive. --- guix/build-system/ant.scm | 16 ++++++++-------- guix/build/ant-build-system.scm | 32 ++++---------------------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/guix/build-system/ant.scm b/guix/build-system/ant.scm index b5626bd42..a4aa90eb8 100644 --- a/guix/build-system/ant.scm +++ b/guix/build-system/ant.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 Ricardo Wurmus +;;; Copyright © 2019 Tim Gesthuizen ;;; ;;; This file is part of GNU Guix. ;;; @@ -55,22 +56,21 @@ (let ((jdk-mod (resolve-interface '(gnu packages java)))) (module-ref jdk-mod 'ant))) -(define (default-zip) - "Return the default ZIP package." - ;; Lazily resolve the binding to avoid a circular dependency. - (let ((zip-mod (resolve-interface '(gnu packages compression)))) - (module-ref zip-mod 'zip))) +(define (default-repack) + "Return the default REPACK package" + (let ((repack-mod (resolve-interface '(gnu packages compression)))) + (module-ref repack-mod 'repack))) (define* (lower name #:key source inputs native-inputs outputs system target (jdk (default-jdk)) (ant (default-ant)) - (zip (default-zip)) + (repack (default-repack)) #:allow-other-keys #:rest arguments) "Return a bag for NAME." (define private-keywords - '(#:source #:target #:jdk #:ant #:zip #:inputs #:native-inputs)) + '(#:source #:target #:jdk #:ant #:repack #:inputs #:native-inputs)) (and (not target) ;XXX: no cross-compilation (bag @@ -85,7 +85,7 @@ ,@(standard-packages))) (build-inputs `(("jdk" ,jdk "jdk") ("ant" ,ant) - ("zip" ,zip) + ("repack" ,repack) ,@native-inputs)) (outputs outputs) (build ant-build) diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm index d79a2d55e..540c985b7 100644 --- a/guix/build/ant-build-system.scm +++ b/guix/build/ant-build-system.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2018 Ricardo Wurmus +;;; Copyright © 2019 Tim Gesthuizen ;;; ;;; This file is part of GNU Guix. ;;; @@ -191,34 +192,9 @@ dependencies of this jar file." 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")) - (manifest (string-append dir "/META-INF/MANIFEST.MF"))) - (with-directory-excursion dir - (invoke "jar" "xf" 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)) - - ;; The jar tool will always set the timestamp on the manifest file - ;; and the containing directory to the current time, even when we - ;; reuse an existing manifest file. To avoid this we use "zip" - ;; instead of "jar". 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))) - (utime jar 0 0) - #t)) + (let* ((tmp (tmpnam))) + (copy-file jar tmp) + (invoke "repack" "-o" jar tmp))) (for-each (match-lambda ((output . directory) -- 2.20.1