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 <jpiotrowski@microsoft.com>
This commit is contained in:
Jeremi Piotrowski 2023-10-04 17:43:44 +02:00
parent 4156bd97d2
commit b9cd26658a

View File

@ -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
}