Skip to contentSkip to conversation

Make systemd as default init manager and configure wired network

PATCH Superseded [email protected] 1 participant 4 messages May 31, 2019

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Make systemd as default init manager and configure wired network

From: Kai Kang <[email protected]>

v5:
* set 'sysvinit' by default for musl
* replace += with _append

v4:
* move the configures to poky.conf. Introduce a new variable 'POKY_INIT_MANAGER' whose value should be either 'systemd' or 'sysvinit' to configure the init manager setting.

Kai Kang (3):
poky.conf: make systemd as default init manager poky-tiny.conf: not backfill distro feature systemd
systemd-conf: configure wired network with dhcp

 meta-poky/conf/distro/poky-tiny.conf                 |  2 +-
 meta-poky/conf/distro/poky.conf                      | 12 ++++++++++++
 meta-poky/conf/local.conf.sample.extended            |  9 ---------
 meta/recipes-core/systemd/systemd-conf/wired.network |  9 +++++++++
 meta/recipes-core/systemd/systemd-conf_242.bb        |  6 ++++++
 5 files changed, 28 insertions(+), 10 deletions(-)
 create mode 100644 meta/recipes-core/systemd/systemd-conf/wired.network
Signature · 1 line
2.20.0
#1 lore raw

PATCH v5 1/3 poky.conf: make systemd as default init manager

From: Kai Kang <[email protected]>

Move configurations from local.conf.sample.extended to poky.conf to make systemd as default init manager for poky. Introduce a new variable 'POKY_INIT_MANAGER' whose value should be either 'systemd' or 'sysvinit' to configure the init manager setting.

For users who still want to use sysvinit, set in local.conf or any other configure file with:

POKY_INIT_MANAGER = "sysvinit"

And consider security perspective, keep musl with sysvinit for now.

