blob: 2a94d5332fc589c0592cdac4348471c7666fd421 [file] [log] [blame]
# 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
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 "${ROOT}/usr/src" -maxdepth 1 -name "lakitu-kernel-[0-9]*")"
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}"
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
}