Skip to contentSkip to conversation

bootimg.bbclass: fixes for iso and hddimg

PATCH New Robert Yang 1 participant 3 messages Jun 30, 2015

lore
Share & tools
lore
#0 lore raw

cover bootimg.bbclass: fixes for iso and hddimg

The following changes since commit 592a1d94a7b0e80059016adb59c4c61e256206f0:

oeqa/parselogs: Whitelist qemumips64 runtime error (2015-06-27 22:49:49 +0100)

are available in the git repository at:

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

Robert Yang (2):
bootimg.bbclass:iso: use mkisofs -iso-level 3 for large iso bootimg.bbclass:hddimg: check the size of rootfs.img for hddimg

 meta/classes/bootimg.bbclass |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 bootimg.bbclass:iso: use mkisofs -iso-level 3 for large iso

There will be problems when rootfs.img is larger than 4GB:
mkisofs: Value too large for defined data type. File /path/to/iso/rootfs.img is too large for current mkisofs settings - ignoring

And will get a wrong iso.

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.

[YOCTO #6449]

---
 meta/classes/bootimg.bbclass |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
meta/classes/bootimg.bbclass +13 -2
index 4abe00e..605edc9 100644
@@ -136,19 +136,30 @@ build_iso() {
 		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=""
+	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
+
 	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} ${ISODIR}
+			${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_compress_opts ${MKISOFS_OPTIONS} $mkisofs_iso_level \
 			-eltorito-alt-boot -eltorito-platform efi \
 			-b efi.img -no-emul-boot \
 			${ISODIR}
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/2 bootimg.bbclass:hddimg: check the size of rootfs.img for hddimg

In reply to Robert Yang

The hddimg uses FAT, so the single file size should be less than 4GB, otherwise errors, check that and error out.

Another way might be use ext2/3/4 rather than FAT, but EFI only supports FAT, if we make EFI use FAT, and non-EFI use extX, that would the code very different, which seems not worth.

[YOCTO #6449]

---
 meta/classes/bootimg.bbclass |   13 +++++++++++++
 1 file changed, 13 insertions(+)
meta/classes/bootimg.bbclass +13 -0
index 605edc9..ab1d1bd 100644
@@ -249,6 +249,19 @@ build_hddimg() {
 			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
Signature · 1 line
1.7.9.5