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\ |
| 20 | " |
| 21 | VOLATILE_BINDS[type] = "list" |
| 22 | VOLATILE_BINDS[separator] = "\n" |
| 23 | |
| 24 | def 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 | |
| 33 | SYSTEMD_SERVICE_${PN} = "${@volatile_systemd_services(d)}" |
| 34 | |
| 35 | FILES_${PN} += "${systemd_unitdir}/system/*.service" |
| 36 | |
| 37 | do_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")} |
| 50 | END |
| 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 | } |
| 60 | do_compile[dirs] = "${WORKDIR}" |
| 61 | |
| 62 | do_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 | } |
| 71 | do_install[dirs] = "${WORKDIR}" |