Patchwork [2/2] rootfs_xxx.bbclass: support read-only-rootfs image feature

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date Dec. 24, 2012, 7:54 a.m.
Message ID <997e976b6a706b1fe3bf4b6c5d67deb5da22af73.1356335387.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/41613/
State New
Headers show

Comments

Qi.Chen@windriver.com - Dec. 24, 2012, 7:54 a.m.
From: Chen Qi <Qi.Chen@windriver.com>

If IMAGE_FEATUERS contains 'read-only-rootfs', we make
populate-volatile.sh run at rootfs time to set up basic files and
directories.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/rootfs_deb.bbclass |   14 ++++++++++++++
 meta/classes/rootfs_ipk.bbclass |   15 +++++++++++++++
 meta/classes/rootfs_rpm.bbclass |   20 +++++++++++++++++++-
 3 files changed, 48 insertions(+), 1 deletion(-)

Patch

diff --git a/meta/classes/rootfs_deb.bbclass b/meta/classes/rootfs_deb.bbclass
index 293953d..052d5d9 100644
--- a/meta/classes/rootfs_deb.bbclass
+++ b/meta/classes/rootfs_deb.bbclass
@@ -84,6 +84,20 @@  fakeroot rootfs_deb_do_rootfs () {
 
 	${ROOTFS_POSTPROCESS_COMMAND}
 
+	# Let populate-volatile.sh run at rootfs time in case of an read-only rootfs
+	if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false", d)}; then
+		if [ ! -e ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
+			echo "${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh doesn't exist."
+			exit 1
+		else
+			${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
+			if [ $? != 0 ]; then
+				echo "Running populate-volatile.sh under ${IMAGE_ROOTFS} failed"
+				exit 1
+			fi
+		fi
+	fi
+
 	log_check rootfs
 }
 
diff --git a/meta/classes/rootfs_ipk.bbclass b/meta/classes/rootfs_ipk.bbclass
index 5c962de..b851049 100644
--- a/meta/classes/rootfs_ipk.bbclass
+++ b/meta/classes/rootfs_ipk.bbclass
@@ -114,6 +114,21 @@  fakeroot rootfs_ipk_do_rootfs () {
 			remove_packaging_data_files
 		fi
 	fi
+
+        # Let populate-volatile.sh run at rootfs time in case of a read-only-rootfs image
+	if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false", d)}; then
+		if [ ! -e ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
+			echo "${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh doesn't exist."
+			exit 1
+		else
+			${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
+			if [ $? != 0 ]; then
+				echo "Running populate-volatile.sh under ${IMAGE_ROOTFS} failed"
+				exit 1
+			fi
+		fi
+	fi
+
 	set +x
 	log_check rootfs
 }
diff --git a/meta/classes/rootfs_rpm.bbclass b/meta/classes/rootfs_rpm.bbclass
index f7e4c5e..733764a 100644
--- a/meta/classes/rootfs_rpm.bbclass
+++ b/meta/classes/rootfs_rpm.bbclass
@@ -89,6 +89,8 @@  fakeroot rootfs_rpm_do_rootfs () {
 
 	# Report delayed package scriptlets
 	for i in ${IMAGE_ROOTFS}/etc/rpm-postinsts/*; do
+                # We should add a check here to check whether we're building a read-only rootfs
+                # If so, exit 1, because there are still postintalls that are to be run on target.
 		if [ -f $i ]; then
 			echo "Delayed package scriptlet: `head -n 3 $i | tail -n 1`"
 		fi
@@ -104,7 +106,7 @@  for i in /etc/rpm-postinsts/*; do
 	if [ -f $i ] && $i; then
 		rm $i
 	else
-		echo "ERROR: postinst $i failed."
+		[ -f $i ] && echo "ERROR: postinst $i failed."
 	fi
 done
 rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
@@ -127,6 +129,22 @@  EOF
 	# Remove all remaining resolver files
 	rm -rf ${IMAGE_ROOTFS}/install
 
+	# Run init scripts that are necessary in case of an read-only rootfs
+	if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false", d)}; then
+		if [ ! -e ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
+			echo "${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh doesn't exist."
+			exit 1
+		else
+			# Run populate_volatile.sh under ${IMAGE_ROOTFS} to set up basic
+                        # directories and files which are related to volatile storage.
+			${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
+			if [ $? != 0 ]; then
+				echo "Running populate-volatile.sh under ${IMAGE_ROOTFS} failed"
+				exit 1
+			fi
+		fi
+	fi
+
 	log_check rootfs
 }