aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/volatile-binds/volatile-binds.bb
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2014-07-23 05:40:12 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-02 09:21:14 +0100
commited7d30dc0cdb6d6c56c50ac7a3440c4ed0ee70d3 (patch)
treeb881104637a06cddac4fa62e6e9ef9f2873ea094 /meta/recipes-core/volatile-binds/volatile-binds.bb
parentb0ac481dda99d8f4be8015964fcb2cb01afce08c (diff)
downloadopenembedded-core-contrib-ed7d30dc0cdb6d6c56c50ac7a3440c4ed0ee70d3.tar.gz
volatile-binds: add recipe
This recipe is designed to play a key role in a read-only rootfs of systemd based systems. It generates service files from a template, volatile-binds.service.in and the VOLATILE_BINDS variable. By default, VOLATILE_BINDS takes the value of "/var/volatile/lib /var/lib\n", which leads to the generation of volatile-var-lib.service file. This file doesn't have any effect in a read-write system, as it has "ConditionPathIsReadWrite = !/var/lib" in the [Unit] section. In other words, this file only has effect in a read-only rootfs. Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'meta/recipes-core/volatile-binds/volatile-binds.bb')
-rw-r--r--meta/recipes-core/volatile-binds/volatile-binds.bb69
1 files changed, 69 insertions, 0 deletions
diff --git a/meta/recipes-core/volatile-binds/volatile-binds.bb b/meta/recipes-core/volatile-binds/volatile-binds.bb
new file mode 100644
index 0000000000..4080ff7ef2
--- /dev/null
+++ b/meta/recipes-core/volatile-binds/volatile-binds.bb
@@ -0,0 +1,69 @@
+SUMMARY = "Volatile bind mount setup and configuration for read-only-rootfs"
+DESCRIPTION = "${SUMMARY}"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://../COPYING.MIT;md5=5750f3aa4ea2b00c2bf21b2b2a7b714d"
+
+SRC_URI = "\
+ file://mount-copybind \
+ file://COPYING.MIT \
+ file://volatile-binds.service.in \
+"
+
+inherit allarch systemd distro_features_check
+
+REQUIRED_DISTRO_FEATURES = "systemd"
+
+VOLATILE_BINDS ?= "\
+ /var/volatile/lib /var/lib\n\
+"
+VOLATILE_BINDS[type] = "list"
+VOLATILE_BINDS[separator] = "\n"
+
+def volatile_systemd_services(d):
+ services = []
+ for line in oe.data.typed_value("VOLATILE_BINDS", d):
+ if not line:
+ continue
+ what, where = line.split(None, 1)
+ services.append("%s.service" % what[1:].replace("/", "-"))
+ return " ".join(services)
+
+SYSTEMD_SERVICE_volatile-binds = "${@volatile_systemd_services(d)}"
+
+FILES_${PN} += "${systemd_unitdir}/system/*.service"
+
+do_compile () {
+ while read spec mountpoint; do
+ if [ -z "$spec" ]; then
+ continue
+ fi
+
+ servicefile="${spec#/}"
+ servicefile="$(echo "$servicefile" | tr / -).service"
+ sed -e "s#@what@#$spec#g; s#@where@#$mountpoint#g" \
+ -e "s#@whatparent@#${spec%/*}#g; s#@whereparent@#${mountpoint%/*}#g" \
+ volatile-binds.service.in >$servicefile
+ done <<END
+${@d.getVar('VOLATILE_BINDS', True).replace("\\n", "\n")}
+END
+
+ if [ -e var-volatile-lib.service ]; then
+ # As the seed is stored under /var/lib, ensure that this service runs
+ # after the volatile /var/lib is mounted.
+ sed -i -e "/^Before=/s/\$/ systemd-random-seed.service/" \
+ -e "/^WantedBy=/s/\$/ systemd-random-seed.service/" \
+ var-volatile-lib.service
+ fi
+}
+do_compile[dirs] = "${WORKDIR}"
+
+do_install () {
+ install -d ${D}${base_sbindir}
+ install -m 0755 mount-copybind ${D}${base_sbindir}/
+
+ install -d ${D}${systemd_unitdir}/system
+ for service in ${SYSTEMD_SERVICE_volatile-binds}; do
+ install -m 0644 $service ${D}${systemd_unitdir}/system/
+ done
+}
+do_install[dirs] = "${WORKDIR}"