Patchwork [06/12] volatiles_sysvinit.bbclass: add recipe

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date Jan. 24, 2013, 8:16 a.m.
Message ID <989ba4f0ead8f84824d4e5822f9b2f58941d73a3.1359014474.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/43259/
State New
Headers show

Comments

Qi.Chen@windriver.com - Jan. 24, 2013, 8:16 a.m.
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

Patch

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)
+}