diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/coreos-kernel.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-kernel.eclass index 70b0c72c21..678800a401 100644 --- a/sdk_container/src/third_party/coreos-overlay/eclass/coreos-kernel.eclass +++ b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-kernel.eclass @@ -114,10 +114,10 @@ kmake() { fi # this can be removed once it is exported globally again export CCACHE_BASEDIR="${S}" - emake \ + emake "--directory=${S}/source" \ ARCH="${kernel_arch}" \ CROSS_COMPILE="${CHOST}-" \ - KBUILD_OUTPUT="build" \ + KBUILD_OUTPUT="../build" \ KCFLAGS="${kernel_cflags}" \ LDFLAGS="" \ "$@" @@ -131,9 +131,50 @@ shred_keys() { fi } +# Populate /lib/modules/$(uname -r)/{build,source} +prepare-lib-modules-release-dirs() { + # build and source must cleaned up to avoid referencing $ROOT + rm "${D}/usr/lib/modules/${version}"/{build,source} || die + + # XXX: For some reason tc-arch-kernel is returning x86_64 on > 2.6.24 + local kernel_arch=$(tc-arch-kernel) + if [ "${kernel_arch}" == "x86_64" ]; then + kernel_arch="x86" + fi + + # Install a stripped source for out-of-tree module builds (Debian-derived) + { + echo source/Makefile + find source/arch/${kernel_arch} -follow -maxdepth 1 -name 'Makefile*' -print + find source/arch/${kernel_arch} -follow \( -name 'module.lds' -o -name 'Kbuild.platforms' -o -name 'Platform' \) -print + find $(find source/arch/${kernel_arch} -follow \( -name include -o -name scripts \) -follow -type d -print) -print + find source/include source/scripts -follow -print + } | cpio -pd \ + --preserve-modification-time \ + --owner=root:root \ + --dereference \ + "${D}/usr/lib/modules/${version}" || die + + # Clean up the build tree and install for out-of-tree module builds + kmake clean + find "build/" -type d -empty -delete || die + rm --recursive \ + "build/bootengine.cpio" \ + "build/.config.old" \ + "build/certs" \ + || die + + find "build/" -print | cpio -pd \ + --preserve-modification-time \ + --owner=root:root \ + "${D}/usr/lib/modules/${version}" || die +} + coreos-kernel_src_unpack() { + # we more or less reproduce the layout in /lib/modules/$(uname -r)/ mkdir -p "${S}/build" || die - ln -s "${KERNEL_DIR}"/* "${S}/" || die + mkdir -p "${S}/source" || die + ln -s "${KERNEL_DIR}"/* "${S}/source/" || die } coreos-kernel_src_prepare() { @@ -211,16 +252,7 @@ coreos-kernel_src_install() { dosym "vmlinuz-${version}" /usr/boot/vmlinuz dosym "config-${version}" /usr/boot/config - # build and source must cleaned up to avoid referencing $ROOT - rm "${D}/usr/lib/modules/${version}"/{build,source} || die - dosym "../../../src/linux-${version}" "/usr/lib/modules/${version}/source" - - # this is just here for linux-info.eclass, mask from prod images - dodir "/usr/lib/modules/${version}/build" - dosym "../../../../boot/config-${version}" \ - "/usr/lib/modules/${version}/build/.config" - - save_config build/defconfig + prepare-lib-modules-release-dirs shred_keys } diff --git a/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-kernel/coreos-kernel-4.3.0-r1.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-kernel/coreos-kernel-4.3.0-r2.ebuild similarity index 86% rename from sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-kernel/coreos-kernel-4.3.0-r1.ebuild rename to sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-kernel/coreos-kernel-4.3.0-r2.ebuild index ad6f2587f5..4cdc6203e3 100644 --- a/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-kernel/coreos-kernel-4.3.0-r1.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-kernel/coreos-kernel-4.3.0-r2.ebuild @@ -2,7 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 EAPI=5 -COREOS_SOURCE_REVISION="" +COREOS_SOURCE_REVISION="-r1" inherit coreos-kernel DESCRIPTION="CoreOS Linux kernel" diff --git a/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/coreos-sources-4.3.0.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/coreos-sources-4.3.0-r1.ebuild similarity index 96% rename from sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/coreos-sources-4.3.0.ebuild rename to sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/coreos-sources-4.3.0-r1.ebuild index 2c76836baf..9c93e60e5d 100644 --- a/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/coreos-sources-4.3.0.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/coreos-sources-4.3.0-r1.ebuild @@ -37,5 +37,6 @@ UNIPATCH_LIST=" ${PATCH_DIR}/0019-net-wireless-wl18xx-Add-missing-MODULE_FIRMWARE.patch \ ${PATCH_DIR}/0020-overlayfs-use-a-minimal-buffer-in-ovl_copy_xattr.patch \ ${PATCH_DIR}/0021-net-switchdev-fix-return-code-of-fdb_dump-stub.patch \ + ${PATCH_DIR}/0022-kbuild-derive-relative-path-for-KBUILD_SRC-from-CURD.patch \ " diff --git a/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/files/4.3/0022-kbuild-derive-relative-path-for-KBUILD_SRC-from-CURD.patch b/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/files/4.3/0022-kbuild-derive-relative-path-for-KBUILD_SRC-from-CURD.patch new file mode 100644 index 0000000000..4474091a94 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-sources/files/4.3/0022-kbuild-derive-relative-path-for-KBUILD_SRC-from-CURD.patch @@ -0,0 +1,30 @@ +From 3348a15e9733c3ffb56ad7f9e9729a919f61eee9 Mon Sep 17 00:00:00 2001 +From: Vito Caputo +Date: Wed, 25 Nov 2015 02:59:45 -0800 +Subject: [PATCH 22/22] kbuild: derive relative path for KBUILD_SRC from CURDIR + +This enables relocating source and build trees to different roots, +provided they stay reachable relative to one another. Useful for +builds done within a sandbox where the eventual root is prefixed +by some undesirable path component. +--- + Makefile | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index d5b3739..f64d968 100644 +--- a/Makefile ++++ b/Makefile +@@ -143,7 +143,8 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make + @: + + sub-make: FORCE +- $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ ++ $(Q)$(MAKE) -C $(KBUILD_OUTPUT) \ ++ KBUILD_SRC=$(shell realpath --relative-to=$(KBUILD_OUTPUT) $(CURDIR)) \ + -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) + + # Leave processing to above invocation of make +-- +2.4.6 +