Skip to content

Commit c45b59a

Browse files
committed
konflux-loxkfile: pick RPMs URLs from the pool repo
Priorize thfedora-coreos-pool repo as we know packages stay pinned longer there. Also it's where rpm-ostree pulls them from so it makse sense. This is a workaround for rpm-software-management/dnf5#2466
1 parent 9dc17d7 commit c45b59a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/konflux-rpm-lockfile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,25 @@ def query_packages_location(locks, repoquery_args):
106106
return pkg_urls
107107

108108
locked_nevras = [f'{k}-{v.get('evra', '')}' for (k, v) in locks.items()]
109-
cmd = ['dnf', 'repoquery'] + locked_nevras + repoquery_args
109+
queryfmt = ["--queryformat", "%{name} %{location}\n"]
110+
cmd = ['dnf', 'repoquery'] + locked_nevras + repoquery_args + queryfmt
110111
result = subprocess.check_output(cmd, text=True)
111112

112113
processed_urls = {}
113-
for line in result.strip().split('\n'):
114+
for line in result.split('\n'):
114115
# ignore empty lines
115116
if not line:
116117
continue
117-
parts = line.split(' ', 1)
118-
# If more than 1 URL is returned we pick the first one
119-
if len(parts) == 2:
120-
name, url = parts
121-
if name not in processed_urls:
122-
processed_urls[name] = url
118+
name, url = line.split(' ')
119+
# Prioritize the url from fedora-coreos-pool
120+
# there is a bug in dnf here where the url returned is incorrect when the
121+
# repofile have more than one baseurl, which causes ppc64le and s390x
122+
# urls comming from fedora and fedora-updates to be invalid
123+
# See https://github.com/rpm-software-management/dnf5/issues/2466
124+
existing_url = processed_urls.get(name, None)
125+
if 'coreos-pool' in url or not existing_url:
126+
processed_urls[name] = url
127+
123128
pkg_urls = list(processed_urls.values())
124129
# sanity check all the locked packages got resolved
125130
if len(pkg_urls) != len(locked_nevras):
@@ -169,7 +174,7 @@ def generate_main(args):
169174
repos = manifest_data.get('repos', [])
170175
repos += manifest_data.get('lockfile-repos', [])
171176

172-
repoquery_args = ["--queryformat", "%{name} %{location}\n", "--disablerepo=*", "--refresh", "--quiet"]
177+
repoquery_args = ["--disablerepo=*", "--refresh", "--quiet"]
173178
# Tell dnf to load repos files from $contextdir
174179
repoquery_args.extend([f"--setopt=reposdir={contextdir}"])
175180

0 commit comments

Comments
 (0)