[Buildroot] [PATCH 3/3] package/ifupdown-scripts: add openrc support

Yann E. MORIN yann.morin.1998 at free.fr
Wed Mar 11 21:15:35 UTC 2020


CarloS< All,

On 2020-03-08 23:50 -0300, unixmania at gmail.com spake thusly:
> From: Carlos Santos <unixmania at gmail.com>
> 
> The "network" script allows configuring an interface by means of two
> /etc/ifup.<if_name> and /etc/ifdown.<if_name> files with the commands
> required to bring it up and down, respectively. So we can support the
> BR2_SYSTEM_DHCP config if netifrc is not selected.
> 
> - Replace the dependency on !BR2_PACKAGE_OPENRC in Config.in by a
>   dependency on !BR2_PACKAGE_NETIFRC.
> 
> - Add an IFUPDOWN_SCRIPTS_PREAMBLE macro to create an empty interfaces
>   file.

I've split that to its own patch. Thus, the patch adding openrc support
is smaller and more self-contained.

Thanks for your work on OpenRC, it's nice to see someone taking care of
it :-) Now, if we could have even more runtime test of it (network,
etc..) that would be even better! ;-]

Regards,
Yann E. MORIN.

> - Make the IFUPDOWN_SCRIPTS_LOCALHOST macro append the "lo" setup to the
>   interfaces file.
> 
> - Add an IFUPDOWN_SCRIPTS_DHCP_OPENRC macro to create the ifup.<if_name>
>   and ifdown.<if_name> files.
> 
> - Add an IFUPDOWN_SCRIPTS_INSTALL_INIT_OPENRC hook that includes the
>   IFUPDOWN_SCRIPTS_{PREAMBLE,DHCP,DHCP_OPENRC} macros. LOCALHOST is not
>   required, since "lo" is configured by the "loopback" script.
> 
> Signed-off-by: Carlos Santos <unixmania at gmail.com>
> ---
>  package/ifupdown-scripts/Config.in           |  2 +-
>  package/ifupdown-scripts/ifupdown-scripts.mk | 22 ++++++++++++++++++--
>  2 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/package/ifupdown-scripts/Config.in b/package/ifupdown-scripts/Config.in
> index 4b984bc30c..166094c511 100644
> --- a/package/ifupdown-scripts/Config.in
> +++ b/package/ifupdown-scripts/Config.in
> @@ -1,7 +1,7 @@
>  config BR2_PACKAGE_IFUPDOWN_SCRIPTS
>  	bool "ifupdown scripts"
>  	default y if BR2_ROOTFS_SKELETON_DEFAULT
> -	depends on !BR2_PACKAGE_SYSTEMD_NETWORKD && !BR2_PACKAGE_OPENRC
> +	depends on !BR2_PACKAGE_SYSTEMD_NETWORKD && !BR2_PACKAGE_NETIFRC
>  	help
>  	  Set of scripts used by ifupdown (either the standalone one,
>  	  or the busybox one) to bring network up, or tear it down.
> diff --git a/package/ifupdown-scripts/ifupdown-scripts.mk b/package/ifupdown-scripts/ifupdown-scripts.mk
> index 16fef783dd..5ef032142c 100644
> --- a/package/ifupdown-scripts/ifupdown-scripts.mk
> +++ b/package/ifupdown-scripts/ifupdown-scripts.mk
> @@ -4,13 +4,17 @@
>  #
>  ################################################################################
>  
> +define IFUPDOWN_SCRIPTS_PREAMBLE
> +	echo "# interface file auto-generated by buildroot" \
> +		> $(TARGET_DIR)/etc/network/interfaces
> +endef
> +
>  define IFUPDOWN_SCRIPTS_LOCALHOST
>  	( \
> -		echo "# interface file auto-generated by buildroot"; \
>  		echo ; \
>  		echo "auto lo"; \
>  		echo "iface lo inet loopback"; \
> -	) > $(TARGET_DIR)/etc/network/interfaces
> +	) >> $(TARGET_DIR)/etc/network/interfaces
>  endef
>  
>  IFUPDOWN_SCRIPTS_DHCP_IFACE = $(call qstrip,$(BR2_SYSTEM_DHCP))
> @@ -26,6 +30,12 @@ define IFUPDOWN_SCRIPTS_DHCP
>  		echo "  hostname \$$(hostname)"; \
>  	) >> $(TARGET_DIR)/etc/network/interfaces
>  endef
> +define IFUPDOWN_SCRIPTS_DHCP_OPENRC
> +	echo "ifup $(IFUPDOWN_SCRIPTS_DHCP_IFACE)" \
> +		> $(TARGET_DIR)/etc/ifup.$(IFUPDOWN_SCRIPTS_DHCP_IFACE)
> +	echo "ifdown $(IFUPDOWN_SCRIPTS_DHCP_IFACE)" \
> +		> $(TARGET_DIR)/etc/ifdown.$(IFUPDOWN_SCRIPTS_DHCP_IFACE)
> +endef
>  endif
>  
>  define IFUPDOWN_SCRIPTS_INSTALL_TARGET_CMDS
> @@ -34,9 +44,16 @@ define IFUPDOWN_SCRIPTS_INSTALL_TARGET_CMDS
>  	$(call SYSTEM_RSYNC,$(IFUPDOWN_SCRIPTS_PKGDIR)/network,$(TARGET_DIR)/etc/network)
>  endef
>  
> +define IFUPDOWN_SCRIPTS_INSTALL_INIT_OPENRC
> +	$(IFUPDOWN_SCRIPTS_PREAMBLE)
> +	$(IFUPDOWN_SCRIPTS_DHCP)
> +	$(IFUPDOWN_SCRIPTS_DHCP_OPENRC)
> +endef
> +
>  define IFUPDOWN_SCRIPTS_INSTALL_INIT_SYSV
>  	$(INSTALL) -D -m 0755 $(IFUPDOWN_SCRIPTS_PKGDIR)/S40network \
>  		$(TARGET_DIR)/etc/init.d/S40network
> +	$(IFUPDOWN_SCRIPTS_PREAMBLE)
>  	$(IFUPDOWN_SCRIPTS_LOCALHOST)
>  	$(IFUPDOWN_SCRIPTS_DHCP)
>  endef
> @@ -47,6 +64,7 @@ endef
>  define IFUPDOWN_SCRIPTS_INSTALL_INIT_SYSTEMD
>  	$(INSTALL) -D -m 644 $(IFUPDOWN_SCRIPTS_PKGDIR)/network.service \
>  		$(TARGET_DIR)/etc/systemd/system/network.service
> +	$(IFUPDOWN_SCRIPTS_PREAMBLE)
>  	$(IFUPDOWN_SCRIPTS_LOCALHOST)
>  	$(IFUPDOWN_SCRIPTS_DHCP)
>  endef
> -- 
> 2.18.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'


More information about the buildroot mailing list