From e3dcb1e3295dd3620c376be5219ca37df73d4926 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 8 Aug 2017 15:14:15 -0700 Subject: [PATCH] Add version output (#1335456) Add -V to livemedia-creator, and log the running version when lorax or lmc is started. --- src/pylorax/__init__.py | 17 +++++++++-------- src/pylorax/cmdline.py | 17 ++++++++--------- src/sbin/livemedia-creator | 4 +++- src/sbin/lorax | 2 ++ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index 1f9ac6e4..fac2a755 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -49,6 +49,15 @@ from pylorax.treeinfo import TreeInfo from pylorax.discinfo import DiscInfo from pylorax.executils import runcmd, runcmd_output + +# get lorax version +try: + import pylorax.version +except ImportError: + vernum = "devel" +else: + vernum = pylorax.version.num + # List of drivers to remove on ppc64 arch to keep initrd < 32MiB REMOVE_PPC64_DRIVERS = "floppy scsi_debug nouveau radeon cirrus mgag200" REMOVE_PPC64_MODULES = "drm plymouth" @@ -178,14 +187,6 @@ class Lorax(BaseLoraxClass): installpkgs = installpkgs or [] excludepkgs = excludepkgs or [] - # get lorax version - try: - import pylorax.version - except ImportError: - vernum = "devel" - else: - vernum = pylorax.version.num - if domacboot: try: runcmd(["rpm", "-q", "hfsplus-tools"]) diff --git a/src/pylorax/cmdline.py b/src/pylorax/cmdline.py index 40527a9f..1b6662d5 100644 --- a/src/pylorax/cmdline.py +++ b/src/pylorax/cmdline.py @@ -22,18 +22,13 @@ import os import sys import argparse +from pylorax import vernum + +version = "{0}-{1}".format(os.path.basename(sys.argv[0]), vernum) + def lorax_parser(): """ Return the ArgumentParser for lorax""" - # get lorax version - try: - from pylorax import version - vernum = version.num - except ImportError: - vernum = "devel" - - version = "{0}-{1}".format(os.path.basename(sys.argv[0]), vernum) - parser = argparse.ArgumentParser(description="Create the Anaconda boot.iso") # required arguments for image creation @@ -290,4 +285,8 @@ def lmc_parser(dracut_default=""): parser.add_argument("--timeout", default=None, type=int, help="Cancel installer after X minutes") + # add the show version option + parser.add_argument("-V", help="show program's version number and exit", + action="version", version=version) + return parser diff --git a/src/sbin/livemedia-creator b/src/sbin/livemedia-creator index ec9b2139..149cb1c7 100755 --- a/src/sbin/livemedia-creator +++ b/src/sbin/livemedia-creator @@ -44,7 +44,7 @@ from mako.template import Template from mako.exceptions import text_error_template # Use the Lorax treebuilder branch for iso creation -from pylorax import ArchData, setup_logging, find_templates +from pylorax import ArchData, setup_logging, find_templates, vernum from pylorax.base import DataHolder from pylorax.treebuilder import TreeBuilder, RuntimeBuilder, udev_escape from pylorax.treebuilder import findkernels @@ -1199,6 +1199,8 @@ def main(): log.debug( opts ) + log.info("livemedia-creator v%s", vernum) + # Find the lorax templates opts.lorax_templates = find_templates(opts.lorax_templates or "/usr/share/lorax") diff --git a/src/sbin/lorax b/src/sbin/lorax index 8a7814b3..0e2f0feb 100755 --- a/src/sbin/lorax +++ b/src/sbin/lorax @@ -54,6 +54,8 @@ def main(): parser = lorax_parser() opts = parser.parse_args() + log.info("Lorax v%s", pylorax.vernum) + if not opts.source and not opts.repos: parser.error("--source, --repo, or both are required.")