public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH 00/12] read-only rootfs support
@ 2013-01-24  8:16 Qi.Chen
  2013-01-24  8:16 ` [PATCH 01/12] sysvinit: add ROOTFS_READ_ONLY variable to rcS-default Qi.Chen
                   ` (11 more replies)
  0 siblings, 12 replies; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

The series of patches add support to read-only rootfs.

The main idea is to use symbolic links to create the illuion that some
directories are writable in case of a read-only rootfs.

We use a similar stragety to update-rc.d.bbclass to manage all the recipes
that need to tweak some specific directories to support a read-only rootfs.
These recipes inherit volatiles.bbclass and set VOLATILE_DIR, VOLATILE_LINK
and VOLATILE_PKGS properly.

The advantage of this strategy is that it deligates the task of supporting
read-only rootfs to the recipes, resulting in a better management scheme.

This set of patches have been tested on minimal images with and without
'read-only-rootfs' image feature enabled. Everything is OK.

For sato images, everything is the same as before if 'read-only-rootfs' is not enabled.
With 'read-only-rootfs' enabled, sato image could work if graphic interface is diabled.
When all postinstall problems are resolved, sato image should work well.


The following changes since commit 37e025f6f9c410005e0f1dee0767e38eaec01cbd:

  bitbake: hob: Hob should display warnings generated during parsing (2013-01-21 19:05:31 +0000)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib ChenQi/readonly-rootfs
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/readonly-rootfs

Chen Qi (12):
  sysvinit: add ROOTFS_READ_ONLY variable to rcS-default
  image.bbclass: add a hook funtion to support readonly rootfs
  core-image.bbclass: support read-only rootfs
  package.bbclass: add VOLATILE_DIR and VOLATILE_LINK to PACKAGEVARS
  volatiles.bbclass: add recipe
  volatiles_sysvinit.bbclass: add recipe
  populate-volatile.sh: improve this script
  initscripts: let populate-volatile.sh create the /tmp link
  initscripts: inherit volatiles to support read-only rootfs
  dropbear: inherit volatiles to support read-only rootfs
  nfs-utils: inherit volatiles to support read-only rootfs
  dbus: inherit volatiles to support read-only rootfs

 meta/classes/core-image.bbclass                    |    4 +
 meta/classes/image.bbclass                         |   18 ++
 meta/classes/package.bbclass                       |    4 +-
 meta/classes/volatiles.bbclass                     |   11 +
 meta/classes/volatiles_sysvinit.bbclass            |   49 ++++
 .../nfs-utils/nfs-utils_1.2.3.bb                   |    7 +-
 meta/recipes-core/dbus/dbus.inc                    |    7 +-
 meta/recipes-core/dropbear/dropbear.inc            |    7 +-
 .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +-
 .../initscripts-1.0/populate-volatile.sh           |  287 ++++++++++----------
 .../initscripts/initscripts-1.0/volatiles          |    1 +
 meta/recipes-core/initscripts/initscripts_1.0.bb   |    6 +-
 meta/recipes-core/sysvinit/sysvinit/rcS-default    |    4 +
 meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb     |    2 +-
 14 files changed, 255 insertions(+), 161 deletions(-)
 create mode 100644 meta/classes/volatiles.bbclass
 create mode 100644 meta/classes/volatiles_sysvinit.bbclass

-- 
1.7.9.5




^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 01/12] sysvinit: add ROOTFS_READ_ONLY variable to rcS-default
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24  8:16 ` [PATCH 02/12] image.bbclass: add a hook funtion to support readonly rootfs Qi.Chen
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

This variable indicates whether the rootfs is intended to be read-only
or not. Changing this value from 'no' to 'yes' on a currently running
system with read-write rootfs and rebooting will give the user a working
system with read-only rootfs.

However, it is not suggested to change its value. Normally, if a read-only
rootfs is required, we should build an image with 'read-only-rootfs' image
feature.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/sysvinit/sysvinit/rcS-default |    4 ++++
 meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb  |    2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/sysvinit/sysvinit/rcS-default b/meta/recipes-core/sysvinit/sysvinit/rcS-default
index 3c9dea9..709cdf6 100644
--- a/meta/recipes-core/sysvinit/sysvinit/rcS-default
+++ b/meta/recipes-core/sysvinit/sysvinit/rcS-default
@@ -23,3 +23,7 @@ FSCKFIX=yes
 #TICKADJ=10000
 # Enable caching in populate-volatile.sh
 VOLATILE_ENABLE_CACHE=yes
+# Indicate whether the rootfs is intended to be read-only or not.
+# Setting ROOTFS_READ_ONLY to yes and rebooting will give you a read-only rootfs.
+# Normally you should not change this value.
+ROOTFS_READ_ONLY=no
diff --git a/meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb b/meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb
index de073b8..bf6a29b 100644
--- a/meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb
+++ b/meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb
@@ -5,7 +5,7 @@ SECTION = "base"
 LICENSE = "GPLv2+"
 LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe \
                     file://COPYRIGHT;endline=15;md5=349c872e0066155e1818b786938876a4"
-PR = "r9"
+PR = "r10"
 
 RDEPENDS_${PN} = "${PN}-inittab"
 
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 02/12] image.bbclass: add a hook funtion to support readonly rootfs
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
  2013-01-24  8:16 ` [PATCH 01/12] sysvinit: add ROOTFS_READ_ONLY variable to rcS-default Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24 19:44   ` Mark Hatle
  2013-01-24  8:16 ` [PATCH 03/12] core-image.bbclass: support read-only rootfs Qi.Chen
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

read_only_rootfs_hook: this funtion is invoked only if 'read-only-rootfs'
is in IMAGE_FEATURES. It tweaks some basic files and makes populate-
volatile.sh script run at rootfs time.

For now, it has real effect only if the init system is sysvinit.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/image.bbclass |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 0293d2e..91045fc 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -201,6 +201,24 @@ run_intercept_scriptlets () {
 	fi
 }
 
