From 17a45ebb8a1aed4989e3884c473718c0b99ddeb4 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 5 Jan 2024 11:21:15 +0100 Subject: [PATCH] preserve times when generating and uploading staging repo --- build_stage_repository | 7 ++++++- upload_stage_rpms | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build_stage_repository b/build_stage_repository index 371f421..cecc046 100755 --- a/build_stage_repository +++ b/build_stage_repository @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +from email.utils import parsedate_to_datetime from subprocess import check_output, STDOUT, CalledProcessError from urllib.request import urlretrieve import os @@ -136,6 +137,7 @@ def sync_prod_repository(collection, version, target_dir, dist, arch): 'dnf', 'reposync', '--refresh', + '--remote-time', '--download-metadata', '--norepopath', '--repo', @@ -256,7 +258,10 @@ def download_copr_packages(packages, urls, repository, downloads_dir, included_p if not os.path.exists(f"{downloads_dir}/{name}"): print(f"Downloading {repository}/{name} to {downloads_dir}") - urlretrieve(download_url, f"{downloads_dir}/{name}") + filename, headers = urlretrieve(download_url, f"{downloads_dir}/{name}") + if 'Last-Modified' in headers: + modification_ts = parsedate_to_datetime(headers['Last-Modified']).timestamp() + os.utime(filename, (modification_ts, modification_ts)) else: print(f"Skipping {repository}/{name}. Already downloaded.") else: diff --git a/upload_stage_rpms b/upload_stage_rpms index 26302b3..050a754 100755 --- a/upload_stage_rpms +++ b/upload_stage_rpms @@ -5,4 +5,4 @@ USER='yumrepostage' HOST='web01.osuosl.theforeman.org' -rsync --checksum --perms --recursive --links --verbose --partial --one-file-system --delete-after "tmp/$PROJECT/$VERSION/" "$USER@$HOST:rsync_cache/$PROJECT/$VERSION/" +rsync --checksum --times --perms --recursive --links --verbose --partial --one-file-system --delete-after "tmp/$PROJECT/$VERSION/" "$USER@$HOST:rsync_cache/$PROJECT/$VERSION/"