summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-07-14 15:33:06 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-17 14:01:37 +0100
commitc23be1034bbdeb0b481ae23b85e4bb4501222d28 (patch)
tree41ab3d601fff904bf28e517a19ba373029ecd5e6 /scripts/lib/wic
parent393e55c1ff72558fddd2103fd8cc6d128df20b74 (diff)
downloadpoky-c23be1034bbdeb0b481ae23b85e4bb4501222d28.tar.gz
wic: isoimage-isohybrid: use grub-efi from deploy dir
isoimage-isohybrid plugin tries to build grub-efi in its working directory if it can't find efi binary. Wic should avoid doing anything in working directories of other recipes. It should use artifacts from the image deployment directory instead. (From OE-Core rev: 9a1709278de877085a8d92f6361624e279a603bf) 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>
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r--scripts/lib/wic/plugins/source/isoimage-isohybrid.py75
1 files changed, 23 insertions, 52 deletions
diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
index ece4b0c19e..d6bd3bff7b 100644
--- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
+++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
@@ -95,7 +95,7 @@ class IsoImagePlugin(SourcePlugin):
95 cfg.write(syslinux_conf) 95 cfg.write(syslinux_conf)
96 96
97 @classmethod 97 @classmethod
98 def do_configure_grubefi(cls, part, creator, cr_workdir): 98 def do_configure_grubefi(cls, part, creator, target_dir):
99 """ 99 """
100 Create loader-specific (grub-efi) config 100 Create loader-specific (grub-efi) config
101 """ 101 """
@@ -109,7 +109,7 @@ class IsoImagePlugin(SourcePlugin):
109 raise WicError("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 else: 111 else:
112 splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg") 112 splash = os.path.join(target_dir, "splash.jpg")
113 if os.path.exists(splash): 113 if os.path.exists(splash):
114 splashline = "menu background splash.jpg" 114 splashline = "menu background splash.jpg"
115 else: 115 else:
@@ -137,9 +137,10 @@ class IsoImagePlugin(SourcePlugin):
137 if splashline: 137 if splashline:
138 grubefi_conf += "%s\n" % splashline 138 grubefi_conf += "%s\n" % splashline
139 139
140 logger.debug("Writing grubefi config %s/EFI/BOOT/grub.cfg", cr_workdir) 140 cfg_path = os.path.join(target_dir, "grub.cfg")
141 logger.debug("Writing grubefi config %s", cfg_path)
141 142
142 with open("%s/EFI/BOOT/grub.cfg" % cr_workdir, "w") as cfg: 143 with open(cfg_path, "w") as cfg:
143 cfg.write(grubefi_conf) 144 cfg.write(grubefi_conf)
144 145
145 @staticmethod 146 @staticmethod
@@ -313,20 +314,13 @@ class IsoImagePlugin(SourcePlugin):
313 314
314 #Create bootloader for efi boot 315 #Create bootloader for efi boot
315 try: 316 try:
316 if source_params['loader'] == 'grub-efi': 317 target_dir = "%s/EFI/BOOT" % isodir
317 # Builds grub.cfg if ISODIR didn't exist or 318 if os.path.exists(target_dir):
318 # didn't contains grub.cfg 319 shutil.rmtree(target_dir)
319 bootimg_dir = img_iso_dir 320
320 if not os.path.exists("%s/EFI/BOOT" % bootimg_dir): 321 os.makedirs(target_dir)
321 bootimg_dir = "%s/bootimg" % cr_workdir
322 if os.path.exists(bootimg_dir):
323 shutil.rmtree(bootimg_dir)
324 install_cmd = "install -d %s/EFI/BOOT" % bootimg_dir
325 exec_cmd(install_cmd)
326
327 if not os.path.isfile("%s/EFI/BOOT/boot.cfg" % bootimg_dir):
328 cls.do_configure_grubefi(part, creator, bootimg_dir)
329 322
323 if source_params['loader'] == 'grub-efi':
330 # Builds bootx64.efi/bootia32.efi if ISODIR didn't exist or 324 # Builds bootx64.efi/bootia32.efi if ISODIR didn't exist or
331 # didn't contains it 325 # didn't contains it
332 target_arch = get_bitbake_var("TARGET_SYS") 326 target_arch = get_bitbake_var("TARGET_SYS")
@@ -334,37 +328,23 @@ class IsoImagePlugin(SourcePlugin):
334 raise WicError("Coludn't find target architecture") 328 raise WicError("Coludn't find target architecture")
335 329
336 if re.match("x86_64", target_arch): 330 if re.match("x86_64", target_arch):
337 grub_target = 'x86_64-efi' 331 grub_image = "grub-efi-bootx64.efi"
338 grub_image = "bootx64.efi"
339 elif re.match('i.86', target_arch): 332 elif re.match('i.86', target_arch):
340 grub_target = 'i386-efi' 333 grub_image = "grub-efi-bootia32.efi"
341 grub_image = "bootia32.efi"
342 else: 334 else:
343 raise WicError("grub-efi is incompatible with target %s" % 335 raise WicError("grub-efi is incompatible with target %s" %
344 target_arch) 336 target_arch)
345 337
346 if not os.path.isfile("%s/EFI/BOOT/%s" \ 338 grub_target = os.path.join(target_dir, grub_image)
347 % (bootimg_dir, grub_image)): 339 if not os.path.isfile(grub_target):
348 grub_path = get_bitbake_var("STAGING_LIBDIR") 340 grub_src = os.path.join(deploy_dir, grub_image)
349 if not grub_path: 341 if not os.path.exists(grub_src):
350 raise WicError("Couldn't find STAGING_LIBDIR, exiting.") 342 raise WicError("Grub loader %s is not found in %s. "
351 343 "Please build grub-efi first" % (grub_image, deploy_dir))
352 grub_core = "%s/grub/%s" % (grub_path, grub_target) 344 shutil.copy(grub_src, grub_target)
353 if not os.path.exists(grub_core): 345
354 raise WicError("Please build grub-efi first") 346 if not os.path.isfile(os.path.join(target_dir, "boot.cfg")):
355 347 cls.do_configure_grubefi(part, creator, target_dir)
356 grub_cmd = "grub-mkimage -p '/EFI/BOOT' "
357 grub_cmd += "-d %s " % grub_core
358 grub_cmd += "-O %s -o %s/EFI/BOOT/%s " \
359 % (grub_target, bootimg_dir, grub_image)
360 grub_cmd += "part_gpt part_msdos ntfs ntfscomp fat ext2 "
361 grub_cmd += "normal chain boot configfile linux multiboot "
362 grub_cmd += "search efi_gop efi_uga font gfxterm gfxmenu "
363 grub_cmd += "terminal minicmd test iorw loadenv echo help "
364 grub_cmd += "reboot serial terminfo iso9660 loopback tar "
365 grub_cmd += "memdisk ls search_fs_uuid udf btrfs xfs lvm "
366 grub_cmd += "reiserfs ata "
367 exec_native_cmd(grub_cmd, native_sysroot)
368 348
369 else: 349 else:
370 raise WicError("unrecognized bootimg-efi loader: %s" % 350 raise WicError("unrecognized bootimg-efi loader: %s" %
@@ -372,15 +352,6 @@ class IsoImagePlugin(SourcePlugin):
372 except KeyError: 352 except KeyError:
373 raise WicError("bootimg-efi requires a loader, none specified") 353 raise WicError("bootimg-efi requires a loader, none specified")
374 354
375 if os.path.exists("%s/EFI/BOOT" % isodir):
376 shutil.rmtree("%s/EFI/BOOT" % isodir)
377
378 shutil.copytree(bootimg_dir+"/EFI/BOOT", isodir+"/EFI/BOOT")
379
380 # If exists, remove cr_workdir/bootimg temporary folder
381 if os.path.exists("%s/bootimg" % cr_workdir):
382 shutil.rmtree("%s/bootimg" % cr_workdir)
383
384 # Create efi.img that contains bootloader files for EFI booting 355 # Create efi.img that contains bootloader files for EFI booting
385 # if ISODIR didn't exist or didn't contains it 356 # if ISODIR didn't exist or didn't contains it
386 if os.path.isfile("%s/efi.img" % img_iso_dir): 357 if os.path.isfile("%s/efi.img" % img_iso_dir):