Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make output archives more reproducible #55

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions go_modules
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def extract(filename, outdir):
os.chdir(outdir)

try:
libarchive.extract_file(filename)
libarchive.extract_file(filename, libarchive.extract.EXTRACT_TIME)
except libarchive.exception.ArchiveError as archive_error:
log.error(archive_error)
exit(1)
Expand Down Expand Up @@ -299,16 +299,21 @@ def main():
os.chdir(go_mod_dir)
vendor_dir = "vendor"

kwargs = {}
mtime = os.path.getmtime(go_mod_path)
log.debug(f"Set archive files times to {mtime}")

options = []
if archive_args["compression"] == "gzip":
options.append("!timestamp")
if archive_args["level"]:
kwargs["options"] = f"compression-level={archive_args['level']}"
options.append(f"compression-level={archive_args['level']}")
with libarchive.file_writer(
vendor_tarfile,
archive_args["format"],
archive_args["compression"],
**kwargs,
options=",".join(options),
) as new_archive:
new_archive.add_files(vendor_dir)
new_archive.add_files(vendor_dir, mtime=mtime, ctime=mtime, atime=mtime)
os.chdir(cwd)


Expand Down
Loading