wic: isoimage-isohybrid: check result of glob()

isoimage-isohybrid plugin uses result of glob call to
get path to initrd image. When glob returns empty list
the plugin crashes with IndexError.

Checking if result of glob call is not empty should fix
the breakage.

(From OE-Core rev: ad02f253f08a3da3fa5c86ae4f6ba7f94b070578)

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ed Bartosh
2017-07-14 15:33:03 +03:00
committed by Richard Purdie
parent 116e14fc45
commit f58ea8c814

View File

@@ -164,9 +164,12 @@ class IsoImagePlugin(SourcePlugin):
machine = os.path.basename(initrd_dir)
initrd = glob.glob('%s/%s*%s.%s' % (initrd_dir, image_name, machine, image_type))[0]
pattern = '%s/%s*%s.%s' % (initrd_dir, image_name, machine, image_type)
files = glob.glob(pattern)
if files:
initrd = files[0]
if not os.path.exists(initrd):
if not initrd or not os.path.exists(initrd):
# Create initrd from rootfs directory
initrd = "%s/initrd.cpio.gz" % cr_workdir
initrd_dir = "%s/INITRD" % cr_workdir