[PATCH] luv-live-image: A new live image for luv
by Matt Fleming
From: Matt Fleming <matt.fleming(a)intel.com>
Having a hard drive image to boot with qemu is fine and dandy but we
really need a bootable image that we can write to removable media and
run on real hardware, not least because that's the thing people will
expect to be find on the project website.
bootimg.bbclass provides much of the functionality we need and already
contains code to build a FAT file system image from our rootfs.
The customization occurs in do_create_img() where we construct a
partition table and append the rootfs FAT file system. While scripts
already exist to build this type of image (scripts/contrib/mkefidisk.sh)
they explicitly disallow booting with an initramfs as the only file
system. The initramfs is integral to our boot procedure.
Tested on real UEFI hardware.
Signed-off-by: Matt Fleming <matt.fleming(a)intel.com>
---
meta-luv/recipes-core/images/luv-live-image.bb | 40 ++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 meta-luv/recipes-core/images/luv-live-image.bb
diff --git a/meta-luv/recipes-core/images/luv-live-image.bb b/meta-luv/recipes-core/images/luv-live-image.bb
new file mode 100644
index 0000000..56f02aa
--- /dev/null
+++ b/meta-luv/recipes-core/images/luv-live-image.bb
@@ -0,0 +1,40 @@
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"
+
+
+DEPENDS_${PN} = "grub-efi"
+
+HDDDIR = "${S}/hddimg"
+LABELS = "luv"
+
+INITRD_IMAGE = "core-image-efi-initramfs"
+INITRD = "${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}-${MACHINE}.cpio.gz"
+MACHINE_FEATURES += "efi"
+
+inherit bootimg
+
+build_img() {
+ IMG="${DEPLOY_DIR_IMAGE}/${PN}.img"
+ VFAT="${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg"
+
+ dd if=/dev/zero of=$IMG bs=512 count=2
+
+ VFAT_SIZE=$(du --apparent-size -ks $VFAT | cut -f 1)
+
+ IMG_SIZE=$(expr $VFAT_SIZE + 1024)
+ dd if=/dev/zero of=$IMG bs=1024 seek=$IMG_SIZE count=0
+
+ parted $IMG mklabel msdos
+
+ parted $IMG mkpart primary 0% "${VFAT_SIZE}kB"
+ parted $IMG set 1 boot on
+
+ dd if=${VFAT} of=$IMG seek=1 obs=512 ibs=1024 count=${VFAT_SIZE}
+}
+
+python do_create_img() {
+ bb.build.exec_func('build_img', d)
+}
+
+do_create_img[depends] += "${INITRD_IMAGE}:do_rootfs"
+addtask create_img after do_bootimg before do_build
--
1.9.0
8 years