]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: isoimage-isohybrid: check result of glob()
authorEd Bartosh <ed.bartosh@linux.intel.com>
Fri, 14 Jul 2017 12:33:03 +0000 (15:33 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 17 Jul 2017 12:48:54 +0000 (13:48 +0100)
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.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/lib/wic/plugins/source/isoimage-isohybrid.py

index ffa542996221f429a4402e18303c3147068e0e40..ece4b0c19ea4e144e7945d9e11039632025565c2 100644 (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