From 2877a4c16e34c9130bd06627f7d44c6c41ce1df7 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Mon, 31 Mar 2014 17:31:01 -0400 Subject: [PATCH] Identify kernel version in a way that does not depend on rpm --- source/steps/ChainBootNode.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/steps/ChainBootNode.py b/source/steps/ChainBootNode.py index 5e7babf..01567ed 100644 --- a/source/steps/ChainBootNode.py +++ b/source/steps/ChainBootNode.py @@ -159,7 +159,13 @@ def Run( vars, log ): utils.sysexec( "cp %s/boot/initrd-boot%s /tmp/initrd" % (SYSIMG_PATH,option), log ) else: # Use chroot to call rpm, b/c the bootimage&nodeimage rpm-versions may not work together - kversion = os.popen("chroot %s rpm -qa kernel | tail -1 | cut -c 8-" % SYSIMG_PATH).read().rstrip() + try: + kversion = os.popen("chroot %s rpm -qa kernel | tail -1 | cut -c 8-" % SYSIMG_PATH).read().rstrip() + major_version = int(kversion[0]) # Check if the string looks like a kernel version + except: + # Try a different method for non-rpm-based distributions + kversion = os.popen("ls -lrt /lib/modules | tail -1 | awk '{print $9;}'").read().rstrip() + utils.sysexec( "cp %s/boot/vmlinuz-%s /tmp/kernel" % (SYSIMG_PATH,kversion), log ) candidates=[] # f16/18: expect initramfs image here -- 2.43.0