* [PATCH 0/3] Remove bootimg.bbclass and boot-directdisk.bbclass
@ 2016-03-29 7:59 Robert Yang
2016-03-29 7:59 ` [PATCH 1/3] boot-directdisk.bbclass: merge it into image-vm.bbclass Robert Yang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Robert Yang @ 2016-03-29 7:59 UTC (permalink / raw)
To: openembedded-core
The following changes since commit a3e254992444b0cc92e182151fefba7e3324ad55:
build-appliance-image: Update to master head revision (2016-03-28 17:02:04 +0100)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib rbt/image
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=3148e125ec883b341b1bbbc8bb3f8845bde01eb2
Robert Yang (3):
boot-directdisk.bbclass: merge it into image-vm.bbclass
bootimg.bbclass: merge it into image-live.bbclass
image-live.bbclass/image-vm.bbclass: remove duplicated code
meta/classes/boot-directdisk.bbclass | 190 ----------------------
meta/classes/bootimg.bbclass | 304 -----------------------------------
meta/classes/gummiboot.bbclass | 2 +-
meta/classes/image-live.bbclass | 266 +++++++++++++++++++++++++++++-
meta/classes/image-vm.bbclass | 167 ++++++++++++++++---
meta/classes/image.bbclass | 46 ++++++
6 files changed, 456 insertions(+), 519 deletions(-)
delete mode 100644 meta/classes/boot-directdisk.bbclass
delete mode 100644 meta/classes/bootimg.bbclass
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] boot-directdisk.bbclass: merge it into image-vm.bbclass
2016-03-29 7:59 [PATCH 0/3] Remove bootimg.bbclass and boot-directdisk.bbclass Robert Yang
@ 2016-03-29 7:59 ` Robert Yang
2016-03-29 7:59 ` [PATCH 2/3] bootimg.bbclass: merge it into image-live.bbclass Robert Yang
2016-03-29 7:59 ` [PATCH 3/3] image-live.bbclass/image-vm.bbclass: remove duplicated code Robert Yang
2 siblings, 0 replies; 6+ messages in thread
From: Robert Yang @ 2016-03-29 7:59 UTC (permalink / raw)
To: openembedded-core
They are doing the same things: create virtual machine images, merge
them into one bbclass makes it easy to understand.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/boot-directdisk.bbclass | 190 ------------------------------
meta/classes/image-vm.bbclass | 216 ++++++++++++++++++++++++++++++++---
2 files changed, 198 insertions(+), 208 deletions(-)
delete mode 100644 meta/classes/boot-directdisk.bbclass
diff --git a/meta/classes/boot-directdisk.bbclass b/meta/classes/boot-directdisk.bbclass
deleted file mode 100644
index 46f88ac..0000000
--- a/meta/classes/boot-directdisk.bbclass
+++ /dev/null
@@ -1,190 +0,0 @@
-# boot-directdisk.bbclass
-# (loosly based off bootimg.bbclass Copyright (C) 2004, Advanced Micro Devices, Inc.)
-#
-# Create an image which can be placed directly onto a harddisk using dd and then
-# booted.
-#
-# This uses syslinux. extlinux would have been nice but required the ext2/3
-# partition to be mounted. grub requires to run itself as part of the install
-# process.
-#
-# The end result is a 512 boot sector populated with an MBR and partition table
-# followed by an msdos fat16 partition containing syslinux and a linux kernel
-# completed by the ext2/3 rootfs.
-#
-# We have to push the msdos parition table size > 16MB so fat 16 is used as parted
-# won't touch fat12 partitions.
-
-# External variables needed
-
-# ${ROOTFS} - the rootfs image to incorporate
-
-do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \
- virtual/kernel:do_deploy \
- syslinux:do_populate_sysroot \
- syslinux-native:do_populate_sysroot \
- parted-native:do_populate_sysroot \
- mtools-native:do_populate_sysroot "
-
-PACKAGES = " "
-EXCLUDE_FROM_WORLD = "1"
-
-BOOTDD_VOLUME_ID ?= "boot"
-BOOTDD_EXTRA_SPACE ?= "16384"
-
-EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
-EFI_PROVIDER ?= "grub-efi"
-EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
-
-# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
-# contain "efi". This way legacy is supported by default if neither is
-# specified, maintaining the original behavior.
-def pcbios(d):
- pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
- if pcbios == "0":
- pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d)
- return pcbios
-
-def pcbios_class(d):
- if d.getVar("PCBIOS", True) == "1":
- return "syslinux"
- return ""
-
-PCBIOS = "${@pcbios(d)}"
-PCBIOS_CLASS = "${@pcbios_class(d)}"
-
-# Get the build_syslinux_cfg() function from the syslinux class
-inherit ${PCBIOS_CLASS}
-inherit ${EFI_CLASS}
-
-DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
-ROOT_VM ?= "root=/dev/sda2"
-
-boot_direct_populate() {
- dest=$1
- install -d $dest
-
- # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use.
- if [ -e ${DEPLOY_DIR_IMAGE}/bzImage ]; then
- install -m 0644 ${DEPLOY_DIR_IMAGE}/bzImage $dest/vmlinuz
- fi
-
- # initrd is made of concatenation of multiple filesystem images
- if [ -n "${INITRD}" ]; then
- rm -f $dest/initrd
- for fs in ${INITRD}
- do
- if [ -s "${fs}" ]; then
- cat ${fs} >> $dest/initrd
- else
- bbfatal "${fs} is invalid. initrd image creation failed."
- fi
- done
- chmod 0644 $dest/initrd
- fi
-}
-
-build_boot_dd() {
- HDDDIR="${S}/hdd/boot"
- HDDIMG="${S}/hdd.image"
- IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect
-
- boot_direct_populate $HDDDIR
-
- if [ "${PCBIOS}" = "1" ]; then
- syslinux_hddimg_populate $HDDDIR
- fi
- if [ "${EFI}" = "1" ]; then
- efi_hddimg_populate $HDDDIR
- fi
-
- if [ "x${AUTO_SYSLINUXMENU}" = "x1" ] ; then
- install -m 0644 ${STAGING_DIR}/${MACHINE}/usr/share/syslinux/vesamenu.c32 $HDDDIR/${SYSLINUXDIR}/
- if [ "x${SYSLINUX_SPLASH}" != "x" ] ; then
- install -m 0644 ${SYSLINUX_SPLASH} $HDDDIR/${SYSLINUXDIR}/splash.lss
- fi
- fi
-
- BLOCKS=`du -bks $HDDDIR | cut -f 1`
- BLOCKS=`expr $BLOCKS + ${BOOTDD_EXTRA_SPACE}`
-
- # Ensure total sectors is an integral number of sectors per
- # track or mcopy will complain. Sectors are 512 bytes, and we
- # generate images with 32 sectors per track. This calculation is
- # done in blocks, thus the mod by 16 instead of 32.
- BLOCKS=$(expr $BLOCKS + $(expr 16 - $(expr $BLOCKS % 16)))
-
- # Remove it since mkdosfs would fail when it exists
- rm -f $HDDIMG
- mkdosfs -n ${BOOTDD_VOLUME_ID} -S 512 -C $HDDIMG $BLOCKS
- mcopy -i $HDDIMG -s $HDDDIR/* ::/
-
- if [ "${PCBIOS}" = "1" ]; then
- syslinux_hdddirect_install $HDDIMG
- fi
- chmod 644 $HDDIMG
-
- ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1`
- TOTALSIZE=`expr $BLOCKS + $ROOTFSBLOCKS`
- END1=`expr $BLOCKS \* 1024`
- END2=`expr $END1 + 512`
- END3=`expr \( $ROOTFSBLOCKS \* 1024 \) + $END1`
-
- echo $ROOTFSBLOCKS $TOTALSIZE $END1 $END2 $END3
- rm -rf $IMAGE
- dd if=/dev/zero of=$IMAGE bs=1024 seek=$TOTALSIZE count=1
-
- parted $IMAGE mklabel msdos
- parted $IMAGE mkpart primary fat16 0 ${END1}B
- parted $IMAGE unit B mkpart primary ext2 ${END2}B ${END3}B
- parted $IMAGE set 1 boot on
-
- parted $IMAGE print
-
- awk "BEGIN { printf \"$(echo ${DISK_SIGNATURE} | fold -w 2 | tac | paste -sd '' | sed 's/\(..\)/\\x&/g')\" }" | \
- dd of=$IMAGE bs=1 seek=440 conv=notrunc
-
- OFFSET=`expr $END2 / 512`
- if [ "${PCBIOS}" = "1" ]; then
- dd if=${STAGING_DATADIR}/syslinux/mbr.bin of=$IMAGE conv=notrunc
- fi
-
- dd if=$HDDIMG of=$IMAGE conv=notrunc seek=1 bs=512
- dd if=${ROOTFS} of=$IMAGE conv=notrunc seek=$OFFSET bs=512
-
- cd ${DEPLOY_DIR_IMAGE}
- rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect
- ln -s ${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect
-}
-
-python do_bootdirectdisk() {
- validate_disk_signature(d)
- set_live_vm_vars(d, 'VM')
- if d.getVar("PCBIOS", True) == "1":
- bb.build.exec_func('build_syslinux_cfg', d)
- if d.getVar("EFI", True) == "1":
- bb.build.exec_func('build_efi_cfg', d)
- bb.build.exec_func('build_boot_dd', d)
-}
-
-def generate_disk_signature():
- import uuid
-
- signature = str(uuid.uuid4())[:8]
-
- if signature != '00000000':
- return signature
- else:
- return 'ffffffff'
-
-def validate_disk_signature(d):
- import re
-
- disk_signature = d.getVar("DISK_SIGNATURE", True)
-
- if not re.match(r'^[0-9a-fA-F]{8}$', disk_signature):
- bb.fatal("DISK_SIGNATURE '%s' must be an 8 digit hex string" % disk_signature)
-
-DISK_SIGNATURE_GENERATED := "${@generate_disk_signature()}"
-
-addtask bootdirectdisk before do_image_complete
diff --git a/meta/classes/image-vm.bbclass b/meta/classes/image-vm.bbclass
index 8608ec0..68cf89b 100644
--- a/meta/classes/image-vm.bbclass
+++ b/meta/classes/image-vm.bbclass
@@ -1,37 +1,217 @@
+# image-vm.bbclass
+# (loosly based off bootimg.bbclass Copyright (C) 2004, Advanced Micro Devices, Inc.)
+#
+# Create an image which can be placed directly onto a harddisk using dd and then
+# booted.
+#
+# This uses syslinux. extlinux would have been nice but required the ext2/3
+# partition to be mounted. grub requires to run itself as part of the install
+# process.
+#
+# The end result is a 512 boot sector populated with an MBR and partition table
+# followed by an msdos fat16 partition containing syslinux and a linux kernel
+# completed by the ext2/3 rootfs.
+#
+# We have to push the msdos parition table size > 16MB so fat 16 is used as parted
+# won't touch fat12 partitions.
-LABELS_VM ?= "boot"
+do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \
+ virtual/kernel:do_deploy \
+ syslinux:do_populate_sysroot \
+ syslinux-native:do_populate_sysroot \
+ parted-native:do_populate_sysroot \
+ mtools-native:do_populate_sysroot \
+ ${PN}:do_image_ext4 \
+ "
+
+IMAGE_TYPEDEP_vmdk = "ext4"
+IMAGE_TYPEDEP_vdi = "ext4"
+IMAGE_TYPEDEP_qcow2 = "ext4"
+IMAGE_TYPEDEP_hdddirect = "ext4"
+IMAGE_TYPES_MASKED += "vmdk vdi qcow2 hdddirect"
+ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.ext4"
+
+# Used by bootloader
+LABELS_VM ?= "boot"
+ROOT_VM ?= "root=/dev/sda2"
# Using an initramfs is optional. Enable it by setting INITRD_IMAGE_VM.
INITRD_IMAGE_VM ?= ""
INITRD_VM ?= "${@'${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE_VM}-${MACHINE}.cpio.gz' if '${INITRD_IMAGE_VM}' else ''}"
do_bootdirectdisk[depends] += "${@'${INITRD_IMAGE_VM}:do_image_complete' if '${INITRD_IMAGE_VM}' else ''}"
-# need to define the dependency and the ROOTFS for directdisk
-do_bootdirectdisk[depends] += "${PN}:do_image_ext4"
-ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.ext4"
+BOOTDD_VOLUME_ID ?= "boot"
+BOOTDD_EXTRA_SPACE ?= "16384"
-# creating VM images relies on having a hdddirect so ensure we inherit it here.
-inherit boot-directdisk
+EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
+EFI_PROVIDER ?= "grub-efi"
+EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
-IMAGE_TYPEDEP_vmdk = "ext4"
-IMAGE_TYPEDEP_vdi = "ext4"
-IMAGE_TYPEDEP_qcow2 = "ext4"
-IMAGE_TYPEDEP_hdddirect = "ext4"
-IMAGE_TYPES_MASKED += "vmdk vdi qcow2 hdddirect"
+# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
+# contain "efi". This way legacy is supported by default if neither is
+# specified, maintaining the original behavior.
+def pcbios(d):
+ pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
+ if pcbios == "0":
+ pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d)
+ return pcbios
+
+def pcbios_class(d):
+ if d.getVar("PCBIOS", True) == "1":
+ return "syslinux"
+ return ""
+
+PCBIOS = "${@pcbios(d)}"
+PCBIOS_CLASS = "${@pcbios_class(d)}"
+
+# Get the build_syslinux_cfg() function from the syslinux class
+inherit ${PCBIOS_CLASS}
+inherit ${EFI_CLASS}
+
+DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
+
+boot_direct_populate() {
+ dest=$1
+ install -d $dest
+
+ # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use.
+ if [ -e ${DEPLOY_DIR_IMAGE}/bzImage ]; then
+ install -m 0644 ${DEPLOY_DIR_IMAGE}/bzImage $dest/vmlinuz
+ fi
+
+ # initrd is made of concatenation of multiple filesystem images
+ if [ -n "${INITRD}" ]; then
+ rm -f $dest/initrd
+ for fs in ${INITRD}
+ do
+ if [ -s "${fs}" ]; then
+ cat ${fs} >> $dest/initrd
+ else
+ bbfatal "${fs} is invalid. initrd image creation failed."
+ fi
+ done
+ chmod 0644 $dest/initrd
+ fi
+}
+
+build_boot_dd() {
+ HDDDIR="${S}/hdd/boot"
+ HDDIMG="${S}/hdd.image"
+ IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect
+
+ boot_direct_populate $HDDDIR
+ if [ "${PCBIOS}" = "1" ]; then
+ syslinux_hddimg_populate $HDDDIR
+ fi
+ if [ "${EFI}" = "1" ]; then
+ efi_hddimg_populate $HDDDIR
+ fi
+
+ if [ "x${AUTO_SYSLINUXMENU}" = "x1" ] ; then
+ install -m 0644 ${STAGING_DIR}/${MACHINE}/usr/share/syslinux/vesamenu.c32 $HDDDIR/${SYSLINUXDIR}/
+ if [ "x${SYSLINUX_SPLASH}" != "x" ] ; then
+ install -m 0644 ${SYSLINUX_SPLASH} $HDDDIR/${SYSLINUXDIR}/splash.lss
+ fi
+ fi
+
+ BLOCKS=`du -bks $HDDDIR | cut -f 1`
+ BLOCKS=`expr $BLOCKS + ${BOOTDD_EXTRA_SPACE}`
+
+ # Ensure total sectors is an integral number of sectors per
+ # track or mcopy will complain. Sectors are 512 bytes, and we
+ # generate images with 32 sectors per track. This calculation is
+ # done in blocks, thus the mod by 16 instead of 32.
+ BLOCKS=$(expr $BLOCKS + $(expr 16 - $(expr $BLOCKS % 16)))
+
+ # Remove it since mkdosfs would fail when it exists
+ rm -f $HDDIMG
+ mkdosfs -n ${BOOTDD_VOLUME_ID} -S 512 -C $HDDIMG $BLOCKS
+ mcopy -i $HDDIMG -s $HDDDIR/* ::/
+
+ if [ "${PCBIOS}" = "1" ]; then
+ syslinux_hdddirect_install $HDDIMG
+ fi
+ chmod 644 $HDDIMG
+
+ ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1`
+ TOTALSIZE=`expr $BLOCKS + $ROOTFSBLOCKS`
+ END1=`expr $BLOCKS \* 1024`
+ END2=`expr $END1 + 512`
+ END3=`expr \( $ROOTFSBLOCKS \* 1024 \) + $END1`
+
+ echo $ROOTFSBLOCKS $TOTALSIZE $END1 $END2 $END3
+ rm -rf $IMAGE
+ dd if=/dev/zero of=$IMAGE bs=1024 seek=$TOTALSIZE count=1
+
+ parted $IMAGE mklabel msdos
+ parted $IMAGE mkpart primary fat16 0 ${END1}B
+ parted $IMAGE unit B mkpart primary ext2 ${END2}B ${END3}B
+ parted $IMAGE set 1 boot on
+
+ parted $IMAGE print
+
+ awk "BEGIN { printf \"$(echo ${DISK_SIGNATURE} | fold -w 2 | tac | paste -sd '' | sed 's/\(..\)/\\x&/g')\" }" | \
+ dd of=$IMAGE bs=1 seek=440 conv=notrunc
+
+ OFFSET=`expr $END2 / 512`
+ if [ "${PCBIOS}" = "1" ]; then
+ dd if=${STAGING_DATADIR}/syslinux/mbr.bin of=$IMAGE conv=notrunc
+ fi
+
+ dd if=$HDDIMG of=$IMAGE conv=notrunc seek=1 bs=512
+ dd if=${ROOTFS} of=$IMAGE conv=notrunc seek=$OFFSET bs=512
+
+ cd ${DEPLOY_DIR_IMAGE}
+ rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect
+ ln -s ${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect
+}
+
+python do_bootdirectdisk() {
+ validate_disk_signature(d)
+ set_live_vm_vars(d, 'VM')
+ if d.getVar("PCBIOS", True) == "1":
+ bb.build.exec_func('build_syslinux_cfg', d)
+ if d.getVar("EFI", True) == "1":
+ bb.build.exec_func('build_efi_cfg', d)
+ bb.build.exec_func('build_boot_dd', d)
+}
+
+def generate_disk_signature():
+ import uuid
+
+ signature = str(uuid.uuid4())[:8]
+
+ if signature != '00000000':
+ return signature
+ else:
+ return 'ffffffff'
+
+def validate_disk_signature(d):
+ import re
+
+ disk_signature = d.getVar("DISK_SIGNATURE", True)
+
+ if not re.match(r'^[0-9a-fA-F]{8}$', disk_signature):
+ bb.fatal("DISK_SIGNATURE '%s' must be an 8 digit hex string" % disk_signature)
+
+DISK_SIGNATURE_GENERATED := "${@generate_disk_signature()}"
+
+run_qemu_img (){
+ type="$1"
+ qemu-img convert -O $type ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.$type
+ ln -sf ${IMAGE_NAME}.$type ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.$type
+}
create_vmdk_image () {
- qemu-img convert -O vmdk ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.vmdk
- ln -sf ${IMAGE_NAME}.vmdk ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.vmdk
+ run_qemu_img vmdk
}
create_vdi_image () {
- qemu-img convert -O vdi ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.vdi
- ln -sf ${IMAGE_NAME}.vdi ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.vdi
+ run_qemu_img vdi
}
create_qcow2_image () {
- qemu-img convert -O qcow2 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.qcow2
- ln -sf ${IMAGE_NAME}.qcow2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.qcow2
+ run_qemu_img qcow2
}
python do_vmimg() {
@@ -43,6 +223,6 @@ python do_vmimg() {
bb.build.exec_func('create_qcow2_image', d)
}
+addtask bootdirectdisk before do_vmimg
addtask vmimg after do_bootdirectdisk before do_image_complete
do_vmimg[depends] += "qemu-native:do_populate_sysroot"
-
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] bootimg.bbclass: merge it into image-live.bbclass
2016-03-29 7:59 [PATCH 0/3] Remove bootimg.bbclass and boot-directdisk.bbclass Robert Yang
2016-03-29 7:59 ` [PATCH 1/3] boot-directdisk.bbclass: merge it into image-vm.bbclass Robert Yang
@ 2016-03-29 7:59 ` Robert Yang
2016-03-29 7:59 ` [PATCH 3/3] image-live.bbclass/image-vm.bbclass: remove duplicated code Robert Yang
2 siblings, 0 replies; 6+ messages in thread
From: Robert Yang @ 2016-03-29 7:59 UTC (permalink / raw)
To: openembedded-core
They are doing the same things: create live images, merge them into one
bbclass makes it easy to understand.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/bootimg.bbclass | 304 ---------------------------------------
meta/classes/gummiboot.bbclass | 2 +-
meta/classes/image-live.bbclass | 308 +++++++++++++++++++++++++++++++++++++++-
meta/classes/image-vm.bbclass | 2 +-
4 files changed, 304 insertions(+), 312 deletions(-)
delete mode 100644 meta/classes/bootimg.bbclass
diff --git a/meta/classes/bootimg.bbclass b/meta/classes/bootimg.bbclass
deleted file mode 100644
index d9ed7db..0000000
--- a/meta/classes/bootimg.bbclass
+++ /dev/null
@@ -1,304 +0,0 @@
-# Copyright (C) 2004, Advanced Micro Devices, Inc. All Rights Reserved
-# Released under the MIT license (see packages/COPYING)
-
-# Creates a bootable image using syslinux, your kernel and an optional
-# initrd
-
-#
-# End result is two things:
-#
-# 1. A .hddimg file which is an msdos filesystem containing syslinux, a kernel,
-# an initrd and a rootfs image. These can be written to harddisks directly and
-# also booted on USB flash disks (write them there with dd).
-#
-# 2. A CD .iso image
-
-# Boot process is that the initrd will boot and process which label was selected
-# in syslinux. Actions based on the label are then performed (e.g. installing to
-# an hdd)
-
-# External variables (also used by syslinux.bbclass)
-# ${INITRD} - indicates a list of filesystem images to concatenate and use as an initrd (optional)
-# ${COMPRESSISO} - Transparent compress ISO, reduce size ~40% if set to 1
-# ${NOISO} - skip building the ISO image if set to 1
-# ${NOHDD} - skip building the HDD image if set to 1
-# ${HDDIMG_ID} - FAT image volume-id
-# ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
-
-do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \
- mtools-native:do_populate_sysroot \
- cdrtools-native:do_populate_sysroot \
- virtual/kernel:do_deploy \
- ${@oe.utils.ifelse(d.getVar('COMPRESSISO', False),'zisofs-tools-native:do_populate_sysroot','')}"
-
-PACKAGES = " "
-EXCLUDE_FROM_WORLD = "1"
-
-HDDDIR = "${S}/hddimg"
-ISODIR = "${S}/iso"
-EFIIMGDIR = "${S}/efi_img"
-COMPACT_ISODIR = "${S}/iso.z"
-COMPRESSISO ?= "0"
-
-ISOLINUXDIR ?= "/isolinux"
-ISO_BOOTIMG = "isolinux/isolinux.bin"
-ISO_BOOTCAT = "isolinux/boot.cat"
-MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table"
-
-BOOTIMG_VOLUME_ID ?= "boot"
-BOOTIMG_EXTRA_SPACE ?= "512"
-
-EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
-EFI_PROVIDER ?= "grub-efi"
-EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
-
-KERNEL_IMAGETYPE ??= "bzImage"
-
-# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
-# contain "efi". This way legacy is supported by default if neither is
-# specified, maintaining the original behavior.
-def pcbios(d):
- pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
- if pcbios == "0":
- pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d)
- return pcbios
-
-PCBIOS = "${@pcbios(d)}"
-PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS', True) == '1']}"
-
-inherit ${EFI_CLASS}
-inherit ${PCBIOS_CLASS}
-
-populate() {
- DEST=$1
- install -d ${DEST}
-
- # Install kernel, initrd, and rootfs.img in DEST for all loaders to use.
- install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ${DEST}/vmlinuz
-
- # initrd is made of concatenation of multiple filesystem images
- if [ -n "${INITRD}" ]; then
- rm -f ${DEST}/initrd
- for fs in ${INITRD}
- do
- if [ -s "${fs}" ]; then
- cat ${fs} >> ${DEST}/initrd
- else
- bbfatal "${fs} is invalid. initrd image creation failed."
- fi
- done
- chmod 0644 ${DEST}/initrd
- fi
-
- if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then
- install -m 0644 ${ROOTFS} ${DEST}/rootfs.img
- fi
-
-}
-
-build_iso() {
- # Only create an ISO if we have an INITRD and NOISO was not set
- if [ -z "${INITRD}" ] || [ "${NOISO}" = "1" ]; then
- bbnote "ISO image will not be created."
- return
- fi
- # ${INITRD} is a list of multiple filesystem images
- for fs in ${INITRD}
- do
- if [ ! -s "${fs}" ]; then
- bbnote "ISO image will not be created. ${fs} is invalid."
- return
- fi
- done
-
-
- populate ${ISODIR}
-
- if [ "${PCBIOS}" = "1" ]; then
- syslinux_iso_populate ${ISODIR}
- fi
- if [ "${EFI}" = "1" ]; then
- efi_iso_populate ${ISODIR}
- build_fat_img ${EFIIMGDIR} ${ISODIR}/efi.img
- fi
-
- # EFI only
- if [ "${PCBIOS}" != "1" ] && [ "${EFI}" = "1" ] ; then
- # Work around bug in isohybrid where it requires isolinux.bin
- # In the boot catalog, even though it is not used
- mkdir -p ${ISODIR}/${ISOLINUXDIR}
- install -m 0644 ${STAGING_DATADIR}/syslinux/isolinux.bin ${ISODIR}${ISOLINUXDIR}
- fi
-
- if [ "${COMPRESSISO}" = "1" ] ; then
- # create compact directory, compress iso
- mkdir -p ${COMPACT_ISODIR}
- mkzftree -z 9 -p 4 -F ${ISODIR}/rootfs.img ${COMPACT_ISODIR}/rootfs.img
-
- # move compact iso to iso, then remove compact directory
- mv ${COMPACT_ISODIR}/rootfs.img ${ISODIR}/rootfs.img
- rm -Rf ${COMPACT_ISODIR}
- mkisofs_compress_opts="-R -z -D -l"
- else
- mkisofs_compress_opts="-r"
- fi
-
- # Check the size of ${ISODIR}/rootfs.img, use mkisofs -iso-level 3
- # when it exceeds 3.8GB, the specification is 4G - 1 bytes, we need
- # leave a few space for other files.
- mkisofs_iso_level=""
-
- if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then
- rootfs_img_size=`stat -c '%s' ${ISODIR}/rootfs.img`
- # 4080218931 = 3.8 * 1024 * 1024 * 1024
- if [ $rootfs_img_size -gt 4080218931 ]; then
- bbnote "${ISODIR}/rootfs.img execeeds 3.8GB, using '-iso-level 3' for mkisofs"
- mkisofs_iso_level="-iso-level 3"
- fi
- fi
-
- if [ "${PCBIOS}" = "1" ] && [ "${EFI}" != "1" ] ; then
- # PCBIOS only media
- mkisofs -V ${BOOTIMG_VOLUME_ID} \
- -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso \
- -b ${ISO_BOOTIMG} -c ${ISO_BOOTCAT} \
- $mkisofs_compress_opts \
- ${MKISOFS_OPTIONS} $mkisofs_iso_level ${ISODIR}
- else
- # EFI only OR EFI+PCBIOS
- mkisofs -A ${BOOTIMG_VOLUME_ID} -V ${BOOTIMG_VOLUME_ID} \
- -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso \
- -b ${ISO_BOOTIMG} -c ${ISO_BOOTCAT} \
- $mkisofs_compress_opts ${MKISOFS_OPTIONS} $mkisofs_iso_level \
- -eltorito-alt-boot -eltorito-platform efi \
- -b efi.img -no-emul-boot \
- ${ISODIR}
- isohybrid_args="-u"
- fi
-
- isohybrid $isohybrid_args ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso
-}
-
-build_fat_img() {
- FATSOURCEDIR=$1
- FATIMG=$2
-
- # Calculate the size required for the final image including the
- # data and filesystem overhead.
- # Sectors: 512 bytes
- # Blocks: 1024 bytes
-
- # Determine the sector count just for the data
- SECTORS=$(expr $(du --apparent-size -ks ${FATSOURCEDIR} | cut -f 1) \* 2)
-
- # Account for the filesystem overhead. This includes directory
- # entries in the clusters as well as the FAT itself.
- # Assumptions:
- # FAT32 (12 or 16 may be selected by mkdosfs, but the extra
- # padding will be minimal on those smaller images and not
- # worth the logic here to caclulate the smaller FAT sizes)
- # < 16 entries per directory
- # 8.3 filenames only
-
- # 32 bytes per dir entry
- DIR_BYTES=$(expr $(find ${FATSOURCEDIR} | tail -n +2 | wc -l) \* 32)
- # 32 bytes for every end-of-directory dir entry
- DIR_BYTES=$(expr $DIR_BYTES + $(expr $(find ${FATSOURCEDIR} -type d | tail -n +2 | wc -l) \* 32))
- # 4 bytes per FAT entry per sector of data
- FAT_BYTES=$(expr $SECTORS \* 4)
- # 4 bytes per FAT entry per end-of-cluster list
- FAT_BYTES=$(expr $FAT_BYTES + $(expr $(find ${FATSOURCEDIR} -type d | tail -n +2 | wc -l) \* 4))
-
- # Use a ceiling function to determine FS overhead in sectors
- DIR_SECTORS=$(expr $(expr $DIR_BYTES + 511) / 512)
- # There are two FATs on the image
- FAT_SECTORS=$(expr $(expr $(expr $FAT_BYTES + 511) / 512) \* 2)
- SECTORS=$(expr $SECTORS + $(expr $DIR_SECTORS + $FAT_SECTORS))
-
- # Determine the final size in blocks accounting for some padding
- BLOCKS=$(expr $(expr $SECTORS / 2) + ${BOOTIMG_EXTRA_SPACE})
-
- # Ensure total sectors is an integral number of sectors per
- # track or mcopy will complain. Sectors are 512 bytes, and we
- # generate images with 32 sectors per track. This calculation is
- # done in blocks, thus the mod by 16 instead of 32.
- BLOCKS=$(expr $BLOCKS + $(expr 16 - $(expr $BLOCKS % 16)))
-
- # mkdosfs will sometimes use FAT16 when it is not appropriate,
- # resulting in a boot failure from SYSLINUX. Use FAT32 for
- # images larger than 512MB, otherwise let mkdosfs decide.
- if [ $(expr $BLOCKS / 1024) -gt 512 ]; then
- FATSIZE="-F 32"
- fi
-
- # mkdosfs will fail if ${FATIMG} exists. Since we are creating an
- # new image, it is safe to delete any previous image.
- if [ -e ${FATIMG} ]; then
- rm ${FATIMG}
- fi
-
- if [ -z "${HDDIMG_ID}" ]; then
- mkdosfs ${FATSIZE} -n ${BOOTIMG_VOLUME_ID} -S 512 -C ${FATIMG} \
- ${BLOCKS}
- else
- mkdosfs ${FATSIZE} -n ${BOOTIMG_VOLUME_ID} -S 512 -C ${FATIMG} \
- ${BLOCKS} -i ${HDDIMG_ID}
- fi
-
- # Copy FATSOURCEDIR recursively into the image file directly
- mcopy -i ${FATIMG} -s ${FATSOURCEDIR}/* ::/
-}
-
-build_hddimg() {
- # Create an HDD image
- if [ "${NOHDD}" != "1" ] ; then
- populate ${HDDDIR}
-
- if [ "${PCBIOS}" = "1" ]; then
- syslinux_hddimg_populate ${HDDDIR}
- fi
- if [ "${EFI}" = "1" ]; then
- efi_hddimg_populate ${HDDDIR}
- fi
-
- # Check the size of ${HDDDIR}/rootfs.img, error out if it
- # exceeds 4GB, it is the single file's max size of FAT fs.
- if [ -f ${HDDDIR}/rootfs.img ]; then
- rootfs_img_size=`stat -c '%s' ${HDDDIR}/rootfs.img`
- max_size=`expr 4 \* 1024 \* 1024 \* 1024`
- if [ $rootfs_img_size -gt $max_size ]; then
- bberror "${HDDDIR}/rootfs.img execeeds 4GB,"
- bberror "this doesn't work on FAT filesystem, you can try either of:"
- bberror "1) Reduce the size of rootfs.img"
- bbfatal "2) Use iso, vmdk or vdi to instead of hddimg\n"
- fi
- fi
-
- build_fat_img ${HDDDIR} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
-
- if [ "${PCBIOS}" = "1" ]; then
- syslinux_hddimg_install
- fi
-
- chmod 644 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
- fi
-}
-
-python do_bootimg() {
- set_live_vm_vars(d, 'LIVE')
- if d.getVar("PCBIOS", True) == "1":
- bb.build.exec_func('build_syslinux_cfg', d)
- if d.getVar("EFI", True) == "1":
- bb.build.exec_func('build_efi_cfg', d)
- bb.build.exec_func('build_hddimg', d)
- bb.build.exec_func('build_iso', d)
- bb.build.exec_func('create_symlinks', d)
-}
-do_bootimg[subimages] = "hddimg iso"
-do_bootimg[imgsuffix] = "."
-
-IMAGE_TYPEDEP_iso = "ext4"
-IMAGE_TYPEDEP_hddimg = "ext4"
-IMAGE_TYPES_MASKED += "iso hddimg"
-
-addtask bootimg before do_image_complete
diff --git a/meta/classes/gummiboot.bbclass b/meta/classes/gummiboot.bbclass
index 9a97ac1..1ebb946 100644
--- a/meta/classes/gummiboot.bbclass
+++ b/meta/classes/gummiboot.bbclass
@@ -4,7 +4,7 @@
# gummiboot.bbclass - equivalent of grub-efi.bbclass
# Set EFI_PROVIDER = "gummiboot" to use gummiboot on your live images instead of grub-efi
-# (images built by bootimage.bbclass or boot-directdisk.bbclass)
+# (images built by image-live.bbclass or image-vm.bbclass)
do_bootimg[depends] += "${MLPREFIX}gummiboot:do_deploy"
do_bootdirectdisk[depends] += "${MLPREFIX}gummiboot:do_deploy"
diff --git a/meta/classes/image-live.bbclass b/meta/classes/image-live.bbclass
index 05e416a..9c725c0 100644
--- a/meta/classes/image-live.bbclass
+++ b/meta/classes/image-live.bbclass
@@ -1,15 +1,46 @@
+# Copyright (C) 2004, Advanced Micro Devices, Inc. All Rights Reserved
+# Released under the MIT license (see packages/COPYING)
+# Creates a bootable image using syslinux, your kernel and an optional
+# initrd
+
+#
+# End result is two things:
+#
+# 1. A .hddimg file which is an msdos filesystem containing syslinux, a kernel,
+# an initrd and a rootfs image. These can be written to harddisks directly and
+# also booted on USB flash disks (write them there with dd).
+#
+# 2. A CD .iso image
+
+# Boot process is that the initrd will boot and process which label was selected
+# in syslinux. Actions based on the label are then performed (e.g. installing to
+# an hdd)
+
+# External variables (also used by syslinux.bbclass)
+# ${INITRD} - indicates a list of filesystem images to concatenate and use as an initrd (optional)
+# ${COMPRESSISO} - Transparent compress ISO, reduce size ~40% if set to 1
+# ${NOISO} - skip building the ISO image if set to 1
+# ${NOHDD} - skip building the HDD image if set to 1
+# ${HDDIMG_ID} - FAT image volume-id
+# ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
+
+do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \
+ mtools-native:do_populate_sysroot \
+ cdrtools-native:do_populate_sysroot \
+ virtual/kernel:do_deploy \
+ ${@oe.utils.ifelse(d.getVar('COMPRESSISO', False),'zisofs-tools-native:do_populate_sysroot','')} \
+ ${PN}:do_image_ext4 \
+ "
+
+
+LABELS_LIVE ?= "boot install"
+ROOT_LIVE ?= "root=/dev/ram0"
INITRD_IMAGE_LIVE ?= "core-image-minimal-initramfs"
INITRD_LIVE ?= "${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE_LIVE}-${MACHINE}.cpio.gz"
-ROOT_LIVE ?= "root=/dev/ram0"
-LABELS_LIVE ?= "boot install"
ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.ext4"
-do_bootimg[depends] += "${PN}:do_image_ext4"
-
-inherit bootimg
-
IMAGE_TYPEDEP_live = "ext4"
IMAGE_TYPEDEP_iso = "ext4"
IMAGE_TYPEDEP_hddimg = "ext4"
@@ -24,3 +55,268 @@ python() {
else:
d.appendVarFlag('do_bootimg', 'depends', ' %s:do_image_complete' % initrd_i)
}
+
+HDDDIR = "${S}/hddimg"
+ISODIR = "${S}/iso"
+EFIIMGDIR = "${S}/efi_img"
+COMPACT_ISODIR = "${S}/iso.z"
+COMPRESSISO ?= "0"
+
+ISOLINUXDIR ?= "/isolinux"
+ISO_BOOTIMG = "isolinux/isolinux.bin"
+ISO_BOOTCAT = "isolinux/boot.cat"
+MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table"
+
+BOOTIMG_VOLUME_ID ?= "boot"
+BOOTIMG_EXTRA_SPACE ?= "512"
+
+EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
+EFI_PROVIDER ?= "grub-efi"
+EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
+
+KERNEL_IMAGETYPE ??= "bzImage"
+
+# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
+# contain "efi". This way legacy is supported by default if neither is
+# specified, maintaining the original behavior.
+def pcbios(d):
+ pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
+ if pcbios == "0":
+ pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d)
+ return pcbios
+
+PCBIOS = "${@pcbios(d)}"
+PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS', True) == '1']}"
+
+inherit ${EFI_CLASS}
+inherit ${PCBIOS_CLASS}
+
+populate() {
+ DEST=$1
+ install -d ${DEST}
+
+ # Install kernel, initrd, and rootfs.img in DEST for all loaders to use.
+ install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ${DEST}/vmlinuz
+
+ # initrd is made of concatenation of multiple filesystem images
+ if [ -n "${INITRD}" ]; then
+ rm -f ${DEST}/initrd
+ for fs in ${INITRD}
+ do
+ if [ -s "${fs}" ]; then
+ cat ${fs} >> ${DEST}/initrd
+ else
+ bbfatal "${fs} is invalid. initrd image creation failed."
+ fi
+ done
+ chmod 0644 ${DEST}/initrd
+ fi
+
+ if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then
+ install -m 0644 ${ROOTFS} ${DEST}/rootfs.img
+ fi
+
+}
+
+build_iso() {
+ # Only create an ISO if we have an INITRD and NOISO was not set
+ if [ -z "${INITRD}" ] || [ "${NOISO}" = "1" ]; then
+ bbnote "ISO image will not be created."
+ return
+ fi
+ # ${INITRD} is a list of multiple filesystem images
+ for fs in ${INITRD}
+ do
+ if [ ! -s "${fs}" ]; then
+ bbnote "ISO image will not be created. ${fs} is invalid."
+ return
+ fi
+ done
+
+
+ populate ${ISODIR}
+
+ if [ "${PCBIOS}" = "1" ]; then
+ syslinux_iso_populate ${ISODIR}
+ fi
+ if [ "${EFI}" = "1" ]; then
+ efi_iso_populate ${ISODIR}
+ build_fat_img ${EFIIMGDIR} ${ISODIR}/efi.img
+ fi
+
+ # EFI only
+ if [ "${PCBIOS}" != "1" ] && [ "${EFI}" = "1" ] ; then
+ # Work around bug in isohybrid where it requires isolinux.bin
+ # In the boot catalog, even though it is not used
+ mkdir -p ${ISODIR}/${ISOLINUXDIR}
+ install -m 0644 ${STAGING_DATADIR}/syslinux/isolinux.bin ${ISODIR}${ISOLINUXDIR}
+ fi
+
+ if [ "${COMPRESSISO}" = "1" ] ; then
+ # create compact directory, compress iso
+ mkdir -p ${COMPACT_ISODIR}
+ mkzftree -z 9 -p 4 -F ${ISODIR}/rootfs.img ${COMPACT_ISODIR}/rootfs.img
+
+ # move compact iso to iso, then remove compact directory
+ mv ${COMPACT_ISODIR}/rootfs.img ${ISODIR}/rootfs.img
+ rm -Rf ${COMPACT_ISODIR}
+ mkisofs_compress_opts="-R -z -D -l"
+ else
+ mkisofs_compress_opts="-r"
+ fi
+
+ # Check the size of ${ISODIR}/rootfs.img, use mkisofs -iso-level 3
+ # when it exceeds 3.8GB, the specification is 4G - 1 bytes, we need
+ # leave a few space for other files.
+ mkisofs_iso_level=""
+
+ if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then
+ rootfs_img_size=`stat -c '%s' ${ISODIR}/rootfs.img`
+ # 4080218931 = 3.8 * 1024 * 1024 * 1024
+ if [ $rootfs_img_size -gt 4080218931 ]; then
+ bbnote "${ISODIR}/rootfs.img execeeds 3.8GB, using '-iso-level 3' for mkisofs"
+ mkisofs_iso_level="-iso-level 3"
+ fi
+ fi
+
+ if [ "${PCBIOS}" = "1" ] && [ "${EFI}" != "1" ] ; then
+ # PCBIOS only media
+ mkisofs -V ${BOOTIMG_VOLUME_ID} \
+ -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso \
+ -b ${ISO_BOOTIMG} -c ${ISO_BOOTCAT} \
+ $mkisofs_compress_opts \
+ ${MKISOFS_OPTIONS} $mkisofs_iso_level ${ISODIR}
+ else
+ # EFI only OR EFI+PCBIOS
+ mkisofs -A ${BOOTIMG_VOLUME_ID} -V ${BOOTIMG_VOLUME_ID} \
+ -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso \
+ -b ${ISO_BOOTIMG} -c ${ISO_BOOTCAT} \
+ $mkisofs_compress_opts ${MKISOFS_OPTIONS} $mkisofs_iso_level \
+ -eltorito-alt-boot -eltorito-platform efi \
+ -b efi.img -no-emul-boot \
+ ${ISODIR}
+ isohybrid_args="-u"
+ fi
+
+ isohybrid $isohybrid_args ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso
+}
+
+build_fat_img() {
+ FATSOURCEDIR=$1
+ FATIMG=$2
+
+ # Calculate the size required for the final image including the
+ # data and filesystem overhead.
+ # Sectors: 512 bytes
+ # Blocks: 1024 bytes
+
+ # Determine the sector count just for the data
+ SECTORS=$(expr $(du --apparent-size -ks ${FATSOURCEDIR} | cut -f 1) \* 2)
+
+ # Account for the filesystem overhead. This includes directory
+ # entries in the clusters as well as the FAT itself.
+ # Assumptions:
+ # FAT32 (12 or 16 may be selected by mkdosfs, but the extra
+ # padding will be minimal on those smaller images and not
+ # worth the logic here to caclulate the smaller FAT sizes)
+ # < 16 entries per directory
+ # 8.3 filenames only
+
+ # 32 bytes per dir entry
+ DIR_BYTES=$(expr $(find ${FATSOURCEDIR} | tail -n +2 | wc -l) \* 32)
+ # 32 bytes for every end-of-directory dir entry
+ DIR_BYTES=$(expr $DIR_BYTES + $(expr $(find ${FATSOURCEDIR} -type d | tail -n +2 | wc -l) \* 32))
+ # 4 bytes per FAT entry per sector of data
+ FAT_BYTES=$(expr $SECTORS \* 4)
+ # 4 bytes per FAT entry per end-of-cluster list
+ FAT_BYTES=$(expr $FAT_BYTES + $(expr $(find ${FATSOURCEDIR} -type d | tail -n +2 | wc -l) \* 4))
+
+ # Use a ceiling function to determine FS overhead in sectors
+ DIR_SECTORS=$(expr $(expr $DIR_BYTES + 511) / 512)
+ # There are two FATs on the image
+ FAT_SECTORS=$(expr $(expr $(expr $FAT_BYTES + 511) / 512) \* 2)
+ SECTORS=$(expr $SECTORS + $(expr $DIR_SECTORS + $FAT_SECTORS))
+
+ # Determine the final size in blocks accounting for some padding
+ BLOCKS=$(expr $(expr $SECTORS / 2) + ${BOOTIMG_EXTRA_SPACE})
+
+ # Ensure total sectors is an integral number of sectors per
+ # track or mcopy will complain. Sectors are 512 bytes, and we
+ # generate images with 32 sectors per track. This calculation is
+ # done in blocks, thus the mod by 16 instead of 32.
+ BLOCKS=$(expr $BLOCKS + $(expr 16 - $(expr $BLOCKS % 16)))
+
+ # mkdosfs will sometimes use FAT16 when it is not appropriate,
+ # resulting in a boot failure from SYSLINUX. Use FAT32 for
+ # images larger than 512MB, otherwise let mkdosfs decide.
+ if [ $(expr $BLOCKS / 1024) -gt 512 ]; then
+ FATSIZE="-F 32"
+ fi
+
+ # mkdosfs will fail if ${FATIMG} exists. Since we are creating an
+ # new image, it is safe to delete any previous image.
+ if [ -e ${FATIMG} ]; then
+ rm ${FATIMG}
+ fi
+
+ if [ -z "${HDDIMG_ID}" ]; then
+ mkdosfs ${FATSIZE} -n ${BOOTIMG_VOLUME_ID} -S 512 -C ${FATIMG} \
+ ${BLOCKS}
+ else
+ mkdosfs ${FATSIZE} -n ${BOOTIMG_VOLUME_ID} -S 512 -C ${FATIMG} \
+ ${BLOCKS} -i ${HDDIMG_ID}
+ fi
+
+ # Copy FATSOURCEDIR recursively into the image file directly
+ mcopy -i ${FATIMG} -s ${FATSOURCEDIR}/* ::/
+}
+
+build_hddimg() {
+ # Create an HDD image
+ if [ "${NOHDD}" != "1" ] ; then
+ populate ${HDDDIR}
+
+ if [ "${PCBIOS}" = "1" ]; then
+ syslinux_hddimg_populate ${HDDDIR}
+ fi
+ if [ "${EFI}" = "1" ]; then
+ efi_hddimg_populate ${HDDDIR}
+ fi
+
+ # Check the size of ${HDDDIR}/rootfs.img, error out if it
+ # exceeds 4GB, it is the single file's max size of FAT fs.
+ if [ -f ${HDDDIR}/rootfs.img ]; then
+ rootfs_img_size=`stat -c '%s' ${HDDDIR}/rootfs.img`
+ max_size=`expr 4 \* 1024 \* 1024 \* 1024`
+ if [ $rootfs_img_size -gt $max_size ]; then
+ bberror "${HDDDIR}/rootfs.img execeeds 4GB,"
+ bberror "this doesn't work on FAT filesystem, you can try either of:"
+ bberror "1) Reduce the size of rootfs.img"
+ bbfatal "2) Use iso, vmdk or vdi to instead of hddimg\n"
+ fi
+ fi
+
+ build_fat_img ${HDDDIR} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
+
+ if [ "${PCBIOS}" = "1" ]; then
+ syslinux_hddimg_install
+ fi
+
+ chmod 644 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
+ fi
+}
+
+python do_bootimg() {
+ set_live_vm_vars(d, 'LIVE')
+ if d.getVar("PCBIOS", True) == "1":
+ bb.build.exec_func('build_syslinux_cfg', d)
+ if d.getVar("EFI", True) == "1":
+ bb.build.exec_func('build_efi_cfg', d)
+ bb.build.exec_func('build_hddimg', d)
+ bb.build.exec_func('build_iso', d)
+ bb.build.exec_func('create_symlinks', d)
+}
+do_bootimg[subimages] = "hddimg iso"
+do_bootimg[imgsuffix] = "."
+
+addtask bootimg before do_image_complete
diff --git a/meta/classes/image-vm.bbclass b/meta/classes/image-vm.bbclass
index 68cf89b..ced8eac 100644
--- a/meta/classes/image-vm.bbclass
+++ b/meta/classes/image-vm.bbclass
@@ -1,5 +1,5 @@
# image-vm.bbclass
-# (loosly based off bootimg.bbclass Copyright (C) 2004, Advanced Micro Devices, Inc.)
+# (loosly based off image-live.bbclass Copyright (C) 2004, Advanced Micro Devices, Inc.)
#
# Create an image which can be placed directly onto a harddisk using dd and then
# booted.
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] image-live.bbclass/image-vm.bbclass: remove duplicated code
2016-03-29 7:59 [PATCH 0/3] Remove bootimg.bbclass and boot-directdisk.bbclass Robert Yang
2016-03-29 7:59 ` [PATCH 1/3] boot-directdisk.bbclass: merge it into image-vm.bbclass Robert Yang
2016-03-29 7:59 ` [PATCH 2/3] bootimg.bbclass: merge it into image-live.bbclass Robert Yang
@ 2016-03-29 7:59 ` Robert Yang
2016-03-29 11:59 ` Richard Purdie
2 siblings, 1 reply; 6+ messages in thread
From: Robert Yang @ 2016-03-29 7:59 UTC (permalink / raw)
To: openembedded-core
Move the common code to image.bbclass and remove duplicated ones.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/image-live.bbclass | 58 ++++++-----------------------------------
meta/classes/image-vm.bbclass | 51 +-----------------------------------
meta/classes/image.bbclass | 46 ++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 100 deletions(-)
diff --git a/meta/classes/image-live.bbclass b/meta/classes/image-live.bbclass
index 9c725c0..335b800 100644
--- a/meta/classes/image-live.bbclass
+++ b/meta/classes/image-live.bbclass
@@ -70,52 +70,11 @@ MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table"
BOOTIMG_VOLUME_ID ?= "boot"
BOOTIMG_EXTRA_SPACE ?= "512"
-EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
-EFI_PROVIDER ?= "grub-efi"
-EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
-
-KERNEL_IMAGETYPE ??= "bzImage"
-
-# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
-# contain "efi". This way legacy is supported by default if neither is
-# specified, maintaining the original behavior.
-def pcbios(d):
- pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
- if pcbios == "0":
- pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d)
- return pcbios
-
-PCBIOS = "${@pcbios(d)}"
-PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS', True) == '1']}"
-
-inherit ${EFI_CLASS}
-inherit ${PCBIOS_CLASS}
-
-populate() {
- DEST=$1
- install -d ${DEST}
-
- # Install kernel, initrd, and rootfs.img in DEST for all loaders to use.
- install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ${DEST}/vmlinuz
-
- # initrd is made of concatenation of multiple filesystem images
- if [ -n "${INITRD}" ]; then
- rm -f ${DEST}/initrd
- for fs in ${INITRD}
- do
- if [ -s "${fs}" ]; then
- cat ${fs} >> ${DEST}/initrd
- else
- bbfatal "${fs} is invalid. initrd image creation failed."
- fi
- done
- chmod 0644 ${DEST}/initrd
- fi
-
- if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then
- install -m 0644 ${ROOTFS} ${DEST}/rootfs.img
+populate_live() {
+ populate $1
+ if [ -s "${ROOTFS}" ]; then
+ install -m 0644 ${ROOTFS} $1/rootfs.img
fi
-
}
build_iso() {
@@ -127,14 +86,13 @@ build_iso() {
# ${INITRD} is a list of multiple filesystem images
for fs in ${INITRD}
do
- if [ ! -s "${fs}" ]; then
- bbnote "ISO image will not be created. ${fs} is invalid."
+ if [ ! -s "$fs" ]; then
+ bbnote "ISO image will not be created. $fs is invalid."
return
fi
done
-
- populate ${ISODIR}
+ populate_live ${ISODIR}
if [ "${PCBIOS}" = "1" ]; then
syslinux_iso_populate ${ISODIR}
@@ -274,7 +232,7 @@ build_fat_img() {
build_hddimg() {
# Create an HDD image
if [ "${NOHDD}" != "1" ] ; then
- populate ${HDDDIR}
+ populate_live ${HDDDIR}
if [ "${PCBIOS}" = "1" ]; then
syslinux_hddimg_populate ${HDDDIR}
diff --git a/meta/classes/image-vm.bbclass b/meta/classes/image-vm.bbclass
index ced8eac..57f04a4 100644
--- a/meta/classes/image-vm.bbclass
+++ b/meta/classes/image-vm.bbclass
@@ -43,63 +43,14 @@ do_bootdirectdisk[depends] += "${@'${INITRD_IMAGE_VM}:do_image_complete' if '${I
BOOTDD_VOLUME_ID ?= "boot"
BOOTDD_EXTRA_SPACE ?= "16384"
-EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
-EFI_PROVIDER ?= "grub-efi"
-EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
-
-# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
-# contain "efi". This way legacy is supported by default if neither is
-# specified, maintaining the original behavior.
-def pcbios(d):
- pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
- if pcbios == "0":
- pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d)
- return pcbios
-
-def pcbios_class(d):
- if d.getVar("PCBIOS", True) == "1":
- return "syslinux"
- return ""
-
-PCBIOS = "${@pcbios(d)}"
-PCBIOS_CLASS = "${@pcbios_class(d)}"
-
-# Get the build_syslinux_cfg() function from the syslinux class
-inherit ${PCBIOS_CLASS}
-inherit ${EFI_CLASS}
-
DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
-boot_direct_populate() {
- dest=$1
- install -d $dest
-
- # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use.
- if [ -e ${DEPLOY_DIR_IMAGE}/bzImage ]; then
- install -m 0644 ${DEPLOY_DIR_IMAGE}/bzImage $dest/vmlinuz
- fi
-
- # initrd is made of concatenation of multiple filesystem images
- if [ -n "${INITRD}" ]; then
- rm -f $dest/initrd
- for fs in ${INITRD}
- do
- if [ -s "${fs}" ]; then
- cat ${fs} >> $dest/initrd
- else
- bbfatal "${fs} is invalid. initrd image creation failed."
- fi
- done
- chmod 0644 $dest/initrd
- fi
-}
-
build_boot_dd() {
HDDDIR="${S}/hdd/boot"
HDDIMG="${S}/hdd.image"
IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect
- boot_direct_populate $HDDDIR
+ populate $HDDDIR
if [ "${PCBIOS}" = "1" ]; then
syslinux_hddimg_populate $HDDDIR
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 62ff07e..5c1973a 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -552,3 +552,49 @@ def set_live_vm_vars(d, suffix):
elif d.getVar(var_with_suffix, True):
d.setVar(var, d.getVar(var_with_suffix, True))
+
+EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
+EFI_PROVIDER ?= "grub-efi"
+EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
+
+# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
+# contain "efi". This way legacy is supported by default if neither is
+# specified, maintaining the original behavior.
+def pcbios(d):
+ pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
+ if pcbios == "0":
+ pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d)
+ return pcbios
+
+PCBIOS = "${@pcbios(d)}"
+PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS', True) == '1']}"
+
+inherit ${EFI_CLASS}
+inherit ${PCBIOS_CLASS}
+
+KERNEL_IMAGETYPE ??= "bzImage"
+
+populate() {
+ dest=$1
+ install -d $dest
+
+ # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use.
+ if [ -e ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ]; then
+ install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} $dest/vmlinuz
+ fi
+
+ # initrd is made of concatenation of multiple filesystem images
+ if [ -n "${INITRD}" ]; then
+ rm -f $dest/initrd
+ for fs in ${INITRD}
+ do
+ if [ -s "$fs" ]; then
+ cat $fs >> $dest/initrd
+ else
+ bbfatal "$fs is invalid. initrd image creation failed."
+ fi
+ done
+ chmod 0644 $dest/initrd
+ fi
+}
+
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] image-live.bbclass/image-vm.bbclass: remove duplicated code
2016-03-29 7:59 ` [PATCH 3/3] image-live.bbclass/image-vm.bbclass: remove duplicated code Robert Yang
@ 2016-03-29 11:59 ` Richard Purdie
2016-03-30 0:42 ` Robert Yang
0 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2016-03-29 11:59 UTC (permalink / raw)
To: Robert Yang, openembedded-core
On Tue, 2016-03-29 at 00:59 -0700, Robert Yang wrote:
> Move the common code to image.bbclass and remove duplicated ones.
Whilst I do like the idea of this patch set, I don't like generic
functions called "populate", or adding EFI variables to image.bbclass
itself.
I believe that some refactoring does make a lot of sense here but this
doesn't look right. The diffstats don't seem to suggest a large volume
of common code either (as yet).
Cheers,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] image-live.bbclass/image-vm.bbclass: remove duplicated code
2016-03-29 11:59 ` Richard Purdie
@ 2016-03-30 0:42 ` Robert Yang
0 siblings, 0 replies; 6+ messages in thread
From: Robert Yang @ 2016-03-30 0:42 UTC (permalink / raw)
To: Richard Purdie, openembedded-core
On 03/29/2016 07:59 PM, Richard Purdie wrote:
> On Tue, 2016-03-29 at 00:59 -0700, Robert Yang wrote:
>> Move the common code to image.bbclass and remove duplicated ones.
>
> Whilst I do like the idea of this patch set, I don't like generic
> functions called "populate", or adding EFI variables to image.bbclass
> itself.
Thanks, I will update it.
>
> I believe that some refactoring does make a lot of sense here but this
> doesn't look right. The diffstats don't seem to suggest a large volume
> of common code either (as yet).
The patch that removes the duplicated code is:
[OE-core] [PATCH 3/3] image-live.bbclass/image-vm.bbclass: remove duplicated code
meta/classes/image-live.bbclass | 58 ++++++-----------------------------------
meta/classes/image-vm.bbclass | 51 +-----------------------------------
meta/classes/image.bbclass | 46 ++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 100 deletions(-)
It removes 45 lines, I will check whether we can do more on these bbclasses.
// Robert
>
> Cheers,
>
> Richard
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-03-30 0:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-29 7:59 [PATCH 0/3] Remove bootimg.bbclass and boot-directdisk.bbclass Robert Yang
2016-03-29 7:59 ` [PATCH 1/3] boot-directdisk.bbclass: merge it into image-vm.bbclass Robert Yang
2016-03-29 7:59 ` [PATCH 2/3] bootimg.bbclass: merge it into image-live.bbclass Robert Yang
2016-03-29 7:59 ` [PATCH 3/3] image-live.bbclass/image-vm.bbclass: remove duplicated code Robert Yang
2016-03-29 11:59 ` Richard Purdie
2016-03-30 0:42 ` Robert Yang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.