Skip to contentSkip to conversation

systemd: set default.target to multi-user.target

PATCH Superseded Radu Moisan 6 participants 21 messages Jan 25, 2013 – Jan 28, 2013

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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

this fixes a service dependency issue;
while graphical.target is the default mode, systemd will try to start display-manager.service which is not available.

---
 meta/conf/distro/include/default-distrovars.inc |    3 +++
 meta/recipes-core/systemd/systemd_196.bb        |    5 +++++
 2 files changed, 8 insertions(+)
meta/conf/distro/include/default-distrovars.inc +3 -0
index f073547..c21d9a3 100644
@@ -22,6 +22,9 @@ DISTRO_FEATURES_LIBC_class-nativesdk = "${DISTRO_FEATURES_LIBC_DEFAULT}"
 DISTRO_FEATURES_INITMAN ?= "sysvinit"
 DISTRO_FEATURES ?= "alsa argp bluetooth ext2 irda largefile pcmcia usbgadget usbhost wifi xattr nfs zeroconf pci 3g x11 ${DISTRO_FEATURES_LIBC} ${DISTRO_FEATURES_INITMAN}"
 
+# "multi-user" vs "graphical"
+SYSTEMD_DEFAULT_TARGET ?= "multi-user"
+
 IMAGE_FEATURES ?= ""
 
 # This is a list of packages that are used by the build system to build the distribution, they are not
