blob: b273293e9a8d85d7748e18c300d87c5ea8de0e1a [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
Brad Bishop6dbb3162019-11-25 09:41:34 -050014inherit allarch systemd features_check
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015
16REQUIRED_DISTRO_FEATURES = "systemd"
17
18VOLATILE_BINDS ?= "\
19 /var/volatile/lib /var/lib\n\
Brad Bishop37a0e4d2017-12-04 01:01:44 -050020 /var/volatile/cache /var/cache\n\
21 /var/volatile/spool /var/spool\n\
22 /var/volatile/srv /srv\n\
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023"
24VOLATILE_BINDS[type] = "list"
25VOLATILE_BINDS[separator] = "\n"
26
27def volatile_systemd_services(d):
28 services = []
29 for line in oe.data.typed_value("VOLATILE_BINDS", d):
30 if not line:
31 continue
32 what, where = line.split(None, 1)
33 services.append("%s.service" % what[1:].replace("/", "-"))
34 return " ".join(services)
35
36SYSTEMD_SERVICE_${PN} = "${@volatile_systemd_services(d)}"
37
38FILES_${PN} += "${systemd_unitdir}/system/*.service"
39
40do_compile () {
41 while read spec mountpoint; do
42 if [ -z "$spec" ]; then
43 continue
44 fi
45
46 servicefile="${spec#/}"
47 servicefile="$(echo "$servicefile" | tr / -).service"
48 sed -e "s#@what@#$spec#g; s#@where@#$mountpoint#g" \
49 -e "s#@whatparent@#${spec%/*}#g; s#@whereparent@#${mountpoint%/*}#g" \
50 volatile-binds.service.in >$servicefile
51 done <<END
Brad Bishop6e60e8b2018-02-01 10:27:11 -050052${@d.getVar('VOLATILE_BINDS').replace("\\n", "\n")}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050053END
54
55 if [ -e var-volatile-lib.service ]; then
56 # As the seed is stored under /var/lib, ensure that this service runs
57 # after the volatile /var/lib is mounted.
58 sed -i -e "/^Before=/s/\$/ systemd-random-seed.service/" \
59 -e "/^WantedBy=/s/\$/ systemd-random-seed.service/" \
60 var-volatile-lib.service
61 fi
62}
63do_compile[dirs] = "${WORKDIR}"
64
65do_install () {
66 install -d ${D}${base_sbindir}
67 install -m 0755 mount-copybind ${D}${base_sbindir}/
68
69 install -d ${D}${systemd_unitdir}/system
Brad Bishop316dfdd2018-06-25 12:45:53 -040070 for service in ${SYSTEMD_SERVICE_${PN}}; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 install -m 0644 $service ${D}${systemd_unitdir}/system/
72 done
Brad Bishop37a0e4d2017-12-04 01:01:44 -050073
74 # Suppress attempts to process some tmpfiles that are not temporary.
75 #
76 install -d ${D}${sysconfdir}/tmpfiles.d ${D}/var/cache
77 ln -s /dev/null ${D}${sysconfdir}/tmpfiles.d/etc.conf
78 ln -s /dev/null ${D}${sysconfdir}/tmpfiles.d/home.conf
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079}
80do_install[dirs] = "${WORKDIR}"