[Buildroot] [PATCH] Allow a single DHCP configuration via the system configuration submenu

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Wed Dec 17 20:29:00 UTC 2014


Dear Jérémy Rosen,

On Wed, 17 Dec 2014 17:15:46 +0100, Jérémy Rosen wrote:

>  support/scripts/generate-network-config.sh | 24 ++++++++++++++++++++++++

Do we really need a helper script to do this?

NETWORK_IFACES = $(TARGET_DIR)/etc/network/interfaces
NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SIMPLE_DHCP_INTERFACE))

define NETWORK_ADD_DHCP_INTERFACE
	echo "auto $(NETWORK_DHCP_IFACE)" >> $(NETWORK_IFACES)
	echo "iface $(NETWORK_DHCP_IFACE) inet dhcp" >> $(NETWORK_IFACES)
endef

define NETWORK_CREATE_IFACES_FILE
	rm -f $(NETWORK_IFACES)
	echo "auto lo" >> $(NETWORK_IFACES)
	echo "iface lo inet loopback" >> $(NETWORK_IFACES)
	$(NETWORK_ADD_DHCP_INTERFACE)
endef

TARGET_FINALIZE_HOOKS += NETWORK_CREATE_IFACES_FILE

> +config BR2_SIMPLE_DHCP
> +	bool "automatic network configuration via DHCP"
> +	default n
> +	depends on !BR2_PACKAGE_SYSTEMD_NETWORKD
> +	help
> +	  Automatically do a DHCP request on startup on selected interface at 
> +	  startup. For more complicated setups use an overlay.
> +
> +comment "automatic network configuration via DHCP is not compatible with networkd"
> +	depends on BR2_PACKAGE_SYSTEMD_NETWORKD
> +
> +config BR2_SIMPLE_DHCP_INTERFACE
> +	string "name of the physical network interface to run DHCP on"
> +	depends on BR2_SIMPLE_DHCP
> +	default eth0
> +	help
> +	  The name of the network interface to configure automatically

Why two options? Just make the BR2_SIMPLE_DHCP_INTERFACE empty by
default (does nothing), and when non-empty, used as the DHCP network
interface.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com



More information about the buildroot mailing list