meta/recipes-core/systemd/systemd_196.bb +5 -0
index a78a8a6..4b97774 100644
@@ -95,6 +95,11 @@ do_install() {
 	install -m 0644 ${WORKDIR}/var-run.conf ${D}${sysconfdir}/tmpfiles.d/
 
 	install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/
+
+
+	if [ -n ${SYSTEMD_DEFAULT_TARGET} ]; then
+		ln -s ${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET}.target ${D}${sysconfdir}/systemd/system/default.target
+	fi
 }
 
 python populate_packages_prepend (){
Signature · 1 line
1.7.9.5
#1 lore raw

meta/conf/distro/include/default-distrovars.inc DISTRO_FEATURES_LIBC_class-nativesdk = "${DISTRO_FEATURES_LIBC_DEFAULT}" · line 26

Quoted 2 lines · Radu Moisan
meta/conf/distro/include/default-distrovars.inc +2 -0
+# "multi-user" vs "graphical"
+SYSTEMD_DEFAULT_TARGET ?= "multi-user"

Default to "graphical", so we're not regressing and just introducing a warning if someone doesn't set this and doesn't have X.

meta/recipes-core/systemd/systemd_196.bb do_install() { · line 102

Quoted 9 lines
meta/recipes-core/systemd/systemd_196.bb +5 -0
@@ -95,6 +95,11 @@ do_install() {
        install -m 0644 ${WORKDIR}/var-run.conf ${D}${sysconfdir}/tmpfiles.d/
 
        install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/
+
+
+       if [ -n ${SYSTEMD_DEFAULT_TARGET} ]; then
+               ln -s ${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET}.target ${D}${sysconfdir}/systemd/system/default.target
+       fi

This will have to happen at image construction time and not package generation time, as different images may have different targets but share the same systemd package.

A rootfs-time postinstall script would work, but isn't very nice. I wonder if there's a better solution, hooking into the image creation should work.

(thinks)

Ross

#2 lore raw
Quoted 21 lines · Ross

meta/conf/distro/include/default-distrovars.inc DISTRO_FEATURES_LIBC_class-nativesdk = "${DISTRO_FEATURES_LIBC_DEFAULT}" · line 26

Quoted 2 lines · Radu Moisan
meta/conf/distro/include/default-distrovars.inc +2 -0
+# "multi-user" vs "graphical"
+SYSTEMD_DEFAULT_TARGET ?= "multi-user"

Default to "graphical", so we're not regressing and just introducing a warning if someone doesn't set this and doesn't have X.

meta/recipes-core/systemd/systemd_196.bb do_install() { · line 102

Quoted 9 lines
meta/recipes-core/systemd/systemd_196.bb +5 -0
@@ -95,6 +95,11 @@ do_install() {
        install -m 0644 ${WORKDIR}/var-run.conf ${D}${sysconfdir}/tmpfiles.d/
 
        install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/
+
+
+       if [ -n ${SYSTEMD_DEFAULT_TARGET} ]; then
+               ln -s ${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET}.target ${D}${sysconfdir}/systemd/system/default.target
+       fi

This will have to happen at image construction time and not package generation time, as different images may have different targets but share the same systemd package.

Quoted 5 lines

A rootfs-time postinstall script would work, but isn't very nice. I wonder if there's a better solution, hooking into the image creation should work.

(thinks)

The point here is that images shouldn't give errors at runtime. Nothing above does anything to address that. There is something going to have to happen at image creation time so that systemd is correctly configured in the current scheme of things.

Cheers,

Richard

#3 lore raw
Quoted 20 lines · Richard Purdie
Quoted 19 lines · Ross

meta/conf/distro/include/default-distrovars.inc DISTRO_FEATURES_LIBC_class-nativesdk = "${DISTRO_FEATURES_LIBC_DEFAULT}" · line 26

Quoted 2 lines · Radu Moisan
meta/conf/distro/include/default-distrovars.inc +2 -0
+# "multi-user" vs "graphical"
+SYSTEMD_DEFAULT_TARGET ?= "multi-user"

Default to "graphical", so we're not regressing and just introducing a warning if someone doesn't set this and doesn't have X.

meta/recipes-core/systemd/systemd_196.bb do_install() { · line 102

Quoted 9 lines
meta/recipes-core/systemd/systemd_196.bb +5 -0
@@ -95,6 +95,11 @@ do_install() {
         install -m 0644 ${WORKDIR}/var-run.conf ${D}${sysconfdir}/tmpfiles.d/
 
         install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/
+
+
+       if [ -n ${SYSTEMD_DEFAULT_TARGET} ]; then
+               ln -s ${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET}.target ${D}${sysconfdir}/systemd/system/default.target
+       fi

This will have to happen at image construction time and not package generation time, as different images may have different targets but share the same systemd package.

Quoted 7 lines
Quoted 5 lines

A rootfs-time postinstall script would work, but isn't very nice. I wonder if there's a better solution, hooking into the image creation should work.

(thinks)

The point here is that images shouldn't give errors at runtime. Nothing above does anything to address that.

I don't understand what you mean. The patch addresses exactly that, warning at runtime, to be more specific the warning about display-manager.service However though, I understand the issues with this approach, so I'll dig a little more into Martin's approach with update-alternatives.

Radu

#4 lore raw
In reply to Burton, Ross
Quoted 6 lines · Ross

meta/conf/distro/include/default-distrovars.inc DISTRO_FEATURES_LIBC_class-nativesdk = "${DISTRO_FEATURES_LIBC_DEFAULT}" · line 26

Quoted 2 lines · Radu Moisan
meta/conf/distro/include/default-distrovars.inc +2 -0
+# "multi-user" vs "graphical"
+SYSTEMD_DEFAULT_TARGET ?= "multi-user"

Default to "graphical", so we're not regressing and just introducing a warning if someone doesn't set this and doesn't have X.

Or empty by default (add quotes in that test -n below).

Quoted 27 lines

meta/recipes-core/systemd/systemd_196.bb do_install() { · line 102

Quoted 10 lines
meta/recipes-core/systemd/systemd_196.bb +5 -0
@@ -95,6 +95,11 @@ do_install() {
        install -m 0644 ${WORKDIR}/var-run.conf ${D}${sysconfdir}/tmpfiles.d/
 
        install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/
+
+
+       if [ -n ${SYSTEMD_DEFAULT_TARGET} ]; then
+               ln -s ${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET}.target ${D}${sysconfdir}/systemd/system/default.target
+       fi

This will have to happen at image construction time and not package generation time, as different images may have different targets but share the same systemd package.

A rootfs-time postinstall script would work, but isn't very nice. I wonder if there's a better solution, hooking into the image creation should work.

(thinks)

Ross

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#5 lore raw

Hi,

Been chatting to Richard. How about systemd ships a symlink to multi-user, and the X11 init script packages change the symlink to graphical in their postinst.

(we must remember to put this in the release notes for anyone who has a custom X init script)

Ross

#6 lore raw
Quoted 11 lines · Ross

Hi,

Been chatting to Richard. How about systemd ships a symlink to multi-user, and the X11 init script packages change the symlink to graphical in their postinst.

(we must remember to put this in the release notes for anyone who has a custom X init script)

Ross

Have not yet tested but how about:

pkg_postinst_systemd () {
if [ -n "$D" ]; then

	# no display-manager.service around?
	if [ ! -e ${D}${systemd_unitdir}/systemd/system/display-manager.service -a \
	     ! grep 'Alias=display-manager.service'
${D}${systemd_unitdir}/systemd/system ]; then
		ln -s ${systemd_unitdir}/system/multi-user.target
${D}${systemd_unitdir}/systemd/system/default.target
	fi
fi

...

Andreas

#7 lore raw
Quoted 10 lines · Andreas Müller
Quoted 9 lines · Ross

Hi,

Been chatting to Richard. How about systemd ships a symlink to multi-user, and the X11 init script packages change the symlink to graphical in their postinst.

(we must remember to put this in the release notes for anyone who has a custom X init script)

Quoted 8 lines
Quoted 2 lines

Ross

Have not yet tested but how about:

pkg_postinst_systemd () {
if [ -n "$D" ]; then

	# no display-manager.service around?
	if [ ! -e ${D}${systemd_unitdir}/systemd/system/display-manager.service -a \

I think you wanted $D ^ here.

Quoted 6 lines

! grep 'Alias=display-manager.service'
${D}${systemd_unitdir}/systemd/system ]; then

		ln -s ${systemd_unitdir}/system/multi-user.target

${D}${systemd_unitdir}/systemd/system/default.target
fi
fi

Cannot we just just u-a for default.target ? And each possible target providing own u-a alternative (DMs with higher prio then systemd)?

Cheers,

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#8 lore raw
Quoted 13 lines · Martin Jansa
Quoted 12 lines · Andreas Müller
Quoted 11 lines · Ross

Hi,

Been chatting to Richard. How about systemd ships a symlink to multi-user, and the X11 init script packages change the symlink to graphical in their postinst.

(we must remember to put this in the release notes for anyone who has a custom X init script)

Ross

Quoted 8 lines
Quoted 6 lines

Have not yet tested but how about:

pkg_postinst_systemd () {
if [ -n "$D" ]; then

      # no display-manager.service around?
      if [ ! -e ${D}${systemd_unitdir}/systemd/system/display-manager.service -a \

I think you wanted $D ^ here.

Yes there are more of this but before cleaning up & run into tests:
Would this find friends?

Quoted 2 lines

Cannot we just just u-a for default.target ? And each possible target providing own u-a alternative (DMs with higher prio then systemd)?

Sorry but I don't understand this

Andreas

#9 lore raw
Quoted 21 lines · Andreas Müller
Quoted 20 lines · Martin Jansa
Quoted 18 lines · Andreas Müller
Quoted 11 lines · Ross

Hi,

Been chatting to Richard. How about systemd ships a symlink to multi-user, and the X11 init script packages change the symlink to graphical in their postinst.

(we must remember to put this in the release notes for anyone who has a custom X init script)

Ross

Have not yet tested but how about:

pkg_postinst_systemd () {
if [ -n "$D" ]; then

      # no display-manager.service around?
      if [ ! -e ${D}${systemd_unitdir}/systemd/system/display-manager.service -a \
Quoted 7 lines
Quoted 1 line

I think you wanted $D ^ here.

Yes there are more of this but before cleaning up & run into tests:
Would this find friends?

Quoted 2 lines

Cannot we just just u-a for default.target ? And each possible target providing own u-a alternative (DMs with higher prio then systemd)?

Sorry but I don't understand this

Something like:

systemd:
inherit update-alternatives
ALTERNATIVE_${PN} = "systemd-def-target"
ALTERNATIVE_TARGET[systemd-def-target] = "${systemd_unitdir}/system/multi-user.target" ALTERNATIVE_LINK_NAME[systemd-def-target] = "${systemd_unitdir}/systemd/system/default.target" ALTERNATIVE_PRIORITY[systemd-def-target] ?= "1"

xserver-nodm-init and DMs:
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}/systemd/system/default.target" ALTERNATIVE_PRIORITY[systemd-def-target] ?= "10"

Cheers,

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#10 lore raw
Quoted 9 lines · Martin Jansa

Something like:

systemd:
inherit update-alternatives
ALTERNATIVE_${PN} = "systemd-def-target"
ALTERNATIVE_TARGET[systemd-def-target] = "${systemd_unitdir}/system/multi-user.target" ALTERNATIVE_LINK_NAME[systemd-def-target] = "${systemd_unitdir}/systemd/system/default.target" ALTERNATIVE_PRIORITY[systemd-def-target] ?= "1"

Quoted 6 lines

xserver-nodm-init and DMs:
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}/systemd/system/default.target" ALTERNATIVE_PRIORITY[systemd-def-target] ?= "10"

Can you make those conditional on the systemd feature so that we don't get complaints from people using something else?

You could use different names and map them to ALTERNATIVE_* inside systemd.bbclass, assuming/enforcing that everyone who wants to set the default target inherits that class I guess.

Ross

#11 lore raw
Quoted 10 lines · Ross Burton
Quoted 9 lines · Martin Jansa

Something like:

systemd:
inherit update-alternatives
ALTERNATIVE_${PN} = "systemd-def-target"
ALTERNATIVE_TARGET[systemd-def-target] = "${systemd_unitdir}/system/multi-user.target" ALTERNATIVE_LINK_NAME[systemd-def-target] = "${systemd_unitdir}/systemd/system/default.target" ALTERNATIVE_PRIORITY[systemd-def-target] ?= "1"

Quoted 8 lines
Quoted 6 lines

xserver-nodm-init and DMs:
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}/systemd/system/default.target" ALTERNATIVE_PRIORITY[systemd-def-target] ?= "10"

Can you make those conditional on the systemd feature so that we don't get complaints from people using something else?

xserver-nodm-init:
ALTERNATIVE_${PN}-systemd = "systemd-def-target"

And only people which install xserver-nodm-init-system in image will see that.

Quoted 1 line

You could use different names and map them to ALTERNATIVE_* inside systemd.bbclass, assuming/enforcing that everyone who wants to set the default target inherits that class I guess.

I don't understand what you mean.

Cheers,

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#12 lore raw
Quoted 23 lines · Martin Jansa
Quoted 10 lines · Ross Burton
Quoted 9 lines · Martin Jansa

Something like:

systemd:
inherit update-alternatives
ALTERNATIVE_${PN} = "systemd-def-target"
ALTERNATIVE_TARGET[systemd-def-target] = "${systemd_unitdir}/system/multi-user.target" ALTERNATIVE_LINK_NAME[systemd-def-target] = "${systemd_unitdir}/systemd/system/default.target" ALTERNATIVE_PRIORITY[systemd-def-target] ?= "1"

Quoted 8 lines
Quoted 6 lines

xserver-nodm-init and DMs:
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}/systemd/system/default.target" ALTERNATIVE_PRIORITY[systemd-def-target] ?= "10"

Can you make those conditional on the systemd feature so that we don't get complaints from people using something else?

xserver-nodm-init:
ALTERNATIVE_${PN}-systemd = "systemd-def-target"

Quoted 7 lines

And only people which install xserver-nodm-init-system in image will see that.

Quoted 1 line

You could use different names and map them to ALTERNATIVE_* inside systemd.bbclass, assuming/enforcing that everyone who wants to set the default target inherits that class I guess.

I don't understand what you mean.

Please let's remember how it started: avoiding a single warning for missing display-manager.service on console images...

Andreas

#13 lore raw
Quoted 2 lines · Andreas Müller

Please let's remember how it started: avoiding a single warning for missing display-manager.service on console images...

Don't be too quick to trivialise this. You start with accepting one warning at boot. Another appears, well its only one more and there was a warning anyway, you can't remember which was always there and is safe to ignore. Before long you have lots of warnings at boot and its ok, we had warnings anyway, right?

Warnings show how much we care about the thing we're producing. Whist this is annoying, lets fix it once and for all, properly.

Cheers,

Richard

#14 lore raw
In reply to Martin Jansa
Quoted 1 line · Martin Jansa

ALTERNATIVE_${PN}-systemd = "systemd-def-target"

Let's not introduce packages controlled on distro features whose sole purpose is to contain a single file. systemd enabled -> units go into $PN.

Or, if we accept PN-systemd packages, then I expect to see PN-sysvinit packages.

Ross

#15 lore raw
Quoted 8 lines · Ross
Quoted 1 line · Martin Jansa

ALTERNATIVE_${PN}-systemd = "systemd-def-target"

Let's not introduce packages controlled on distro features whose sole purpose is to contain a single file. systemd enabled -> units go into $PN.

Or, if we accept PN-systemd packages, then I expect to see PN-sysvinit packages.

I expect to see PN-sysvinit so we can void them ;-)

--
Otavio Salvador O.S. Systems
E-mail: [email protected] http://www.ossystems.com.br
Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br

#16 lore raw
In reply to Burton, Ross
Quoted 6 lines · Ross
Quoted 1 line · Martin Jansa

ALTERNATIVE_${PN}-systemd = "systemd-def-target"

Let's not introduce packages controlled on distro features whose sole purpose is to contain a single file. systemd enabled -> units go into $PN.

It's more than that: postinst and companions to auto enable/disable services.

Andreas

#17 lore raw
Quoted 8 lines · Andreas Müller
Quoted 6 lines · Ross
Quoted 1 line · Martin Jansa

ALTERNATIVE_${PN}-systemd = "systemd-def-target"

Let's not introduce packages controlled on distro features whose sole purpose is to contain a single file. systemd enabled -> units go into $PN.

It's more than that: postinst and companions to auto enable/disable services.

Which are controlled by a distribution feature, so have no need to be in a separate package.

Ross

#18 lore raw
In reply to Burton, Ross
Quoted 6 lines · Ross
Quoted 1 line · Martin Jansa

ALTERNATIVE_${PN}-systemd = "systemd-def-target"

Let's not introduce packages controlled on distro features whose sole purpose is to contain a single file. systemd enabled -> units go into $PN.

So I guess upgrade path from meta-systemd won't be ever provided (e.g. with RPROVIDES/RCONFLICTS/RREPLACES combo).

* check_data_file_clashes: Package dbus-1 wants to install file
* /lib/systemd/system/multi-user.target.wants/dbus.service But that file is already provided by package * dbus-systemd
* check_data_file_clashes: Package dbus-1 wants to install file
* /lib/systemd/system/dbus.socket
But that file is already provided by package * dbus-systemd
* check_data_file_clashes: Package dbus-1 wants to install file
* /lib/systemd/system/sockets.target.wants/dbus.socket But that file is already provided by package * dbus-systemd
* check_data_file_clashes: Package dbus-1 wants to install file
* /lib/systemd/system/dbus.target.wants/dbus.socket
But that file is already provided by package * dbus-systemd
* check_data_file_clashes: Package dbus-1 wants to install file
* /lib/systemd/system/dbus.service
But that file is already provided by package * dbus-systemd

Quoted 1 line

Or, if we accept PN-systemd packages, then I expect to see PN-sysvinit packages.

I wouldn't mind PN-sysvinit, PN-upstart, PN-openrc

It was easy to blacklist sysvinit scripts and then control which packages should have systemd support just by IMAGE_INSTALL.

Cheers,

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#19 lore raw
Quoted 2 lines · Martin Jansa

So I guess upgrade path from meta-systemd won't be ever provided (e.g. with RPROVIDES/RCONFLICTS/RREPLACES combo).

I'd prefer not too, but if we have to we can.

Quoted 1 line

I wouldn't mind PN-sysvinit, PN-upstart, PN-openrc

But what's the point when its a distro variable? With systemd daemons are actively making code changes instead of it merely being a different init file, so an image feature just won't work.

Ross

#20 lore raw
Quoted 11 lines · Ross
Quoted 2 lines · Martin Jansa

So I guess upgrade path from meta-systemd won't be ever provided (e.g. with RPROVIDES/RCONFLICTS/RREPLACES combo).

I'd prefer not too, but if we have to we can.

Quoted 1 line

I wouldn't mind PN-sysvinit, PN-upstart, PN-openrc

But what's the point when its a distro variable? With systemd daemons are actively making code changes instead of it merely being a different init file, so an image feature just won't work.

to control which packages should have systemd support just by IMAGE_INSTALL.

With latest systemd.bbclass you can still install them but not enable them by default, but even after SYSTEMD_AUTO_RRECOMMENDS was introduced I prefered to turn that off and control what I want in images (or install from feed).

Imagine situation when someone wants ntpd package just for ocassional manual sync, but someone else wants to pull ntpd to image together with systemd .service file to make sure his device is always using right time.

Cheers,

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]