blob: cce0ede420eafc407b9daa4055dd0821e7801593 [file] [log] [blame]
#
# Copyright 2022 Google LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
EAPI="7"
inherit linux-mod
DESCRIPTION="XEMU is a fast emulation device for Linux. It provides the ability to create and manipulate address spaces, and switch execution into those address spaces."
HOMEPAGE="https://github.com/google/gvisor"
XEMU_TAR_FILE=xemu-${PV}.tar.gz
SRC_URI="gs://chromeos-localmirror/distfiles/${XEMU_TAR_FILE}
-> ${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="*"
IUSE=""
RESTRICT="mirror"
DEPEND="virtual/linux-sources"
RDEPEND="${DEPEND}"
# Because our kernel version string ends with '+' (e.g. # "4.4.70+"), Gentoo
# Linux's linux-info.eclass cannot locate the kernel build output directory.
KBUILD_OUTPUT=${KERNEL_DIR}/build
S="${WORKDIR}"
# modulename(libdir:srcdir:objdir)
MODULE_NAMES="xemu(kernel/drivers/xemu:${S}:${S})"
src_compile() {
cros_allow_gnu_build_tools
LIBELF="$("${CBUILD}-pkg-config" libelf --libs 2> /dev/null || echo -lelf)"
BUILD_PARAMS="HOST_LIBELF_LIBS=${LIBELF} CONFIG_XEMU=m CC=${CC}"
BUILD_PARAMS+=" -C ${KBUILD_OUTPUT} M=${S}"
BUILD_TARGETS="modules"
linux-mod_src_compile
}
src_install() {
# Sign the module first.
MODULE_OBJECT=xemu.ko
cp ${MODULE_OBJECT} ${MODULE_OBJECT}.orig
"${KBUILD_OUTPUT}"/scripts/sign-file \
sha256 \
"${KBUILD_OUTPUT}"/certs/signing_key.pem \
"${KBUILD_OUTPUT}"/certs/signing_key.x509 \
${MODULE_OBJECT}
# Do not strip the signature.
dostrip -x /lib/modules/"${KV_FULL}"/kernel/drivers/xemu/${MODULE_OBJECT}
linux-mod_src_install
insinto /etc/modules-load.d
#doins "${FILESDIR}"/xemu.conf
}