diff --git a/src/pylorax/api/yumbase.py b/src/pylorax/api/yumbase.py index a9092236..18377e68 100644 --- a/src/pylorax/api/yumbase.py +++ b/src/pylorax/api/yumbase.py @@ -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 diff --git a/src/sbin/lorax-composer b/src/sbin/lorax-composer index 44fd64e8..2c3df668 100755 --- a/src/sbin/lorax-composer +++ b/src/sbin/lorax-composer @@ -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())