blob: 0bea03249ad514467eb6a7f77331d79ae06f92b1 [file] [log] [blame]
#
# Copyright 2024 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
CROS_WORKON_COMMIT="d73be6b341a42c313a617f487dbaeeea9aece079"
CROS_WORKON_TREE="922021fc5978c2c5444d45726df6a74d4d5d9edc"
CROS_WORKON_REPO="https://cos.googlesource.com"
CROS_WORKON_PROJECT="third_party/kernel"
CROS_WORKON_LOCALNAME="kernel/v6.1"
# This must be inherited *after* EGIT/CROS_WORKON variables defined
inherit cros-workon cros-kernel2
# Copied verbatim from the lakitu-kernel ebuild.
cos_kernel_config_arch() {
case ${ARCH} in
amd64) echo "x86";;
arm64) echo "arm64";;
*) die "Unknown architecture: ${ARCH}";;
esac
}
STRIP_MASK+=" /usr/src/${P}/build/vmlinux"
STRIP_MASK+=" *.ko"
DESCRIPTION="A dump capture kernel for kdump functionality"
HOMEPAGE="https://cloud.google.com/container-optimized-os"
KEYWORDS="*"
# shellcheck disable=SC2154
CHROMEOS_KERNEL_CONFIG="arch/$(cos_kernel_config_arch)/configs/lakitu_dump_defconfig"
src_prepare() {
default
# This has the same behavior as cos-kernel_src_prepare.
cros_allow_gnu_build_tools
cros-kernel2_src_prepare
}
# Use stripped-down version of cros-kernel2 configure routine
# to avoid dragging in all fragments enabled by USE flags.
src_configure() {
# Combination of two lines from cros-kernel2_src_configure
local config="${CHROMEOS_KERNEL_CONFIG}"
# All lines below taken verbatim from cros-kernel2_src_configure
local build_cfg="$(get_build_cfg)"
elog "Using kernel config: ${config}"
cp -f "${config}" "${build_cfg}" || die
local old_defconfig="$(cros-workon_get_build_dir)/cros-old-defconfig"
kmake olddefconfig
cp -a "${build_cfg}" "${old_defconfig}" || die
}
src_install() {
dodir /boot/kdump
kmake INSTALL_PATH="${D}/boot/kdump" INSTALL_MOD_PATH="${D}" \
INSTALL_MOD_STRIP=1 install
local version
version=$(kmake -s --no-print-directory kernelrelease)
ln -sf "vmlinuz-${version}" "${D}/boot/kdump/vmlinuz" || die
# We also strips the symbol table /boot/kdump/System.map-* at:
# overlay-lakitu/scripts/board_specific_setup.sh
}