From 77a7eb266d924351ac0dcd93cfadb4789a2d740d Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 28 Oct 2015 17:56:23 -0700 Subject: [PATCH] lorax: Add --sharedir to override configuration path One of the most useful things to override is the path to the templates, this adds a cmdline option to do that instead of needing to create a whole configuration file and pass it. --- src/sbin/lorax | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sbin/lorax b/src/sbin/lorax index 71b9fa7a..897f7a9a 100755 --- a/src/sbin/lorax +++ b/src/sbin/lorax @@ -116,6 +116,8 @@ def main(args): default=[]) optional.add_argument("--noverify", action="store_false", default=True, dest="verify", help="Do not verify the install root") + optional.add_argument("--sharedir", metavar="SHAREDIR", type=os.path.abspath, + help="Directory containing all the templates. Overrides config file sharedir") # add the show version option parser.add_argument("-V", help="show program's version number and exit", @@ -146,6 +148,8 @@ def main(args): opts.cachedir = os.path.abspath(opts.cachedir) if opts.workdir: opts.workdir = os.path.abspath(opts.workdir) + if opts.sharedir and not os.path.isdir(opts.sharedir): + parser.error("sharedir %s doesn't exist." % opts.sharedir) setup_logging(opts) @@ -193,6 +197,11 @@ def main(args): lorax = pylorax.Lorax() lorax.configure(conf_file=opts.config) lorax.conf.set("lorax", "logdir", os.path.dirname(opts.logfile)) + + # Override the config file's template sharedir + if opts.sharedir: + lorax.conf.set("lorax", "sharedir", opts.sharedir) + lorax.run(dnfbase, opts.product, opts.version, opts.release, opts.variant, opts.bugurl, opts.isfinal, workdir=tempdir, outputdir=outputdir, buildarch=opts.buildarch,