mk-origtargz: create reproducible tarballs and --mtime option
Adding a Reproducible Builds usertag and pinging the ML -- I hadn't
spotted this wishlist bug before.
On Thu Aug 31, 2017 at 10:57 AM CEST, Chris Lamb wrote:
mk-origtargz: create reproducible tarballs and --mtime option
Adding a Reproducible Builds usertag and pinging the ML -- I hadn't
spotted this wishlist bug before.
How about adding f.e. ``--sort name`` to the tar invocation?
+1 on reproducible tarballs.
On Thu, Mar 20, 2025 at 10:37:15PM +0100, Simon Josefsson wrote:
+1 on reproducible tarballs.
sure, +1, patches welcome! :) \o/
https://www.gnu.org/software/tar/manual/html_section/Formats.html
...
I also see 'posix' as archive format:
"The format defined by POSIX.1-2001 and later."
"This archive format will be the default format for future versions of
GNU tar."
...
btw: Is this what you mean by 'pax'?
The serverfault page describes it as POSIX.1-2001, but the Formats page doesn't have the word 'pax'.
Holger Levsen <holger@layer-acht.org> writes:
On Thu, Mar 20, 2025 at 10:37:15PM +0100, Simon Josefsson wrote:
+1 on reproducible tarballs.
sure, +1, patches welcome! :) \o/
Attached starting point, thoughts?
https://salsa.debian.org/debian/devscripts/-/merge_requests/490
The patch needs review/improvement from those more familiar with
mk-origtargz and the debian/tests/ framework.
My main argument is that solving this is harder than it looks, and I
fear that solving the general problem here may actually be infeasible.
It can help to realize this, otherwise one may think that solving this
is just a matter of adding the right parameters (which is what the patch attempt to do).
While we could attempt to continue patch things, how about a bigger
question: why do we re-create tarballs?
For those wanting to understand why solving the --mtime concern is a
hard problem, here is a partial helper tool to aid with this:
https://lists.gnu.org/archive/html/bug-gnulib/2025-02/msg00166.html
I dislike all that complexity though, so for some upstream projects
(libtasn1, libidn2, inetutils, ...) I am using a heavy hammer like this:
TAR_OPTIONS += --mode=go+u,go-w --mtime=$(abs_top_srcdir)/NEWS mtime-NEWS-to-git-HEAD:
$(AM_V_GEN)if test -e $(srcdir)/.git \
&& command -v git > /dev/null; then \
touch -m -t "$$(git log -1 --format=%cd --date=format-local:%Y%m%d%H%M.%S)" $(srcdir)/NEWS; \
fi
We could do the same in Debian, replacing NEWS with last timestamp of debian/changelog, but it is important to remember that this is an ugly workaround rather than a solution.
Solving it like this will lead to other problems.
Solving it properly requires going to the root cause of
the problem, which is what Bruno is chasing in that e-mail thread.
From a811a58bb007f7f0fe474e0ff1a105c48fedc238 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <simon@josefsson.org>
Date: Fri, 21 Mar 2025 09:40:48 +0100
Subject: [PATCH] MkOrigtargz: Improve tarball reproducibility.
The --format=ustar is better than the V7 format and is
a conservative choice if we don't want to switch to PAX
just yet, see discussion here: https://serverfault.com/questions/250511/which-tar-file-format-should-i-use
Using --numeric-owner --owner=0 --group=0 avoids relying on the target
system having a /etc/passwd and /etc/group user/group called 'root'
and that they both map to uid/gid 0 which is the intent.
Sorting filenames with --sort=name improve tarball reproducability.
Hard code permissions with --mode=go=rX,u+rw,a-s inspired by Guix.
Using --mtime and --clamp-mtime remains and is the complex part.
---
lib/Devscripts/MkOrigtargz.pm | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/lib/Devscripts/MkOrigtargz.pm b/lib/Devscripts/MkOrigtargz.pm index b1a691dc..86993afc 100644
--- a/lib/Devscripts/MkOrigtargz.pm
+++ b/lib/Devscripts/MkOrigtargz.pm
@@ -110,11 +110,19 @@ sub make_orig_targz {
# tar it all up
spawn(
exec => [
- 'tar', '--owner=root',
- '--group=root', '--mode=a+rX',
- '--create', '--file',
- "$destfiletar", '--directory',
- $tempdir, @files
+ 'tar',
+ '--format=ustar',
+ '--owner=0',
+ '--group=0',
+ '--numeric-owner',
+ '--sort=name',
+ '--mode=go=rX,u+rw,a-s',
+ '--create',
+ '--file',
+ "$destfiletar",
+ '--directory',
+ $tempdir,
+ @files
],
wait_child => 1
);
--
On Fri Mar 21, 2025 at 10:06 AM CET, Simon Josefsson wrote:
From a811a58bb007f7f0fe474e0ff1a105c48fedc238 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <simon@josefsson.org>
Date: Fri, 21 Mar 2025 09:40:48 +0100
Subject: [PATCH] MkOrigtargz: Improve tarball reproducibility.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 480 |
Nodes: | 16 (2 / 14) |
Uptime: | 250:37:42 |
Calls: | 9,532 |
Files: | 13,650 |
Messages: | 6,137,993 |