+# A hook function to support read-only-rootfs IMAGE_FEATURES
+# Currently, it only supports sysvinit system.
+read_only_rootfs_hook () {
+	if ${@base_contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
+	        # Tweak the mount option in fstab
+		sed -i '/rootfs/ s/defaults/ro/' ${IMAGE_ROOTFS}/etc/fstab
+	        # Change the value of ROOTFS_READ_ONLY in /etc/default/rcS to yes
+		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 [ -e ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
+			${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
+		fi
+	fi
+}
+
 fakeroot do_rootfs () {
 	#set -x
 	# When use the rpm incremental image generation, don't remove the rootfs
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 03/12] core-image.bbclass: support read-only rootfs
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
  2013-01-24  8:16 ` [PATCH 01/12] sysvinit: add ROOTFS_READ_ONLY variable to rcS-default Qi.Chen
  2013-01-24  8:16 ` [PATCH 02/12] image.bbclass: add a hook funtion to support readonly rootfs Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24  8:16 ` [PATCH 04/12] package.bbclass: add VOLATILE_DIR and VOLATILE_LINK to PACKAGEVARS Qi.Chen
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

The hook function is appended to ROOTFS_POSTPROCESS_COMMAND
properly to support the 'read-only-rootfs' image feature.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/core-image.bbclass |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/classes/core-image.bbclass b/meta/classes/core-image.bbclass
index e0f6dbb..0e6663d 100644
--- a/meta/classes/core-image.bbclass
+++ b/meta/classes/core-image.bbclass
@@ -28,6 +28,7 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3
 # - dev-pkgs            - development packages (headers, etc.) for all installed packages in the rootfs
 # - dbg-pkgs            - debug symbol packages for all installed packages in the rootfs
 # - doc-pkgs            - documentation packages for all installed packages in the rootfs
+# - read-only-rootfs    - tweaks an image to support read-only rootfs
 #
 PACKAGE_GROUP_x11 = "packagegroup-core-x11"
 PACKAGE_GROUP_x11-base = "packagegroup-core-x11-base"
@@ -76,3 +77,6 @@ ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
 
 # Zap the root password if debug-tweaks feature is not enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "", "zap_root_password ; ",d)}'
+
+# Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is enabled
+ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 04/12] package.bbclass: add VOLATILE_DIR and VOLATILE_LINK to PACKAGEVARS
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
                   ` (2 preceding siblings ...)
  2013-01-24  8:16 ` [PATCH 03/12] core-image.bbclass: support read-only rootfs Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24  8:16 ` [PATCH 05/12] volatiles.bbclass: add recipe Qi.Chen
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

These two variables are used by recipes that inherit volatiles.bbclass.
The usage of them is similar to INITSCRIPT_NAME and INITSCRIPT_PARAMS.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/package.bbclass |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 8e07168..b4298ad 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1842,7 +1842,9 @@ python package_depchains() {
 
 # Since bitbake can't determine which variables are accessed during package
 # iteration, we need to list them here:
-PACKAGEVARS = "FILES RDEPENDS RRECOMMENDS SUMMARY DESCRIPTION RSUGGESTS RPROVIDES RCONFLICTS PKG ALLOW_EMPTY pkg_postinst pkg_postrm INITSCRIPT_NAME INITSCRIPT_PARAMS DEBIAN_NOAUTONAME ALTERNATIVE PKGE PKGV PKGR"
+PACKAGEVARS = "FILES RDEPENDS RRECOMMENDS SUMMARY DESCRIPTION RSUGGESTS RPROVIDES \
+RCONFLICTS PKG ALLOW_EMPTY pkg_postinst pkg_postrm INITSCRIPT_NAME INITSCRIPT_PARAMS \
+DEBIAN_NOAUTONAME ALTERNATIVE PKGE PKGV PKGR VOLATILE_DIR VOLATILE_LINK"
 
 def gen_packagevar(d):
     ret = []
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 05/12] volatiles.bbclass: add recipe
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
                   ` (3 preceding siblings ...)
  2013-01-24  8:16 ` [PATCH 04/12] package.bbclass: add VOLATILE_DIR and VOLATILE_LINK to PACKAGEVARS Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24 10:31   ` Martin Jansa
  2013-01-24  8:16 ` [PATCH 06/12] volatiles_sysvinit.bbclass: " Qi.Chen
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

All recipes that need to tweak their directories need to inherit this
class and set VOLATILE_DIR, VOLATILE_LINK and VOLATILE_PKGS.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/volatiles.bbclass |   11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 meta/classes/volatiles.bbclass

diff --git a/meta/classes/volatiles.bbclass b/meta/classes/volatiles.bbclass
new file mode 100644
index 0000000..f27e598
--- /dev/null
+++ b/meta/classes/volatiles.bbclass
@@ -0,0 +1,11 @@
+# This bbclass is for read-only-rootfs support. All recipes that may tweak their
+# own directories in order to run correctly in a read-only rootfs enviroment
+# should inherit this class and set VOLATILE_DIR, VOLATILE_LINK, VOLATILE_PKGS.
+
+# For each package, the net result is a read-only specific conf file generated
+# and packaged, which has the name of readonly-${VOLATILESPN}.
+
+# All these config files are then parsed by populate-volatile.sh to create proper
+# directories and links.
+
+inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 06/12] volatiles_sysvinit.bbclass: add recipe
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
                   ` (4 preceding siblings ...)
  2013-01-24  8:16 ` [PATCH 05/12] volatiles.bbclass: add recipe Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24  8:16 ` [PATCH 07/12] populate-volatile.sh: improve this script Qi.Chen
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

This bbclass is used to support read-only rootfs with sysvinit init
manager.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/volatiles_sysvinit.bbclass |   49 +++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 meta/classes/volatiles_sysvinit.bbclass

diff --git a/meta/classes/volatiles_sysvinit.bbclass b/meta/classes/volatiles_sysvinit.bbclass
new file mode 100644
index 0000000..df5bedc
--- /dev/null
+++ b/meta/classes/volatiles_sysvinit.bbclass
@@ -0,0 +1,49 @@
+# This bbclass is used to support read-only rootfs with sysvinit init manager.
+
+VOLATILESPN ?= "${PN}"
+VOLATILES_PKGD_DIR = "${PKGD}${sysconfdir}/default/volatiles"
+CONF_FILE_NAME = "readonly-${VOLATILESPN}"
+
+CONF_FILE = "${VOLATILES_PKGD_DIR}/${CONF_FILE_NAME}"
+
+def volatiles_after_parse(d):
+    if d.getVar('VOLATILE_PKGS') == None:
+        if d.getVar('VOLATILE_DIR') == None:
+            raise bb.build.FuncFailed, "%s inherits volatiles but doesn't set VOLATILE_DIR" % d.getVar('FILE')
+        if d.getVar('VOLATILE_LINK') == None:
+            raise bb.build.FuncFailed, "%s inherits volatiles but doesn't set VOLATILE_LINK" % d.getVar('FILE')
+
+python __anonymous() {
+    volatiles_after_parse(d)
+}
+
+do_install_prepend () {
+    install -d ${D}${sysconfdir}/default/volatiles
+}
+
+python populate_packages_prepend () {
+    def volatiles_package(pkg):
+        bb.debug(1, 'generating volatile config files for %s' % pkg)
+        localdata = bb.data.createCopy(d)
+        overrides = localdata.getVar("OVERRIDES", True)
+        localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides))
+        bb.data.update_data(localdata)
+
+        # install read-only specific conf files
+        filepath = localdata.getVar('CONF_FILE', True)
+        dirpath = localdata.getVar('VOLATILE_DIR', True)
+        linkpath = localdata.getVar('VOLATILE_LINK', True)
+        f = open(filepath, 'a')
+        f.write("d root root 0755 %s none\n" % dirpath)
+        f.write("l root root 0755 %s %s\n" % (linkpath, dirpath))
+        f.close()
+
+    pkgs = d.getVar('VOLATILE_PKGS', True)
+    if pkgs == None:
+        pkgs = d.getVar('VOLATILESPN', True)
+        packages = (d.getVar('PACKAGES', True) or "").split()
+        if not pkgs in packages and packages != []:
+            pkgs = packages[0]
+    for pkg in pkgs.split():
+        volatiles_package(pkg)
+}
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 07/12] populate-volatile.sh: improve this script
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
                   ` (5 preceding siblings ...)
  2013-01-24  8:16 ` [PATCH 06/12] volatiles_sysvinit.bbclass: " Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24  8:16 ` [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link Qi.Chen
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

Here's a list of improvements:
1) Make it run correctly at rootfs time.
2) Handle link config items more reasonably.
3) Support read-only rootfs.
4) Avoid data loss when removing directories.