[YOCTO #13031]

---
 meta-poky/conf/distro/poky.conf           | 12 ++++++++++++
 meta-poky/conf/local.conf.sample.extended |  9 ---------
 2 files changed, 12 insertions(+), 9 deletions(-)
meta-poky/conf/distro/poky.conf +12 -0
index 78621e6dbf..95c339cba3 100644
@@ -21,6 +21,18 @@ POKY_DEFAULT_EXTRA_RRECOMMENDS = "kernel-module-af-packet"
 
 DISTRO_FEATURES ?= "${DISTRO_FEATURES_DEFAULT} ${POKY_DEFAULT_DISTRO_FEATURES}"
 
+# Use systemd for system initialization
+POKY_INIT_MANAGER ?= "systemd"
+
+# Consider security perspective, keep musl with sysvinit for now
+POKY_INIT_MANAGER_libc-musl = "sysvinit"
+
+DISTRO_FEATURES_BACKFILL_append = " ${POKY_INIT_MANAGER}"
+DISTRO_FEATURES_BACKFILL_CONSIDERED_append = " ${@bb.utils.contains('POKY_INIT_MANAGER', 'systemd', 'sysvinit', 'systemd', d)}"
+VIRTUAL-RUNTIME_login_manager = "${@bb.utils.contains('POKY_INIT_MANAGER', 'systemd', 'shadow-base', 'busybox', d)}"
+VIRTUAL-RUNTIME_init_manager = "${POKY_INIT_MANAGER}"
+VIRTUAL-RUNTIME_initscripts = "${@bb.utils.contains('POKY_INIT_MANAGER', 'systemd', 'systemd-compat-units', 'initscripts', d)}"
+
 PREFERRED_VERSION_linux-yocto ?= "5.0%"
 
 SDK_NAME = "${DISTRO}-${TCLIBC}-${SDKMACHINE}-${IMAGE_BASENAME}-${TUNE_PKGARCH}-${MACHINE}"
meta-poky/conf/local.conf.sample.extended +0 -9
index 26603debe6..e20fc5dbf3 100644
@@ -377,12 +377,3 @@ DISTRO_FEATURES_remove = "x11"
 #VIRTUAL-RUNTIME_initscripts = "initscripts"
 #VIRTUAL-RUNTIME_keymaps = "keymaps"
 #DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
-
-#
-# Use systemd for system initialization
-#
-#DISTRO_FEATURES_append = " systemd"
-#DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
-#VIRTUAL-RUNTIME_login_manager = "shadow-base"
-#VIRTUAL-RUNTIME_init_manager = "systemd"
-#VIRTUAL-RUNTIME_initscripts = "systemd-compat-units"
Signature · 1 line
2.20.0
#2 lore raw

PATCH v5 2/3 poky-tiny.conf: not backfill distro feature systemd

In reply to [email protected]

From: Kai Kang <[email protected]>

systemd has been added to DISTRO_FEATURES_BACKFILL for poky by default, but it is compatible with poky-tiny. So not backfile it to DISTRO_FEATURES by adding it to DISTRO_FEATURES_BACKFILL_CONSIDERED.

---
 meta-poky/conf/distro/poky-tiny.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-poky/conf/distro/poky-tiny.conf +1 -1
index 1f8b6e8ff3..ad95919e6c 100644
@@ -87,7 +87,7 @@ VIRTUAL-RUNTIME_login_manager = "busybox"
 VIRTUAL-RUNTIME_init_manager = "busybox"
 VIRTUAL-RUNTIME_initscripts = "initscripts"
 VIRTUAL-RUNTIME_keymaps = "keymaps"
-DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
+DISTRO_FEATURES_BACKFILL_CONSIDERED += "systemd sysvinit"
 
 # FIXME: Consider adding "modules" to MACHINE_FEATURES and using that in
 # packagegroup-core-base to select modutils-initscripts or not.  Similar with "net" and
Signature · 1 line
2.20.0
#3 lore raw

PATCH v5 3/3 systemd-conf: configure wired network with dhcp

In reply to [email protected]

From: Kai Kang <[email protected]>

Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1. And do not install it for qemu bsps.

Refer to
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd

[YOCTO #13057]

---
 meta/recipes-core/systemd/systemd-conf/wired.network | 9 +++++++++
 meta/recipes-core/systemd/systemd-conf_242.bb        | 6 ++++++
 2 files changed, 15 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd-conf/wired.network
meta/recipes-core/systemd/systemd-conf/wired.network new file +9 -0
new file mode 100644
index 0000000000..253aee9382
@@ -0,0 +1,9 @@
+[Match]
+Name=en* eth*
+
+[Network]
+DHCP=yes
+
+[DHCP]
+RouteMetric=10
+ClientIdentifier=mac
meta/recipes-core/systemd/systemd-conf_242.bb +6 -0
index 96beea53a7..d9ec023bfd 100644
@@ -10,17 +10,22 @@ SRC_URI = "\
     file://logind.conf \
     file://system.conf \
     file://system.conf-qemuall \
+    file://wired.network \
 "
 
 do_install() {
 	install -D -m0644 ${WORKDIR}/journald.conf ${D}${systemd_unitdir}/journald.conf.d/00-${PN}.conf
 	install -D -m0644 ${WORKDIR}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf
 	install -D -m0644 ${WORKDIR}/system.conf ${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf
+	install -D -m0644 ${WORKDIR}/wired.network ${D}${systemd_unitdir}/network/80-wired.network
 }
 
 # Based on change from YP bug 8141, OE commit 5196d7bacaef1076c361adaa2867be31759c1b52
 do_install_append_qemuall() {
 	install -D -m0644 ${WORKDIR}/system.conf-qemuall ${D}${systemd_unitdir}/system.conf.d/01-${PN}.conf
+
+	# Do not install wired.network for qemu bsps
+	rm -rf ${D}${systemd_unitdir}/network
 }
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
@@ -29,4 +34,5 @@ FILES_${PN} = "\
     ${systemd_unitdir}/journald.conf.d/ \
     ${systemd_unitdir}/logind.conf.d/ \
     ${systemd_unitdir}/system.conf.d/ \
+    ${systemd_unitdir}/network/ \
 "
Signature · 1 line
2.20.0