]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
systemd: fix systemd-udev-hwdb-update service ChenQi/systemd-udev-hwdb-update
authorChen Qi <Qi.Chen@windriver.com>
Fri, 24 Oct 2014 03:12:21 +0000 (11:12 +0800)
committerChen Qi <Qi.Chen@windriver.com>
Fri, 24 Oct 2014 03:24:08 +0000 (11:24 +0800)
The new version of systemd has implemented the following feature.
Opointer.de/blog/projects/stateless.html

As a result, the systemd-udev-hwdb-update.service would always run
at first boot. This will cause failure if the target device doesn't
have enough storage space. Besides, as we run `udevadm hwdb --update' as
a postinst of udev-hwdb at rootfs time, there's no need to run this
again at system start-up.

The purpose of this patch is as follows.
If `udev hwdb --update' fails at rootfs time, systemd-udev-hwdb-update.service
is executed at first boot; otherwise, the service is not executed.

This patch achieves the above goal by setting CondistonNeedsUpdate to
"/etc/udev" in the service file, and creating /etc/udev/.updated file if the
postinst succeeds.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
meta/recipes-core/systemd/systemd_216.bb

index ebf939574d8d8364c6f076a7bbb786654c19dbd4..cd818185984d2a4ea79b5ea96f96008fccebc546 100644 (file)
@@ -149,6 +149,10 @@ do_install() {
 
        # Enable journal to forward message to syslog daemon
        sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' ${D}${sysconfdir}/systemd/journald.conf
+
+       # Make systemd-udev-hwdb-update to check /etc/udev
+       cp ${D}${systemd_unitdir}/system/systemd-udev-hwdb-update.service ${D}${sysconfdir}/systemd/system
+       sed -i -e 's#ConditionNeedsUpdate=/etc#ConditionNeedsUpdate=/etc/udev#g' ${D}${sysconfdir}/systemd/system/systemd-udev-hwdb-update.service
 }
 
 do_install_ptest () {
@@ -355,10 +359,18 @@ ALTERNATIVE_PRIORITY[runlevel] ?= "300"
 
 pkg_postinst_udev-hwdb () {
        if test -n "$D"; then
-               ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
-                       --root $D
+               if ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
+                       --root $D; then
+                       touch $D/etc/udev/.updated
+               else
+                       exit 1
+               fi
        else
-               udevadm hwdb --update
+               if udevadm hwdb --update; then
+                       touch $D/etc/udev/.updated
+               else
+                       exit 1
+               fi
        fi
 }