Skip to contentSkip to conversation

Make systemd as default init manager and configure wired network

PATCH Superseded [email protected] 2 participants 5 messages Jun 2, 2019 – Jun 4, 2019

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

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

From: Kai Kang <[email protected]>

v6:
* create .inc files as Richard suggested, and include them according to POKY_INIT_MANAGER

Kai Kang (2):
poky.conf: make systemd as default init manager
systemd-conf: configure wired network with dhcp

 .../conf/distro/include/init-template-mdev-busybox.inc   | 7 +++++++
 .../conf/distro/include/init-template-systemd-compat.inc | 7 +++++++
 meta-poky/conf/distro/include/init-template-systemd.inc  | 5 +++++
 meta-poky/conf/distro/include/init-template-sysvinit.inc | 6 ++++++
 meta-poky/conf/distro/poky-tiny.conf                     | 8 +-------
 meta-poky/conf/distro/poky.conf                          | 6 ++++++
 meta/recipes-core/systemd/systemd-conf/wired.network     | 9 +++++++++
 meta/recipes-core/systemd/systemd-conf_242.bb            | 6 ++++++
 8 files changed, 47 insertions(+), 7 deletions(-)
 create mode 100644 meta-poky/conf/distro/include/init-template-mdev-busybox.inc
 create mode 100644 meta-poky/conf/distro/include/init-template-systemd-compat.inc
 create mode 100644 meta-poky/conf/distro/include/init-template-systemd.inc
 create mode 100644 meta-poky/conf/distro/include/init-template-sysvinit.inc
 create mode 100644 meta/recipes-core/systemd/systemd-conf/wired.network
Signature · 1 line
2.20.0
#1 lore raw

PATCH v6 1/2 poky.conf: make systemd as default init manager

From: Kai Kang <[email protected]>

Introduce a new variable POKY_INIT_MANAGER and create 4 .inc files to configure init manager settings. Var POKY_INIT_MANAGER accepts 4 values:
sysvinit, systemd, systemd-compat and mdev-busybox. Set systemd by default for DISTRO poky. And set mdev-busybox for DISTRO poky-tiny which doesn't change its init manger settings.

