systemd: rework network.service installation
PATCH 1/1 systemd: rework network.service installation
The installation of the network.service file is now performed via the <pkg>_INIT_SYSTEMD mechanism instead of an installation hook.
--- package/systemd/systemd.mk | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
package/systemd/systemd.mk +11 -12
@@ -101,6 +101,13 @@ ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),y) SYSTEMD_CONF_OPT += --enable-networkd else SYSTEMD_CONF_OPT += --disable-networkd +define SYSTEMD_INSTALL_SERVICE_NETWORK + $(INSTALL) -D -m 644 package/systemd/network.service \ + $(TARGET_DIR)/etc/systemd/system/network.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + ln -fs ../network.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/network.service +endef endif ifeq ($(BR2_PACKAGE_SYSTEMD_TIMESYNCD),y)
@@ -145,28 +152,20 @@ define SYSTEMD_SANITIZE_PATH_IN_UNITS -exec $(SED) 's,$(HOST_DIR),,g' {} \; endef -define SYSTEMD_INSTALL_NETWORK_HOOK - $(INSTALL) -D -m 644 package/systemd/network.service \ - $(TARGET_DIR)/etc/systemd/system/network.service - mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants - ln -fs ../network.service \ - $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/network.service -endef - SYSTEMD_POST_INSTALL_TARGET_HOOKS += \ SYSTEMD_INSTALL_INIT_HOOK \ SYSTEMD_INSTALL_TTY_HOOK \ SYSTEMD_INSTALL_MACHINEID_HOOK \ SYSTEMD_SANITIZE_PATH_IN_UNITS -ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),) -SYSTEMD_POST_INSTALL_TARGET_HOOKS += SYSTEMD_INSTALL_NETWORK_HOOK -endif - define SYSTEMD_USERS systemd-journal -1 systemd-journal -1 * /var/log/journal - - Journal systemd-journal-gateway -1 systemd-journal-gateway -1 * /var/log/journal - - Journal Gateway $(SYSTEMD_USER_TIMESYNC) endef +define SYSTEMD_INSTALL_INIT_SYSTEMD + $(SYSTEMD_INSTALL_SERVICE_NETWORK) +endef + $(eval $(autotools-package))
Signature · 1 line
1.9.3
PATCH 1/1 systemd: rework network.service installation
Eric, All,
On 2014-06-16 22:52 +0200, Eric Le Bihan spake thusly:
Quoted 2 lines
The installation of the network.service file is now performed via the <pkg>_INIT_SYSTEMD mechanism instead of an installation hook.
Would mind also switching the other hooks over to use _INIT_SYSTEMD while you are at it? ;-)
Quoted 10 lines
Signed-off-by Eric Le Bihan <[email protected]>--- package/systemd/systemd.mk | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)package/systemd/systemd.mk +0
-0
package/systemd/systemd.mk ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),y) · line 110
Quoted 10 lines
package/systemd/systemd.mk +7
-0@@ -101,6 +101,13 @@ ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),y) SYSTEMD_CONF_OPT += --enable-networkd else SYSTEMD_CONF_OPT += --disable-networkd +define SYSTEMD_INSTALL_SERVICE_NETWORK + $(INSTALL) -D -m 644 package/systemd/network.service \ + $(TARGET_DIR)/etc/systemd/system/network.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + ln -fs ../network.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/network.service +endef
So, if networkd is disabled, you still install the network units?
Should that block not go in the non-else part of the condition instead?
Regards,
Yann E. MORIN.
Quoted 43 lines
package/systemd/systemd.mk +4
-12endif ifeq ($(BR2_PACKAGE_SYSTEMD_TIMESYNCD),y)@@ -145,28 +152,20 @@ define SYSTEMD_SANITIZE_PATH_IN_UNITS -exec $(SED) 's,$(HOST_DIR),,g' {} \; endef -define SYSTEMD_INSTALL_NETWORK_HOOK - $(INSTALL) -D -m 644 package/systemd/network.service \ - $(TARGET_DIR)/etc/systemd/system/network.service - mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants - ln -fs ../network.service \ - $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/network.service -endef - SYSTEMD_POST_INSTALL_TARGET_HOOKS += \ SYSTEMD_INSTALL_INIT_HOOK \ SYSTEMD_INSTALL_TTY_HOOK \ SYSTEMD_INSTALL_MACHINEID_HOOK \ SYSTEMD_SANITIZE_PATH_IN_UNITS -ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),) -SYSTEMD_POST_INSTALL_TARGET_HOOKS += SYSTEMD_INSTALL_NETWORK_HOOK -endif - define SYSTEMD_USERS systemd-journal -1 systemd-journal -1 * /var/log/journal - - Journal systemd-journal-gateway -1 systemd-journal-gateway -1 * /var/log/journal - - Journal Gateway $(SYSTEMD_USER_TIMESYNC) endef +define SYSTEMD_INSTALL_INIT_SYSTEMD + $(SYSTEMD_INSTALL_SERVICE_NETWORK) +endef + $(eval $(autotools-package))Signature · 6 lines
1.9.3 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 systemd: rework network.service installation
Quoted 8 lines · Yann E. MORIN
Eric, All,
On 2014-06-16 22:52 +0200, Eric Le Bihan spake thusly:
Quoted 2 lines
The installation of the network.service file is now performed via the <pkg>_INIT_SYSTEMD mechanism instead of an installation hook.
Would mind also switching the other hooks over to use
_INIT_SYSTEMDwhile you are at it? ;-)
I thought _INIT_SYSTEMD was for installing services only, as was _INIT_SYSV, so IMHO only SYSTEMD_INSTALL_TTY_HOOK could be converted to SYSTEMD_INSTALL_SERVICE_TTY. The other installation hooks are real clean up operations, not services.
Quoted 23 lines
Quoted 10 lines
Signed-off-by Eric Le Bihan <[email protected]>--- package/systemd/systemd.mk | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)package/systemd/systemd.mk +0
-0package/systemd/systemd.mk ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),y) · line 110
Quoted 10 lines
package/systemd/systemd.mk +7
-0@@ -101,6 +101,13 @@ ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),y) SYSTEMD_CONF_OPT += --enable-networkd else SYSTEMD_CONF_OPT += --disable-networkd +define SYSTEMD_INSTALL_SERVICE_NETWORK + $(INSTALL) -D -m 644 package/systemd/network.service \ + $(TARGET_DIR)/etc/systemd/system/network.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + ln -fs ../network.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/network.service +endefSo, if networkd is disabled, you still install the network units?
Quoted 1 line
Should that block not go in the non-else part of the condition instead?
No, because systemd-networkd and network.service are mutually exclusive solutions for managing the network.
When systemd is compiled with systemd-networkd support, another service (systemd-networkd.service, of course) is installed and enabled. This is a recent addition to systemd (v212).
The patch provided by Ivan dates from v44 and provides an alternative to systemd-networkd, based on ifupdown (as /etc/init.d/S40network).
If systemd-networkd is selected, I chose not to install network.service to avoid confusing the end user, who will have only one way to manage the network.
Perhaps I should also make BR2_PACKAGE_SYSTEMD_NETWORKD depends on !BR2_PACKAGE_NETWORK_MANAGER as systemd-networkd and NetworKManager both manages the network. But they do not play in the same category, and it looks like the developpers of NetworKManager are trying to make them coexist in peace [1].
Best regards,
ELB
[1] https://www.mail-archive.com/systemd-devel at lists.freedesktop.org/msg18419.html