[oe-commits] Mike Looijmans : image.bbclass: Always try to run populate-volatile.sh at rootfs time

git at git.openembedded.org git at git.openembedded.org
Tue Sep 1 21:21:10 UTC 2015


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

Author: Mike Looijmans <mike.looijmans at topic.nl>
Date:   Wed Aug 12 09:00:43 2015 +0200

image.bbclass: Always try to run populate-volatile.sh at rootfs time

Currently populate-volatile.sh will only run when "readonly-rootfs" is
selected.

Running this script is very useful even on read/write root filesystems,
because it reduces the number of "fixup" actions at first boot of the
device. That not only reduces boot time, it also reduces the flash space
usage. Also, when the system happens to have a read-only filesystem
because for example the "read-only" switch of the SD card was set, or
because the filesystem had errors on it, it will still be able to boot.

I've been manually adding these lines to each and every image recipe I've
used, so I guess it's time to move this into core.

Signed-off-by: Mike Looijmans <mike.looijmans at topic.nl>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 meta/classes/image.bbclass | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 4e66535..32ddc08 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -187,6 +187,9 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'deb
 # Create /etc/timestamp during image construction to give a reasonably sane default time setting
 ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
 
+# Create the volatile cache. Required for read-only rootfs, useful for all sysvinit systems to reduce writes to the system
+ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "rootfs_populate_volatile_cache;", "", d)}'
+
 # Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
 
@@ -218,6 +221,16 @@ do_rootfs[cleandirs] += "${S}"
 # task, so that we have a single fakeroot context for the whole process.
 do_rootfs[umask] = "022"
 
+
+# Run populate-volatile.sh at rootfs time to set up basic files and
+# directories to reduce writes at first boot and to support read-only
+# rootfs.
+rootfs_populate_volatile_cache() {
+		if [ -x ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
+			${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
+		fi
+}
+
 # A hook function to support read-only-rootfs IMAGE_FEATURES
 read_only_rootfs_hook () {
 	# Tweak the mount option and fs_passno for rootfs in fstab
@@ -228,11 +241,6 @@ read_only_rootfs_hook () {
 		if [ -e ${IMAGE_ROOTFS}/etc/default/rcS ]; then
 			sed -i 's/ROOTFS_READ_ONLY=no/ROOTFS_READ_ONLY=yes/' ${IMAGE_ROOTFS}/etc/default/rcS
 		fi
-		# Run populate-volatile.sh at rootfs time to set up basic files
-		# and directories to support read-only rootfs.
-		if [ -x ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
-			${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
-		fi
 		# If we're using openssh and the /etc/ssh directory has no pre-generated keys,
 		# we should configure openssh to use the configuration file /etc/ssh/sshd_config_readonly
 		# and the keys under /var/run/ssh.



More information about the Openembedded-commits mailing list