From b9cd26658ab887b24ecb1a92e802bf414ea7437d Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Wed, 4 Oct 2023 17:43:44 +0200 Subject: [PATCH] net-misc/ena-driver: Allow installing as kernel builtin This change installs the module sources and symlinks the module into the kernel tree for building together in-tree kernel modules. This replaces the ena driver in the kernel which is an older version (2.1.0) as far as reported version goes. This is required for the module to be correctly signed for secure boot. Signed-off-by: Jeremi Piotrowski --- .../ena-driver/ena-driver-2.9.1.ebuild | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/sdk_container/src/third_party/coreos-overlay/net-misc/ena-driver/ena-driver-2.9.1.ebuild b/sdk_container/src/third_party/coreos-overlay/net-misc/ena-driver/ena-driver-2.9.1.ebuild index eb8ed95258..64758602b6 100644 --- a/sdk_container/src/third_party/coreos-overlay/net-misc/ena-driver/ena-driver-2.9.1.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/net-misc/ena-driver/ena-driver-2.9.1.ebuild @@ -12,8 +12,13 @@ SRC_URI="https://github.com/amzn/amzn-drivers/archive/ena_linux_${PV}.tar.gz -> LICENSE="GPL-2" SLOT="0" KEYWORDS="~amd64 ~arm64" +IUSE="+builtin" BDEPEND="app-arch/unzip" +DEPEND="builtin? ( sys-kernel/coreos-sources:= ) + !!>${CATEGORY}/${PF} + !!<${CATEGORY}/${PF} +" S="${WORKDIR}/amzn-drivers-ena_linux_${PV}/kernel/linux/ena" @@ -24,8 +29,53 @@ DOCS=( ENA_Linux_Best_Practices.rst ) +pkg_setup() { + if use builtin; then + return + fi + linux-mod-r1_pkg_setup +} + src_compile() { + if use builtin; then + return + fi local modlist=( ena=net ) - local modargs=( CONFIG_MODULE_SIG=n BUILD_KERNEL="${KV_FULL}" ) + local modargs=( CONFIG_MODULE_SIG=n KERNEL_BUILD_DIR="${KV_OUT_DIR}" ) linux-mod-r1_src_compile } + +src_install() { + if use builtin; then + sed -i \ + -e 's|ENA_COM_PATH=.*|ENA_COM_PATH=ena_com|' \ + -e 's|$(src)|$(srctree)/$(src)|' Makefile + dodir /usr/src + insinto /usr/src/"${PF}" + doins -r "." + + insinto /usr/src/"${PF}"/ena_com + doins -r "../common/ena_com/." + + return + fi + linux-mod-r1_src_install +} + +pkg_postinst() { + if use builtin; then + mv ${EROOT}/usr/src/linux/drivers/net/ethernet/amazon/{ena,ena.orig} + ln -s ../../../../../"${PF}" ${EROOT}/usr/src/linux/drivers/net/ethernet/amazon/ena + return + fi + linux-mod-r1_pkg_postinst +} + +pkg_postrm() { + if use builtin; then + rm -f ${EROOT}/usr/src/linux/drivers/net/ethernet/amazon/ena + mv ${EROOT}/usr/src/linux/drivers/net/ethernet/amazon/{ena.orig,ena} + return + fi + linux-mod-r1_pkg_postrm +}