Fix a problem with using a mirror as the primary url

Because of how Anaconda is run it needs to be passed a baseurl (using
--repo on the anaconda cmdline), not a mirrorlist url. This fixes it so
that the first mirror is used if the main repository is using a
mirrorlist.
This commit is contained in:
Brian C. Lane 2018-02-12 17:38:58 -08:00
parent a1427b1a31
commit c399447b81
2 changed files with 13 additions and 1 deletions

View File

@ -52,7 +52,15 @@ def repo_to_ks(r, url="url"):
Set url to "baseurl" if it is a repo, leave it as "url" for the installation url. Set url to "baseurl" if it is a repo, leave it as "url" for the installation url.
""" """
cmd = "" cmd = ""
if r.metalink: if url == "url":
if not r.urls:
raise RuntimeError("Cannot find a base url for %s" % r.name)
# url is passed to Anaconda on the cmdline with --repo, so it cannot support a mirror
# If a mirror is setup yum will return the list of mirrors in .urls
# So just use the first one.
cmd += '--%s="%s" ' % (url, r.urls[0])
elif r.metalink:
# XXX Total Hack # XXX Total Hack
# RHEL7 kickstart doesn't support metalink. If the url has 'metalink' in it, rewrite it as 'mirrorlist' # RHEL7 kickstart doesn't support metalink. If the url has 'metalink' in it, rewrite it as 'mirrorlist'
if "metalink" in r.metalink: if "metalink" in r.metalink:

View File

@ -142,6 +142,10 @@ def make_compose(cfg, results_dir):
ks_version = makeVersion(RHEL7) ks_version = makeVersion(RHEL7)
ks = KickstartParser(ks_version, errorsAreFatal=False, missingIncludeIsFatal=False) ks = KickstartParser(ks_version, errorsAreFatal=False, missingIncludeIsFatal=False)
ks.readKickstart(ks_path) ks.readKickstart(ks_path)
# anaconda can only handle a url, it cannot use a mirrorlist or metalink for the primary repository.
if not ks.handler.method.url:
raise RuntimeError("The kickstart is missing a valid url line")
repo_url = ks.handler.method.url repo_url = ks.handler.method.url
# Load the compose configuration # Load the compose configuration