From unknown Sat Jun 21 12:27:22 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#45675 <45675@debbugs.gnu.org> To: bug#45675 <45675@debbugs.gnu.org> Subject: Status: Zip-based archives store timestamps Reply-To: bug#45675 <45675@debbugs.gnu.org> Date: Sat, 21 Jun 2025 19:27:22 +0000 retitle 45675 Zip-based archives store timestamps reassign 45675 guix submitter 45675 Miguel =C3=81ngel Arruga Vivas severity 45675 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 05 08:10:46 2021 Received: (at submit) by debbugs.gnu.org; 5 Jan 2021 13:10:46 +0000 Received: from localhost ([127.0.0.1]:41074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kwm6o-0002aw-C0 for submit@debbugs.gnu.org; Tue, 05 Jan 2021 08:10:46 -0500 Received: from lists.gnu.org ([209.51.188.17]:35504) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kwm6m-0002ao-Hv for submit@debbugs.gnu.org; Tue, 05 Jan 2021 08:10:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwm6l-0001iS-Ku for bug-guix@gnu.org; Tue, 05 Jan 2021 08:10:44 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:33382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwm6h-00050G-Tb for bug-guix@gnu.org; Tue, 05 Jan 2021 08:10:43 -0500 Received: by mail-wm1-x335.google.com with SMTP id n16so1463432wmc.0 for ; Tue, 05 Jan 2021 05:10:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version; bh=q3p+v0ydj3YwPzN4NEbbfBWJzixi05yKl+2hfkargQs=; b=KgDvMy9qNTc7bq0jSBIsyFRH82Ak7b3ZRp7wCpymn2ypr7HjvHkplOYCqy/w/bgMWF K757BxRAedz5sBafKf3ROFbprelDJShVy5R2XEX+YI3zHeTK2wHge/ITbHtfTnJDhmKt XH9y8vdx86mDkHPHlxtzs5UvekiqOo6aCW7ubFESgoUJKtoeFCgu2N1ai7MIShShbJF3 EsWjMgnlWev94lN0bJ0NYd8sDByv0qzxltOPCazSdYeHbiOTI7+ZdaHy1zizoY6IgGSm izeu4lUPErQtQFRklS7T6DxAZNrhLf3Hh4WaKcnpbeAkxwuqjnojmoYbHaTGXuSPl5Kk RicA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=q3p+v0ydj3YwPzN4NEbbfBWJzixi05yKl+2hfkargQs=; b=DSP1eXA8e6hnHJDVIWAcO4g+2Ej1nGGNjcJZAwlv1AT7HG/xNJQfeEcDsxw6eGix29 O7gjyrOK+8GULWCOY1SASCtUsSoUIkzslQtRdYkMdHu1t6tKXrBHzZaBowdl0MfX2LaB UchGA76pP92uEPRtrf27eXHMUuqufEUqvs1/2poiiFYMiOn757qMX+90jxBl/t80Dr3D fz5fi+3g9Iw/SaEKahxMcQ6So9JosEDAagG8EPHLJe7oj8Cqd7tDgZKLAh3oiWxmOTGk VCTzyqt3DZ4MKMgD3v56EPfh9uYuqEk41z7DARJKr8ANJ4mq+6An9PJ+HF/1YplDhZ/I RHlA== X-Gm-Message-State: AOAM532JxxN8BbhwUKLszbPKYec/+qhHj+BM2HDfWvfwgj3k4sS0Ee+s EzoooNeHdh2ozV0dma90bhhZ9uTZOuw= X-Google-Smtp-Source: ABdhPJz+iXNDLJhRQba1kjCoVo8sjWFiIfp6nvTMAyvlRUtT2R10LHLmBFhWToNWTsAsr9PRODtQUQ== X-Received: by 2002:a1c:1f54:: with SMTP id f81mr3475679wmf.44.1609852238574; Tue, 05 Jan 2021 05:10:38 -0800 (PST) Received: from unfall (36.193.158.146.dynamic.jazztel.es. [146.158.193.36]) by smtp.gmail.com with ESMTPSA id k18sm105063653wrd.45.2021.01.05.05.10.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 05:10:38 -0800 (PST) From: =?utf-8?Q?Miguel_=C3=81ngel_Arruga_Vivas?= To: bug-guix@gnu.org Subject: Zip-based archives store timestamps Date: Tue, 05 Jan 2021 14:10:37 +0100 Message-ID: <877dor34xe.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=rosen644835@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) A procedure like reset-gzip-timestamp should be useful for reproducibility purposes, adapted to zip based archives as Smalltalk's STAR or Java's JAR binary formats, as some or all of their contents are generated usually at build time. On the latest Zip specification[1], which only seem to be encumbered regarding encryption, there is one header ID which could be used for timestamp purposes (0x0020) but third party header IDs are allowed, which include a "commonly used" 0x5455 timestamp. [1] https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE-6.3.8.TXT From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 05 10:18:12 2021 Received: (at 45675) by debbugs.gnu.org; 5 Jan 2021 15:18:12 +0000 Received: from localhost ([127.0.0.1]:42431 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kwo68-0008OG-7p for submit@debbugs.gnu.org; Tue, 05 Jan 2021 10:18:12 -0500 Received: from lepiller.eu ([89.234.186.109]:59284) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kwo65-0008O6-W5 for 45675@debbugs.gnu.org; Tue, 05 Jan 2021 10:18:11 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 46e393f4; Tue, 5 Jan 2021 15:18:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date :in-reply-to:references:mime-version:content-type :content-transfer-encoding:subject:to:from:message-id; s=dkim; bh=70dzVBReiBbAg9R71sDlFQsqicjQjwU9jwiEsBJ5gt8=; b=ULF2+Bnp2xe+ KCCRKO0GnsX6yhGC5BQb34M7qMzOc/qYJEYqbZxxW2etW+36EG7r6DiuEOxXSS9u /IXq6Zqb0Id2VhxhEAkjYnzNoRPZKyWxkOB5Oi+NqMEqnpimqSr+3/bGX4AUwREO rV8Wx5GO22zlx3GOZzfvAvmuCmc7pjqRQvS70iopd4btM9x9Rrs/GqjDYprXYS5a 12Vx8ZsaHwD+2jVgif7abqNt1ErwEMKWIguRHvByxraRRSOK9xr2fn6ZIbNg3PVA jKa8/ekEw/c7JueFnTFXnRmRZW9b5p3s0s4tPIvLuUXuQuovxr02Ki+mwvp2xDJe awaOmKWeeA== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 0cbf809d (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Tue, 5 Jan 2021 15:18:06 +0000 (UTC) Date: Tue, 05 Jan 2021 10:17:53 -0500 User-Agent: K-9 Mail for Android In-Reply-To: <877dor34xe.fsf@gmail.com> References: <877dor34xe.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----36TF2YAIOY4UFT533E1QW292I7VPF3" Content-Transfer-Encoding: 7bit Subject: Re: bug#45675: Zip-based archives store timestamps To: =?ISO-8859-1?Q?Miguel_=C1ngel_Arruga_Vivas?= , 45675@debbugs.gnu.org From: Julien Lepiller Message-ID: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45675 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) ------36TF2YAIOY4UFT533E1QW292I7VPF3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable For java packages, we have a strip-jar-timestamps phase in the ant-build-sy= stem=2E Le 5 janvier 2021 08:10:37 GMT-05:00, "Miguel =C3=81ngel Arruga Vivas" a =C3=A9crit : >A procedure like reset-gzip-timestamp should be useful for >reproducibility purposes, adapted to zip based archives as Smalltalk's >STAR or Java's JAR binary formats, as some or all of their contents are >generated usually at build time=2E > >On the latest Zip specification[1], which only seem to be encumbered >regarding encryption, there is one header ID which could be used for >timestamp purposes (0x0020) but third party header IDs are allowed, >which include a "commonly used" 0x5455 timestamp=2E > >[1] https://pkware=2Ecachefly=2Enet/webdocs/APPNOTE/APPNOTE-6=2E3=2E8=2ET= XT ------36TF2YAIOY4UFT533E1QW292I7VPF3 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable For java packages, we have a strip-jar-timestamps = phase in the ant-build-system=2E

