Skip to content

Commit

Permalink
preserve times when generating and uploading staging repo
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Jan 8, 2024
1 parent 2fc267d commit 17a45eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion build_stage_repository
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -136,6 +137,7 @@ def sync_prod_repository(collection, version, target_dir, dist, arch):
'dnf',
'reposync',
'--refresh',
'--remote-time',
'--download-metadata',
'--norepopath',
'--repo',
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion upload_stage_rpms
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

0 comments on commit 17a45eb

Please sign in to comment.