[oe-commits] Jonas Eriksson : cpio rootfs build: Avoid modifying rootfs dir

git at git.openembedded.org git at git.openembedded.org
Thu Mar 27 09:36:05 UTC 2014


Module: openembedded-core.git
Branch: master
Commit: 706055503f493a5af73240c0983c46dbe31d8fe9
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=706055503f493a5af73240c0983c46dbe31d8fe9

Author: Jonas Eriksson <jonas.eriksson at enea.com>
Date:   Mon Mar 24 16:56:05 2014 +0100

cpio rootfs build: Avoid modifying rootfs dir

The Linux kernel requires that initrd images contain a /init file for
the image to be used as an initrd, even if it is empty. Adding it into
the rootfs directory creates a race, that can upset tar when building
both a .tar and .cpio image file ("tar: .: file changed as we read it").
Additionally, whether or not the tar file will contain the /init file is
also up to the race condition.

To avoid this problem, move the /init addition out from the rootfs
directory, and thus only include it in the .cpio image.

Signed-off-by: Jonas Eriksson <jonas.eriksson at enea.com>
Signed-off-by: Josep Puigdemont <josep.puigdemont at enea.com>
Cc: Laurentiu Palcu <laurentiu.palcu at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 meta/classes/image_types.bbclass | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index b693317..f38e3b6 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -66,10 +66,12 @@ IMAGE_CMD_squashfs-xz = "mksquashfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_
 IMAGE_CMD_tar = "tar -cvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar -C ${IMAGE_ROOTFS} ."
 
 IMAGE_CMD_cpio () {
-	if [ ! -L ${IMAGE_ROOTFS}/init ]; then
-		touch ${IMAGE_ROOTFS}/init
-	fi
 	(cd ${IMAGE_ROOTFS} && find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
+	if [ ! -e ${IMAGE_ROOTFS}/init ]; then
+		mkdir -p ${WORKDIR}/cpio_append
+		touch ${WORKDIR}/cpio_append/init
+		(cd  ${WORKDIR}/cpio_append && echo ./init | cpio -oA -H newc -F ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
+	fi
 }
 
 ELF_KERNEL ?= "${STAGING_DIR_HOST}/usr/src/kernel/${KERNEL_IMAGETYPE}"



More information about the Openembedded-commits mailing list