[Buildroot] [PATCH v2] Allow a single DHCP configuration via the system configuration submenu
Thomas Petazzoni
thomas.petazzoni at free-electrons.com
Fri Jan 2 15:24:55 UTC 2015
Dear Jérémy Rosen,
On Fri, 2 Jan 2015 16:06:02 +0100, Jérémy Rosen wrote:
> +define SIMPLE_NETWORK
> + mkdir -p $(TARGET_DIR)/etc/network/
> +
> + echo "# interface file auto-generated by buildroot" > $(TARGET_DIR)/etc/network/interfaces
> + echo >> $(TARGET_DIR)/etc/network/interfaces
> + echo "auto lo" >> $(TARGET_DIR)/etc/network/interfaces
> + echo "iface lo inet loopback" >> $(TARGET_DIR)/etc/network/interfaces
> + echo >> $(TARGET_DIR)/etc/network/interfaces
> +
> + if [ -n "$(BR2_SIMPLE_DHCP)" ] ; then \
> + echo "auto $(BR2_SIMPLE_DHCP)" >> $(TARGET_DIR)/etc/network/interfaces ; \
> + echo "iface $(BR2_SIMPLE_DHCP) inet dhcp" >> $(TARGET_DIR)/etc/network/interfaces ; \
> + fi
Can we use make instead of the shell for this condition? Also,
BR_SIMPLE_DHCP has some double quotes, so you probably want to use
qstrip. Something like:
define SET_NETWORK_LOCALHOST
echo "# interface file auto-generated by buildroot" > $(TARGET_DIR)/etc/network/interfaces
echo >> $(TARGET_DIR)/etc/network/interfaces
echo "auto lo" >> $(TARGET_DIR)/etc/network/interfaces
echo "iface lo inet loopback" >> $(TARGET_DIR)/etc/network/interfaces
echo >> $(TARGET_DIR)/etc/network/interfaces
endef
NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SIMPLE_DHCP))
ifneq ($(NETWORK_DHCP_IFACE),)
define SET_NETWORK_DHCP
echo "auto $(NETWORK_DHCP_IFACE)" >> $(TARGET_DIR)/etc/network/interfaces
echo "iface $(NETWORK_DHCP_IFACE) inet dhcp" >> $(TARGET_DIR)/etc/network/interfaces
endef
endif
define SET_NETWORK
mkdir -p $(TARGET_DIR)/etc/network/
$(SET_NETWORK_LOCALHOST)
$(SET_NETWORK_DHCP)
endef
TARGET_FINALIZE_HOOKS += SET_NETWORK
It would be good to avoid the repeated redirects to
$(TARGET_DIR)/etc/network/interfaces, but I don't immediately see an
elegant way of doing that.
Thanks,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
More information about the buildroot
mailing list