[OE-core] [PATCH 06/12] volatiles_sysvinit.bbclass: add recipe

Qi.Chen at windriver.com Qi.Chen at windriver.com
Thu Jan 24 08:16:46 UTC 2013


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

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

[YOCTO #3406]

Signed-off-by: Chen Qi <Qi.Chen at 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





More information about the Openembedded-core mailing list