toolchain: generate check-headers program under $(BUILD_DIR)
authorCarlos Santos <unixmania@gmail.com>
Tue, 24 Sep 2019 11:46:11 +0000 (08:46 -0300)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Wed, 25 Sep 2019 20:07:24 +0000 (22:07 +0200)
Some installations mount /tmp with the 'noexec' option, which prevents
running the program generated there to check the kernel headers.

Avoid the problem by generating the program under $(BUILD_DIR), passed
as the first argument to check-kernel-headers.sh.

We could globally export a TMPDIR environment variable with some path
under $(BUILD_DIR) but such solution would be too intrusive, depriving
the user from the freedom to set TMPDIR at his will (or needs).

Fixes: https://bugs.busybox.net/show_bug.cgi?id=12241
Signed-off-by: Carlos Santos <unixmania@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/linux-headers/linux-headers.mk
support/scripts/check-kernel-headers.sh
toolchain/helpers.mk
toolchain/toolchain-external/pkg-toolchain-external.mk

index 46f270a0e1db4afcd87873e63a9587558d2f2218..676c8c44ea19003f7e2205531ccad4de49faedd7 100644 (file)
@@ -133,6 +133,7 @@ endef
 ifeq ($(BR2_KERNEL_HEADERS_VERSION)$(BR2_KERNEL_HEADERS_AS_KERNEL)$(BR2_KERNEL_HEADERS_CUSTOM_TARBALL)$(BR2_KERNEL_HEADERS_CUSTOM_GIT),y)
 define LINUX_HEADERS_CHECK_VERSION
        $(call check_kernel_headers_version,\
+               $(BUILD_DIR),\
                $(STAGING_DIR),\
                $(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)))
 endef
index a8cca78b275de310bd75a28509fcd4929cdd8075..a8b94f6a026e884d5b85f1d4c2a61c162035f9ea 100755 (executable)
@@ -1,14 +1,15 @@
 #!/bin/sh
 
-SYSROOT="${1}"
+BUILDDIR="${1}"
+SYSROOT="${2}"
 # Make sure we have enough version components
-HDR_VER="${2}.0.0"
+HDR_VER="${3}.0.0"
 
 HDR_M="${HDR_VER%%.*}"
 HDR_V="${HDR_VER#*.}"
 HDR_m="${HDR_V%%.*}"
 
-EXEC="$(mktemp -check-headers.XXXXXX)"
+EXEC="$(mktemp -p "${BUILDDIR}" -t .check-headers.XXXXXX)"
 
 # We do not want to account for the patch-level, since headers are
 # not supposed to change for different patchlevels, so we mask it out.
index 86d945a5b185eff7802936ab60a429951bfb5271..6a4f7223c82d9152cacde6b80495222c1c48d367 100644 (file)
@@ -158,13 +158,12 @@ copy_toolchain_sysroot = \
 # Check the specified kernel headers version actually matches the
 # version in the toolchain.
 #
-# $1: sysroot directory
-# $2: kernel version string, in the form: X.Y
+# $1: build directory
+# $2: sysroot directory
+# $3: kernel version string, in the form: X.Y
 #
 check_kernel_headers_version = \
-       if ! support/scripts/check-kernel-headers.sh $(1) $(2); then \
-               exit 1; \
-       fi
+       support/scripts/check-kernel-headers.sh $(1) $(2) $(3)
 
 #
 # Check the specific gcc version actually matches the version in the
index c3ddff263fe90aff3b19d6ba46e5a2f3ace12c98..c00211d59ca77e65e38411a7261c52b8e1250d68 100644 (file)
@@ -531,6 +531,7 @@ define $(2)_CONFIGURE_CMDS
        $$(Q)$$(call check_unusable_toolchain,$$(TOOLCHAIN_EXTERNAL_CC))
        $$(Q)SYSROOT_DIR="$$(call toolchain_find_sysroot,$$(TOOLCHAIN_EXTERNAL_CC))" ; \
        $$(call check_kernel_headers_version,\
+               $$(BUILD_DIR)\
                $$(call toolchain_find_sysroot,$$(TOOLCHAIN_EXTERNAL_CC)),\
                $$(call qstrip,$$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))); \
        $$(call check_gcc_version,$$(TOOLCHAIN_EXTERNAL_CC),\