Add --releasever option to lorax-composer

If it isn't set the releasever value will use yum and the system / to
find the releasever.
This commit is contained in:
Brian C. Lane 2017-11-27 11:15:46 -08:00
parent d6f41fbfa1
commit efd15aaad7
2 changed files with 14 additions and 0 deletions

View File

@ -72,6 +72,14 @@ def get_base_object(conf):
if not os.path.isdir(yb.preconf.root):
os.makedirs(yb.preconf.root)
_releasever = conf.get_default("composer", "releasever", None)
if not _releasever:
distroverpkg = ['system-release(releasever)', 'redhat-release']
# Use yum private function to guess the releasever
_releasever = yum.config._getsysver("/", distroverpkg)
log.info("releasever = %s", _releasever)
yb.preconf.releasever = _releasever
# Turn on as much yum logging as we can
yb.preconf.debuglevel = 6
yb.preconf.errorlevel = 6

View File

@ -55,6 +55,8 @@ def get_parser():
help="show program's version number and exit")
parser.add_argument("-c", "--config", default="/etc/lorax/composer.conf", metavar="CONFIG",
help="Path to lorax-composer configuration file.")
parser.add_argument( "--releasever", default=None, metavar="STRING",
help="Release version to use for $releasever in yum repository urls" )
parser.add_argument("RECIPES", metavar="RECIPES",
help="Path to the recipes")
@ -128,6 +130,10 @@ if __name__ == '__main__':
server.config["GITLOCK"] = GitLock(repo=repo, lock=Lock(), dir=opts.RECIPES)
server.config["COMPOSER_CFG"] = configure(conf_file=opts.config)
# If the user passed in a releasever set it in the configuration
if opts.releasever:
server.config["COMPOSER_CFG"].set("composer", "releasever", opts.releasever)
# Get a YumBase to share with the requests
yb = get_base_object(server.config["COMPOSER_CFG"])
server.config["YUMLOCK"] = YumLock(yb=yb, lock=Lock())