[YOCTO #3406]
[YOCTO #3404]
[YOCTO #3181]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 .../initscripts-1.0/populate-volatile.sh           |  287 ++++++++++----------
 1 file changed, 143 insertions(+), 144 deletions(-)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index d2175d7..61ef6c9 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -8,192 +8,191 @@
 # Short-Description:  Populate the volatile filesystem
 ### END INIT INFO
 
-. /etc/default/rcS
-
-CFGDIR="/etc/default/volatiles"
-TMPROOT="/var/tmp"
+# Get ROOT_DIR
+DIRNAME=`dirname $0`
+ROOT_DIR=`echo $DIRNAME | sed -ne 's:etc/.*::p'`
+
+. ${ROOT_DIR}/etc/default/rcS
+# When running populat-volatile.sh at rootfs time, disable cache.
+[ "$ROOT_DIR" != "/" ] && VOLATILE_ENABLE_CACHE=no
+# If rootfs is read-only, disable cache.
+[ "$ROOTFS_READ_ONLY" = "yes" ] && VOLATILE_ENABLE_CACHE=no
+# All above statements will be moved to a central place, say var.sh which
+# encapsulates '. /etc/default/rcS'.
+
+CFGDIR="${ROOT_DIR}/etc/default/volatiles"
+TMPROOT="${ROOT_DIR}/var/volatile/tmp"
 COREDEF="00_core"
+READONLY_MATCH="readonly-"
 
-[ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
+[ "${VERBOSE}" != "no" ] && echo "Setting up basic files related to volatile storage under ${ROOT_DIR}."
 
 create_file() {
-	EXEC=" 
-	touch \"$1\"; 
-	chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; 
-	chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 " 
+	EXEC="
+	touch \"$1\";
+	chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" > /dev/null 2>&1;
+	chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" > /dev/null 2>&1 "
 
 	test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
 
 	[ -e "$1" ] && {
-	  [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
+		[ "${VERBOSE}" != "no" ] && echo "Target $1 already exists. Skipping."
 	} || {
-	  eval $EXEC &
+		if [ "$ROOT_DIR" = "/" ]; then
+			eval $EXEC
+		else
+			# Some operations at rootfs time may fail and should fail,
+		        # but these failures should not be logged.
+			eval $EXEC > /dev/null 2>&1
+		fi
 	}
 }
 
 mk_dir() {
-	EXEC=" 
-	mkdir -p \"$1\"; 
-	chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; 
-	chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
+	EXEC="
+	mkdir -p \"$1\";
+	chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" 2>&1; 
+	chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" 2>&1 "
 
 	test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
-	
 	[ -e "$1" ] && {
-	  [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
+		[ "${VERBOSE}" != "no" ] && echo "Target ${1} already exists. Skipping."
 	} || {
-	  eval $EXEC
+		if [ "$ROOT_DIR" = "/" ]; then
+			eval $EXEC
+		else
+			# Some operations at rootfs time may fail and should fail,
+                        # but these failures should not be logged.
+			eval $EXEC > /dev/null 2>&1
+		fi
 	}
 }
 
 link_file() {
-	EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty0 2>&1" 
-
-	test "$VOLATILE_ENABLE_CACHE" = yes && echo "	$EXEC" >> /etc/volatile.cache.build
-	
-	[ -e "$2" ] && {
-	  echo "Cannot create link over existing -${TNAME}-." >&2
-	} || {
-	  eval $EXEC &
-	}
+	EXEC="
+	if [ -L \"$2\" ]; then
+		[ \"$(readlink -f \"$2\")\" != \"$(readlink -f \"$1\")\" ] && { rm -f \"$2\"; ln -sf \"$1\" \"$2\"; };
+	elif [ -d \"$2\" ]; then
+		for f in $2/* $2/.[^.]*; do [ -e $f ] && cp -rf $f $1; done;
+		rm -rf \"$2\";
+		ln -sf \"$1\" \"$2\";
+	else
+		ln -sf \"$1\" \"$2\";
+	fi
+        "
+        test "$VOLATILE_ENABLE_CACHE" = yes && echo "   $EXEC" >> /etc/volatile.cache.build
+	if [ "$ROOT_DIR" = "/" ]; then
+		eval $EXEC
+	else
+		# Some operations at rootfs time may fail and should fail,
+                # but these failures should not be logged
+		eval $EXEC > /dev/null 2>&1
+	fi
 }
 
 check_requirements() {
+	cleanup() {
+		rm "${TMP_INTERMED}"
+		rm "${TMP_DEFINED}"
+		rm "${TMP_COMBINED}"
+	}
+	
+	CFGFILE="$1"
+	[ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0
+	# read-only-rootfs specific conf files should only be applied when rootfs is read-only
+	case `basename "${CFGFILE}"` in
+		${READONLY_MATCH}*)
+		[ "$ROOTFS_READ_ONLY" = "yes" ] && return 0 || return 1
+		;;
+		*)
+		;;
+	esac
 
-  cleanup() {
-    rm "${TMP_INTERMED}"
-    rm "${TMP_DEFINED}"
-    rm "${TMP_COMBINED}"
-    }
-    
-  CFGFILE="$1"
-
-  [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0
-
-  TMP_INTERMED="${TMPROOT}/tmp.$$"
-  TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
-  TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
-
-
-  cat /etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
-  cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}"
-  cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
-
-  NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
-  NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`"
-
-  [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && {
-    echo "Undefined users:"
-    diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
-    cleanup
-    return 1
-    }
-
+	TMP_INTERMED="${TMPROOT}/tmp.$$"
+	TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
+	TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
+
+	cat ${ROOT_DIR}/etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
+	cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}"
+	cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
+	NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
+	NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`"
+
+	[ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && {
+		echo "Undefined users:"
+		diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
+		cleanup
+		return 1
+	}
 
-  cat /etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
-  cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}"
-  cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
 
-  NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`"
-  NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`"
+	cat ${ROOT_DIR}/etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
+	cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}"
+	cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
 
-  [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && {
-    echo "Undefined groups:"
-    diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
-    cleanup
-    return 1
-    }
+	NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`"
+	NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`"
 
-  # Add checks for required directories here
+	[ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && {
+		echo "Undefined groups:"
+		diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
+		cleanup
+		return 1
+	}
 
-  cleanup
-  return 0
-  }
+	cleanup
+	return 0
+}
 
 apply_cfgfile() {
+	CFGFILE="$1"
+	[ ${VERBOSE} != "no" ] && echo "Applying config file: $CFGFILE"
+	
+	check_requirements "${CFGFILE}" || {
+		echo "Skipping ${CFGFILE}"
+		return 1
+	}
 
-  CFGFILE="$1"
-
-  check_requirements "${CFGFILE}" || {
-    echo "Skipping ${CFGFILE}"
-    return 1
-    }
-
-  cat ${CFGFILE} | grep -v "^#" | \
-  while read LINE; do
-
-    eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
-
-    [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
-
-
-    [ "${TTYPE}" = "l" ] && {
-      TSOURCE="$TLTARGET"
-      [ -L "${TNAME}" ] || {
-        [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-."
-        link_file "${TSOURCE}" "${TNAME}" &
-        }
-      continue
-      }
-
-    [ -L "${TNAME}" ] && {
-      [ "${VERBOSE}" != "no" ] && echo "Found link."
-      NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'`
-      echo ${NEWNAME} | grep -v "^/" >/dev/null && {
-        TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}"
-        [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-."
-        } || {
-        TNAME="${NEWNAME}"
-        [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-."
-        }
-      }
-
-    case "${TTYPE}" in
-      "f")  [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-."
-            create_file "${TNAME}" &
-	    ;;
-      "d")  [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-."
-            mk_dir "${TNAME}"
-	    # Add check to see if there's an entry in fstab to mount.
-	    ;;
-      *)    [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
-            continue
-	    ;;
-    esac
-
-
-    done
-
-  return 0
-
-  }
-
-clearcache=0
-exec 9</proc/cmdline
-while read line <&9
-do
-	case "$line" in
-		*clearcache*)  clearcache=1
-			       ;;
-		*)	       continue
-			       ;;
-	esac
-done
-exec 9>&-
+	cat ${CFGFILE} | grep -v "^#" | sed -e '/^$/ d' | \
+		while read LINE; do
+		eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
+		TNAME=${ROOT_DIR}/${TNAME}
+		[ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
+
+		[ "${TTYPE}" = "l" ] && {
+			TSOURCE="$TLTARGET"
+			[ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-."
+			link_file "${TSOURCE}" "${TNAME}"
+			continue
+		}
+		case "${TTYPE}" in
+			"f")  [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-."
+				create_file "${TNAME}"
+				;;
+			"d")  [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-."
+				mk_dir "${TNAME}"
+				;;
+			*)    [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
+				continue
+				;;
+		esac
+	done
+	return 0
+}
 
-if test -e /etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
+if test -e ${ROOT_DIR}/etc/volatile.cache -a $VOLATILE_ENABLE_CACHE = yes -a x$1 != xupdate
 then
-	sh /etc/volatile.cache
+	sh ${ROOT_DIR}/etc/volatile.cache
 else	
-	rm -f /etc/volatile.cache /etc/volatile.cache.build
+	rm -f ${ROOT_DRI}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build
 	for file in `ls -1 "${CFGDIR}" | sort`; do
 		apply_cfgfile "${CFGDIR}/${file}"
 	done
 
-	[ -e /etc/volatile.cache.build ] && sync && mv /etc/volatile.cache.build /etc/volatile.cache
+	[ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache
 fi
 
-if test -f /etc/ld.so.cache -a ! -f /var/run/ld.so.cache
+if [ "${ROOT_DIR}" = "/" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ]
 then
 	ln -s /etc/ld.so.cache /var/run/ld.so.cache
 fi
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
                   ` (6 preceding siblings ...)
  2013-01-24  8:16 ` [PATCH 07/12] populate-volatile.sh: improve this script Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24 16:11   ` Mark Hatle
  2013-01-24 17:39   ` Mark Hatle
  2013-01-24  8:16 ` [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs Qi.Chen
                   ` (3 subsequent siblings)
  11 siblings, 2 replies; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

Previously, the /tmp link (/tmp -> /var/tmp) was created by the
bootmisc.sh script. So in case of a read-only rootfs, this symlink
would not be created correctly.

The populate-volatile.sh script is intended to handle all directories
and files related to volatile storage, so we should let it create
the /tmp link.

In addition, because of the improments of populate-volatile.sh, the data
loss problem of bug#3404 is also resolved by this patch.

[YOCTO #3406]
[YOCTO #3404]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +--------
 .../initscripts/initscripts-1.0/volatiles          |    1 +
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index 4f76cb4..3b5a47f 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -54,14 +54,7 @@ fi
 
 #
 # This is as good a place as any for a sanity check
-# /tmp should be a symlink to /var/tmp to cut down on the number
-# of mounted ramdisks.
-if test ! -L /tmp && test -d /var/tmp
-then
-	rm -rf /tmp
-	ln -sf /var/tmp /tmp
-fi
-
+#
 # Set the system clock from hardware clock
 # If the timestamp is more recent than the current time,
 # use the timestamp instead.
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/volatiles b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
index e0741aa..f7e2ef7 100644
--- a/meta/recipes-core/initscripts/initscripts-1.0/volatiles
+++ b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
@@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock
 l root root 0755 /var/log /var/volatile/log
 l root root 0755 /var/run /var/volatile/run
 l root root 1777 /var/tmp /var/volatile/tmp
+l root root 1777 /tmp /var/tmp
 d root root 0755 /var/lock/subsys none
 f root root 0664 /var/log/wtmp none
 f root root 0664 /var/run/utmp none
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
                   ` (7 preceding siblings ...)
  2013-01-24  8:16 ` [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-25 13:11   ` Burton, Ross
  2013-01-24  8:16 ` [PATCH 10/12] dropbear: " Qi.Chen
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

Inherit volatiles.bbclass to support read-only rootfs.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/initscripts/initscripts_1.0.bb |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/initscripts/initscripts_1.0.bb b/meta/recipes-core/initscripts/initscripts_1.0.bb
index 6e15f88..a33c0f6 100644
--- a/meta/recipes-core/initscripts/initscripts_1.0.bb
+++ b/meta/recipes-core/initscripts/initscripts_1.0.bb
@@ -3,7 +3,7 @@ DESCRIPTION = "Initscripts provide the basic system startup initialization scrip
 SECTION = "base"
 LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
-PR = "r139"
+PR = "r140"
 
 INHIBIT_DEFAULT_DEPS = "1"
 
@@ -42,6 +42,10 @@ ALTERNATIVE_PRIORITY = "90"
 ALTERNATIVE_${PN} = "functions"
 ALTERNATIVE_LINK_NAME[functions] = "${sysconfdir}/init.d/functions"
 
+inherit volatiles
+VOLATILE_DIR = "/var/volatile/lib/urandom"
+VOLATILE_LINK = "/var/lib/urandom"
+
 HALTARGS ?= "-d -f"
 
 do_configure() {
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 10/12] dropbear: inherit volatiles to support read-only rootfs
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
                   ` (8 preceding siblings ...)
  2013-01-24  8:16 ` [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24  8:16 ` [PATCH 11/12] nfs-utils: " Qi.Chen
  2013-01-24  8:16 ` [PATCH 12/12] dbus: " Qi.Chen
  11 siblings, 0 replies; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

Inherit volatiles.bbclass to support read-only rootfs.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/dropbear/dropbear.inc |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-core/dropbear/dropbear.inc b/meta/recipes-core/dropbear/dropbear.inc
index 3a39c95..efc685c 100644
--- a/meta/recipes-core/dropbear/dropbear.inc
+++ b/meta/recipes-core/dropbear/dropbear.inc
@@ -2,7 +2,7 @@ DESCRIPTION = "Dropbear is a lightweight SSH and SCP implementation"
 HOMEPAGE = "http://matt.ucc.asn.au/dropbear/dropbear.html"
 SECTION = "console/network"
 
-INC_PR = "r2"
+INC_PR = "r3"
 
 # some files are from other projects and have others license terms:
 #   public domain, OpenSSH 3.5p1, OpenSSH3.6.1p2, PuTTY
@@ -26,11 +26,14 @@ PAM_SRC_URI = "file://dropbear-enable-pam.patch \
                file://dropbear-configuration-file.patch \
                file://dropbear"
 
-inherit autotools update-rc.d
+inherit autotools update-rc.d volatiles
 
 INITSCRIPT_NAME = "dropbear"
 INITSCRIPT_PARAMS = "defaults 10"
 
+VOLATILE_DIR = "/var/volatile/lib/dropbear"
+VOLATILE_LINK = "/var/lib/dropbear"
+
 CFLAGS_prepend = " -I. "
 LD = "${CC}"
 
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 11/12] nfs-utils: inherit volatiles to support read-only rootfs
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
                   ` (9 preceding siblings ...)
  2013-01-24  8:16 ` [PATCH 10/12] dropbear: " Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24  8:16 ` [PATCH 12/12] dbus: " Qi.Chen
  11 siblings, 0 replies; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

Inherit volatiles.bbclass to support read-only rootfs.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 .../nfs-utils/nfs-utils_1.2.3.bb                   |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_1.2.3.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_1.2.3.bb
index 84b8e76..55208d5 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils_1.2.3.bb
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_1.2.3.bb
@@ -12,7 +12,7 @@ DEPENDS = "libcap libnfsidmap libevent util-linux tcp-wrappers"
 RDEPENDS_${PN} = "rpcbind"
 RRECOMMENDS_${PN} = "kernel-module-nfsd"
 
-PR = "r5"
+PR = "r6"
 
 SRC_URI = "${SOURCEFORGE_MIRROR}/nfs/nfs-utils-${PV}.tar.bz2 \
            file://nfs-utils-1.0.6-uclibc.patch \
@@ -34,7 +34,10 @@ INITSCRIPT_NAME = "nfsserver"
 # in the shutdown levels, but that works fine.
 INITSCRIPT_PARAMS = "defaults"
 
-inherit autotools update-rc.d
+inherit autotools update-rc.d volatiles
+
+VOLATILE_DIR = "/var/volatile/lib/nfs"
+VOLATILE_LINK = "/var/lib/nfs"
 
 # --enable-uuid is need for cross-compiling
 EXTRA_OECONF = "--with-statduser=nobody \
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 12/12] dbus: inherit volatiles to support read-only rootfs
  2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
                   ` (10 preceding siblings ...)
  2013-01-24  8:16 ` [PATCH 11/12] nfs-utils: " Qi.Chen
@ 2013-01-24  8:16 ` Qi.Chen
  2013-01-24 10:45   ` Burton, Ross
  11 siblings, 1 reply; 31+ messages in thread
From: Qi.Chen @ 2013-01-24  8:16 UTC (permalink / raw)
  To: openembedded-core; +Cc: Zhenfeng.Zhao

From: Chen Qi <Qi.Chen@windriver.com>

Inherit volatiles.bbclass to support read-only rootfs.

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/dbus/dbus.inc |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-core/dbus/dbus.inc b/meta/recipes-core/dbus/dbus.inc
index 88218b7..f614285 100644
--- a/meta/recipes-core/dbus/dbus.inc
+++ b/meta/recipes-core/dbus/dbus.inc
@@ -12,17 +12,20 @@ DEPENDS_class-nativesdk = "nativesdk-expat virtual/nativesdk-libintl virtual/lib
 RDEPENDS_dbus = "${@base_contains('DISTRO_FEATURES', 'ptest', 'dbus-ptest', '', d)}"
 RDEPENDS_class-native = ""
 
-INC_PR = "r5"
+INC_PR = "r6"
 
 SRC_URI = "http://dbus.freedesktop.org/releases/dbus/dbus-${PV}.tar.gz \
            file://tmpdir.patch; \
            file://dbus-1.init"
 
-inherit useradd autotools pkgconfig gettext update-rc.d
+inherit useradd autotools pkgconfig gettext update-rc.d volatiles
 
 INITSCRIPT_NAME = "dbus-1"
 INITSCRIPT_PARAMS = "start 02 5 3 2 . stop 20 0 1 6 ."
 
+VOLATILE_DIR = "/var/volatile/lib/dbus"
+VOLATILE_LINK = "/var/lib/dbus"
+
 USERADD_PACKAGES = "${PN}"
 GROUPADD_PARAM_${PN} = "-r netdev"
 USERADD_PARAM_${PN} = "--system --home ${localstatedir}/lib/dbus \
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH 05/12] volatiles.bbclass: add recipe
  2013-01-24  8:16 ` [PATCH 05/12] volatiles.bbclass: add recipe Qi.Chen
@ 2013-01-24 10:31   ` Martin Jansa
  2013-01-24 11:37     ` Richard Purdie
  0 siblings, 1 reply; 31+ messages in thread
From: Martin Jansa @ 2013-01-24 10:31 UTC (permalink / raw)
  To: Qi.Chen; +Cc: Zhenfeng.Zhao, openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1735 bytes --]

On Thu, Jan 24, 2013 at 04:16:45PM +0800, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
> 
> All recipes that need to tweak their directories need to inherit this
> class and set VOLATILE_DIR, VOLATILE_LINK and VOLATILE_PKGS.
> 
> [YOCTO #3406]
> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>  meta/classes/volatiles.bbclass |   11 +++++++++++
>  1 file changed, 11 insertions(+)
>  create mode 100644 meta/classes/volatiles.bbclass
> 
> diff --git a/meta/classes/volatiles.bbclass b/meta/classes/volatiles.bbclass
> new file mode 100644
> index 0000000..f27e598
> --- /dev/null
> +++ b/meta/classes/volatiles.bbclass
> @@ -0,0 +1,11 @@
> +# This bbclass is for read-only-rootfs support. All recipes that may tweak their
> +# own directories in order to run correctly in a read-only rootfs enviroment
> +# should inherit this class and set VOLATILE_DIR, VOLATILE_LINK, VOLATILE_PKGS.
> +
> +# For each package, the net result is a read-only specific conf file generated
> +# and packaged, which has the name of readonly-${VOLATILESPN}.
> +
> +# All these config files are then parsed by populate-volatile.sh to create proper
> +# directories and links.
> +
> +inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}

Does "inherit " work?

I mean empty inherit when DISTRO_FEATURES don't contain sysvinit? IIRC
it will fail to parse.

Cheers,

> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 205 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 12/12] dbus: inherit volatiles to support read-only rootfs
  2013-01-24  8:16 ` [PATCH 12/12] dbus: " Qi.Chen
@ 2013-01-24 10:45   ` Burton, Ross
  2013-01-25  3:05     ` ChenQi
  0 siblings, 1 reply; 31+ messages in thread
From: Burton, Ross @ 2013-01-24 10:45 UTC (permalink / raw)
  To: Qi.Chen; +Cc: Zhenfeng.Zhao, openembedded-core

On 24 January 2013 08:16,  <Qi.Chen@windriver.com> wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
>
> Inherit volatiles.bbclass to support read-only rootfs.

Please explain why DBus needs volatiles.bbclass to support a readonly
rootfs.  Presumably it's because the machine UUID is written to
/var/lib, are there any other reasons?

Ross



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 05/12] volatiles.bbclass: add recipe
  2013-01-24 10:31   ` Martin Jansa
@ 2013-01-24 11:37     ` Richard Purdie
  2013-01-24 11:45       ` Burton, Ross
  0 siblings, 1 reply; 31+ messages in thread
From: Richard Purdie @ 2013-01-24 11:37 UTC (permalink / raw)
  To: Martin Jansa; +Cc: Zhenfeng.Zhao, openembedded-core

On Thu, 2013-01-24 at 11:31 +0100, Martin Jansa wrote:
> On Thu, Jan 24, 2013 at 04:16:45PM +0800, Qi.Chen@windriver.com wrote:
> > From: Chen Qi <Qi.Chen@windriver.com>
> > 
> > All recipes that need to tweak their directories need to inherit this
> > class and set VOLATILE_DIR, VOLATILE_LINK and VOLATILE_PKGS.
> > 
> > [YOCTO #3406]
> > 
> > Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> > ---
> >  meta/classes/volatiles.bbclass |   11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >  create mode 100644 meta/classes/volatiles.bbclass
> > 
> > diff --git a/meta/classes/volatiles.bbclass b/meta/classes/volatiles.bbclass
> > new file mode 100644
> > index 0000000..f27e598
> > --- /dev/null
> > +++ b/meta/classes/volatiles.bbclass
> > @@ -0,0 +1,11 @@
> > +# This bbclass is for read-only-rootfs support. All recipes that may tweak their
> > +# own directories in order to run correctly in a read-only rootfs enviroment
> > +# should inherit this class and set VOLATILE_DIR, VOLATILE_LINK, VOLATILE_PKGS.
> > +
> > +# For each package, the net result is a read-only specific conf file generated
> > +# and packaged, which has the name of readonly-${VOLATILESPN}.
> > +
> > +# All these config files are then parsed by populate-volatile.sh to create proper
> > +# directories and links.
> > +
> > +inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}
> 
> Does "inherit " work?
> 
> I mean empty inherit when DISTRO_FEATURES don't contain sysvinit? IIRC
> it will fail to parse.

The above syntax does now work. A plain "inherit " won't but something
with an expression in does get handled correctly. It did not used to
work with older bitbake versions.

Cheers,

Richard




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 05/12] volatiles.bbclass: add recipe
  2013-01-24 11:37     ` Richard Purdie
@ 2013-01-24 11:45       ` Burton, Ross
  2013-01-25  8:58         ` ChenQi
  0 siblings, 1 reply; 31+ messages in thread
From: Burton, Ross @ 2013-01-24 11:45 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core, Martin Jansa, Zhenfeng.Zhao

On 24 January 2013 11:37, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>> > +inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}
>>
>> Does "inherit " work?
>>
>> I mean empty inherit when DISTRO_FEATURES don't contain sysvinit? IIRC
>> it will fail to parse.
>
> The above syntax does now work. A plain "inherit " won't but something
> with an expression in does get handled correctly. It did not used to
> work with older bitbake versions.

The syntax works but that expression won't. If sysvinit was backfilled
(pending patch from Marcin) because the distribution didn't pick
sysvinit or systemd explicitly, the backfill happens after this
expression is parsed.

I'm testing a change where these tests happen against
DISTRO_FEATURES_INITMAN instead now.

Ross



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link
  2013-01-24  8:16 ` [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link Qi.Chen
@ 2013-01-24 16:11   ` Mark Hatle
  2013-01-24 17:39   ` Mark Hatle
  1 sibling, 0 replies; 31+ messages in thread
From: Mark Hatle @ 2013-01-24 16:11 UTC (permalink / raw)
  To: openembedded-core

On 1/24/13 2:16 AM, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
>
> Previously, the /tmp link (/tmp -> /var/tmp) was created by the
> bootmisc.sh script. So in case of a read-only rootfs, this symlink
> would not be created correctly.
>
> The populate-volatile.sh script is intended to handle all directories
> and files related to volatile storage, so we should let it create
> the /tmp link.
>
> In addition, because of the improments of populate-volatile.sh, the data
> loss problem of bug#3404 is also resolved by this patch.
>
> [YOCTO #3406]
> [YOCTO #3404]
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>   .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +--------
>   .../initscripts/initscripts-1.0/volatiles          |    1 +
>   2 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index 4f76cb4..3b5a47f 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -54,14 +54,7 @@ fi
>
>   #
>   # This is as good a place as any for a sanity check
> -# /tmp should be a symlink to /var/tmp to cut down on the number
> -# of mounted ramdisks.
> -if test ! -L /tmp && test -d /var/tmp
> -then
> -	rm -rf /tmp
> -	ln -sf /var/tmp /tmp
> -fi
> -

I saw this the other day.  It seems like the wrong solution, if the expectation 
is that all systems want this linked behavior.  Instead the link should be 
configured in the meta/files/fs-perms.txt

Something like:

-/tmp                            01777   root    root    false - - -
+/tmp                            link    /var/tmp

Making that change would avoid this patch, and then all of the filesystems could 
inherit this behavior.  (Other distributions that don't want it can provide 
their own custom fs-perms.txt file, and simply set the older value, which will 
append to the default.)

> +#
>   # Set the system clock from hardware clock
>   # If the timestamp is more recent than the current time,
>   # use the timestamp instead.
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/volatiles b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
> index e0741aa..f7e2ef7 100644
> --- a/meta/recipes-core/initscripts/initscripts-1.0/volatiles
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
> @@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock
>   l root root 0755 /var/log /var/volatile/log
>   l root root 0755 /var/run /var/volatile/run
>   l root root 1777 /var/tmp /var/volatile/tmp
> +l root root 1777 /tmp /var/tmp
>   d root root 0755 /var/lock/subsys none
>   f root root 0664 /var/log/wtmp none
>   f root root 0664 /var/run/utmp none
>




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link
  2013-01-24  8:16 ` [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link Qi.Chen
  2013-01-24 16:11   ` Mark Hatle
@ 2013-01-24 17:39   ` Mark Hatle
  2013-01-25  6:17     ` ChenQi
  1 sibling, 1 reply; 31+ messages in thread
From: Mark Hatle @ 2013-01-24 17:39 UTC (permalink / raw)
  To: openembedded-core

On 1/24/13 2:16 AM, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
>
> Previously, the /tmp link (/tmp -> /var/tmp) was created by the
> bootmisc.sh script. So in case of a read-only rootfs, this symlink
> would not be created correctly.
>
> The populate-volatile.sh script is intended to handle all directories
> and files related to volatile storage, so we should let it create
> the /tmp link.
>
> In addition, because of the improments of populate-volatile.sh, the data
> loss problem of bug#3404 is also resolved by this patch.
>
> [YOCTO #3406]
> [YOCTO #3404]
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>   .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +--------
>   .../initscripts/initscripts-1.0/volatiles          |    1 +
>   2 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index 4f76cb4..3b5a47f 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -54,14 +54,7 @@ fi
>
>   #
>   # This is as good a place as any for a sanity check
> -# /tmp should be a symlink to /var/tmp to cut down on the number
> -# of mounted ramdisks.
> -if test ! -L /tmp && test -d /var/tmp
> -then
> -	rm -rf /tmp
> -	ln -sf /var/tmp /tmp
> -fi
> -

I saw this the other day.  It seems like the wrong solution, if the expectation 
is that all systems want this linked behavior.  Instead the link should be 
configured in the meta/files/fs-perms.txt

Something like:

-/tmp                            01777   root    root    false - - -
+/tmp                            link    /var/tmp

Making that change would avoid this patch, and then all of the filesystems could 
inherit this behavior.  (Other distributions that don't want it can provide 
their own custom fs-perms.txt file, and simply set the older value, which will 
append to the default.)

> +#
>   # Set the system clock from hardware clock
>   # If the timestamp is more recent than the current time,
>   # use the timestamp instead.
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/volatiles b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
> index e0741aa..f7e2ef7 100644
> --- a/meta/recipes-core/initscripts/initscripts-1.0/volatiles
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
> @@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock
>   l root root 0755 /var/log /var/volatile/log
>   l root root 0755 /var/run /var/volatile/run
>   l root root 1777 /var/tmp /var/volatile/tmp
> +l root root 1777 /tmp /var/tmp
>   d root root 0755 /var/lock/subsys none
>   f root root 0664 /var/log/wtmp none
>   f root root 0664 /var/run/utmp none
>




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 02/12] image.bbclass: add a hook funtion to support readonly rootfs
  2013-01-24  8:16 ` [PATCH 02/12] image.bbclass: add a hook funtion to support readonly rootfs Qi.Chen
@ 2013-01-24 19:44   ` Mark Hatle
  2013-01-25  2:49     ` ChenQi
  0 siblings, 1 reply; 31+ messages in thread
From: Mark Hatle @ 2013-01-24 19:44 UTC (permalink / raw)
  To: openembedded-core

On 1/24/13 2:16 AM, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
>
> read_only_rootfs_hook: this funtion is invoked only if 'read-only-rootfs'
> is in IMAGE_FEATURES. It tweaks some basic files and makes populate-
> volatile.sh script run at rootfs time.
>
> For now, it has real effect only if the init system is sysvinit.
>
> [YOCTO #3406]
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>   meta/classes/image.bbclass |   18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 0293d2e..91045fc 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -201,6 +201,24 @@ run_intercept_scriptlets () {
>   	fi
>   }
>
> +# A hook function to support read-only-rootfs IMAGE_FEATURES
> +# Currently, it only supports sysvinit system.
> +read_only_rootfs_hook () {
> +	if ${@base_contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
> +	        # Tweak the mount option in fstab
> +		sed -i '/rootfs/ s/defaults/ro/' ${IMAGE_ROOTFS}/etc/fstab

There is a slight bug in the above.  Not all configurations will contain an 
/etc/fstab!  So you need to check for the existence of the file before you try 
to sed it.

(Initramfs is where I hit a problem trying to test this.)

--Mark

> +	        # Change the value of ROOTFS_READ_ONLY in /etc/default/rcS to yes
> +		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 [ -e ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
> +			${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
> +		fi
> +	fi
> +}
> +
>   fakeroot do_rootfs () {
>   	#set -x
>   	# When use the rpm incremental image generation, don't remove the rootfs
>




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 02/12] image.bbclass: add a hook funtion to support readonly rootfs
  2013-01-24 19:44   ` Mark Hatle
@ 2013-01-25  2:49     ` ChenQi
  0 siblings, 0 replies; 31+ messages in thread
From: ChenQi @ 2013-01-25  2:49 UTC (permalink / raw)
  To: openembedded-core

On 01/25/2013 03:44 AM, Mark Hatle wrote:
> On 1/24/13 2:16 AM, Qi.Chen@windriver.com wrote:
>> From: Chen Qi <Qi.Chen@windriver.com>
>>
>> read_only_rootfs_hook: this funtion is invoked only if 
>> 'read-only-rootfs'
>> is in IMAGE_FEATURES. It tweaks some basic files and makes populate-
>> volatile.sh script run at rootfs time.
>>
>> For now, it has real effect only if the init system is sysvinit.
>>
>> [YOCTO #3406]
>>
>> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
>> ---
>>   meta/classes/image.bbclass |   18 ++++++++++++++++++
>>   1 file changed, 18 insertions(+)
>>
>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>> index 0293d2e..91045fc 100644
>> --- a/meta/classes/image.bbclass
>> +++ b/meta/classes/image.bbclass
>> @@ -201,6 +201,24 @@ run_intercept_scriptlets () {
>>       fi
>>   }
>>
>> +# A hook function to support read-only-rootfs IMAGE_FEATURES
>> +# Currently, it only supports sysvinit system.
>> +read_only_rootfs_hook () {
>> +    if ${@base_contains("DISTRO_FEATURES", "sysvinit", "true", 
>> "false", d)}; then
>> +            # Tweak the mount option in fstab
>> +        sed -i '/rootfs/ s/defaults/ro/' ${IMAGE_ROOTFS}/etc/fstab
>
> There is a slight bug in the above.  Not all configurations will 
> contain an /etc/fstab!  So you need to check for the existence of the 
> file before you try to sed it.
>
> (Initramfs is where I hit a problem trying to test this.)
>
> --Mark
>

Thank you for pointing it out. I'll fix it.

Thanks,
Chen Qi

>> +            # Change the value of ROOTFS_READ_ONLY in 
>> /etc/default/rcS to yes
>> +        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 [ -e ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
>> +            ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
>> +        fi
>> +    fi
>> +}
>> +
>>   fakeroot do_rootfs () {
>>       #set -x
>>       # When use the rpm incremental image generation, don't remove 
>> the rootfs
>>
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
>




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 12/12] dbus: inherit volatiles to support read-only rootfs
  2013-01-24 10:45   ` Burton, Ross
@ 2013-01-25  3:05     ` ChenQi
  2013-01-25 13:02       ` Burton, Ross
  0 siblings, 1 reply; 31+ messages in thread
From: ChenQi @ 2013-01-25  3:05 UTC (permalink / raw)
  To: Burton, Ross; +Cc: Zhenfeng.Zhao, openembedded-core

On 01/24/2013 06:45 PM, Burton, Ross wrote:
> On 24 January 2013 08:16,  <Qi.Chen@windriver.com> wrote:
>> From: Chen Qi <Qi.Chen@windriver.com>
>>
>> Inherit volatiles.bbclass to support read-only rootfs.
> Please explain why DBus needs volatiles.bbclass to support a readonly
> rootfs.  Presumably it's because the machine UUID is written to
> /var/lib, are there any other reasons?
>
> Ross
>
>
I added this patch because I encountered an error when starting the sato 
image.
That is, the machine UUID needs to be written to /var/lib.

I'm not familiar with dbus. Is it not necessary?

Thanks,
Chen Qi



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link
  2013-01-24 17:39   ` Mark Hatle
@ 2013-01-25  6:17     ` ChenQi
  0 siblings, 0 replies; 31+ messages in thread
From: ChenQi @ 2013-01-25  6:17 UTC (permalink / raw)
  To: openembedded-core

On 01/25/2013 01:39 AM, Mark Hatle wrote:
> On 1/24/13 2:16 AM, Qi.Chen@windriver.com wrote:
>> From: Chen Qi <Qi.Chen@windriver.com>
>>
>> Previously, the /tmp link (/tmp -> /var/tmp) was created by the
>> bootmisc.sh script. So in case of a read-only rootfs, this symlink
>> would not be created correctly.
>>
>> The populate-volatile.sh script is intended to handle all directories
>> and files related to volatile storage, so we should let it create
>> the /tmp link.
>>
>> In addition, because of the improments of populate-volatile.sh, the data
>> loss problem of bug#3404 is also resolved by this patch.
>>
>> [YOCTO #3406]
>> [YOCTO #3404]
>>
>> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
>> ---
>>   .../initscripts/initscripts-1.0/bootmisc.sh        |    9 +--------
>>   .../initscripts/initscripts-1.0/volatiles          |    1 +
>>   2 files changed, 2 insertions(+), 8 deletions(-)
>>
>> diff --git 
>> a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh 
>> b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
>> index 4f76cb4..3b5a47f 100755
>> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
>> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
>> @@ -54,14 +54,7 @@ fi
>>
>>   #
>>   # This is as good a place as any for a sanity check
>> -# /tmp should be a symlink to /var/tmp to cut down on the number
>> -# of mounted ramdisks.
>> -if test ! -L /tmp && test -d /var/tmp
>> -then
>> -    rm -rf /tmp
>> -    ln -sf /var/tmp /tmp
>> -fi
>> -
>
> I saw this the other day.  It seems like the wrong solution, if the 
> expectation is that all systems want this linked behavior. Instead the 
> link should be configured in the meta/files/fs-perms.txt
>
> Something like:
>
> -/tmp                            01777   root    root    false - - -
> +/tmp                            link    /var/tmp
>
> Making that change would avoid this patch, and then all of the 
> filesystems could inherit this behavior.  (Other distributions that 
> don't want it can provide their own custom fs-perms.txt file, and 
> simply set the older value, which will append to the default.)
>

Thank you for your careful review :)

Here's a little more explanation on this patch. (Correct me if I'm wrong 
somewhere.)

No matter we're going to change the fs-perms.txt file or not, this patch 
is needed for things to work correctly. The populate-volatile.sh in 
sysvinit scripts, together with its configuration files, are a final 
means to ensure the directories, files and links related to volatile 
storage are created correctly.

There are link config items in fs-perms.txt.
${localstatedir}/cache    link    volatile/cache
${localstatedir}/run    link    volatile/run
${localstatedir}/log    link    volatile/log
${localstatedir}/lock    link    volatile/lock
${localstatedir}/tmp    link    volatile/tmp
There configurations are great and very reasonable, because they are 
common for different init systems.

But I'm not very sure about this link config item -- "/tmp link    
/var/tmp "

I want to restrict the creation of this link (/tmp -> /var/tmp) in the 
sysvinit scripts, because in this way, it doesn't affect other init 
systems such as systemd. The same strategy goes with the /run directory.

Here's the output from the mount command from a systemd-based 
core-image-minimal image:
root@qemux86:~# mount | grep tmpfs
devtmpfs on /dev type devtmpfs 
(rw,relatime,size=59032k,nr_inodes=14758,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755)
tmpfs on /tmp type tmpfs (rw)
tmpfs on /var/volatile type tmpfs (rw,relatime)
tmpfs on /media/ram type tmpfs (rw,relatime)

Here's the output form the mount command from a sysv-based 
core-image-minimal image:
root@qemux86:~# mount | grep tmpfs
devtmpfs on /dev type devtmpfs 
(rw,relatime,size=59032k,nr_inodes=14758,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
tmpfs on /media/ram type tmpfs (rw,relatime)

Best Regards,
Chen Qi

>> +#
>>   # Set the system clock from hardware clock
>>   # If the timestamp is more recent than the current time,
>>   # use the timestamp instead.
>> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/volatiles 
>> b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
>> index e0741aa..f7e2ef7 100644
>> --- a/meta/recipes-core/initscripts/initscripts-1.0/volatiles
>> +++ b/meta/recipes-core/initscripts/initscripts-1.0/volatiles
>> @@ -31,6 +31,7 @@ l root root 1777 /var/lock /var/volatile/lock
>>   l root root 0755 /var/log /var/volatile/log
>>   l root root 0755 /var/run /var/volatile/run
>>   l root root 1777 /var/tmp /var/volatile/tmp
>> +l root root 1777 /tmp /var/tmp
>>   d root root 0755 /var/lock/subsys none
>>   f root root 0664 /var/log/wtmp none
>>   f root root 0664 /var/run/utmp none
>>
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
>




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 05/12] volatiles.bbclass: add recipe
  2013-01-24 11:45       ` Burton, Ross
@ 2013-01-25  8:58         ` ChenQi
  2013-01-25 14:05           ` Burton, Ross
  0 siblings, 1 reply; 31+ messages in thread
From: ChenQi @ 2013-01-25  8:58 UTC (permalink / raw)
  To: openembedded-core

On 01/24/2013 07:45 PM, Burton, Ross wrote:
> On 24 January 2013 11:37, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
>>>> +inherit ${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}
>>> Does "inherit " work?
>>>
>>> I mean empty inherit when DISTRO_FEATURES don't contain sysvinit? IIRC
>>> it will fail to parse.
>> The above syntax does now work. A plain "inherit " won't but something
>> with an expression in does get handled correctly. It did not used to
>> work with older bitbake versions.
> The syntax works but that expression won't. If sysvinit was backfilled
> (pending patch from Marcin) because the distribution didn't pick
> sysvinit or systemd explicitly, the backfill happens after this
> expression is parsed.
>
> I'm testing a change where these tests happen against
> DISTRO_FEATURES_INITMAN instead now.
>
> Ross
>
> _

It seems that the backfill happens *before* this expression is parsed.

I tested it with DISTRO_FEATURES explicitly set in local.conf (basically 
the default value, except that it contains no init manager). It worked 
out well.

#
DISTRO ?= "poky"
DISTRO_FEATURES_LIBC_DEFAULT = "ipv4 ipv6 libc-backtrace libc-big-macros 
libc-bsd libc-cxx-tests libc-catgets libc-charsets libc-crypt \
                     libc-crypt-ufc libc-db-aliases libc-envz libc-fcvt 
libc-fmtmsg libc-fstab libc-ftraverse \
                     libc-getlogin libc-idn libc-inet-anl libc-libm 
libc-libm-big libc-locales libc-locale-code \
                     libc-memusage libc-nis libc-nsswitch libc-rcmd 
libc-rtld-debug libc-spawn libc-streams libc-sunrpc \
                     libc-utmp libc-utmpx libc-wordexp 
libc-posix-clang-wchar libc-posix-regexp libc-posix-regexp-glibc \
                     libc-posix-wchar-io"
DISTRO_FEATURES_LIBC = "${DISTRO_FEATURES_LIBC_DEFAULT}"
DISTRO_FEATURES_LIBC_class-nativesdk = "${DISTRO_FEATURES_LIBC_DEFAULT}"
DISTRO_FEATURES = "alsa argp bluetooth ext2 irda largefile pcmcia 
usbgadget usbhost wifi xattr nfs zeroconf pci 3g x11 
${DISTRO_FEATURES_LIBC}"


I also added the following lines to volatiles.bbclass to examine the 
DISTRO_FEATURES when parsing the volatiles.bbclass.

+python __anonymous() {
+    bb.error("DISTRO_FEATURES: %s" % d.getVar('DISTRO_FEATURES', True))
+}
+
  inherit 
${@base_contains('DISTRO_FEATURES','sysvinit','volatiles_sysvinit','',d)}

And the DISTRO_FEATURES contains 'sysvinit'.

ERROR: DISTRO_FEATURES: alsa argp bluetooth ext2 irda largefile pcmcia 
usbgadget usbhost wifi xattr nfs zeroconf pci 3g x11 ipv4 ipv6 
libc-backtrace libc-big-macros libc-bsd libc-cxx-tests libc-catgets 
libc-charsets libc-crypt libc-crypt-ufc libc-db-aliases libc-envz 
libc-fcvt libc-fmtmsg libc-fstab libc-ftraverse libc-getlogin libc-idn 
libc-inet-anl libc-libm libc-libm-big libc-locales libc-locale-code 
libc-memusage libc-nis libc-nsswitch libc-rcmd libc-rtld-debug 
libc-spawn libc-streams libc-sunrpc libc-utmp libc-utmpx libc-wordexp 
libc-posix-clang-wchar libc-posix-regexp libc-posix-regexp-glibc 
libc-posix-wchar-io pulseaudio sysvinit largefile opengl multiarch

Best Regards,
Chen Qi

> ______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
>




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 12/12] dbus: inherit volatiles to support read-only rootfs
  2013-01-25  3:05     ` ChenQi
@ 2013-01-25 13:02       ` Burton, Ross
  0 siblings, 0 replies; 31+ messages in thread
From: Burton, Ross @ 2013-01-25 13:02 UTC (permalink / raw)
  To: ChenQi; +Cc: Zhenfeng.Zhao, openembedded-core

On 25 January 2013 03:05, ChenQi <Qi.Chen@windriver.com> wrote:
> I added this patch because I encountered an error when starting the sato
> image.
> That is, the machine UUID needs to be written to /var/lib.
>
> I'm not familiar with dbus. Is it not necessary?

The file is necessary and needs to be persistent for at least the
lifetime of a boot, so generating it on dbus startup and writing to a
tmpfs is fine.

My point was that the commit doesn't say *why* it does what it does.

Ross



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs
  2013-01-24  8:16 ` [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs Qi.Chen
@ 2013-01-25 13:11   ` Burton, Ross
  2013-01-25 14:14     ` Richard Purdie
  2013-01-28  1:45     ` ChenQi
  0 siblings, 2 replies; 31+ messages in thread
From: Burton, Ross @ 2013-01-25 13:11 UTC (permalink / raw)
  To: Qi.Chen; +Cc: Zhenfeng.Zhao, openembedded-core

On 24 January 2013 08:16,  <Qi.Chen@windriver.com> wrote:
> +VOLATILE_DIR = "/var/volatile/lib/urandom"
> +VOLATILE_LINK = "/var/lib/urandom"

A better solution would be to not attempt to save and restore a seed
value that is intended to persist across reboots when it's on a tmpfs.
 Putting the urandom seed into tmpfs is just a waste of time.

Ross



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 05/12] volatiles.bbclass: add recipe
  2013-01-25  8:58         ` ChenQi
@ 2013-01-25 14:05           ` Burton, Ross
  2013-01-28  3:32             ` ChenQi
  0 siblings, 1 reply; 31+ messages in thread
From: Burton, Ross @ 2013-01-25 14:05 UTC (permalink / raw)
  To: ChenQi; +Cc: openembedded-core

On 25 January 2013 08:58, ChenQi <Qi.Chen@windriver.com> wrote:
> It seems that the backfill happens *before* this expression is parsed.

Yes, because of these two patches that I reviewed and submitted yesterday:

commit 4db8a3daafdedf39e081f4f6130f6cdcde03ed62
Author: Richard Purdie <richard.purdie@linuxfoundation.org>
Date:   Thu Jan 24 17:52:56 2013 +0000

    base: make feature backfilling happen earlier

commit c98363450fc4ccab82b34a37a95bd172cf6e115f
Author: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Date:   Thu Jan 24 17:52:55 2013 +0000

    bitbake.conf: unbreak all builds with custom DISTRO_FEATURES

Ross



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs
  2013-01-25 13:11   ` Burton, Ross
@ 2013-01-25 14:14     ` Richard Purdie
  2013-01-28  2:11       ` ChenQi
  2013-01-28  1:45     ` ChenQi
  1 sibling, 1 reply; 31+ messages in thread
From: Richard Purdie @ 2013-01-25 14:14 UTC (permalink / raw)
  To: Burton, Ross; +Cc: Zhenfeng.Zhao, openembedded-core

On Fri, 2013-01-25 at 13:11 +0000, Burton, Ross wrote:
> On 24 January 2013 08:16,  <Qi.Chen@windriver.com> wrote:
> > +VOLATILE_DIR = "/var/volatile/lib/urandom"
> > +VOLATILE_LINK = "/var/lib/urandom"
> 
> A better solution would be to not attempt to save and restore a seed
> value that is intended to persist across reboots when it's on a tmpfs.
>  Putting the urandom seed into tmpfs is just a waste of time.

I have to wonder why we don't put a union mount tmpfs over /var/lib to
be honest...

or if we don't want to depend on unionfs, a tmpfs over /var/lib...

Cheers,

Richard




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs
  2013-01-25 13:11   ` Burton, Ross
  2013-01-25 14:14     ` Richard Purdie
@ 2013-01-28  1:45     ` ChenQi
  1 sibling, 0 replies; 31+ messages in thread
From: ChenQi @ 2013-01-28  1:45 UTC (permalink / raw)
  To: Burton, Ross; +Cc: Zhenfeng.Zhao, openembedded-core

On 01/25/2013 09:11 PM, Burton, Ross wrote:
> On 24 January 2013 08:16,  <Qi.Chen@windriver.com> wrote:
>> +VOLATILE_DIR = "/var/volatile/lib/urandom"
>> +VOLATILE_LINK = "/var/lib/urandom"
> A better solution would be to not attempt to save and restore a seed
> value that is intended to persist across reboots when it's on a tmpfs.
>   Putting the urandom seed into tmpfs is just a waste of time.
>
> Ross
>
>
I agree.

I'll just remove this patch.

Thanks,
Chen Qi



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs
  2013-01-25 14:14     ` Richard Purdie
@ 2013-01-28  2:11       ` ChenQi
  0 siblings, 0 replies; 31+ messages in thread
From: ChenQi @ 2013-01-28  2:11 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core, Zhenfeng.Zhao

On 01/25/2013 10:14 PM, Richard Purdie wrote:
> On Fri, 2013-01-25 at 13:11 +0000, Burton, Ross wrote:
>> On 24 January 2013 08:16,  <Qi.Chen@windriver.com> wrote:
>>> +VOLATILE_DIR = "/var/volatile/lib/urandom"
>>> +VOLATILE_LINK = "/var/lib/urandom"
>> A better solution would be to not attempt to save and restore a seed
>> value that is intended to persist across reboots when it's on a tmpfs.
>>   Putting the urandom seed into tmpfs is just a waste of time.
> I have to wonder why we don't put a union mount tmpfs over /var/lib to
> be honest...
>
> or if we don't want to depend on unionfs, a tmpfs over /var/lib...
>
> Cheers,
>
> Richard
>
>
>
A union mount tmpfs over /var/lib (and maybe /etc) was the first 
solution that came into my mind. Then I saw a bug related to unionfs 
about getcwd() call, and I saw the unionfs was still disabled for live 
images. So I thought "maybe I should not use unionfs".

A tmpfs over /var/lib.
Hmm... I thought about that too. The reason that I didn't use this 
method was that I thought that some directories under /etc might also 
need to be written to.
It turns out that this concern seems unnecessary.

Anyway, I'll try out the tmpfs-over-var-lib method and let you know the 
result.

Thanks,
Chen Qi



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 05/12] volatiles.bbclass: add recipe
  2013-01-25 14:05           ` Burton, Ross
@ 2013-01-28  3:32             ` ChenQi
  0 siblings, 0 replies; 31+ messages in thread
From: ChenQi @ 2013-01-28  3:32 UTC (permalink / raw)
  To: Burton, Ross; +Cc: openembedded-core

On 01/25/2013 10:05 PM, Burton, Ross wrote:
> On 25 January 2013 08:58, ChenQi <Qi.Chen@windriver.com> wrote:
>> It seems that the backfill happens *before* this expression is parsed.
> Yes, because of these two patches that I reviewed and submitted yesterday:
>
> commit 4db8a3daafdedf39e081f4f6130f6cdcde03ed62
> Author: Richard Purdie <richard.purdie@linuxfoundation.org>
> Date:   Thu Jan 24 17:52:56 2013 +0000
>
>      base: make feature backfilling happen earlier
>
> commit c98363450fc4ccab82b34a37a95bd172cf6e115f
> Author: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
> Date:   Thu Jan 24 17:52:55 2013 +0000
>
>      bitbake.conf: unbreak all builds with custom DISTRO_FEATURES
>
> Ross
>
>
Ah... Yes.

Thanks for making things clear for me :)

Best Regards,
Chen Qi




^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2013-01-28  3:47 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-24  8:16 [PATCH 00/12] read-only rootfs support Qi.Chen
2013-01-24  8:16 ` [PATCH 01/12] sysvinit: add ROOTFS_READ_ONLY variable to rcS-default Qi.Chen
2013-01-24  8:16 ` [PATCH 02/12] image.bbclass: add a hook funtion to support readonly rootfs Qi.Chen
2013-01-24 19:44   ` Mark Hatle
2013-01-25  2:49     ` ChenQi
2013-01-24  8:16 ` [PATCH 03/12] core-image.bbclass: support read-only rootfs Qi.Chen
2013-01-24  8:16 ` [PATCH 04/12] package.bbclass: add VOLATILE_DIR and VOLATILE_LINK to PACKAGEVARS Qi.Chen
2013-01-24  8:16 ` [PATCH 05/12] volatiles.bbclass: add recipe Qi.Chen
2013-01-24 10:31   ` Martin Jansa
2013-01-24 11:37     ` Richard Purdie
2013-01-24 11:45       ` Burton, Ross
2013-01-25  8:58         ` ChenQi
2013-01-25 14:05           ` Burton, Ross
2013-01-28  3:32             ` ChenQi
2013-01-24  8:16 ` [PATCH 06/12] volatiles_sysvinit.bbclass: " Qi.Chen
2013-01-24  8:16 ` [PATCH 07/12] populate-volatile.sh: improve this script Qi.Chen
2013-01-24  8:16 ` [PATCH 08/12] initscripts: let populate-volatile.sh create the /tmp link Qi.Chen
2013-01-24 16:11   ` Mark Hatle
2013-01-24 17:39   ` Mark Hatle
2013-01-25  6:17     ` ChenQi
2013-01-24  8:16 ` [PATCH 09/12] initscripts: inherit volatiles to support read-only rootfs Qi.Chen
2013-01-25 13:11   ` Burton, Ross
2013-01-25 14:14     ` Richard Purdie
2013-01-28  2:11       ` ChenQi
2013-01-28  1:45     ` ChenQi
2013-01-24  8:16 ` [PATCH 10/12] dropbear: " Qi.Chen
2013-01-24  8:16 ` [PATCH 11/12] nfs-utils: " Qi.Chen
2013-01-24  8:16 ` [PATCH 12/12] dbus: " Qi.Chen
2013-01-24 10:45   ` Burton, Ross
2013-01-25  3:05     ` ChenQi
2013-01-25 13:02       ` Burton, Ross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox