| # 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=6 |
| 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}" |
| |
| # Prevent kernel module signature being striped. |
| STRIP_MASK+=" *.ko" |
| |
| MODULE_NAME="loadpin_trigger" |
| |
| pkg_setup() { |
| MODULE_NAMES="${MODULE_NAME}(::)" |
| # 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 |
| BUILD_PARAMS="KERNEL_SOURCES=${KV_DIR} KBUILD_OUTPUT=${KBUILD_OUTPUT}" |
| } |
| |
| src_prepare() { |
| cp "${FILESDIR}"/* . |
| cos-linux-mod_src_prepare |
| } |
| |
| src_compile() { |
| cros_allow_gnu_build_tools |
| 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 |
| } |