diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2021-09-09 02:16:42 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2021-09-09 02:59:03 +0200 |
commit | 153a877d333d3b85920267535aef950056c92192 (patch) | |
tree | 49f00909f104fac428d1b69f4215bae7c55ab7b9 /gen_funcs.sh | |
parent | initrd.scripts: don't skip top level devices with partitions (diff) | |
download | genkernel-153a877d333d3b85920267535aef950056c92192.tar.gz genkernel-153a877d333d3b85920267535aef950056c92192.tar.bz2 genkernel-153a877d333d3b85920267535aef950056c92192.zip |
Refactor (compressed) kernel module handling
To support a specific module compression algorithm, two things are needed:
Used depmod utility on host system building the kernel must support chosen
module compression algorithm to generate proper modules.dep file or
genkernel would be unable to read module dependencies when copying modules
to initramfs.
At runtime, used modprobe utility must be able to handle chosen module
compression algorithm or modules would be unloadable.
To address the first requirement, genkernel will now check if used kmod
utility on host system supports chosen module compression algorithm.
To address the runtime requirement, this commit will switch from BusyBox's
modutils implementation to kmod because BusyBox does not support ZSTD
compression (yet).
Bug: https://bugs.gentoo.org/809344
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'gen_funcs.sh')
-rwxr-xr-x | gen_funcs.sh | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/gen_funcs.sh b/gen_funcs.sh index d40607c7..6bc59e64 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -287,6 +287,48 @@ is_psf_file() { echo "${file_is_psf}" } +is_kext_supported_by_kmod() { + [[ ${#} -ne 1 ]] \ + && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!" + + local requested_feature=${1} + requested_feature=${requested_feature##*.} + requested_feature=${requested_feature^^} + + local is_supported=no + + if [[ "${requested_feature}" == GZ ]] + then + requested_feature=ZLIB + elif [[ "${requested_feature}" == ZST ]] + then + requested_feature=ZSTD + fi + + case "${requested_feature}" in + KO) + is_supported=yes + ;; + *) + local line + while read line; do + if [[ ! ${line} =~ ^[\+\-] ]] + then + continue + fi + + if [[ ${line} =~ \+${requested_feature} ]] + then + is_supported=yes + break + fi + done < <("${KMOD_CMD}" -V) + ;; + esac + + echo "${is_supported}" +} + is_valid_ssh_host_keys_parameter_value() { local parameter_value=${1} @@ -2123,6 +2165,36 @@ make_bootdir_writable() { fi } +get_kext_kmod_use_flag() { + [[ ${#} -ne 1 ]] \ + && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!" + + local kext=${1} + kext=${kext##*.} + kext=${kext^^} + + local use_flag= + + case "${kext}" in + GZ) + use_flag="zlib" + ;; + KO) + ;; + XZ) + use_flag="lzma" + ;; + ZST) + use_flag="zstd" + ;; + *) + gen_die "$(get_useful_function_stack)Internal error: KEXT '${kext}' is unknown!" + ;; + esac + + echo "${use_flag}" +} + # @FUNCTION: get_nproc # @USAGE: [${fallback:-1}] # @DESCRIPTION: |