From 75a5bf6f50a6ddccda6afcc9f3dc610f1b25d9c7 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 7 Dec 2015 14:01:28 +0100 Subject: [PATCH] bugfixes for the location of kernel and initrd as observed on recent f23 plus, a couple of calls to format() had real {} that needed doubling --- source/steps/ChainBootNode.py | 29 ++++++++++++++++++++++------- source/steps/ValidateNodeInstall.py | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/source/steps/ChainBootNode.py b/source/steps/ChainBootNode.py index d298dea..1fa9609 100644 --- a/source/steps/ChainBootNode.py +++ b/source/steps/ChainBootNode.py @@ -168,17 +168,24 @@ def Run(vars, log): 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;}'"\ + kversion = os.popen("ls -lrt {}/lib/modules | tail -1 | awk '{{print $9;}}'"\ .format(SYSIMG_PATH)).read().rstrip() - utils.sysexec("cp {}/boot/vmlinuz-{} /tmp/kernel".format(SYSIMG_PATH, kversion), log) - candidates = [] + # kernel and initrd come in various locations depending on the distro + + kernel_candidates = [] + kernel_candidates.append("/boot/vmlinux-{}*".format(kversion)) + # on f23 starting dec. 2015 - what a twisted naming scheme + kernel_candidates.append("/boot/*/{}*/initrd".format(kversion)) + + initrd_candidates = [] # f16/18: expect initramfs image here - candidates.append ("/boot/initramfs-{}.img".format(kversion)) + initrd_candidates.append ("/boot/initramfs-{}.img".format(kversion)) # f20: uses a uid of some kind, e.g. /boot/543f88c129de443baaa65800cf3927ce//initrd - candidates.append ("/boot/*/{}/initrd".format(kversion)) + initrd_candidates.append ("/boot/*/{}/initrd".format(kversion)) # Ubuntu: - candidates.append ("/boot/initrd.img-{}".format(kversion)) + initrd_candidates.append ("/boot/initrd.img-{}".format(kversion)) + def find_file_in_sysimg (candidates): import glob for pattern in candidates: @@ -186,7 +193,15 @@ def Run(vars, log): log.write("locating initrd: found {} matches in {}\n".format(len(matches), pattern)) if matches: return matches[0] - initrd = find_file_in_sysimg(candidates) + + kernel = find_file_in_sysimg(kernel_candidates) + if kernel: + utils.sysexec("cp {} /tmp/kernel".format(kernel), log) + else: + raise Exception("Unable to locate kernel - bailing out") + + + initrd = find_file_in_sysimg(initrd_candidates) if initrd: utils.sysexec("cp {} /tmp/initrd".format(initrd), log) else: diff --git a/source/steps/ValidateNodeInstall.py b/source/steps/ValidateNodeInstall.py index becb675..159d4d3 100644 --- a/source/steps/ValidateNodeInstall.py +++ b/source/steps/ValidateNodeInstall.py @@ -157,7 +157,7 @@ def Run(vars, log): os.stat("{}/boot/vmlinuz-{}".format(SYSIMG_PATH, kversion)) major_version = int(kversion[0]) # Check if the string looks like a kernel version except: - kversion = os.popen("ls -lrt {}/lib/modules | tail -1 | awk '{print $9;}'"\ + kversion = os.popen("ls -lrt {}/lib/modules | tail -1 | awk '{{print $9;}}'"\ .format(SYSIMG_PATH)).read().rstrip() except OSError as e: log.write("Couldn't locate base kernel (you might be using the stock kernel).\n") -- 2.43.0