Skip to contentSkip to conversation

V2 Remove bootimg.bbclass and boot-directdisk.bbclass

PATCH New Robert Yang 1 participant 5 messages Mar 30, 2016

lore
Share & tools
lore
#0 lore raw

cover V2 Remove bootimg.bbclass and boot-directdisk.bbclass

* V2:
- populate() -> populate_kernel()
- Put the common code in live-vm-common.bbclass rather than image.bbclass.
- Remove invalid code in image-vm.bbclass

// Robert

The following changes since commit b3f80743cd1b9a15a8ee4d20c2a54c2f6cbcd13c:

gcc: Backport fixes for musl ssp configuration (2016-03-29 23:19:45 +0100)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib 95c58580b5700d138d32ba21cb1e488296ff5282
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=95c58580b5700d138d32ba21cb1e488296ff5282

Robert Yang (4):
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 image-vm.bbclass: remove invalid code

 meta/classes/boot-directdisk.bbclass | 190 ----------------------
 meta/classes/bootimg.bbclass         | 304 -----------------------------------
 meta/classes/gummiboot.bbclass       |   2 +-
 meta/classes/image-live.bbclass      | 268 +++++++++++++++++++++++++++++-
 meta/classes/image-vm.bbclass        | 162 ++++++++++++++++---
 meta/classes/image.bbclass           |  12 --
 meta/classes/live-vm-common.bbclass  |  58 +++++++
 7 files changed, 465 insertions(+), 531 deletions(-)
 delete mode 100644 meta/classes/boot-directdisk.bbclass
 delete mode 100644 meta/classes/bootimg.bbclass
 create mode 100644 meta/classes/live-vm-common.bbclass
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 boot-directdisk.bbclass: merge it into image-vm.bbclass

They are doing the same things: create virtual machine images, merge them into one bbclass makes it easy to understand.

---
 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
meta/classes/boot-directdisk.bbclass deleted +0 -190
deleted file mode 100644
index 46f88ac9..0000000
@@ -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
meta/classes/image-vm.bbclass +198 -18

241 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/4 bootimg.bbclass: merge it into image-live.bbclass

In reply to Robert Yang

They are doing the same things: create live images, merge them into one bbclass makes it easy to understand.

---
 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
meta/classes/bootimg.bbclass deleted +0 -304
deleted file mode 100644
index d9ed7db..0000000
@@ -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
meta/classes/gummiboot.bbclass +1 -1
index 9a97ac1..1ebb946 100644
@@ -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"
meta/classes/image-live.bbclass +302 -6

320 lines not on this page · raw message

meta/classes/image-vm.bbclass +1 -1
index 68cf89b..ced8eac 100644
@@ -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.
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/4 image-live.bbclass/image-vm.bbclass: remove duplicated code

In reply to Robert Yang

Move the common code to live_vm_common.bbclass and remove duplicated ones.

---
 meta/classes/image-live.bbclass     | 60 +++++++------------------------------
 meta/classes/image-vm.bbclass       | 53 ++------------------------------
 meta/classes/image.bbclass          | 12 --------
 meta/classes/live-vm-common.bbclass | 58 +++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+), 112 deletions(-)
 create mode 100644 meta/classes/live-vm-common.bbclass
meta/classes/image-live.bbclass +10 -50
index 9c725c0..c114f50 100644
@@ -25,6 +25,8 @@
 # ${HDDIMG_ID} - FAT image volume-id
 # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
 
+inherit live-vm-common
+
 do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \
                         mtools-native:do_populate_sysroot \
                         cdrtools-native:do_populate_sysroot \
@@ -70,52 +72,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_kernel $1
+	if [ -s "${ROOTFS}" ]; then
+		install -m 0644 ${ROOTFS} $1/rootfs.img
 	fi
-
 }
 
 build_iso() {
@@ -127,14 +88,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 +234,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}
meta/classes/image-vm.bbclass +3 -50

72 lines not on this page · raw message

meta/classes/image.bbclass +0 -12
index 62ff07e..0667a6a 100644
@@ -540,15 +540,3 @@ do_bundle_initramfs () {
 }
 addtask bundle_initramfs after do_image_complete
 
-# Some of the vars for vm and live image are conflicted, this function
-# is used for fixing the problem.
-def set_live_vm_vars(d, suffix):
-    vars = ['GRUB_CFG', 'SYSLINUX_CFG', 'ROOT', 'LABELS', 'INITRD']
-    for var in vars:
-        var_with_suffix = var + '_' + suffix
-        if d.getVar(var, True):
-            bb.warn('Found potential conflicted var %s, please use %s rather than %s' % \
-                (var, var_with_suffix, var))
-        elif d.getVar(var_with_suffix, True):
-            d.setVar(var, d.getVar(var_with_suffix, True))
-
meta/classes/live-vm-common.bbclass new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/4 image-vm.bbclass: remove invalid code

In reply to Robert Yang

It has been done in syslinux.bbclass.

---
 meta/classes/image-vm.bbclass | 7 -------
 1 file changed, 7 deletions(-)
meta/classes/image-vm.bbclass +0 -7
index 66712a6..326dc04 100644
@@ -61,13 +61,6 @@ build_boot_dd() {
 		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}`
 
Signature · 1 line
2.7.4