Add the version to the log (#1335456)

Log the version number as INFO and add -V version display to
livemedia-creator.

Resolves: rhbz#1335456
This commit is contained in:
Brian C. Lane 2017-08-08 16:12:21 -07:00
parent 7aa71188b9
commit 1b29041089
3 changed files with 22 additions and 19 deletions

View File

@ -49,6 +49,14 @@ from treeinfo import TreeInfo
from discinfo import DiscInfo from discinfo import DiscInfo
from executils import runcmd, runcmd_output from 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 # List of drivers to remove on ppc64 arch to keep initrd < 32MiB
REMOVE_PPC64_DRIVERS = "floppy scsi_debug nouveau radeon cirrus mgag200" REMOVE_PPC64_DRIVERS = "floppy scsi_debug nouveau radeon cirrus mgag200"
REMOVE_PPC64_MODULES = "drm plymouth" REMOVE_PPC64_MODULES = "drm plymouth"
@ -155,14 +163,6 @@ class Lorax(BaseLoraxClass):
installpkgs = installpkgs or [] installpkgs = installpkgs or []
# get lorax version
try:
import pylorax.version
except ImportError:
vernum = "devel"
else:
vernum = pylorax.version.num
if domacboot: if domacboot:
try: try:
runcmd(["rpm", "-q", "hfsplus-tools"]) runcmd(["rpm", "-q", "hfsplus-tools"])

View File

@ -48,7 +48,7 @@ from mako.template import Template
from mako.exceptions import text_error_template from mako.exceptions import text_error_template
# Use the Lorax treebuilder branch for iso creation # Use the Lorax treebuilder branch for iso creation
from pylorax import ArchData from pylorax import ArchData, vernum
from pylorax.base import DataHolder from pylorax.base import DataHolder
from pylorax.treebuilder import TreeBuilder, RuntimeBuilder, udev_escape from pylorax.treebuilder import TreeBuilder, RuntimeBuilder, udev_escape
from pylorax.treebuilder import findkernels from pylorax.treebuilder import findkernels
@ -65,6 +65,8 @@ try:
except ImportError: except ImportError:
libvirt = None libvirt = None
VERSION = "{0}-{1}".format(os.path.basename(sys.argv[0]), vernum)
# Default parameters for rebuilding initramfs, override with --dracut-args # Default parameters for rebuilding initramfs, override with --dracut-args
DRACUT_DEFAULT = ["--xz", "--add", "livenet dmsquash-live convertfs pollcdrom", DRACUT_DEFAULT = ["--xz", "--add", "livenet dmsquash-live convertfs pollcdrom",
"--omit", "plymouth", "--no-hostonly", "--no-early-microcode"] "--omit", "plymouth", "--no-hostonly", "--no-early-microcode"]
@ -1136,10 +1138,16 @@ if __name__ == '__main__':
parser.add_argument( "--squashfs_args", parser.add_argument( "--squashfs_args",
help="additional squashfs args" ) help="additional squashfs args" )
# add the show version option
parser.add_argument("-V", help="show program's version number and exit",
action="version", version=VERSION)
# parse the arguments
opts = parser.parse_args() opts = parser.parse_args()
setup_logging(opts) setup_logging(opts)
log.info("livemedia-creator %s", vernum)
log.debug( opts ) log.debug( opts )
if os.getuid() != 0: if os.getuid() != 0:

View File

@ -42,6 +42,8 @@ import yum
yum.logginglevels._added_handlers = True yum.logginglevels._added_handlers = True
import pylorax import pylorax
VERSION = "{0}-{1}".format(os.path.basename(sys.argv[0]), pylorax.vernum)
def setup_logging(opts): def setup_logging(opts):
# Setup logging to console and to logfile # Setup logging to console and to logfile
log.setLevel(logging.DEBUG) log.setLevel(logging.DEBUG)
@ -77,14 +79,6 @@ def setup_logging(opts):
def main(args): def main(args):
# get lorax version
try:
from pylorax import version
vernum = version.num
except ImportError:
vernum = "devel"
version = "{0}-{1}".format(os.path.basename(args[0]), vernum)
usage = "%prog -p PRODUCT -v VERSION -r RELEASE -s REPOSITORY OUTPUTDIR" usage = "%prog -p PRODUCT -v VERSION -r RELEASE -s REPOSITORY OUTPUTDIR"
parser = OptionParser(usage=usage) parser = OptionParser(usage=usage)
@ -161,13 +155,13 @@ def main(args):
# add the show version option # add the show version option
parser.add_option("-V", help="show program's version number and exit", parser.add_option("-V", help="show program's version number and exit",
action="store_true", default=False, dest="showver") action="store_true", dest="showver")
# parse the arguments # parse the arguments
opts, args = parser.parse_args() opts, args = parser.parse_args()
if opts.showver: if opts.showver:
print(version) print(VERSION)
sys.exit(0) sys.exit(0)
try: try:
@ -190,6 +184,7 @@ def main(args):
setup_logging(opts) setup_logging(opts)
log.info("Lorax %s", pylorax.vernum)
tempfile.tempdir = opts.tmp tempfile.tempdir = opts.tmp
# create the temporary directory for lorax # create the temporary directory for lorax