From c8506749a7873cecdce64a6ffcf34ef66cbcaa41 Mon Sep 17 00:00:00 2001 From: inference Date: Tue, 24 Jan 2023 09:06:28 +0000 Subject: [PATCH] Add file purpose. Switch license from BSD-3-Clause-Clear to GPL-3.0-or-later. --- portage/bashrc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 portage/bashrc diff --git a/portage/bashrc b/portage/bashrc new file mode 100644 index 0000000..8811e64 --- /dev/null +++ b/portage/bashrc @@ -0,0 +1,36 @@ +# Inferencium +# Portage - bashrc + +# Copyright 2022-2023 Inference +# SPDX-License-Identifier: GPL-3.0-or-later + +# Version: 1.0.0.2 + + +# Automatically update cfg-update index. +pre_pkg_setup() { + [[ $ROOT = / ]] && cfg-update --index +} + +function pre_pkg_preinst() { + # Sign out-of-tree kernel modules. + if [[ "$(type -t linux-mod_pkg_preinst)" != "function" ]]; then + # The package does not seem to install any kernel modules. + return + fi + # Get signature algorithm used by the kernel. + local module_sig_hash="$(grep -Po '(?<=CONFIG_MODULE_SIG_HASH=").*(?=")' "${KERNEL_DIR}/.config")" + # Get the key file used by the kernel. + local module_sig_key="$(grep -Po '(?<=CONFIG_MODULE_SIG_KEY=").*(?=")' "${KERNEL_DIR}/.config")" + module_sig_key="${module_sig_key:-certs/signing_key.pem}" + # Key file or PKCS11 URI path. + if [[ "${module_sig_key#pkcs11:}" == "${module_sig_key}" && "${module_sig_key#/}" == "${module_sig_key}" ]]; then + local key_path="${KERNEL_DIR}/${module_sig_key}" + else + local key_path="${module_sig_key}" + fi + # Certificate path. + local cert_path="${KERNEL_DIR}/certs/signing_key.x509" + # Sign all installed modules before merging. + find "${D%/}/${INSDESTTREE#/}/" -name "*.ko" -exec "${KERNEL_DIR}/scripts/sign-file" "${module_sig_hash}" "${key_path}" "${cert_path}" '{}' \; +}