New option --clamp-mtime
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`. Typical use case is to make builds reproducible: to loose less information, it's better to keep the original date of an archive, except for files modified during the build process. In that case, using a reference (and thus reproducible) timestamps for the latter is good enough. See <https://wiki.debian.org/ReproducibleBuilds> for more information. Patch submitted by Jeremy Bobbio and Daniel Kahn Gillmor <dkg@fifthhorseman.net> * doc/tar.1: Document --clamp-mtime * doc/tar.texi: Likewise. * src/common.h (set_mtime_option_mode): New enum (set_mtime_option): Change type to enum set_mtime_option_mode. (NEWER_OPTION_INITIALIZED): Rename to NEWER_OPTION_INITIALIZED. * src/create.c (start_header): Set mtime depending on set_mtime_option. * src/tar.c (options,parse_opt): New option --clamp-mtime (decode_options): Initialize mtime_option * tests/time02.at: New testcase. * tests/Makefile.am: Add new testcase * tests/testsuite.at: Likewise.
This commit is contained in:
committed by
Sergey Poznyakoff
parent
8d31493c99
commit
13d04fe6ae
@@ -13,7 +13,7 @@
|
||||
.\"
|
||||
.\" You should have received a copy of the GNU General Public License
|
||||
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
.TH TAR 1 "March 16, 2016" "TAR" "GNU TAR Manual"
|
||||
.TH TAR 1 "March 23, 2016" "TAR" "GNU TAR Manual"
|
||||
.SH NAME
|
||||
tar \- an archiving utility
|
||||
.SH SYNOPSIS
|
||||
@@ -1051,6 +1051,9 @@ Display progress messages every \fIN\fRth record (default 10).
|
||||
\fB\-\-checkpoint\-action\fR=\fIACTION\fR
|
||||
Run \fIACTION\fR on each checkpoint.
|
||||
.TP
|
||||
\fB\-\-clamp\-mtime\fR
|
||||
Only set time when the file is more recent than what was given with \-\-mtime.
|
||||
.TP
|
||||
\fB\-\-full\-time\fR
|
||||
Print file time to its full resolution.
|
||||
.TP
|
||||
|
||||
21
doc/tar.texi
21
doc/tar.texi
@@ -2585,6 +2585,11 @@ complies to UNIX98, was introduced with version
|
||||
writing the archive. This allows you to directly act on archives
|
||||
while saving space. @xref{gzip}.
|
||||
|
||||
@opsummary{clamp-mtime}
|
||||
@item --clamp-mtime
|
||||
|
||||
(See @option{--mtime}.)
|
||||
|
||||
@opsummary{confirmation}
|
||||
@item --confirmation
|
||||
|
||||
@@ -2985,6 +2990,11 @@ either a textual date representation (@pxref{Date input formats}) or a
|
||||
name of the existing file, starting with @samp{/} or @samp{.}. In the
|
||||
latter case, the modification time of that file is used. @xref{override}.
|
||||
|
||||
When @command{--clamp-mtime} is also specified, files with
|
||||
modification times earlier than @var{date} will retain their actual
|
||||
modification times, and @var{date} will only be used for files whose
|
||||
modification times are later than @var{date}.
|
||||
|
||||
@opsummary{multi-volume}
|
||||
@item --multi-volume
|
||||
@itemx -M
|
||||
@@ -5445,6 +5455,17 @@ tar: Option --mtime: Treating date 'yesterday' as 2006-06-20
|
||||
@dots{}
|
||||
@end smallexample
|
||||
|
||||
@noindent
|
||||
When used with @option{--clamp-mtime} @GNUTAR{} will only set the
|
||||
modification date to @var{date} on files whose actual modification
|
||||
date is later than @var{date}. This is to make it easy to build
|
||||
reproducible archives given a common timestamp for generated files
|
||||
while still retaining the original timestamps of untouched files.
|
||||
|
||||
@smallexample
|
||||
$ @kbd{tar -c -f archive.tar --clamp-mtime --mtime=@atchar{}$SOURCE_DATE_EPOCH .}
|
||||
@end smallexample
|
||||
|
||||
@item --owner=@var{user}
|
||||
@opindex owner
|
||||
|
||||
|
||||
Reference in New Issue
Block a user