package/netifrc: add support for BR2_SYSTEM_DHCP
authorMichał Łyszczek <michal.lyszczek@bofc.pl>
Sun, 4 Aug 2019 12:14:19 +0000 (14:14 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Mon, 23 Sep 2019 20:57:04 +0000 (22:57 +0200)
This patch makes openrc-netifrc package aware of BR2_SYSTEM_DHCP
config, and if set, will start dhcp daemon on configured interface.

Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
[yann.morin.1998@free.fr:
  - simplify condition for BR2_SYSTEM_DHCP
  - reword commit log
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/netifrc/netifrc.mk
system/Config.in

index 5dc262230b9de72202689457a31d0295b23e3eca..d13dc356f3d80b199bcfdf7b9df686972646e225 100644 (file)
@@ -32,8 +32,19 @@ define NETIFRC_REMOVE_UDEV
 endef
 endif # BR2_PACKAGE_HAS_UDEV
 
+NETIFRC_DHCP_IFACE = $(call qstrip,$(BR2_SYSTEM_DHCP))
+ifneq ($(NETIFRC_DHCP_IFACE),)
+NETIFRC_DHCP_CFG = config_$(NETIFRC_DHCP_IFACE)="dhcp"
+define NETIFRC_DHCP_SERVICE
+       ln -sf net.lo $(TARGET_DIR)/etc/init.d/net.$(NETIFRC_DHCP_IFACE)
+       ln -sf /etc/init.d/net.$(NETIFRC_DHCP_IFACE) \
+               $(TARGET_DIR)/etc/runlevels/default/net.$(NETIFRC_DHCP_IFACE)
+endef
+endif # BR2_SYSTEM_DHCP != ""
+
 define NETIFRC_NET_CFG
        config_lo="127.0.0.1/8"
+       $(NETIFRC_DHCP_CFG)
 endef
 
 define NETIFRC_INSTALL_TARGET_CMDS
@@ -41,6 +52,7 @@ define NETIFRC_INSTALL_TARGET_CMDS
        $(NETIFRC_REMOVE_UDEV)
        $(call PRINTF,$(NETIFRC_NET_CFG)) > $(TARGET_DIR)/etc/conf.d/net
        ln -sf /etc/init.d/net.lo $(TARGET_DIR)/etc/runlevels/default/net.lo
+       $(NETIFRC_DHCP_SERVICE)
 endef
 
 $(eval $(generic-package))
index 1bfe069b2e968de163fac294ca66804e0bd76444..c87266f4318e4a7d7d406f1eaaa45f35cb368a33 100644 (file)
@@ -377,7 +377,8 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 config BR2_SYSTEM_DHCP
        string "Network interface to configure through DHCP"
        default ""
-       depends on BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN || BR2_PACKAGE_SYSTEMD_NETWORKD
+       depends on BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN || \
+               BR2_PACKAGE_SYSTEMD_NETWORKD || BR2_PACKAGE_NETIFRC
        help
          Enter here the name of the network interface (E.G. eth0) to
          automatically configure through DHCP at bootup.
@@ -388,8 +389,9 @@ config BR2_SYSTEM_DHCP
          overwrite /etc/network/interfaces or add a networkd
          configuration file.
 
-comment "automatic network configuration via DHCP needs ifupdown or busybox or networkd"
-       depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN || BR2_PACKAGE_SYSTEMD_NETWORKD)
+comment "automatic network configuration via DHCP needs ifupdown or busybox or networkd or netifrc"
+       depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN || \
+               BR2_PACKAGE_SYSTEMD_NETWORKD || BR2_PACKAGE_NETIFRC)
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT