]> git.ipfire.org Git - thirdparty/libarchive.git/commit
bsdtar: Support `--mtime` and `--clamp-mtime` (#2601)
authorZhaofeng Li <hello@zhaofeng.li>
Thu, 15 May 2025 12:08:14 +0000 (06:08 -0600)
committerGitHub <noreply@github.com>
Thu, 15 May 2025 12:08:14 +0000 (14:08 +0200)
commitc26f0377457db392bd57a640e8fe25506120f810
treebf22bbc8e145d137c4c9b6b6cd1052eb472a0e55
parent84ac71335fd7bc151be763dd525353c182b280b5
bsdtar: Support `--mtime` and `--clamp-mtime` (#2601)

Hi,

This PR adds support for setting a forced mtime on all written files
(`--mtime` and `--clamp-mtime`) in bsdtar.

The end goal will be to support all functionalities in
<https://reproducible-builds.org/docs/archives/#full-example>, namely
`--sort` and disabling other attributes (atime, ctime, etc.).

Fixes #971.

## History

- [v1](https://github.com/zhaofengli/libarchive/tree/forced-mtime-v1):
Added `archive_read_disk_set_forced_mtime` in libarchive. As a result,
it was only applied when reading from the filesystem and not from other
archives.
- [v2](https://github.com/zhaofengli/libarchive/tree/forced-mtime-v2):
Refactored to apply the forced mtime in `archive_write`.
- v3 (current): Reduced libarchive change to exposing
`archive_parse_date`, moved clamping logic into bsdtar.

---------

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
19 files changed:
COPYING
Makefile.am
contrib/android/Android.mk
libarchive/CMakeLists.txt
libarchive/archive.h
libarchive/archive_getdate.h [deleted file]
libarchive/archive_match.c
libarchive/archive_parse_date.c [moved from libarchive/archive_getdate.c with 99% similarity]
libarchive/test/CMakeLists.txt
libarchive/test/test_archive_match_time.c
libarchive/test/test_archive_parse_date.c [moved from libarchive/test/test_archive_getdate.c with 95% similarity]
tar/bsdtar.1
tar/bsdtar.c
tar/bsdtar.h
tar/cmdline.c
tar/test/CMakeLists.txt
tar/test/test_option_mtime.c [new file with mode: 0644]
tar/util.c
tar/write.c