1
1
#!/usr/bin/python3
2
2
3
+ import argparse
3
4
import dnf .subject
4
5
import hawkey
5
6
import os
@@ -41,13 +42,23 @@ def assert_epochs_match(overrides_epoch: int, rpmfile_epoch: str):
41
42
f" and overrides file entry ({ overrides_epoch } )" )
42
43
43
44
44
- assert os .path .isdir ("builds" ), "Missing builds/ dir; is this a cosa workdir?"
45
+ parser = argparse .ArgumentParser (description = 'Download override RPMs from koji.' )
46
+ parser .add_argument ('--downloaddir' , default = 'overrides/rpm' ,
47
+ help = 'Directory to download override RPMs to (default: overrides/rpm).' )
48
+ parser .add_argument ('--lockfiledir' , default = 'src/config' ,
49
+ help = 'Directory to check lock file (default: src/config).' )
50
+
51
+ args = parser .parse_args ()
52
+
53
+ for path in [args .downloaddir , args .lockfiledir ]:
54
+ assert os .path .isdir (path ), f"Not found: { path } "
55
+
56
+ print (f"Download override rpms to { args .downloaddir } /" )
45
57
46
58
rpms = set ()
47
- os .makedirs ('overrides/rpm' , exist_ok = True )
48
- for filename in os .listdir (os .path .join ("src/config" )):
59
+ for filename in os .listdir (args .lockfiledir ):
49
60
if is_override_lockfile (filename ):
50
- with open (f'src/config/ { filename } ' ) as f :
61
+ with open (os . path . join ( args . lockfiledir , filename ) ) as f :
51
62
lockfile = yaml .safe_load (f )
52
63
if lockfile is None or 'packages' not in lockfile :
53
64
continue
@@ -58,13 +69,13 @@ def assert_epochs_match(overrides_epoch: int, rpmfile_epoch: str):
58
69
rpminfo = get_rpminfo (f"{ pkg } -{ pkgobj ['evra' ]} " )
59
70
rpmnvra = f"{ rpminfo .name } -{ rpminfo .version } -{ rpminfo .release } .{ rpminfo .arch } "
60
71
rpms .add (rpmnvra )
61
- subprocess .check_call (['koji' , 'download-build' , '--rpm' , rpmnvra ], cwd = 'overrides/rpm' )
72
+ subprocess .check_call (['koji' , 'download-build' , '--rpm' , rpmnvra ], cwd = args . downloaddir )
62
73
# Make sure the epoch matches what was in the overrides file
63
74
# otherwise we can get errors: https://github.com/coreos/fedora-coreos-config/pull/293
64
75
cp = subprocess .run (['rpm' , '-qp' , '--queryformat' , '%{E}' , f'{ rpmnvra } .rpm' ],
65
76
check = True ,
66
77
capture_output = True ,
67
- cwd = 'overrides/rpm' )
78
+ cwd = args . downloaddir )
68
79
rpmfile_epoch = cp .stdout .decode ('utf-8' )
69
80
assert_epochs_match (rpminfo .epoch , rpmfile_epoch )
70
81
0 commit comments