patchGNU tar - Patches: patch #8925, Support --clamp-mtime for binary...


You are not allowed to post comments on this tracker with your current authentication level.

patch #8925: Support --clamp-mtime for binary reproducibility

Submitter:  Ximin Luo <infinity0>
Submitted:  Wed 02 Mar 2016 01:25:12 PM UTC
Category:  Operations on Archives Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  gray Open/Closed:  Closed

Thu 24 Mar 2016 05:33:34 AM UTC, comment #1: 

The patch is incorporated into Git repository (commit 13d04fe6ae5a343415299359944382f7a6d37816). It will appear in the next stable release of GNU tar (v.1.29). Thank you!

Sergey Poznyakoff <gray>
Group administrator
Wed 02 Mar 2016 01:25:12 PM UTC, original submission:  

[This is a resubmission of]

This feature is desired by important users of tar for reproducible
archive creation (e.g., dpkg-dev -- see
<>).  It is intended in the same
spirit as other features in GNU tar (e.g., --exclude-vcs-ignores) that
offer simple ways to handle common use cases related to software
development and distribution.

The new `--clamp-mtime` option will change the behavior of `--mtime` to
only use the time specified if the file mtime is newer than the given time.
The `--clamp-mtime` option can only be used together with `--mtime`.

This addresses a common scenario: a software distributor wants to ship
compiled binaries, but the package shipped should also include some
files copied directly from the source distribution (e.g. config files,
etc).  At the same time, we'd like the archive in question to be
"reproducible" where possible -- getting a byte-for-byte identical
match upon rebuild.  See <> for more

With this feature, a reproducible tarball can be created by noting the
time just before the build (either via $(date) or some pre-build
artifact like a revision control system or changelog), and then
bounding the mtimes in the resulting archive via --clamp-mtime.

In order to implement the option, we transform `set_mtime_option` from
a bool to an enum with three values: use original file mtime, force all mtimes
to be of the same value, and clamp mtimes (as explained above).

To verify that `--clamp-mtime` is used together with `--mtime`, `mtime_option`
is now initialized to a minimal value as done for `newer_mtime_option`. As
the same macro can now be used for both options, NEWER_OPTION_INITIALIZED
has been renamed to TIME_OPTION_INITIALIZED.

Documentation and the test suite have also been updated.
 doc/tar.1          |  5 ++++-
 doc/tar.texi       | 21 +++++++++++++++++++++
 src/common.h       | 17 ++++++++++++-----
 src/create.c       | 15 ++++++++++++++-
 src/list.c         |  2 +-
 src/tar.c          | 23 ++++++++++++++++++++---
 tests/  |  1 +
 tests/ |  1 +
 tests/    | 42 ++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 116 insertions(+), 11 deletions(-)

Ximin Luo <infinity0>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #36526:  clamp-mtime.patch added by infinity0 (10KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by gray (Posted a comment)
  • -email is unavailable- added by infinity0 (Submitted the item)
  • -email is unavailable- added by infinity0

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-12 gray Open/ClosedOpen Closed
    2016-03-24 gray StatusNone Done
        Assigned toNone gray
    2016-03-02 infinity0 Attached File- Added clamp-mtime.patch, #36526
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code