Skip to contentSkip to conversation

systemd: mark /etc as updated to avoid unnecessary services to run

PATCH In review Chen Qi 2 participants 3 messages Sep 25, 2019

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

cover systemd: mark /etc as updated to avoid unnecessary services to run

*** BLURB HERE ***
The following changes since commit 81f9e815d36848761a9dfa94b00ad998bb39a4a6:

build-appliance-image: Update to master head revision (2019-09-19 20:32:53 +0100)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib ChenQi/etc-updated
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/etc-updated

Chen Qi (1):
systemd: mark /etc as updated to avoid unnecessary services to run

 meta/classes/rootfs-postcommands.bbclass | 6 ++++++
 meta/recipes-core/systemd/systemd_243.bb | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/1 systemd: mark /etc as updated to avoid unnecessary services to run

We have updated hwdb via postinstall, updated systemd users via 'systemd_create_users', so there's no need to update /etc. Mark it as updated to avoid unnecessary services like systemd-hwdb-update.service to run.

This would solve timeout problem on qemumips. So also remove the timeout change for systemd-hwdb-update.service.

---
 meta/classes/rootfs-postcommands.bbclass | 6 ++++++
 meta/recipes-core/systemd/systemd_243.bb | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
meta/classes/rootfs-postcommands.bbclass +6 -0
index 88f75d0..9323e92 100644
@@ -36,6 +36,8 @@ POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log"
 # Set default target for systemd images
 SYSTEMD_DEFAULT_TARGET ?= '${@bb.utils.contains("IMAGE_FEATURES", "x11-base", "graphical.target", "multi-user.target", d)}'
 ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "systemd", "set_systemd_default_target; systemd_create_users;", "", d)}'
+# Mark /etc as updated for systemd as we have done things in rootfs time
+ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "systemd", "systemd_mark_etc_updated;", "", d)}'
 
 ROOTFS_POSTPROCESS_COMMAND += 'empty_var_volatile;'
 
@@ -86,6 +88,10 @@ systemd_create_users () {
 	done
 }
 
+systemd_mark_etc_updated () {
+	touch ${IMAGE_ROOTFS}${sysconfdir}/.updated
+}
+
 #
 # A hook function to support read-only-rootfs IMAGE_FEATURES
 #
meta/recipes-core/systemd/systemd_243.bb +0 -6
index f0e8c56..0148c37 100644
@@ -298,12 +298,6 @@ do_install() {
 	install -Dm 0644 ${WORKDIR}/99-default.preset ${D}${systemd_unitdir}/system-preset/99-default.preset
 }
 
-do_install_append () {
-       # Mips qemu is extremely slow, allow more time for the hwdb update
-       # This is a workaround until https://github.com/systemd/systemd/issues/13581 is resolved
-       sed -i -e s#TimeoutSec=90s#TimeoutSec=180s# ${D}${systemd_unitdir}/system/systemd-hwdb-update.service
-}
-
 python populate_packages_prepend (){
     systemdlibdir = d.getVar("rootlibdir")
     do_split_packages(d, systemdlibdir, '^lib(.*)\.so\.*', 'lib%s', 'Systemd %s library', extra_depends='', allow_links=True)
Signature · 1 line
1.9.1
#2 lore raw
Quoted 7 lines · Chen Qi

We have updated hwdb via postinstall, updated systemd users via 'systemd_create_users', so there's no need to update /etc. Mark it as updated to avoid unnecessary services like systemd-hwdb-update.service to run.

This would solve timeout problem on qemumips. So also remove the timeout change for systemd-hwdb-update.service.

I was going to send almost this exact patch, *but* I don't think it's right.

Arbitrary service files can use ConditionNeedsUpdate, and marking /etc as updated because we don't want hwdb-update to run also means we don't execute ldconfig.service, systemd-sysusers.server, or any other service files that were added and expected to be ran on first boot.

Some other distributions rip out systemd-hwdb-update entirely and use traditional postinsts to handle it:

Debian: https://salsa.debian.org/systemd-team/systemd/blob/master/debian/rules#L221
Clear: https://github.com/clearlinux-pkgs/systemd/blob/master/systemd.spec#L419

I believe that we should do the same.

Ross