lorax-composer: Update the yum metadata at startup

Otherwise it can become out of date and depsolving will fail.
This commit is contained in:
Brian C. Lane 2018-03-13 15:16:12 -07:00
parent 2e61bc8bf9
commit e425b7ccca

View File

@ -22,7 +22,6 @@ log = logging.getLogger("lorax-composer")
import ConfigParser import ConfigParser
from fnmatch import fnmatchcase from fnmatch import fnmatchcase
from glob import glob from glob import glob
from distutils.util import strtobool
import os import os
import yum import yum
# This is a hack to short circuit yum's internal logging # This is a hack to short circuit yum's internal logging
@ -102,4 +101,13 @@ def get_base_object(conf):
if any(map(lambda pattern: fnmatchcase(name, pattern), enabled_repos)): # pylint: disable=cell-var-from-loop if any(map(lambda pattern: fnmatchcase(name, pattern), enabled_repos)): # pylint: disable=cell-var-from-loop
yb.getReposFromConfigFile(repo_file) yb.getReposFromConfigFile(repo_file)
# Update the metadata from the enabled repos to speed up later operations
log.info("Updating yum repository metadata")
for r in yb.repos.sort():
r.metadata_expire = 0
r.mdpolicy = "group:all"
yb.doRepoSetup()
yb.repos.doSetup()
yb.repos.populateSack(mdtype='all', cacheonly=1)
return yb return yb