Skip to content

Commit b602161

Browse files
committed
Set mirrorlist instead of baseurl in .repo files & accept both when reading
This is related to the new preload functionality of zypper. See https://lists.opensuse.org/archives/list/[email protected]/thread/JR725AXWDZYLJ3PKIKYAYQQAXE6OWQMM/
1 parent 72d6483 commit b602161

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

opi/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ def get_repos():
271271
for alias in cp.sections():
272272
if not bool(int(cp.get(alias, 'enabled'))):
273273
continue
274+
url = cp[alias].get('baseurl')
275+
if not url:
276+
url = cp[alias].get('mirrorlist')
277+
if url:
278+
url = re.sub(r"\?mirrorlist$", "", url)
274279
repo = {
275280
'alias': alias,
276281
'filename': re.sub(r'\.repo$', '', repo_file),
@@ -293,7 +298,14 @@ def add_repo(filename, name, url, enabled=True, gpgcheck=True, gpgkey=None, repo
293298
tf = tempfile.NamedTemporaryFile('w')
294299
tf.file.write(f'[{filename}]\n')
295300
tf.file.write(f'name={name}\n')
296-
tf.file.write(f'baseurl={url}\n')
301+
if url.startswith('https://download.opensuse.org') or url.startswith('https://cdn.opensuse.org'):
302+
# These servers support the /?mirrorlist suffix
303+
# see https://lists.opensuse.org/archives/list/[email protected]/thread/JR725AXWDZYLJ3PKIKYAYQQAXE6OWQMM/
304+
if not url.endswith('/'):
305+
url = f"{url}/"
306+
tf.file.write(f'mirrorlist={url}?mirrorlist\n')
307+
else:
308+
tf.file.write(f'baseurl={url}\n')
297309
tf.file.write(f'enabled={enabled:d}\n')
298310
tf.file.write(f'type={repo_type}\n')
299311
tf.file.write(f'gpgcheck={gpgcheck:d}\n')

0 commit comments

Comments
 (0)