Le 5 jan= vier 2021 08:10:37 GMT-05:00, "Miguel =C3=81ngel Arruga Vivas" <rosen644= 835@gmail=2Ecom> a =C3=A9crit :
A procedure like reset-gzip-timestamp should be usef=
ul for
reproducibility purposes, adapted to zip based archives as Smallt= alk's
STAR or Java's JAR binary formats, as some or all of their content= s are
generated usually at build time=2E

On the latest Zip specif= ication[1], which only seem to be encumbered
regarding encryption, there= is one header ID which could be used for
timestamp purposes (0x0020) bu= t third party header IDs are allowed,
which include a "commonly used" 0x= 5455 timestamp=2E

[1] https://pkware=2Ecachefly=2Enet/webdo= cs/APPNOTE/APPNOTE-6=2E3=2E8=2ETXT



------36TF2YAIOY4UFT533E1QW292I7VPF3-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 06 17:34:13 2021 Received: (at 45675) by debbugs.gnu.org; 6 Jan 2021 22:34:13 +0000 Received: from localhost ([127.0.0.1]:45809 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxHNd-0005ea-01 for submit@debbugs.gnu.org; Wed, 06 Jan 2021 17:34:13 -0500 Received: from mail-wr1-f46.google.com ([209.85.221.46]:41696) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxHNb-0005eO-L4 for 45675@debbugs.gnu.org; Wed, 06 Jan 2021 17:34:12 -0500 Received: by mail-wr1-f46.google.com with SMTP id a12so3782061wrv.8 for <45675@debbugs.gnu.org>; Wed, 06 Jan 2021 14:34:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=fCdFDDC/xpCRoDsCgcClRvhiStXO6uM3h7Y5XXg0FZQ=; b=k5ipH7yAQ9Hf5DtrhuP6bey380IZdf5FK490WQDt60bB0JTJoWi3y2tCKpF7Rewrdf VOpZNwAB4RDDQthr+CTRgOIL3FFOlNvzLG+Wy86mFv29rt99QDANKinXTOoxnXOW4WsS BohiI6H+t4AxHSmM2ihMnsZvJNdrkTu1jRxmat2D0ormwNTsyBbfxtQmVQ4p767j4+tV ozFYWdiv2gM/xcAt2NHnq2ZYt+AhawestyYfL3Z2htdlcVmJuigSBEFsFFNNpWWflSZG H/y3CGY4R7HuaIGUo9ERXsIxX4ZwzLaOtAmw8bckUsbvE1MSiIBtDtCiQxSTzBuedcMg yWiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=fCdFDDC/xpCRoDsCgcClRvhiStXO6uM3h7Y5XXg0FZQ=; b=FGuvR0fvTFwF0WLYF9GQigrQmUvNlgkfnPOtX/F4aKPcKVGFJuKvrq5QECXN/PJJQU 2EH3aUqdRY/z38U1G4G7yDEYlGSZxu968NwNB8U8uFLEPni5LlG9qzDW1b38y91ANE8z SHHNVg7MYTy2dgQ+jTiao34JaJrcP/Kc0CLsLbDrxdZRx03eyQoLr8MDFgDFmaCJXgTp CevY68xy8YS8by+DBwMnG5dd9sEUosPnA1za+FWoXBGOGNXHSx9M38ri9fxEP6wLaxjT RMSEryI8AtKaA3Oc5FejmGHY9ZXKw4WyiWqubr8PSV+nyST7G832/Cvsa3oOIIIyt/mB ns4w== X-Gm-Message-State: AOAM5301iBbB7Z5FtvOb/x39seUyySfq5A+YzBK3yFBBIBkDII9iPDNo MzJop2vC8lyp3E8uIehimFQarIr8Zp0= X-Google-Smtp-Source: ABdhPJwBuuxZdaqh0tdVbWRWOT6DyAb3HWo5SnYQYTrpMQpZCGvZkR3OlBh0CszOwT6eoqk/Mg4RdA== X-Received: by 2002:a5d:4a06:: with SMTP id m6mr6376151wrq.189.1609972445699; Wed, 06 Jan 2021 14:34:05 -0800 (PST) Received: from unfall (36.193.158.146.dynamic.jazztel.es. [146.158.193.36]) by smtp.gmail.com with ESMTPSA id u26sm4616264wmm.24.2021.01.06.14.34.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 14:34:04 -0800 (PST) From: =?utf-8?Q?Miguel_=C3=81ngel_Arruga_Vivas?= To: Julien Lepiller Subject: Re: bug#45675: Zip-based archives store timestamps References: <877dor34xe.fsf@gmail.com> Date: Wed, 06 Jan 2021 23:34:01 +0100 In-Reply-To: (Julien Lepiller's message of "Tue, 05 Jan 2021 10:17:53 -0500") Message-ID: <87a6tl1yqu.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 45675 Cc: 45675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain Hi, Julien Lepiller writes: > For java packages, we have a strip-jar-timestamps phase in the ant-build-system. Thanks for the pointer. Do you think could be worth to extract that into (guix build utils) as the attached patch (WIP) does? It rebuilds the world and replaces all of "old usages", so I'm still waiting to reach ant-bootstrap... Happy hacking! Miguel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-wip-build-utils-Extract-reset-zip-timestamp-and-use-.patch Content-Description: wip.patch >From dd2e78badad805cff8be940411994533aed8b059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?= Date: Wed, 6 Jan 2021 23:29:36 +0100 Subject: [PATCH] wip-build-utils: Extract reset-zip-timestamp and use it everywhere. --- gnu/packages/java.scm | 73 ++++++++------------------------- guix/build/ant-build-system.scm | 32 ++++----------- guix/build/utils.scm | 48 ++++++++++++++++++++++ 3 files changed, 73 insertions(+), 80 deletions(-) diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index 758f8f1859..82d18bf62a 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -411,28 +411,11 @@ JNI.") (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))))) + (let ((mktempdir (lambda () + (mkdtemp! "jar-contents.XXXXXX")))) + (reset-zip-timestamp jar mktempdir + #:first-file "/META-INF/MANIFEST.MF" + #:compression-level "-0"))) (for-each repack-archive (find-files (string-append (assoc-ref %outputs "out") "/lib") @@ -1962,21 +1945,10 @@ new Date();")) (add-after 'install 'strip-zip-timestamps (lambda* (#:key outputs #:allow-other-keys) (use-modules (guix build syscalls)) - (for-each (lambda (zip) - (let ((dir (mkdtemp! "zip-contents.XXXXXX"))) - (with-directory-excursion dir - (invoke "unzip" zip)) - (delete-file zip) - (for-each (lambda (file) - (let ((s (lstat file))) - (unless (eq? (stat:type s) 'symlink) - (format #t "reset ~a~%" file) - (utime file 0 0 0 0)))) - (find-files dir #:directories? #t)) - (with-directory-excursion dir - (let ((files (find-files "." ".*" #:directories? #t))) - (apply invoke "zip" "-0" "-X" zip files))))) - (find-files (assoc-ref outputs "doc") ".*.zip$")) + (let ((mktempdir (lambda () (mkdtemp! "zip-contents.XXXXXX")))) + (for-each (lambda (zip) + (reset-zip-timestamp zip mktempdir)) + (find-files (assoc-ref outputs "doc") ".*.zip$"))) #t))))) (inputs `(("alsa-lib" ,alsa-lib) @@ -2197,25 +2169,14 @@ new Date();")) (use-modules (guix build syscalls) (ice-9 binary-ports) (rnrs bytevectors)) - (letrec ((repack-archive - (lambda (archive) - (let ((dir (mkdtemp! "zip-contents.XXXXXX"))) - (with-directory-excursion dir - (invoke "unzip" archive)) - (delete-file archive) - (for-each (compose repack-archive canonicalize-path) - (find-files dir "(ct.sym|.*.jar)$")) - (let ((reset-file-timestamp - (lambda (file) - (let ((s (lstat file))) - (unless (eq? (stat:type s) 'symlink) - (format #t "reset ~a~%" file) - (utime file 0 0 0 0)))))) - (for-each reset-file-timestamp - (find-files dir #:directories? #t))) - (with-directory-excursion dir - (let ((files (find-files "." ".*" #:directories? #t))) - (apply invoke "zip" "-0" "-X" archive files))))))) + (let* ((mktempdir (lambda () + (mkdtemp! "zip-contents.XXXXXX"))) + (repack-archive + (lambda (archive) + (reset-zip-timestamp archive mktempdir + #:compression-level "-0" + #:recursion-regexp + "(ct.sym|.*.jar)$")))) (for-each repack-archive (find-files (assoc-ref outputs "doc") ".*.zip$")) (for-each repack-archive diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm index fae1b47ec5..d6c8b71abc 100644 --- a/guix/build/ant-build-system.scm +++ b/guix/build/ant-build-system.scm @@ -201,35 +201,19 @@ 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)) - + (let ((manifest "/META-INF/MANIFEST.MF") + (mktmpdir (lambda () (mkdtemp! "jar-contents.XXXXXX")))) ;; 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)) - + (reset-zip-timestamp jar mktmpdir + #:first-file manifest + ;; To ensure that the reference scanner can detect + ;; all store references in the jars we disable + ;; compression with the "-0" option. + #:compression-level "-0"))) (for-each (match-lambda ((output . directory) (for-each repack-archive diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 419c10195b..3f82d87732 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -56,7 +56,9 @@ elf-file? ar-file? gzip-file? + zip-file? reset-gzip-timestamp + reset-zip-timestamp with-directory-excursion mkdir-p install-file @@ -282,6 +284,52 @@ preserve FILE's modification time." (lambda () (chdir init))))) +(define %zip-magic-bytes + ;; Magic bytes of zip file. Beware, it's a small header so there could be + ;; false positives. + #vu8(#x50 #x4b)) + +(define zip-file? + (file-header-match %zip-magic-bytes)) + +(define* (reset-zip-timestamp zip-file tmp-dir-generator + #:key (first-file #f) + (compression-level "-6") + (recursion-regexp #f)) + "Reset the timestamps inside ZIP-FILE, regenerating it with the +COMPRESSION-LEVEL provided, and optionally placing FIRST-FILE at the +beginning of the archive when it exists. + +TMP-DIR-GENERATOR must return a different directory each time it is called +when RECURSION-REGEXP is provided." + (let* ((dir (tmp-dir-generator)) + (first-file (string-append dir first-file))) + (with-directory-excursion dir + (invoke "unzip" zip-file)) + (delete-file zip-file) + (when recursion-regexp + (for-each (lambda (file) + (reset-zip-timestamp (canonicalize-path file) + tmp-dir-generator + #:first-file first-file + #:compression-level compression-level + #:recursion-regexp recursion-regexp)) + (find-files dir recursion-regexp))) + (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)) + + (with-directory-excursion dir + (let* ((files (find-files "." ".*" #:directories? #t)) + (call-zip `("zip" ,compression-level "-X" ,zip-file)) + (command (if (file-exists? first-file) + `(,@call-zip ,first-file ,@files) + `(,@call-zip ,@files)))) + (apply invoke command))) + (utime zip-file 0 0))) + (define (mkdir-p dir) "Create directory DIR and all its ancestors." (define absolute? -- 2.30.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 06 18:11:13 2021 Received: (at 45675) by debbugs.gnu.org; 6 Jan 2021 23:11:13 +0000 Received: from localhost ([127.0.0.1]:45876 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxHxR-0006Z8-Dm for submit@debbugs.gnu.org; Wed, 06 Jan 2021 18:11:13 -0500 Received: from lepiller.eu ([89.234.186.109]:59382) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxHxP-0006Yy-Av for 45675@debbugs.gnu.org; Wed, 06 Jan 2021 18:11:12 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id a612cbc3; Wed, 6 Jan 2021 23:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date :in-reply-to:references:mime-version:content-type :content-transfer-encoding:subject:to:cc:from:message-id; s= dkim; bh=57Z7Y45iFWaGgjfwXQnzN3NuFMUd5Rdsvrxnuq1G4Yk=; b=lPqSMLj 6NYzo3uULp/RB08JlrPOn7p+G/mBGBolpFjT7uCFbuo5z+7/C/5DDD2yeSu0xKjg NBrEJDLG/MQo4pMyg+hku2Hj7DHiRWxdfdpiHwSk0S9MVWurpCzfK6pgHKQNuSR1 bLSfU9rdU2VuAZrU0mCuzp7mpajmjJdP04pLri48ErJ13oKcoSfwr7GSCuFIbSAL CLEXPYVu7WAMI0VeZGXVhpxqjBvVuXAmZMiJ/bGihT1CdoEeDbeTvwJZDhvrjMbc v3rBwrdqlxCD+WwVRgqVHKN57Y4KiQ6Gnh8wrQ/7xCfqhTUBMJf/IrTfgsZYeIC3 LY4ur68d758ldsw== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 1cea2433 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Wed, 6 Jan 2021 23:11:08 +0000 (UTC) Date: Wed, 06 Jan 2021 18:10:59 -0500 User-Agent: K-9 Mail for Android In-Reply-To: <87a6tl1yqu.fsf@gmail.com> References: <877dor34xe.fsf@gmail.com> <87a6tl1yqu.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----VNE1SXDTA0STRLUT5PT37XU56RJI4A" Content-Transfer-Encoding: 7bit Subject: Re: bug#45675: Zip-based archives store timestamps To: =?ISO-8859-1?Q?Miguel_=C1ngel_Arruga_Vivas?= From: Julien Lepiller Message-ID: <456A5C5F-50D7-4409-A36F-56BE670F9FE1@lepiller.eu> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45675 Cc: 45675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) ------VNE1SXDTA0STRLUT5PT37XU56RJI4A Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This sounds like a good idea indeed Le 6 janvier 2021 17:34:01 GMT-05:00, "Miguel =C3=81ngel Arruga Vivas" a =C3=A9crit : >Hi, > >Julien Lepiller writes: > >> For java packages, we have a strip-jar-timestamps phase in the >ant-build-system=2E > >Thanks for the pointer=2E Do you think could be worth to extract that >into (guix build utils) as the attached patch (WIP) does? It rebuilds >the world and replaces all of "old usages", so I'm still waiting to >reach ant-bootstrap=2E=2E=2E > >Happy hacking! >Miguel ------VNE1SXDTA0STRLUT5PT37XU56RJI4A Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable This sounds like a good idea indeed

Le 6 janvier 2021 17:34:01 GMT-05:00, "Miguel =C3=81nge= l Arruga Vivas" <rosen644835@gmail=2Ecom> a =C3=A9crit :
Hi,

Julien Lepiller <julien@lepiller=2Eeu&= gt; writes:

For jav= a packages, we have a strip-jar-timestamps phase in the ant-build-system=2E=

Thanks for the pointer=2E Do you think could be worth= to extract that
into (guix build utils) as the attached patch (WIP) doe= s? It rebuilds
the world and replaces all of "old usages", so I'm still= waiting to
reach ant-bootstrap=2E=2E=2E

Happy hacking!
Miguel=
------VNE1SXDTA0STRLUT5PT37XU56RJI4A--