Skip to contentSkip to conversation

systemd: update-alternatives rework with update-alternatives.bbclass

PATCH New Radu Moisan 1 participant 3 messages Apr 9, 2013

lore
Share & tools
lore
#0 lore raw

v2 cover systemd: update-alternatives rework with update-alternatives.bbclass

Radu Moisan (2):
systemd: use update-alternatives.bbclass
systemd: set default.target to multi-user.target

 meta/recipes-core/systemd/systemd_199.bb |   40 +++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/2 systemd: use update-alternatives.bbclass

switch from using plain update-alternatives command to update-alternatives.bbclass style

Fixes [Yocto #4181]

---
 meta/recipes-core/systemd/systemd_199.bb |   36 +++++++++++++++++-------------
 1 file changed, 21 insertions(+), 15 deletions(-)
meta/recipes-core/systemd/systemd_199.bb +21 -15
index 2464b83..354e557 100644
@@ -16,7 +16,7 @@ DEPENDS += "${@base_contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
 
 SECTION = "base/shell"
 
-inherit gtk-doc useradd pkgconfig autotools perlnative update-rc.d
+inherit gtk-doc useradd pkgconfig autotools perlnative update-rc.d update-alternatives
 
 SRC_URI = "http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz \
            file://touchscreen.rules \
@@ -251,21 +251,27 @@ python __anonymous() {
 # TODO:
 # u-a for runlevel and telinit
 
-pkg_postinst_systemd () {
-update-alternatives --install ${base_sbindir}/init init ${systemd_unitdir}/systemd 300
-update-alternatives --install ${base_sbindir}/halt halt ${base_bindir}/systemctl 300
-update-alternatives --install ${base_sbindir}/reboot reboot ${base_bindir}/systemctl 300
-update-alternatives --install ${base_sbindir}/shutdown shutdown ${base_bindir}/systemctl 300
-update-alternatives --install ${base_sbindir}/poweroff poweroff ${base_bindir}/systemctl 300
-}
+ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff"
 
-pkg_prerm_systemd () {
-update-alternatives --remove init ${systemd_unitdir}/systemd
-update-alternatives --remove halt ${base_bindir}/systemctl
-update-alternatives --remove reboot ${base_bindir}/systemctl
-update-alternatives --remove shutdown ${base_bindir}/systemctl
-update-alternatives --remove poweroff ${base_bindir}/systemctl
-}
+ALTERNATIVE_TARGET[init] = "${systemd_unitdir}/systemd"
+ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
+ALTERNATIVE_PRIORITY[init] ?= "300"
+
+ALTERNATIVE_TARGET[halt] = "${base_bindir}/systemctl"
+ALTERNATIVE_LINK_NAME[halt] = "${base_sbindir}/halt"
+ALTERNATIVE_PRIORITY[halt] ?= "300"
+
+ALTERNATIVE_TARGET[reboot] = "${base_bindir}/systemctl"
+ALTERNATIVE_LINK_NAME[reboot] = "${base_sbindir}/reboot"
+ALTERNATIVE_PRIORITY[reboot] ?= "300"
+
+ALTERNATIVE_TARGET[shutdown] = "${base_bindir}/systemctl"
+ALTERNATIVE_LINK_NAME[shutdown] = "${base_sbindir}/shutdown"
+ALTERNATIVE_PRIORITY[shutdown] ?= "300"
+
+ALTERNATIVE_TARGET[poweroff] = "${base_bindir}/systemctl"
+ALTERNATIVE_LINK_NAME[poweroff] = "${base_sbindir}/poweroff"
+ALTERNATIVE_PRIORITY[poweroff] ?= "300"
 
 pkg_postinst_udev-hwdb () {
 	if test -n "$D"; then
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 2/2 systemd: set default.target to multi-user.target

In reply to Radu Moisan

This fixes a service dependency issue;
When graphical.target is the default mode, systemd will try to start display-manager.service which is not available on some targets.

For xserver-nodm-init we would then have something like:
inherit update-alternatives
ALTERNATIVE_${PN} = "systemd-def-target" ALTERNATIVE_TARGET[systemd-def-target] = "${systemd_unitdir}/system/graphical.target" ALTERNATIVE_LINK_NAME[systemd-def-target] = "${systemd_unitdir}/system/default.target" ALTERNATIVE_PRIORITY[systemd-def-target] ?= "10"

Fixes [Yocto #3816]

---
 meta/recipes-core/systemd/systemd_199.bb |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/recipes-core/systemd/systemd_199.bb +5 -1
index 354e557..bd5881b 100644
@@ -251,7 +251,7 @@ python __anonymous() {
 # TODO:
 # u-a for runlevel and telinit
 
-ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff"
+ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff systemd-def-target"
 
 ALTERNATIVE_TARGET[init] = "${systemd_unitdir}/systemd"
 ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
@@ -273,6 +273,10 @@ ALTERNATIVE_TARGET[poweroff] = "${base_bindir}/systemctl"
 ALTERNATIVE_LINK_NAME[poweroff] = "${base_sbindir}/poweroff"
 ALTERNATIVE_PRIORITY[poweroff] ?= "300"
 
+ALTERNATIVE_TARGET[systemd-def-target] = "${systemd_unitdir}/system/multi-user.target"
+ALTERNATIVE_LINK_NAME[systemd-def-target] = "${systemd_unitdir}/system/default.target"
+ALTERNATIVE_PRIORITY[systemd-def-target] ?= "1"
+
 pkg_postinst_udev-hwdb () {
 	if test -n "$D"; then
 		exit 1
Signature · 1 line
1.7.9.5