From be485eaaefab1dfdcad6f2a9dbbcb1db1c3d49e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 12 Jun 2026 21:12:59 +0200 Subject: [PATCH] sys-kernel/gentoo-kernel-modprep: Use a repacked image tarball MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- sys-kernel/gentoo-kernel-modprep/Manifest | 1 + .../gentoo-kernel-modprep-7.0.12-r1.ebuild | 175 ++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 sys-kernel/gentoo-kernel-modprep/gentoo-kernel-modprep-7.0.12-r1.ebuild diff --git a/sys-kernel/gentoo-kernel-modprep/Manifest b/sys-kernel/gentoo-kernel-modprep/Manifest index 90b4333e6e2df..bc5fcbda6d847 100644 --- a/sys-kernel/gentoo-kernel-modprep/Manifest +++ b/sys-kernel/gentoo-kernel-modprep/Manifest @@ -10,6 +10,7 @@ DIST gentoo-kernel-7.0.12-1.amd64.gpkg.tar 355604480 BLAKE2B 9352700a48792dc64ff DIST gentoo-kernel-7.0.12-1.arm64.gpkg.tar 326850560 BLAKE2B 169cd5df5af911d1da1dda53b7f2d1d9c8862cb40f9c655a385202d0dbd3359499364468e7ae087e917eb1a95868d05e91b8c7444a315ad88c31d304cab94c2d SHA512 215ea31a3ff452947fa8e396d929983df8a67f3e8f3f23a2c03cb27a345446485c0dcc7686ea5e43d6acc37f238bfd0887de26f61793c73ace0e402d4ef3bb90 DIST gentoo-kernel-7.0.12-1.ppc64le.gpkg.tar 78663680 BLAKE2B 5ba2b7fbcff4ecf717534bdbf83a4c6db5d698dee69bd79d2436127a23d4c91f61498be94b3369a5b74694ed7f125216e823fcd5edfca7aa73e04722f708bec8 SHA512 8afaf3401cfb4f694e7eed06c873ddc51313f4789107bb8a28c027082ee4f7e8df37c8931549ac2607486f8f3d66fb59d84483534b837bf0a9f73921167fe743 DIST gentoo-kernel-7.0.12-1.x86.gpkg.tar 85555200 BLAKE2B ad9fd7d11b9966e5a4470ef585b4e7cf3ed636a11953ccac538d5adc285b5e6dafa21ad2d0325b251cd0fdcb555ebf517251df757120f6d656d9a39bfd17bc3d SHA512 15ceb2aff05cba13492929189fcd03dd17cd411bedfc65e80fb4ba2b6d66517b294242ed50a9a196b6b806ecc2032e0c9a0fae2190944540d936575dafd57f82 +DIST gentoo-kernel-modprep-7.0.12.tar.xz 10081604 BLAKE2B 99202299290b1f4bd66282d4ef9b0ed2202b5aaf028065992987d973b8c3349365c104b81225ebeaf310d0997739c1defbcf38e58991d1f13ab520f94a2a3c1e SHA512 fe579542d3b7055195632f5798943222a1e3e2d0351491f526c4fe842cbfabe3473da95d9d95f4273d75724f60ecd6f6acc3a8ee5549a876cb81625803ae3164 DIST linux-7.0.tar.xz 157143652 BLAKE2B 3d9795083c8938f80f480de0d10bfd9c525640e59d5c7f22983de3f12ee42c84c31be902cafb05579ddb1c32bac5ed06b0d4953f9705450be185bd2d9ab08f89 SHA512 8c85b708342f8f09ca25b2234b22e93b62b144a9ef919fbb21827f52fa47498e778c79db1559524dd7fb360f95b2ce174171443c1859656c281be41d2b6c5a0b DIST linux-7.x-sha256sums-20260523.asc 4541 BLAKE2B 17062ee8e93d4c81aa8adf1952650462d097229a76991873b42867a122bab9e5b33502a98a5df8c6ab52031601f3bcef6c82f50a86e0dcf1e1b680fff3ad2280 SHA512 3fd12772887ccf7b568ad641467fc9bfc29ea590e826e59f4c426cd11280fa7871e4b61f091d6bc3780d13e095c6b4b450fb5356606d32d70d4e985ee9832a64 DIST linux-7.x-sha256sums-20260601.asc 4878 BLAKE2B 1a08d3eecaa37ab2f2aa10801025c214fa919c0842ba24d9bc9a555d10c64ac87bc8afb99c37c94ae65a1e73b408257d8483cef590ce55f80e438ef374ffe4cf SHA512 6c650dbc9d58cb42aef6b2bcd418dd20fb608a4f449f4300c78d8427d35a732227f5c6bc79a4d4c4e6975698b0cbd1c64488a89d59cdd0f8da8912dcee6a9e6e diff --git a/sys-kernel/gentoo-kernel-modprep/gentoo-kernel-modprep-7.0.12-r1.ebuild b/sys-kernel/gentoo-kernel-modprep/gentoo-kernel-modprep-7.0.12-r1.ebuild new file mode 100644 index 0000000000000..c3e564edc324f --- /dev/null +++ b/sys-kernel/gentoo-kernel-modprep/gentoo-kernel-modprep-7.0.12-r1.ebuild @@ -0,0 +1,175 @@ +# Copyright 2020-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit dist-kernel-utils toolchain-funcs verify-sig + +BASE_P=linux-${PV%.*} +PATCH_PV=${PV%_p*} +PATCHSET=linux-gentoo-patches-${PV} +SHA256SUM_DATE=20260609 + +DESCRIPTION="Minimal subset of gentoo-kernel-bin for building modules, for containers" +HOMEPAGE=" + https://wiki.gentoo.org/wiki/Project:Distribution_Kernel + https://www.kernel.org/ +" +SRC_URI+=" + https://cdn.kernel.org/pub/linux/kernel/v$(ver_cut 1).x/${BASE_P}.tar.xz + https://cdn.kernel.org/pub/linux/kernel/v$(ver_cut 1).x/patch-${PATCH_PV}.xz + https://distfiles.gentoo.org/pub/proj/dist-kernel/patchsets/$(ver_cut 1-2)/${PATCHSET}.tar.xz + https://distfiles.gentoo.org/pub/proj/dist-kernel/binpkg/modprep/$(ver_cut 1-2)/${P}.tar.xz + verify-sig? ( + https://cdn.kernel.org/pub/linux/kernel/v$(ver_cut 1).x/sha256sums.asc + -> linux-$(ver_cut 1).x-sha256sums-${SHA256SUM_DATE}.asc + ) +" +S=${WORKDIR} + +LICENSE="GPL-2" +SLOT=${PV} +KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86" + +RDEPEND=" + virtual/libelf + !sys-kernel/gentoo-kernel-bin:${SLOT} +" +BDEPEND=" + app-alternatives/bc + app-alternatives/lex + app-alternatives/yacc + dev-util/pahole + sys-libs/binutils-libs + virtual/libelf + verify-sig? ( >=sec-keys/openpgp-keys-kernel-20250702 ) +" + +KV_LOCALVERSION='-gentoo-dist-bin' +KV_FULL=${PV/_p/-p}${KV_LOCALVERSION} + +VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/kernel.org.asc + +src_unpack() { + if use verify-sig; then + cd "${DISTDIR}" || die + verify-sig_verify_signed_checksums \ + "linux-$(ver_cut 1).x-sha256sums-${SHA256SUM_DATE}.asc" \ + sha256 "${BASE_P}.tar.xz patch-${PATCH_PV}.xz" + cd "${WORKDIR}" || die + fi + + unpack "${BASE_P}.tar.xz" "patch-${PATCH_PV}.xz" "${PATCHSET}.tar.xz" + local pkg_arch=${ARCH} + [[ ${ARCH} == ppc64 ]] && pkg_arch=ppc64le + tar -x -f "${DISTDIR}/${P}.tar.xz" "${P}/${pkg_arch}" || die +} + +src_prepare() { + local patch + cd "${BASE_P}" || die + eapply "${WORKDIR}/patch-${PATCH_PV}" + eapply "${WORKDIR}/${PATCHSET}" + + default + + # add Gentoo patchset version + local extraversion=${PV#${PATCH_PV}} + sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${extraversion/_/-}:" Makefile || die +} + +src_configure() { + # force ld.bfd if we can find it easily + local HOSTLD="$(tc-getBUILD_LD)" + if type -P "${HOSTLD}.bfd" &>/dev/null; then + HOSTLD+=.bfd + fi + local LD="$(tc-getLD)" + if type -P "${LD}.bfd" &>/dev/null; then + LD+=.bfd + fi + tc-export_build_env + local makeargs=( + V=1 + WERROR=0 + + HOSTCC="$(tc-getBUILD_CC)" + HOSTCXX="$(tc-getBUILD_CXX)" + HOSTLD="${HOSTLD}" + HOSTAR="$(tc-getBUILD_AR)" + HOSTCFLAGS="${BUILD_CFLAGS}" + HOSTLDFLAGS="${BUILD_LDFLAGS}" + + CROSS_COMPILE=${CHOST}- + AS="$(tc-getAS)" + CC="$(tc-getCC)" + LD="${LD}" + AR="$(tc-getAR)" + NM="$(tc-getNM)" + STRIP="$(tc-getSTRIP)" + OBJCOPY="$(tc-getOBJCOPY)" + OBJDUMP="$(tc-getOBJDUMP)" + READELF="$(tc-getREADELF)" + + # we need to pass it to override colliding Gentoo envvar + ARCH="$(tc-arch-kernel)" + + O="${WORKDIR}"/modprep + ) + + local kernel_dir=( "${P}"/*/usr/src/"linux-${KV_FULL}" ) + + mkdir modprep || die + cp "${kernel_dir}/.config" modprep/ || die + emake -C "${BASE_P}" "${makeargs[@]}" modules_prepare +} + +src_install() { + local rel_kernel_dir=/usr/src/linux-${KV_FULL} + local pkg_dir=( "${P}"/* ) + local kernel_dir="${pkg_dir}/usr/src/linux-${KV_FULL}" + local image="${kernel_dir}/$(dist-kernel_get_image_path)" + local uki="${image%/*}/uki.efi" + + mv "${pkg_dir}"/lib "${ED}"/ || die + cd "${kernel_dir}" || die + insinto "${rel_kernel_dir}" + doins System.map Module.symvers + doins -r certs include scripts + + local kern_arch=$(tc-arch-kernel) + insinto "${rel_kernel_dir}/arch/${kern_arch}" + doins -r "arch/${kern_arch}/include" + + # Add the identifier + echo "${CATEGORY}/${PF}:${SLOT}" > "${ED}${rel_kernel_dir}/dist-kernel" || die + + cd "${WORKDIR}/${BASE_P}" || die + insinto "${rel_kernel_dir}" + doins -r include + + # remove everything but Makefile* and Kconfig* + find -type f '!' '(' -name 'Makefile*' -o -name 'Kconfig*' ')' \ + -delete || die + find -type l -delete || die + cp -p -R * "${ED}${rel_kernel_dir}/" || die + + # strip out-of-source build stuffs from modprep + # and then copy built files + cd "${WORKDIR}" || die + find modprep -type f '(' \ + -name Makefile -o \ + -name '*.[ao]' -o \ + '(' -name '.*' -a -not -name '.config' ')' \ + ')' -delete || die + rm modprep/source || die + cp -p -R modprep/. "${ED}${rel_kernel_dir}"/ || die +} + +pkg_preinst() { + dist-kernel_update_lib_symlinks +} + +pkg_postinst() { + dist-kernel_update_src_symlink "${EROOT}/usr/src/linux" "${KV_FULL}" +}