diff options
author | Tom Zanussi <tom.zanussi@linux.intel.com> | 2014-02-03 19:16:59 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-02-04 12:57:36 +0000 |
commit | 94b805f1b4b9df596ab6275c6cd2dcada50c2ba4 (patch) | |
tree | 0707123986c84347f7e85cde43db6b1f40b9fc95 /scripts/lib | |
parent | e663d2f5c10ca2c71b287c5af19f74b0de0d7c7c (diff) | |
download | poky-94b805f1b4b9df596ab6275c6cd2dcada50c2ba4.tar.gz |
wic: Hook up BootimgEFIPlugin and BootimgPcbiosPlugin plugins
Remove all the Wic_PartData and DirectImageCreator code now
implemented by the BootimgEFIPlugin and BootimgPcbiosPlugin plugins,
as well as all the special-cased boot_type code, significantly
cleaning up the code.
Replace the calling code with general-purpose plugin invocations, in
essence calling the appropriate implementations at run-time based on
the --source value in effect.
Change the directdisk.wks and mkefidisk.wks scripts to make use of the
new plugins.
(From OE-Core rev: 43558610a5793888ff2b18bd3a27c7ab558e5ad0)
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/image/canned-wks/directdisk.wks | 2 | ||||
-rw-r--r-- | scripts/lib/image/canned-wks/mkefidisk.wks | 2 | ||||
-rw-r--r-- | scripts/lib/mic/imager/direct.py | 194 | ||||
-rw-r--r-- | scripts/lib/mic/kickstart/custom_commands/partition.py | 155 | ||||
-rw-r--r-- | scripts/lib/mic/plugins/source/bootimg-efi.py | 6 | ||||
-rw-r--r-- | scripts/lib/mic/plugins/source/bootimg-pcbios.py | 6 |
6 files changed, 86 insertions, 279 deletions
diff --git a/scripts/lib/image/canned-wks/directdisk.wks b/scripts/lib/image/canned-wks/directdisk.wks index d54b382fd0..397a929c74 100644 --- a/scripts/lib/image/canned-wks/directdisk.wks +++ b/scripts/lib/image/canned-wks/directdisk.wks | |||
@@ -3,7 +3,7 @@ | |||
3 | # can directly dd to boot media. | 3 | # can directly dd to boot media. |
4 | 4 | ||
5 | 5 | ||
6 | part /boot --source bootimg --ondisk sda --fstype=msdos --label boot --active --align 1024 | 6 | part /boot --source bootimg-pcbios --ondisk sda --fstype=msdos --label boot --active --align 1024 |
7 | part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 | 7 | part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 |
8 | 8 | ||
9 | bootloader --timeout=0 --append="rootwait rootfstype=ext3 video=vesafb vga=0x318 console=tty0" | 9 | bootloader --timeout=0 --append="rootwait rootfstype=ext3 video=vesafb vga=0x318 console=tty0" |
diff --git a/scripts/lib/image/canned-wks/mkefidisk.wks b/scripts/lib/image/canned-wks/mkefidisk.wks index 8a3e1f6bc1..e976bc80dd 100644 --- a/scripts/lib/image/canned-wks/mkefidisk.wks +++ b/scripts/lib/image/canned-wks/mkefidisk.wks | |||
@@ -2,7 +2,7 @@ | |||
2 | # long-description: Creates a partitioned EFI disk image that the user | 2 | # long-description: Creates a partitioned EFI disk image that the user |
3 | # can directly dd to boot media. | 3 | # can directly dd to boot media. |
4 | 4 | ||
5 | part /boot --source bootimg --ondisk sda --fstype=efi --label msdos --active --align 1024 | 5 | part /boot --source bootimg-efi --ondisk sda --fstype=msdos --label msdos --active --align 1024 |
6 | 6 | ||
7 | part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 | 7 | part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 |
8 | 8 | ||
diff --git a/scripts/lib/mic/imager/direct.py b/scripts/lib/mic/imager/direct.py index 3827eb8e94..f8c300c787 100644 --- a/scripts/lib/mic/imager/direct.py +++ b/scripts/lib/mic/imager/direct.py | |||
@@ -35,6 +35,11 @@ from mic.utils.partitionedfs import PartitionedMount | |||
35 | from mic.utils.errors import CreatorError, MountError | 35 | from mic.utils.errors import CreatorError, MountError |
36 | from mic.imager.baseimager import BaseImageCreator | 36 | from mic.imager.baseimager import BaseImageCreator |
37 | from mic.utils.oe.misc import * | 37 | from mic.utils.oe.misc import * |
38 | from mic.plugin import pluginmgr | ||
39 | |||
40 | disk_methods = { | ||
41 | "do_install_disk":None, | ||
42 | } | ||
38 | 43 | ||
39 | class DirectImageCreator(BaseImageCreator): | 44 | class DirectImageCreator(BaseImageCreator): |
40 | """ | 45 | """ |
@@ -78,7 +83,6 @@ class DirectImageCreator(BaseImageCreator): | |||
78 | self.native_sysroot = native_sysroot | 83 | self.native_sysroot = native_sysroot |
79 | self.hdddir = hdddir | 84 | self.hdddir = hdddir |
80 | self.staging_data_dir = staging_data_dir | 85 | self.staging_data_dir = staging_data_dir |
81 | self.boot_type = "" | ||
82 | 86 | ||
83 | def __write_fstab(self): | 87 | def __write_fstab(self): |
84 | """overriden to generate fstab (temporarily) in rootfs. This | 88 | """overriden to generate fstab (temporarily) in rootfs. This |
@@ -101,7 +105,7 @@ class DirectImageCreator(BaseImageCreator): | |||
101 | def _update_fstab(self, fstab_lines, parts): | 105 | def _update_fstab(self, fstab_lines, parts): |
102 | """Assume partition order same as in wks""" | 106 | """Assume partition order same as in wks""" |
103 | for num, p in enumerate(parts, 1): | 107 | for num, p in enumerate(parts, 1): |
104 | if p.mountpoint == "/" or p.mountpoint == "/boot": | 108 | if not p.mountpoint or p.mountpoint == "/" or p.mountpoint == "/boot": |
105 | continue | 109 | continue |
106 | if self._ptable_format == 'msdos' and num > 3: | 110 | if self._ptable_format == 'msdos' and num > 3: |
107 | device_name = "/dev/" + p.disk + str(num + 1) | 111 | device_name = "/dev/" + p.disk + str(num + 1) |
@@ -132,6 +136,15 @@ class DirectImageCreator(BaseImageCreator): | |||
132 | 136 | ||
133 | return fstab_contents | 137 | return fstab_contents |
134 | 138 | ||
139 | def set_bootimg_dir(self, bootimg_dir): | ||
140 | """ | ||
141 | Accessor for bootimg_dir, the actual location used for the source | ||
142 | of the bootimg. Should be set by source plugins (only if they | ||
143 | change the default bootimg source) so the correct info gets | ||
144 | displayed for print_outimage_info(). | ||
145 | """ | ||
146 | self.bootimg_dir = bootimg_dir | ||
147 | |||
135 | def _get_parts(self): | 148 | def _get_parts(self): |
136 | if not self.ks: | 149 | if not self.ks: |
137 | raise CreatorError("Failed to get partition info, " | 150 | raise CreatorError("Failed to get partition info, " |
@@ -182,19 +195,18 @@ class DirectImageCreator(BaseImageCreator): | |||
182 | """ Construct full file path to a file we generate. """ | 195 | """ Construct full file path to a file we generate. """ |
183 | return os.path.join(path, self._full_name(name, extention)) | 196 | return os.path.join(path, self._full_name(name, extention)) |
184 | 197 | ||
185 | def get_boot_type(self): | 198 | def get_default_source_plugin(self): |
186 | """ Determine the boot type from fstype and mountpoint. """ | 199 | """ |
187 | parts = self._get_parts() | 200 | The default source plugin i.e. the plugin that's consulted for |
188 | 201 | overall image generation tasks outside of any particular | |
189 | boot_type = "" | 202 | partition. For convenience, we just hang it off the |
190 | 203 | bootloader handler since it's the one non-partition object in | |
191 | for p in parts: | 204 | any setup. By default the default plugin is set to the same |
192 | if p.mountpoint == "/boot": | 205 | plugin as the /boot partition; since we hang it off the |
193 | if p.fstype == "msdos": | 206 | bootloader object, the default can be explicitly set using the |
194 | boot_type = "pcbios" | 207 | --source bootloader param. |
195 | else: | 208 | """ |
196 | boot_type = p.fstype | 209 | return self.ks.handler.bootloader.source |
197 | return boot_type | ||
198 | 210 | ||
199 | # | 211 | # |
200 | # Actual implemention | 212 | # Actual implemention |
@@ -231,25 +243,7 @@ class DirectImageCreator(BaseImageCreator): | |||
231 | if not self.ks.handler.bootloader.source and p.mountpoint == "/boot": | 243 | if not self.ks.handler.bootloader.source and p.mountpoint == "/boot": |
232 | self.ks.handler.bootloader.source = p.source | 244 | self.ks.handler.bootloader.source = p.source |
233 | 245 | ||
234 | self.boot_type = self.get_boot_type() | ||
235 | |||
236 | if not self.bootimg_dir: | ||
237 | if self.boot_type == "pcbios": | ||
238 | self.bootimg_dir = self.staging_data_dir | ||
239 | elif self.boot_type == "efi": | ||
240 | self.bootimg_dir = self.hdddir | ||
241 | |||
242 | if self.boot_type == "pcbios": | ||
243 | self._create_syslinux_config() | ||
244 | elif self.boot_type == "efi": | ||
245 | self._create_grubefi_config() | ||
246 | else: | ||
247 | raise CreatorError("Failed to detect boot type (no /boot partition?), " | ||
248 | "please check your kickstart setting.") | ||
249 | |||
250 | for p in parts: | 246 | for p in parts: |
251 | if p.fstype == "efi": | ||
252 | p.fstype = "msdos" | ||
253 | # need to create the filesystems in order to get their | 247 | # need to create the filesystems in order to get their |
254 | # sizes before we can add them and do the layout. | 248 | # sizes before we can add them and do the layout. |
255 | # PartitionedMount.mount() actually calls __format_disks() | 249 | # PartitionedMount.mount() actually calls __format_disks() |
@@ -266,9 +260,8 @@ class DirectImageCreator(BaseImageCreator): | |||
266 | # when/if we need to actually do package selection we | 260 | # when/if we need to actually do package selection we |
267 | # should modify things to use those objects, but for now | 261 | # should modify things to use those objects, but for now |
268 | # we can avoid that. | 262 | # we can avoid that. |
269 | p.prepare(self.workdir, self.oe_builddir, self.boot_type, | 263 | p.prepare(self, self.workdir, self.oe_builddir, self.rootfs_dir, |
270 | self.rootfs_dir, self.bootimg_dir, self.kernel_dir, | 264 | self.bootimg_dir, self.kernel_dir, self.native_sysroot) |
271 | self.native_sysroot) | ||
272 | 265 | ||
273 | self.__instimage.add_partition(int(p.size), | 266 | self.__instimage.add_partition(int(p.size), |
274 | p.disk, | 267 | p.disk, |
@@ -311,8 +304,16 @@ class DirectImageCreator(BaseImageCreator): | |||
311 | For now, it just prepares the image to be bootable by e.g. | 304 | For now, it just prepares the image to be bootable by e.g. |
312 | creating and installing a bootloader configuration. | 305 | creating and installing a bootloader configuration. |
313 | """ | 306 | """ |
314 | if self.boot_type == "pcbios": | 307 | source_plugin = self.get_default_source_plugin() |
315 | self._install_syslinux() | 308 | if source_plugin: |
309 | self._source_methods = pluginmgr.get_source_plugin_methods(source_plugin, disk_methods) | ||
310 | for disk_name, disk in self.__instimage.disks.items(): | ||
311 | self._source_methods["do_install_disk"](disk, disk_name, self, | ||
312 | self.workdir, | ||
313 | self.oe_builddir, | ||
314 | self.bootimg_dir, | ||
315 | self.kernel_dir, | ||
316 | self.native_sysroot) | ||
316 | 317 | ||
317 | def print_outimage_info(self): | 318 | def print_outimage_info(self): |
318 | """ | 319 | """ |
@@ -352,123 +353,6 @@ class DirectImageCreator(BaseImageCreator): | |||
352 | 353 | ||
353 | return (rootdev, root_part_uuid) | 354 | return (rootdev, root_part_uuid) |
354 | 355 | ||
355 | def _create_syslinux_config(self): | ||
356 | hdddir = "%s/hdd/boot" % self.workdir | ||
357 | rm_cmd = "rm -rf " + self.workdir | ||
358 | exec_cmd(rm_cmd) | ||
359 | |||
360 | install_cmd = "install -d %s" % hdddir | ||
361 | tmp = exec_cmd(install_cmd) | ||
362 | |||
363 | splash = os.path.join(self.workdir, "/hdd/boot/splash.jpg") | ||
364 | if os.path.exists(splash): | ||
365 | splashline = "menu background splash.jpg" | ||
366 | else: | ||
367 | splashline = "" | ||
368 | |||
369 | (rootdev, root_part_uuid) = self._get_boot_config() | ||
370 | options = self.ks.handler.bootloader.appendLine | ||
371 | |||
372 | syslinux_conf = "" | ||
373 | syslinux_conf += "PROMPT 0\n" | ||
374 | timeout = kickstart.get_timeout(self.ks) | ||
375 | if not timeout: | ||
376 | timeout = 0 | ||
377 | syslinux_conf += "TIMEOUT " + str(timeout) + "\n" | ||
378 | syslinux_conf += "\n" | ||
379 | syslinux_conf += "ALLOWOPTIONS 1\n" | ||
380 | syslinux_conf += "SERIAL 0 115200\n" | ||
381 | syslinux_conf += "\n" | ||
382 | if splashline: | ||
383 | syslinux_conf += "%s\n" % splashline | ||
384 | syslinux_conf += "DEFAULT boot\n" | ||
385 | syslinux_conf += "LABEL boot\n" | ||
386 | |||
387 | kernel = "/vmlinuz" | ||
388 | syslinux_conf += "KERNEL " + kernel + "\n" | ||
389 | |||
390 | if self._ptable_format == 'msdos': | ||
391 | rootstr = rootdev | ||
392 | else: | ||
393 | if not root_part_uuid: | ||
394 | raise MountError("Cannot find the root GPT partition UUID") | ||
395 | rootstr = "PARTUUID=%s" % root_part_uuid | ||
396 | |||
397 | syslinux_conf += "APPEND label=boot root=%s %s\n" % (rootstr, options) | ||
398 | |||
399 | msger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg" \ | ||
400 | % self.workdir) | ||
401 | cfg = open("%s/hdd/boot/syslinux.cfg" % self.workdir, "w") | ||
402 | cfg.write(syslinux_conf) | ||
403 | cfg.close() | ||
404 | |||
405 | def _create_grubefi_config(self): | ||
406 | hdddir = "%s/hdd/boot" % self.workdir | ||
407 | rm_cmd = "rm -rf %s" % self.workdir | ||
408 | exec_cmd(rm_cmd) | ||
409 | |||
410 | install_cmd = "install -d %s/EFI/BOOT" % hdddir | ||
411 | tmp = exec_cmd(install_cmd) | ||
412 | |||
413 | splash = os.path.join(self.workdir, "/EFI/boot/splash.jpg") | ||
414 | if os.path.exists(splash): | ||
415 | splashline = "menu background splash.jpg" | ||
416 | else: | ||
417 | splashline = "" | ||
418 | |||
419 | (rootdev, root_part_uuid) = self._get_boot_config() | ||
420 | options = self.ks.handler.bootloader.appendLine | ||
421 | |||
422 | grubefi_conf = "" | ||
423 | grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n" | ||
424 | grubefi_conf += "default=boot\n" | ||
425 | timeout = kickstart.get_timeout(self.ks) | ||
426 | if not timeout: | ||
427 | timeout = 0 | ||
428 | grubefi_conf += "timeout=%s\n" % timeout | ||
429 | grubefi_conf += "menuentry 'boot'{\n" | ||
430 | |||
431 | kernel = "/vmlinuz" | ||
432 | |||
433 | if self._ptable_format == 'msdos': | ||
434 | rootstr = rootdev | ||
435 | else: | ||
436 | if not root_part_uuid: | ||
437 | raise MountError("Cannot find the root GPT partition UUID") | ||
438 | rootstr = "PARTUUID=%s" % root_part_uuid | ||
439 | |||
440 | grubefi_conf += "linux %s root=%s rootwait %s\n" \ | ||
441 | % (kernel, rootstr, options) | ||
442 | grubefi_conf += "}\n" | ||
443 | if splashline: | ||
444 | syslinux_conf += "%s\n" % splashline | ||
445 | |||
446 | msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \ | ||
447 | % self.workdir) | ||
448 | cfg = open("%s/hdd/boot/EFI/BOOT/grub.cfg" % self.workdir, "w") | ||
449 | cfg.write(grubefi_conf) | ||
450 | cfg.close() | ||
451 | |||
452 | def _install_syslinux(self): | ||
453 | mbrfile = "%s/syslinux/" % self.bootimg_dir | ||
454 | if self._ptable_format == 'gpt': | ||
455 | mbrfile += "gptmbr.bin" | ||
456 | else: | ||
457 | mbrfile += "mbr.bin" | ||
458 | |||
459 | if not os.path.exists(mbrfile): | ||
460 | msger.error("Couldn't find %s. If using the -e option, do you have the right MACHINE set in local.conf? If not, is the bootimg_dir path correct?" % mbrfile) | ||
461 | |||
462 | for disk_name, disk in self.__instimage.disks.items(): | ||
463 | full_path = self._full_path(self.__imgdir, disk_name, "direct") | ||
464 | msger.debug("Installing MBR on disk %s as %s with size %s bytes" \ | ||
465 | % (disk_name, full_path, disk['min_size'])) | ||
466 | |||
467 | rc = runner.show(['dd', 'if=%s' % mbrfile, | ||
468 | 'of=%s' % full_path, 'conv=notrunc']) | ||
469 | if rc != 0: | ||
470 | raise MountError("Unable to set MBR to %s" % full_path) | ||
471 | |||
472 | def _unmount_instroot(self): | 356 | def _unmount_instroot(self): |
473 | if not self.__instimage is None: | 357 | if not self.__instimage is None: |
474 | try: | 358 | try: |
diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py index fe8e55a376..4974a87d93 100644 --- a/scripts/lib/mic/kickstart/custom_commands/partition.py +++ b/scripts/lib/mic/kickstart/custom_commands/partition.py | |||
@@ -28,8 +28,14 @@ import shutil | |||
28 | 28 | ||
29 | from pykickstart.commands.partition import * | 29 | from pykickstart.commands.partition import * |
30 | from mic.utils.oe.misc import * | 30 | from mic.utils.oe.misc import * |
31 | |||
32 | from mic.kickstart.custom_commands import * | 31 | from mic.kickstart.custom_commands import * |
32 | from mic.plugin import pluginmgr | ||
33 | |||
34 | partition_methods = { | ||
35 | "do_stage_partition":None, | ||
36 | "do_prepare_partition":None, | ||
37 | "do_configure_partition":None, | ||
38 | } | ||
33 | 39 | ||
34 | class Wic_PartData(Mic_PartData): | 40 | class Wic_PartData(Mic_PartData): |
35 | removedKeywords = Mic_PartData.removedKeywords | 41 | removedKeywords = Mic_PartData.removedKeywords |
@@ -50,8 +56,22 @@ class Wic_PartData(Mic_PartData): | |||
50 | 56 | ||
51 | return retval | 57 | return retval |
52 | 58 | ||
53 | def prepare(self, cr_workdir, oe_builddir, boot_type, rootfs_dir, | 59 | def set_size(self, size): |
54 | bootimg_dir, kernel_dir, native_sysroot): | 60 | """ |
61 | Accessor for actual partition size, which must be set by source | ||
62 | plugins. | ||
63 | """ | ||
64 | self.size = size | ||
65 | |||
66 | def set_source_file(self, source_file): | ||
67 | """ | ||
68 | Accessor for source_file, the location of the generated partition | ||
69 | image, which must be set by source plugins. | ||
70 | """ | ||
71 | self.source_file = source_file | ||
72 | |||
73 | def prepare(self, cr, cr_workdir, oe_builddir, rootfs_dir, bootimg_dir, | ||
74 | kernel_dir, native_sysroot): | ||
55 | """ | 75 | """ |
56 | Prepare content for individual partitions, depending on | 76 | Prepare content for individual partitions, depending on |
57 | partition command parameters. | 77 | partition command parameters. |
@@ -65,121 +85,24 @@ class Wic_PartData(Mic_PartData): | |||
65 | native_sysroot) | 85 | native_sysroot) |
66 | return | 86 | return |
67 | 87 | ||
68 | if self.source == "bootimg" and boot_type == "pcbios": | 88 | if self.source.startswith("rootfs"): |
69 | self.prepare_bootimg_pcbios(cr_workdir, oe_builddir, bootimg_dir, | ||
70 | kernel_dir, native_sysroot) | ||
71 | elif self.source == "bootimg" and boot_type == "efi": | ||
72 | self.prepare_bootimg_efi(cr_workdir, oe_builddir, bootimg_dir, | ||
73 | kernel_dir, native_sysroot) | ||
74 | elif self.source.startswith("rootfs"): | ||
75 | self.prepare_rootfs(cr_workdir, oe_builddir, rootfs_dir, | 89 | self.prepare_rootfs(cr_workdir, oe_builddir, rootfs_dir, |
76 | native_sysroot) | 90 | native_sysroot) |
77 | 91 | else: | |
78 | def prepare_bootimg_pcbios(self, cr_workdir, oe_builddir, bootimg_dir, | 92 | self._source_methods = pluginmgr.get_source_plugin_methods(self.source, partition_methods) |
79 | kernel_dir, native_sysroot): | 93 | self._source_methods["do_configure_partition"](self, cr, cr_workdir, |
80 | """ | 94 | oe_builddir, |
81 | Prepare content for a legacy bios boot partition. | 95 | bootimg_dir, |
82 | """ | 96 | kernel_dir, |
83 | staging_kernel_dir = kernel_dir | 97 | native_sysroot) |
84 | staging_data_dir = bootimg_dir | 98 | self._source_methods["do_stage_partition"](self, cr, cr_workdir, |
85 | 99 | oe_builddir, | |
86 | hdddir = "%s/hdd/boot" % cr_workdir | 100 | bootimg_dir, kernel_dir, |
87 | 101 | native_sysroot) | |
88 | install_cmd = "install -m 0644 %s/bzImage %s/vmlinuz" \ | 102 | self._source_methods["do_prepare_partition"](self, cr, cr_workdir, |
89 | % (staging_kernel_dir, hdddir) | 103 | oe_builddir, |
90 | tmp = exec_cmd(install_cmd) | 104 | bootimg_dir, kernel_dir, |
91 | 105 | native_sysroot) | |
92 | install_cmd = "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" \ | ||
93 | % (staging_data_dir, hdddir) | ||
94 | tmp = exec_cmd(install_cmd) | ||
95 | |||
96 | du_cmd = "du -bks %s" % hdddir | ||
97 | rc, out = exec_cmd(du_cmd) | ||
98 | blocks = int(out.split()[0]) | ||
99 | |||
100 | blocks += BOOTDD_EXTRA_SPACE | ||
101 | |||
102 | # Ensure total sectors is an integral number of sectors per | ||
103 | # track or mcopy will complain. Sectors are 512 bytes, and we | ||
104 | # generate images with 32 sectors per track. This calculation is | ||
105 | # done in blocks, thus the mod by 16 instead of 32. | ||
106 | blocks += (16 - (blocks % 16)) | ||
107 | |||
108 | # dosfs image, created by mkdosfs | ||
109 | bootimg = "%s/boot.img" % cr_workdir | ||
110 | |||
111 | dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (bootimg, blocks) | ||
112 | exec_native_cmd(dosfs_cmd, native_sysroot) | ||
113 | |||
114 | mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) | ||
115 | exec_native_cmd(mcopy_cmd, native_sysroot) | ||
116 | |||
117 | syslinux_cmd = "syslinux %s" % bootimg | ||
118 | exec_native_cmd(syslinux_cmd, native_sysroot) | ||
119 | |||
120 | chmod_cmd = "chmod 644 %s" % bootimg | ||
121 | exec_cmd(chmod_cmd) | ||
122 | |||
123 | du_cmd = "du -Lbms %s" % bootimg | ||
124 | rc, out = exec_cmd(du_cmd) | ||
125 | bootimg_size = out.split()[0] | ||
126 | |||
127 | self.size = bootimg_size | ||
128 | self.source_file = bootimg | ||
129 | |||
130 | def prepare_bootimg_efi(self, cr_workdir, oe_builddir, bootimg_dir, | ||
131 | kernel_dir, native_sysroot): | ||
132 | """ | ||
133 | Prepare content for an EFI (grub) boot partition. | ||
134 | """ | ||
135 | staging_kernel_dir = kernel_dir | ||
136 | staging_data_dir = bootimg_dir | ||
137 | |||
138 | hdddir = "%s/hdd/boot" % cr_workdir | ||
139 | |||
140 | install_cmd = "install -m 0644 %s/bzImage %s/vmlinuz" % \ | ||
141 | (staging_kernel_dir, hdddir) | ||
142 | tmp = exec_cmd(install_cmd) | ||
143 | |||
144 | shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, | ||
145 | "%s/grub.cfg" % cr_workdir) | ||
146 | |||
147 | cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir) | ||
148 | exec_cmd(cp_cmd, True) | ||
149 | |||
150 | shutil.move("%s/grub.cfg" % cr_workdir, | ||
151 | "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir) | ||
152 | |||
153 | du_cmd = "du -bks %s" % hdddir | ||
154 | rc, out = exec_cmd(du_cmd) | ||
155 | blocks = int(out.split()[0]) | ||
156 | |||
157 | blocks += BOOTDD_EXTRA_SPACE | ||
158 | |||
159 | # Ensure total sectors is an integral number of sectors per | ||
160 | # track or mcopy will complain. Sectors are 512 bytes, and we | ||
161 | # generate images with 32 sectors per track. This calculation is | ||
162 | # done in blocks, thus the mod by 16 instead of 32. | ||
163 | blocks += (16 - (blocks % 16)) | ||
164 | |||
165 | # dosfs image, created by mkdosfs | ||
166 | bootimg = "%s/boot.img" % cr_workdir | ||
167 | |||
168 | dosfs_cmd = "mkdosfs -n efi -C %s %d" % (bootimg, blocks) | ||
169 | exec_native_cmd(dosfs_cmd, native_sysroot) | ||
170 | |||
171 | mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) | ||
172 | exec_native_cmd(mcopy_cmd, native_sysroot) | ||
173 | |||
174 | chmod_cmd = "chmod 644 %s" % bootimg | ||
175 | exec_cmd(chmod_cmd) | ||
176 | |||
177 | du_cmd = "du -Lbms %s" % bootimg | ||
178 | rc, out = exec_cmd(du_cmd) | ||
179 | bootimg_size = out.split()[0] | ||
180 | |||
181 | self.size = bootimg_size | ||
182 | self.source_file = bootimg | ||
183 | 106 | ||
184 | def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir, | 107 | def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir, |
185 | rootfs_dir): | 108 | rootfs_dir): |
diff --git a/scripts/lib/mic/plugins/source/bootimg-efi.py b/scripts/lib/mic/plugins/source/bootimg-efi.py index f2bd071aff..3e0997bacf 100644 --- a/scripts/lib/mic/plugins/source/bootimg-efi.py +++ b/scripts/lib/mic/plugins/source/bootimg-efi.py | |||
@@ -107,7 +107,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
107 | if not bootimg_dir: | 107 | if not bootimg_dir: |
108 | msger.error("Couldn't find HDDDIR, exiting\n") | 108 | msger.error("Couldn't find HDDDIR, exiting\n") |
109 | # just so the result notes display it | 109 | # just so the result notes display it |
110 | cr.bootimg_dir = bootimg_dir | 110 | cr.set_bootimg_dir(bootimg_dir) |
111 | 111 | ||
112 | staging_kernel_dir = kernel_dir | 112 | staging_kernel_dir = kernel_dir |
113 | staging_data_dir = bootimg_dir | 113 | staging_data_dir = bootimg_dir |
@@ -155,7 +155,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
155 | rc, out = exec_cmd(du_cmd) | 155 | rc, out = exec_cmd(du_cmd) |
156 | bootimg_size = out.split()[0] | 156 | bootimg_size = out.split()[0] |
157 | 157 | ||
158 | part.size = bootimg_size | 158 | part.set_size(bootimg_size) |
159 | part.source_file = bootimg | 159 | part.set_source_file(bootimg) |
160 | 160 | ||
161 | 161 | ||
diff --git a/scripts/lib/mic/plugins/source/bootimg-pcbios.py b/scripts/lib/mic/plugins/source/bootimg-pcbios.py index 1da2a41fa7..3cd446f052 100644 --- a/scripts/lib/mic/plugins/source/bootimg-pcbios.py +++ b/scripts/lib/mic/plugins/source/bootimg-pcbios.py | |||
@@ -135,7 +135,7 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
135 | if not bootimg_dir: | 135 | if not bootimg_dir: |
136 | msger.error("Couldn't find STAGING_DATADIR, exiting\n") | 136 | msger.error("Couldn't find STAGING_DATADIR, exiting\n") |
137 | # just so the result notes display it | 137 | # just so the result notes display it |
138 | cr.bootimg_dir = bootimg_dir | 138 | cr.set_bootimg_dir(bootimg_dir) |
139 | 139 | ||
140 | staging_kernel_dir = kernel_dir | 140 | staging_kernel_dir = kernel_dir |
141 | staging_data_dir = bootimg_dir | 141 | staging_data_dir = bootimg_dir |
@@ -181,7 +181,7 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
181 | rc, out = exec_cmd(du_cmd) | 181 | rc, out = exec_cmd(du_cmd) |
182 | bootimg_size = out.split()[0] | 182 | bootimg_size = out.split()[0] |
183 | 183 | ||
184 | part.size = bootimg_size | 184 | part.set_size(bootimg_size) |
185 | part.source_file = bootimg | 185 | part.set_source_file(bootimg) |
186 | 186 | ||
187 | 187 | ||