From 52070f045c965810d518517fd8024fcffeb43783 Mon Sep 17 00:00:00 2001 From: Mark Hamzy Date: Wed, 3 Apr 2013 15:32:25 -0500 Subject: [PATCH] fix version query and add one to the log file Fix "lorax -V" and add a "version is ???" to the log file so we can easily know what version of lorax is used to build an iso. Changed to try/import for versioning because the version file is autogenerated. --- src/pylorax/__init__.py | 10 ++++++++++ src/sbin/lorax | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index 069628e8..37829da8 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -142,6 +142,14 @@ class Lorax(BaseLoraxClass): assert self._configured + # get lorax version + try: + import pylorax.version + except ImportError: + vernum = "devel" + else: + vernum = pylorax.version.num + if domacboot: try: runcmd(["rpm", "-q", "hfsplus-tools"]) @@ -161,6 +169,8 @@ class Lorax(BaseLoraxClass): self.init_stream_logging() self.init_file_logging(logdir) + + logger.debug("version is {0}".format(vernum)) logger.debug("using work directory {0.workdir}".format(self)) logger.debug("using log directory {0}".format(logdir)) diff --git a/src/sbin/lorax b/src/sbin/lorax index d831b971..4aab5406 100755 --- a/src/sbin/lorax +++ b/src/sbin/lorax @@ -76,7 +76,15 @@ def setup_logging(opts): def main(args): - version = "{0} 0.1".format(os.path.basename(args[0])) + # get lorax version + try: + import pylorax.version + except ImportError: + vernum = "devel" + else: + vernum = pylorax.version.num + + version = "{0}-{1}".format(os.path.basename(args[0]), vernum) usage = "%prog -p PRODUCT -v VERSION -r RELEASE -s REPOSITORY OUTPUTDIR" parser = OptionParser(usage=usage) @@ -136,15 +144,15 @@ def main(args): # parse the arguments opts, args = parser.parse_args() + if opts.showver: + print(version) + sys.exit(0) + try: outputdir = os.path.abspath(args[0]) except IndexError: parser.error("missing one or more required arguments") - if opts.showver: - print(version) - sys.exit(0) - # check for the required arguments if not opts.product or not opts.version or not opts.release \ or not opts.source or not outputdir: