blob: fee7275e32d22ef25beca74b39acef53db4b2f67 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Volatile bind mount setup and configuration for read-only-rootfs"
2DESCRIPTION = "${SUMMARY}"
3LICENSE = "MIT"
4LIC_FILES_CHKSUM = "file://COPYING.MIT;md5=5750f3aa4ea2b00c2bf21b2b2a7b714d"
5
6SRC_URI = "\
7 file://mount-copybind \
8 file://COPYING.MIT \
9 file://volatile-binds.service.in \
10"
11
12S = "${WORKDIR}"
13
14inherit allarch systemd distro_features_check
15
16REQUIRED_DISTRO_FEATURES = "systemd"
17
18VOLATILE_BINDS ?= "\
19 /var/volatile/lib /var/lib\n\
20"
21VOLATILE_BINDS[type] = "list"
22VOLATILE_BINDS[separator] = "\n"
23
24def volatile_systemd_services(d):
25 services = []
26 for line in oe.data.typed_value("VOLATILE_BINDS", d):
27 if not line:
28 continue
29 what, where = line.split(None, 1)
30 services.append("%s.service" % what[1:].replace("/", "-"))
31 return " ".join(services)
32
33SYSTEMD_SERVICE_${PN} = "${@volatile_systemd_services(d)}"
34
35FILES_${PN} += "${systemd_unitdir}/system/*.service"
36
37do_compile () {
38 while read spec mountpoint; do
39 if [ -z "$spec" ]; then
40 continue
41 fi
42
43 servicefile="${spec#/}"
44 servicefile="$(echo "$servicefile" | tr / -).service"
45 sed -e "s#@what@#$spec#g; s#@where@#$mountpoint#g" \
46 -e "s#@whatparent@#${spec%/*}#g; s#@whereparent@#${mountpoint%/*}#g" \
47 volatile-binds.service.in >$servicefile
48 done <<END
49${@d.getVar('VOLATILE_BINDS', True).replace("\\n", "\n")}
50END
51
52 if [ -e var-volatile-lib.service ]; then
53 # As the seed is stored under /var/lib, ensure that this service runs
54 # after the volatile /var/lib is mounted.
55 sed -i -e "/^Before=/s/\$/ systemd-random-seed.service/" \
56 -e "/^WantedBy=/s/\$/ systemd-random-seed.service/" \
57 var-volatile-lib.service
58 fi
59}
60do_compile[dirs] = "${WORKDIR}"
61
62do_install () {
63 install -d ${D}${base_sbindir}
64 install -m 0755 mount-copybind ${D}${base_sbindir}/
65
66 install -d ${D}${systemd_unitdir}/system
67 for service in ${SYSTEMD_SERVICE_volatile-binds}; do
68 install -m 0644 $service ${D}${systemd_unitdir}/system/
69 done
70}
71do_install[dirs] = "${WORKDIR}"