summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/plugins/source/isoimage-isohybrid.py')
-rw-r--r--scripts/lib/wic/plugins/source/isoimage-isohybrid.py63
1 files changed, 23 insertions, 40 deletions
diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
index 33de6d8db5..df86acc0e0 100644
--- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
+++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
@@ -25,8 +25,8 @@ import logging
25import os 25import os
26import re 26import re
27import shutil 27import shutil
28import sys
29 28
29from wic.errors import WicError
30from wic.engine import get_custom_config 30from wic.engine import get_custom_config
31from wic.pluginbase import SourcePlugin 31from wic.pluginbase import SourcePlugin
32from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var 32from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var
@@ -106,9 +106,8 @@ class IsoImagePlugin(SourcePlugin):
106 logger.debug("Using custom configuration file %s for grub.cfg", 106 logger.debug("Using custom configuration file %s for grub.cfg",
107 configfile) 107 configfile)
108 else: 108 else:
109 logger.error("configfile is specified " 109 raise WicError("configfile is specified "
110 "but failed to get it from %s", configfile) 110 "but failed to get it from %s", configfile)
111 sys.exit(1)
112 else: 111 else:
113 splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg") 112 splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg")
114 if os.path.exists(splash): 113 if os.path.exists(splash):
@@ -153,23 +152,19 @@ class IsoImagePlugin(SourcePlugin):
153 if not initrd: 152 if not initrd:
154 initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 153 initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
155 if not initrd_dir: 154 if not initrd_dir:
156 logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting.\n") 155 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting.")
157 sys.exit(1)
158 156
159 image_name = get_bitbake_var("IMAGE_BASENAME") 157 image_name = get_bitbake_var("IMAGE_BASENAME")
160 if not image_name: 158 if not image_name:
161 logger.error("Couldn't find IMAGE_BASENAME, exiting.\n") 159 raise WicError("Couldn't find IMAGE_BASENAME, exiting.")
162 sys.exit(1)
163 160
164 image_type = get_bitbake_var("INITRAMFS_FSTYPES") 161 image_type = get_bitbake_var("INITRAMFS_FSTYPES")
165 if not image_type: 162 if not image_type:
166 logger.error("Couldn't find INITRAMFS_FSTYPES, exiting.\n") 163 raise WicError("Couldn't find INITRAMFS_FSTYPES, exiting.")
167 sys.exit(1)
168 164
169 target_arch = get_bitbake_var("TRANSLATED_TARGET_ARCH") 165 target_arch = get_bitbake_var("TRANSLATED_TARGET_ARCH")
170 if not target_arch: 166 if not target_arch:
171 logger.error("Couldn't find TRANSLATED_TARGET_ARCH, exiting.\n") 167 raise WicError("Couldn't find TRANSLATED_TARGET_ARCH, exiting.")
172 sys.exit(1)
173 168
174 initrd = glob.glob('%s/%s*%s.%s' % (initrd_dir, image_name, target_arch, image_type))[0] 169 initrd = glob.glob('%s/%s*%s.%s' % (initrd_dir, image_name, target_arch, image_type))[0]
175 170
@@ -192,8 +187,7 @@ class IsoImagePlugin(SourcePlugin):
192 os.symlink(os.readlink("%s/sbin/init" % rootfs_dir), \ 187 os.symlink(os.readlink("%s/sbin/init" % rootfs_dir), \
193 "%s/init" % initrd_dir) 188 "%s/init" % initrd_dir)
194 else: 189 else:
195 logger.error("Couldn't find or build initrd, exiting.\n") 190 raise WicError("Couldn't find or build initrd, exiting.")
196 sys.exit(1)
197 191
198 exec_cmd("cd %s && find . | cpio -o -H newc -R +0:+0 >./initrd.cpio " \ 192 exec_cmd("cd %s && find . | cpio -o -H newc -R +0:+0 >./initrd.cpio " \
199 % initrd_dir, as_shell=True) 193 % initrd_dir, as_shell=True)
@@ -239,8 +233,7 @@ class IsoImagePlugin(SourcePlugin):
239 233
240 if part.rootfs_dir is None: 234 if part.rootfs_dir is None:
241 if not 'ROOTFS_DIR' in rootfs_dir: 235 if not 'ROOTFS_DIR' in rootfs_dir:
242 logger.error("Couldn't find --rootfs-dir, exiting.\n") 236 raise WicError("Couldn't find --rootfs-dir, exiting.")
243 sys.exit(1)
244 rootfs_dir = rootfs_dir['ROOTFS_DIR'] 237 rootfs_dir = rootfs_dir['ROOTFS_DIR']
245 else: 238 else:
246 if part.rootfs_dir in rootfs_dir: 239 if part.rootfs_dir in rootfs_dir:
@@ -248,16 +241,14 @@ class IsoImagePlugin(SourcePlugin):
248 elif part.rootfs_dir: 241 elif part.rootfs_dir:
249 rootfs_dir = part.rootfs_dir 242 rootfs_dir = part.rootfs_dir
250 else: 243 else:
251 logger.error("Couldn't find --rootfs-dir=%s connection " 244 raise WicError("Couldn't find --rootfs-dir=%s connection "
252 "or it is not a valid path, exiting.\n", 245 "or it is not a valid path, exiting." %
253 part.rootfs_dir) 246 part.rootfs_dir)
254 sys.exit(1)
255 247
256 if not os.path.isdir(rootfs_dir): 248 if not os.path.isdir(rootfs_dir):
257 rootfs_dir = get_bitbake_var("IMAGE_ROOTFS") 249 rootfs_dir = get_bitbake_var("IMAGE_ROOTFS")
258 if not os.path.isdir(rootfs_dir): 250 if not os.path.isdir(rootfs_dir):
259 logger.error("Couldn't find IMAGE_ROOTFS, exiting.\n") 251 raise WicError("Couldn't find IMAGE_ROOTFS, exiting.")
260 sys.exit(1)
261 252
262 part.rootfs_dir = rootfs_dir 253 part.rootfs_dir = rootfs_dir
263 254
@@ -296,8 +287,7 @@ class IsoImagePlugin(SourcePlugin):
296 if source_params.get('initrd'): 287 if source_params.get('initrd'):
297 initrd = source_params['initrd'] 288 initrd = source_params['initrd']
298 if not deploy_dir: 289 if not deploy_dir:
299 logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") 290 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
300 sys.exit(1)
301 cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir) 291 cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir)
302 exec_cmd(cp_cmd) 292 exec_cmd(cp_cmd)
303 else: 293 else:
@@ -340,8 +330,7 @@ class IsoImagePlugin(SourcePlugin):
340 # didn't contains it 330 # didn't contains it
341 target_arch = get_bitbake_var("TARGET_SYS") 331 target_arch = get_bitbake_var("TARGET_SYS")
342 if not target_arch: 332 if not target_arch:
343 logger.error("Coludn't find target architecture\n") 333 raise WicError("Coludn't find target architecture")
344 sys.exit(1)
345 334
346 if re.match("x86_64", target_arch): 335 if re.match("x86_64", target_arch):
347 grub_target = 'x86_64-efi' 336 grub_target = 'x86_64-efi'
@@ -350,21 +339,18 @@ class IsoImagePlugin(SourcePlugin):
350 grub_target = 'i386-efi' 339 grub_target = 'i386-efi'
351 grub_image = "bootia32.efi" 340 grub_image = "bootia32.efi"
352 else: 341 else:
353 logger.error("grub-efi is incompatible with target %s\n", 342 raise WicError("grub-efi is incompatible with target %s" %
354 target_arch) 343 target_arch)
355 sys.exit(1)
356 344
357 if not os.path.isfile("%s/EFI/BOOT/%s" \ 345 if not os.path.isfile("%s/EFI/BOOT/%s" \
358 % (bootimg_dir, grub_image)): 346 % (bootimg_dir, grub_image)):
359 grub_path = get_bitbake_var("STAGING_LIBDIR", "wic-tools") 347 grub_path = get_bitbake_var("STAGING_LIBDIR", "wic-tools")
360 if not grub_path: 348 if not grub_path:
361 logger.error("Couldn't find STAGING_LIBDIR, exiting.\n") 349 raise WicError("Couldn't find STAGING_LIBDIR, exiting.")
362 sys.exit(1)
363 350
364 grub_core = "%s/grub/%s" % (grub_path, grub_target) 351 grub_core = "%s/grub/%s" % (grub_path, grub_target)
365 if not os.path.exists(grub_core): 352 if not os.path.exists(grub_core):
366 logger.error("Please build grub-efi first\n") 353 raise WicError("Please build grub-efi first")
367 sys.exit(1)
368 354
369 grub_cmd = "grub-mkimage -p '/EFI/BOOT' " 355 grub_cmd = "grub-mkimage -p '/EFI/BOOT' "
370 grub_cmd += "-d %s " % grub_core 356 grub_cmd += "-d %s " % grub_core
@@ -380,12 +366,10 @@ class IsoImagePlugin(SourcePlugin):
380 exec_native_cmd(grub_cmd, native_sysroot) 366 exec_native_cmd(grub_cmd, native_sysroot)
381 367
382 else: 368 else:
383 logger.error("unrecognized bootimg-efi loader: %s", 369 raise WicError("unrecognized bootimg-efi loader: %s" %
384 source_params['loader']) 370 source_params['loader'])
385 sys.exit(1)
386 except KeyError: 371 except KeyError:
387 logger.error("bootimg-efi requires a loader, none specified") 372 raise WicError("bootimg-efi requires a loader, none specified")
388 sys.exit(1)
389 373
390 if os.path.exists("%s/EFI/BOOT" % isodir): 374 if os.path.exists("%s/EFI/BOOT" % isodir):
391 shutil.rmtree("%s/EFI/BOOT" % isodir) 375 shutil.rmtree("%s/EFI/BOOT" % isodir)
@@ -431,8 +415,7 @@ class IsoImagePlugin(SourcePlugin):
431 # Prepare files for legacy boot 415 # Prepare files for legacy boot
432 syslinux_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools") 416 syslinux_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools")
433 if not syslinux_dir: 417 if not syslinux_dir:
434 logger.error("Couldn't find STAGING_DATADIR, exiting.\n") 418 raise WicError("Couldn't find STAGING_DATADIR, exiting.")
435 sys.exit(1)
436 419
437 if os.path.exists("%s/isolinux" % isodir): 420 if os.path.exists("%s/isolinux" % isodir):
438 shutil.rmtree("%s/isolinux" % isodir) 421 shutil.rmtree("%s/isolinux" % isodir)