blob: d6701d5f2a8eb128456b351b3fb3bc0261b966eb [file] [log] [blame] [edit]
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Distributed under the terms of the GNU General Public License v2.
# This package installs a kernel module loadpin-trigger.ko and configures
# OS to load the module on boot. The kernel module calls
# kernel_read_file_from_path to load a dummy file into kernel, which will
# trigger loadpin. We used to rely on loading kernel modules to pin to
# rootfs, but the recent kernel param loadpin.exclude=kernel-module we added
# makes loadpin ignore module loading.
EAPI=7
inherit cos-linux-mod gmec-kernel-finder
DESCRIPTION="Kernel module to trigger loadpin on boot"
LICENSE="GPL-2"
SLOT="vanilla"
KEYWORDS="*"
DEPEND="virtual/linux-sources"
RDEPEND="
${DEPEND}
"
S="${WORKDIR}"
# modulename(libdir:srcdir:objdir)
export MODULE_NAMES="loadpin_trigger(::)"
pkg_setup() {
# We cannot rely on auto detection because we have two kernels installed.
KERNEL_DIR="$(find-gmec-kernel-source-tree)"
KBUILD_OUTPUT="${KERNEL_DIR}/build"
linux-mod_pkg_setup
}
src_prepare() {
cp "${FILESDIR}"/* .
cos-linux-mod_src_prepare
}
src_compile() {
cros_allow_gnu_build_tools
export BUILD_PARAMS="KDIR=${KBUILD_OUTPUT} MO=${S}/"
cos-linux-mod_src_compile
}
src_install() {
cos-linux-mod_src_install
# Install a dummy file to /etc. The file will be read by
# loadpin-trigger so that rootfs will be pinned.
if [[ ! -e /etc/loadpin_trigger ]]; then
insinto /etc
newins "${FILESDIR}"/loadpin_trigger_dummy loadpin_trigger
fi
}