Skip to contentSkip to conversation

package/dhcp: add host-gawk to dependencies and build environment

PATCH Superseded Sergey Matyukevich 2 participants 3 messages Feb 14, 2021 – May 20, 2021

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/dhcp: add host-gawk to dependencies and build environment

DHCP package may silently fail to install binaries to the target image. The problem occurs when buildroot configuration and build host provide different flavors of awk. For instance, mawk on build host and gawk in buildroot output/host. In this case isc-dhcp configure script detects gawk in output/host and generates Makefiles specifying gawk without absolute path. During Buildroot installation phase, those Makefiles are used to install dhcp binaries. They attempt to use gawk without absolute path. However build host does not have gawk.

To resolve the issue add host-gawk to the list of dhcp dependencies and explicitely specify absolute path to host-gawk.

---

Changes v1 -> v2 (after review and tests by Thomas Petazzoni):
- suggested change is the same
- root cause is figured out and commit message updated

The root cause is explained in commit message. Here are the steps to reproduce the issue.

Buildroot Docker image at support/docker/Dockerfile provides a way to reproduce the issue. This docker image includes mawk. Each of the following cases starts from default qemu_x86_defconfig:

1. Keep using uclibc, enable isc-dhcp server and client Buildroot does not have any awk flavor installed in output/host, so mawk from build host is used. Build dhcp. The result is ok: both dhclient and dhcpd are installed on the target.

2. Switch to glibc, enable isc-dhcp server and client
Note that glibc package has host-gawk among its dependencies. So in this case build host awk (mawk) differs from buildroot host awk (gawk). Build dhcp. The result is not ok: neither dhclient nor dhcpd are installed to the target.

Regards,
Sergey

 package/dhcp/dhcp.mk | 3 +++
 1 file changed, 3 insertions(+)
package/dhcp/dhcp.mk +3 -0
index 988c7792dc..4a9e98485c 100644
@@ -10,6 +10,7 @@ DHCP_INSTALL_STAGING = YES
 DHCP_LICENSE = MPL-2.0
 DHCP_LICENSE_FILES = LICENSE
 DHCP_DEPENDENCIES = bind
+DHCP_DEPENDENCIES = bind host-gawk
 DHCP_CPE_ID_VENDOR = isc
 
 # use libtool-enabled configure.ac
@@ -22,6 +23,8 @@ DHCP_CONF_ENV = \
 		-D_PATH_DHCLIENT_CONF=\"/etc/dhcp/dhclient.conf\"' \
 	CFLAGS='$(TARGET_CFLAGS) -DISC_CHECK_NONE=1'
 
+DHCP_CONF_ENV += ac_cv_prog_AWK=$(HOST_DIR)/bin/gawk
+
 DHCP_CONF_OPTS = \
 	--with-libbind=$(STAGING_DIR)/usr \
 	--with-randomdev=/dev/random \
Signature · 1 line
2.30.1
#1 lore raw

PATCH v2 1/1 package/dhcp: add host-gawk to dependencies and build environment

Quoted 9 lines · Sergey Matyukevich

DHCP package may silently fail to install binaries to the target image. The problem occurs when buildroot configuration and build host provide different flavors of awk. For instance, mawk on build host and gawk in buildroot output/host. In this case isc-dhcp configure script detects gawk in output/host and generates Makefiles specifying gawk without absolute path. During Buildroot installation phase, those Makefiles are used to install dhcp binaries. They attempt to use gawk without absolute path. However build host does not have gawk.

Quoted 4 lines

To resolve the issue add host-gawk to the list of dhcp dependencies and explicitely specify absolute path to host-gawk.

Heiko recently posted a patch that does the same thing, and I applied that one
because it only adds the dependency when the server is enabled (client doesn't need gawk).

Thanks!

Regards,
Arnout

Quoted 52 lines

---

Changes v1 -> v2 (after review and tests by Thomas Petazzoni):
- suggested change is the same
- root cause is figured out and commit message updated

The root cause is explained in commit message. Here are the steps to reproduce the issue.

Buildroot Docker image at support/docker/Dockerfile provides a way to reproduce the issue. This docker image includes mawk. Each of the following cases starts from default qemu_x86_defconfig:

1. Keep using uclibc, enable isc-dhcp server and client Buildroot does not have any awk flavor installed in output/host, so mawk from build host is used. Build dhcp. The result is ok: both dhclient and dhcpd are installed on the target.

2. Switch to glibc, enable isc-dhcp server and client
Note that glibc package has host-gawk among its dependencies. So in this case build host awk (mawk) differs from buildroot host awk (gawk). Build dhcp. The result is not ok: neither dhclient nor dhcpd are installed to the target.

Regards,
Sergey

 package/dhcp/dhcp.mk | 3 +++
 1 file changed, 3 insertions(+)
package/dhcp/dhcp.mk +3 -0
index 988c7792dc..4a9e98485c 100644
@@ -10,6 +10,7 @@ DHCP_INSTALL_STAGING = YES
 DHCP_LICENSE = MPL-2.0
 DHCP_LICENSE_FILES = LICENSE
 DHCP_DEPENDENCIES = bind
+DHCP_DEPENDENCIES = bind host-gawk
 DHCP_CPE_ID_VENDOR = isc
 
 # use libtool-enabled configure.ac
@@ -22,6 +23,8 @@ DHCP_CONF_ENV = \
 		-D_PATH_DHCLIENT_CONF=\"/etc/dhcp/dhclient.conf\"' \
 	CFLAGS='$(TARGET_CFLAGS) -DISC_CHECK_NONE=1'
 
+DHCP_CONF_ENV += ac_cv_prog_AWK=$(HOST_DIR)/bin/gawk
+
 DHCP_CONF_OPTS = \
 	--with-libbind=$(STAGING_DIR)/usr \
 	--with-randomdev=/dev/random \
#2 lore raw

PATCH v2 1/1 package/dhcp: add host-gawk to dependencies and build environment

Hello Arnout,

Quoted 9 lines
Quoted 9 lines

DHCP package may silently fail to install binaries to the target image. The problem occurs when buildroot configuration and build host provide different flavors of awk. For instance, mawk on build host and gawk in buildroot output/host. In this case isc-dhcp configure script detects gawk in output/host and generates Makefiles specifying gawk without absolute path. During Buildroot installation phase, those Makefiles are used to install dhcp binaries. They attempt to use gawk without absolute path. However build host does not have gawk.

Quoted 8 lines
Quoted 4 lines

To resolve the issue add host-gawk to the list of dhcp dependencies and explicitely specify absolute path to host-gawk.

Heiko recently posted a patch that does the same thing, and I applied that one
because it only adds the dependency when the server is enabled (client doesn't need gawk).

I did some build tests in support/docker/Dockerfile image. It turns out that the patch suggested by Heiko is not enough. It adds host-gawk to dependencies, but it does not set explicit path to this gawk in dhcp configuration scripts. As a result, the same issue can be reproduced immediately even with uclibc. The build test is as follows:
- use docker builder image described in support/docker/Dockerfile -- note that this image provides mawk flavor
- start from default qemu_x86_defconfig
- enable both isc-dhcp client and server

As a result, neighter dhclient nor dhcpd are installed into output/target. Previously, before the applied patch, the issue could be reproduced only with glibc which pulled host-gawk dependency. Besides, unless I missed something in my tests, dhclient installation is also impacted, so host-gawk should be added globally.

I will update my patch and send v3.

Regards,
Sergey