[YOCTO #13031]

---
 .../conf/distro/include/init-template-mdev-busybox.inc    | 7 +++++++
 .../conf/distro/include/init-template-systemd-compat.inc  | 7 +++++++
 meta-poky/conf/distro/include/init-template-systemd.inc   | 5 +++++
 meta-poky/conf/distro/include/init-template-sysvinit.inc  | 6 ++++++
 meta-poky/conf/distro/poky-tiny.conf                      | 8 +-------
 meta-poky/conf/distro/poky.conf                           | 6 ++++++
 6 files changed, 32 insertions(+), 7 deletions(-)
 create mode 100644 meta-poky/conf/distro/include/init-template-mdev-busybox.inc
 create mode 100644 meta-poky/conf/distro/include/init-template-systemd-compat.inc
 create mode 100644 meta-poky/conf/distro/include/init-template-systemd.inc
 create mode 100644 meta-poky/conf/distro/include/init-template-sysvinit.inc
meta-poky/conf/distro/include/init-template-mdev-busybox.inc new file +7 -0
new file mode 100644
index 0000000000..b07d9de5b4
@@ -0,0 +1,7 @@
+# enable mdev/busybox for init
+DISTRO_FEATURES_BACKFILL_CONSIDERED_append = " systemd sysvinit"
+VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
+VIRTUAL-RUNTIME_init_manager = "busybox"
+VIRTUAL-RUNTIME_initscripts = "initscripts"
+VIRTUAL-RUNTIME_keymaps = "keymaps"
+VIRTUAL-RUNTIME_login_manager = "busybox"
meta-poky/conf/distro/include/init-template-systemd-compat.inc new file +7 -0
new file mode 100644
index 0000000000..22151f8866
@@ -0,0 +1,7 @@
+# Don't append sysvinit to DISTRO_FEATURES here because it has been set
+# in DISTRO_FEATURES_BACKFILL. And then this .inc file could be used by
+# init-template-systemd.inc
+DISTRO_FEATURES_append = " systemd"
+VIRTUAL-RUNTIME_init_manager = "systemd"
+VIRTUAL-RUNTIME_initscripts = "systemd-compat-units"
+VIRTUAL-RUNTIME_login_manager = "shadow-base"
meta-poky/conf/distro/include/init-template-systemd.inc new file +5 -0
new file mode 100644
index 0000000000..d04847028c
@@ -0,0 +1,5 @@
+# Use systemd for system initialization
+
+require init-template-systemd-compat.inc
+
+DISTRO_FEATURES_BACKFILL_CONSIDERED_append = " sysvinit"
meta-poky/conf/distro/include/init-template-sysvinit.inc new file +6 -0
new file mode 100644
index 0000000000..7725b30e1e
@@ -0,0 +1,6 @@
+# Use sysvinit for system initialization
+DISTRO_FEATURES_append = " sysvinit"
+DISTRO_FEATURES_BACKFILL_CONSIDERED_append = " systemd"
+VIRTUAL-RUNTIME_init_manager = "sysvinit"
+VIRTUAL-RUNTIME_initscripts = "initscripts"
+VIRTUAL-RUNTIME_login_manager = "busybox"
meta-poky/conf/distro/poky-tiny.conf +1 -7
index 1f8b6e8ff3..8ba0b9a4bb 100644
@@ -81,13 +81,7 @@ DISTRO_FEATURES_append_libc-musl = " largefile"
 DISTRO_FEATURES_class-native = "${DISTRO_FEATURES_DEFAULT} ${POKY_DEFAULT_DISTRO_FEATURES}"
 DISTRO_FEATURES_class-nativesdk = "${DISTRO_FEATURES_DEFAULT} ${POKY_DEFAULT_DISTRO_FEATURES}"
 
-# enable mdev/busybox for init
-VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
-VIRTUAL-RUNTIME_login_manager = "busybox"
-VIRTUAL-RUNTIME_init_manager = "busybox"
-VIRTUAL-RUNTIME_initscripts = "initscripts"
-VIRTUAL-RUNTIME_keymaps = "keymaps"
-DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
+POKY_INIT_MANAGER ?= "mdev-busybox"
 
 # FIXME: Consider adding "modules" to MACHINE_FEATURES and using that in
 # packagegroup-core-base to select modutils-initscripts or not.  Similar with "net" and
meta-poky/conf/distro/poky.conf +6 -0
index 78621e6dbf..e544f7e52c 100644
@@ -84,3 +84,9 @@ require conf/distro/include/no-static-libs.inc
 require conf/distro/include/yocto-uninative.inc
 require conf/distro/include/security_flags.inc
 INHERIT += "uninative"
+
+# Make systemd as default init manager for poky
+# and set sysvinit for musl consider security
+POKY_INIT_MANAGER ??= "systemd"
+POKY_INIT_MANAGER_libc-musl = "sysvinit"
+require conf/distro/include/init-template-${POKY_INIT_MANAGER}.inc
Signature · 1 line
2.20.0
#2 lore raw

PATCH v6 2/2 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
#3 lore raw
In reply to [email protected]
Quoted 9 lines · On Sun, 2019-06-02 at 10:55 -0400, [email protected] wrote:

From: Kai Kang <[email protected]>

v6:
* create .inc files as Richard suggested, and include them according to POKY_INIT_MANAGER

Kai Kang (2):
poky.conf: make systemd as default init manager
systemd-conf: configure wired network with dhcp

This is looking good, I do agree with Peter about the file naming. I ran it through the autobuilder to see where we are at runtime and the results were not so good:

https://autobuilder.yoctoproject.org/typhoon/#/builders/85/builds/484

We may need to reduce some of the free space in the ptest image and it looks like there is an NFS startup failure issue in the sdk images. There may be other issues in there too but those were the two I immediately saw.

Cheers,

Richard

author
#4 lore raw
Quoted 11 lines · On 2019/6/3 下午8:30, [email protected] wrote:
Quoted 9 lines · On Sun, 2019-06-02 at 10:55 -0400, [email protected] wrote:

From: Kai Kang <[email protected]>

v6:
* create .inc files as Richard suggested, and include them according to POKY_INIT_MANAGER

Kai Kang (2):
poky.conf: make systemd as default init manager
systemd-conf: configure wired network with dhcp

This is looking good, I do agree with Peter about the file naming.

OK.

Quoted 10 lines

I
ran it through the autobuilder to see where we are at runtime and the results were not so good:

https://autobuilder.yoctoproject.org/typhoon/#/builders/85/builds/484

We may need to reduce some of the free space in the ptest image and it looks like there is an NFS startup failure issue in the sdk images. There may be other issues in there too but those were the two I immediately saw.

I'll check the issues one by one.

Regards,
Kai

Quoted 6 lines

Cheers,

Richard

Signature · 1 line
Kai Kang