Skip to content

Commit c7cb8d9

Browse files
oliverkurthGitHub Enterprise
authored andcommitted
Merge pull request #49 from vcf/topic/okurth/cherrpicks-support-snapshots
cherrpicks support snapshots
2 parents 5fc8244 + 947c2bd commit c7cb8d9

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

docker/create-cherrypicks-repo

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def main():
2929
try:
3030
opts, args = getopt.getopt(sys.argv[1:], "d:hs:p:", longopts=["base-repo-url=", "requires", "source-repo-url="])
3131
except:
32-
print (f"{sys.argv[0]}: invalid option")
32+
print(f"{sys.argv[0]}: invalid option")
3333
sys.exit(2)
3434

3535
for o, a in opts:
@@ -66,7 +66,7 @@ def main():
6666

6767
upstream_repos = plf_json.get('upstream-repos', {})
6868
if src_repo_url is not None:
69-
upstream_repos['_src_repo'] = {'baseurl' : src_repo_url, 'enabled': 1, 'gpgcheck': 0}
69+
upstream_repos['_src_repo'] = {'baseurl': src_repo_url, 'enabled': 1, 'gpgcheck': 0}
7070
for _, ur in upstream_repos.items():
7171
if 'priority' not in ur:
7272
ur['priority'] = 75
@@ -75,8 +75,20 @@ def main():
7575

7676
base_repos = plf_json.get('base-repos', {})
7777
for i, br_url in enumerate(base_repo_urls):
78+
snapshot = None
79+
# snapshot is optional, and is specified as a comma separated value
80+
# after the base URL
81+
if "," in br_url:
82+
br_url, snapshot = br_url.split(",", maxsplit=1)
7883
# make sure priority is higher (lower value), so this gets prefered over upstream_repos
79-
base_repos[f'_base_repo_{i}'] = {'baseurl' : br_url, 'enabled': 1, 'gpgcheck': 0, 'priority': 25}
84+
base_repos[f'_base_repo_{i}'] = {'baseurl': br_url, 'enabled': 1, 'gpgcheck': 0, 'priority': 25}
85+
if snapshot is not None:
86+
base_repos[f'_base_repo_{i}']['snapshot'] = snapshot
87+
88+
print("upstream repos:")
89+
print(json.dumps(upstream_repos, indent=4))
90+
print("base repos:")
91+
print(json.dumps(base_repos, indent=4))
8092

8193
packages = []
8294
if 'packages' in plf_json:
@@ -103,6 +115,15 @@ def main():
103115
tdnf_inst = tdnf.Tdnf(reposdir=repos_dir, installroot=install_root, releasever="5.0")
104116

105117
if do_requires:
118+
# cherry picked packages may have requirements that are not explictely listed,
119+
# but may be satisfied in the "base" repository. If so, we do not need to add them into
120+
# the temporary repository. We test for this by simulating an install, but with "downloadonly",
121+
# and using the "assumeno" option. Only packages from the upstream repo will be downloaded.
122+
123+
# Example: if we cherry-pick python3=3.11.13-4.ph5, it will require python3-libs=3.11.3-4.ph5, which will
124+
# also only be available in the upstream repo. However, it requires "openssl" as well, which is available in the base repo,
125+
# so we do not need to add it to the temporary repository.
126+
106127
# get list of all available packages
107128
retval, pkginfo_available = tdnf_inst.run(["list", "--available"])
108129
assert retval == 0, "tdnf failed while listing packages"
@@ -164,6 +185,9 @@ def main():
164185
packages = list(set(pkgs_all + packages))
165186

166187
retval, tdnf_out = tdnf_inst.run(["--downloadonly", f"--downloaddir={dst_repo_dir}", "--nodeps", "install"] + packages)
188+
print("tdnf output:")
189+
print(json.dumps(tdnf_out, indent=4))
190+
print(f"tdnf retval: {retval}")
167191
assert retval == 0, "tdnf failed while downloading packages"
168192

169193
subprocess.run(["createrepo", dst_repo_dir], check=True)

0 commit comments

Comments
 (0)