Add copyright information. Optimise comments.

This commit is contained in:
inference 2022-06-15 14:11:00 +01:00
parent c050dd4fc2
commit d64a512d84

View File

@ -1,26 +1,31 @@
# This hook is neccesary for automatic updating of the cfg-update index, please do not modify it! # Portage bashrc
# Copyright 2022 Inference
# This hook is necessary for automatic updating of the cfg-update index.
pre_pkg_setup() { pre_pkg_setup() {
[[ $ROOT = / ]] && cfg-update --index [[ $ROOT = / ]] && cfg-update --index
} }
function pre_pkg_preinst() { function pre_pkg_preinst() {
# This hook signs any out-of-tree kernel modules. # Sign out-of-tree kernel modules.
if [[ "$(type -t linux-mod_pkg_preinst)" != "function" ]]; then if [[ "$(type -t linux-mod_pkg_preinst)" != "function" ]]; then
# The package does not seem to install any kernel modules. # The package does not seem to install any kernel modules.
return return
fi fi
# Get the signature algorithm used by the kernel. # Get signature algorithm used by the kernel.
local module_sig_hash="$(grep -Po '(?<=CONFIG_MODULE_SIG_HASH=").*(?=")' "${KERNEL_DIR}/.config")" local module_sig_hash="$(grep -Po '(?<=CONFIG_MODULE_SIG_HASH=").*(?=")' "${KERNEL_DIR}/.config")"
# Get the key file used by the kernel. # Get the key file used by the kernel.
local module_sig_key="$(grep -Po '(?<=CONFIG_MODULE_SIG_KEY=").*(?=")' "${KERNEL_DIR}/.config")" local module_sig_key="$(grep -Po '(?<=CONFIG_MODULE_SIG_KEY=").*(?=")' "${KERNEL_DIR}/.config")"
module_sig_key="${module_sig_key:-certs/signing_key.pem}" module_sig_key="${module_sig_key:-certs/signing_key.pem}"
# Path to the key file or PKCS11 URI # Key file or PKCS11 URI path.
if [[ "${module_sig_key#pkcs11:}" == "${module_sig_key}" && "${module_sig_key#/}" == "${module_sig_key}" ]]; then if [[ "${module_sig_key#pkcs11:}" == "${module_sig_key}" && "${module_sig_key#/}" == "${module_sig_key}" ]]; then
local key_path="${KERNEL_DIR}/${module_sig_key}" local key_path="${KERNEL_DIR}/${module_sig_key}"
else else
local key_path="${module_sig_key}" local key_path="${module_sig_key}"
fi fi
# Certificate path # Certificate path.
local cert_path="${KERNEL_DIR}/certs/signing_key.x509" local cert_path="${KERNEL_DIR}/certs/signing_key.x509"
# Sign all installed modules before merging. # Sign all installed modules before merging.
find "${D%/}/${INSDESTTREE#/}/" -name "*.ko" -exec "${KERNEL_DIR}/scripts/sign-file" "${module_sig_hash}" "${key_path}" "${cert_path}" '{}' \; find "${D%/}/${INSDESTTREE#/}/" -name "*.ko" -exec "${KERNEL_DIR}/scripts/sign-file" "${module_sig_hash}" "${key_path}" "${cert_path}" '{}' \;