Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Volatile bind mount setup and configuration for read-only-rootfs" |
| 2 | DESCRIPTION = "${SUMMARY}" |
| 3 | LICENSE = "MIT" |
| 4 | LIC_FILES_CHKSUM = "file://COPYING.MIT;md5=5750f3aa4ea2b00c2bf21b2b2a7b714d" |
| 5 | |
| 6 | SRC_URI = "\ |
| 7 | file://mount-copybind \ |
| 8 | file://COPYING.MIT \ |
| 9 | file://volatile-binds.service.in \ |
| 10 | " |
| 11 | |
| 12 | S = "${WORKDIR}" |
| 13 | |
| 14 | inherit allarch systemd distro_features_check |
| 15 | |
| 16 | REQUIRED_DISTRO_FEATURES = "systemd" |
| 17 | |
| 18 | VOLATILE_BINDS ?= "\ |
| 19 | /var/volatile/lib /var/lib\n\ |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame^] | 20 | /var/volatile/cache /var/cache\n\ |
| 21 | /var/volatile/spool /var/spool\n\ |
| 22 | /var/volatile/srv /srv\n\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | " |
| 24 | VOLATILE_BINDS[type] = "list" |
| 25 | VOLATILE_BINDS[separator] = "\n" |
| 26 | |
| 27 | def 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 | |
| 36 | SYSTEMD_SERVICE_${PN} = "${@volatile_systemd_services(d)}" |
| 37 | |
| 38 | FILES_${PN} += "${systemd_unitdir}/system/*.service" |
| 39 | |
| 40 | do_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 |
| 52 | ${@d.getVar('VOLATILE_BINDS', True).replace("\\n", "\n")} |
| 53 | END |
| 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 | } |
| 63 | do_compile[dirs] = "${WORKDIR}" |
| 64 | |
| 65 | do_install () { |
| 66 | install -d ${D}${base_sbindir} |
| 67 | install -m 0755 mount-copybind ${D}${base_sbindir}/ |
| 68 | |
| 69 | install -d ${D}${systemd_unitdir}/system |
| 70 | for service in ${SYSTEMD_SERVICE_volatile-binds}; do |
| 71 | install -m 0644 $service ${D}${systemd_unitdir}/system/ |
| 72 | done |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame^] | 73 | |
| 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | } |
| 80 | do_install[dirs] = "${WORKDIR}" |