- log.write( "Copying kernel and initrd for booting.\n" )
- utils.sysexec( "cp %s/boot/kernel-boot%s /tmp/kernel" % (SYSIMG_PATH,option), log )
- utils.sysexec( "cp %s/boot/initrd-boot%s /tmp/initrd" % (SYSIMG_PATH,option), log )
+ log.write("Copying kernel and initrd for booting.\n")
+ if vars['virt'] == 'vs':
+ utils.sysexec("cp {}/boot/kernel-boot{} /tmp/kernel".format(SYSIMG_PATH, option), log)
+ utils.sysexec("cp {}/boot/initrd-boot{} /tmp/initrd".format(SYSIMG_PATH, option), log)
+ else:
+ # Use chroot to call rpm, b/c the bootimage&nodeimage rpm-versions may not work together
+ try:
+ kversion = os.popen("chroot {} rpm -qa kernel | tail -1 | cut -c 8-"\
+ .format(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;}'"\
+ .format(SYSIMG_PATH)).read().rstrip()
+
+ utils.sysexec("cp {}/boot/vmlinuz-{} /tmp/kernel".format(SYSIMG_PATH, kversion), log)
+ candidates = []
+ # f16/18: expect initramfs image here
+ candidates.append ("/boot/initramfs-{}.img".format(kversion))
+ # f20: uses a uid of some kind, e.g. /boot/543f88c129de443baaa65800cf3927ce/<kversion>/initrd
+ candidates.append ("/boot/*/{}/initrd".format(kversion))
+ # Ubuntu:
+ candidates.append ("/boot/initrd.img-{}".format(kversion))
+ def find_file_in_sysimg (candidates):
+ import glob
+ for pattern in candidates:
+ matches = glob.glob(SYSIMG_PATH+pattern)
+ log.write("locating initrd: found {} matches in {}\n".format(len(matches), pattern))
+ if matches:
+ return matches[0]
+ initrd = find_file_in_sysimg(candidates)
+ if initrd:
+ utils.sysexec("cp {} /tmp/initrd".format(initrd), log)
+ else:
+ raise Exception("Unable to locate initrd - bailing out")