From 36c97b8220c87423b9b379074902aa4757c73b7b Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Tue, 17 Jan 2023 04:14:46 +0100 Subject: [PATCH] armbian-next: extensions: rename `kernel-localmodconfig` to just `lsmod` - rename `KERNEL_CONFIG_FROM_LSMOD` to just `LSMOD` too - default `LSMOD` to `${BOARD}` - and make it "better" --- extensions/kernel-localmodconfig.sh | 21 --------------------- extensions/lsmod.sh | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 extensions/kernel-localmodconfig.sh create mode 100644 extensions/lsmod.sh diff --git a/extensions/kernel-localmodconfig.sh b/extensions/kernel-localmodconfig.sh deleted file mode 100644 index 4700a646a4..0000000000 --- a/extensions/kernel-localmodconfig.sh +++ /dev/null @@ -1,21 +0,0 @@ -function extension_prepare_config__prepare_localmodconfig() { - # If defined, ${KERNEL_CONFIG_FROM_LSMOD} can contain a lsmod to apply to the kernel configuration. - # to get a file for this run 'lsmod > my_machine.lsmod' and then put it in userpatches/lsmod/ - export KERNEL_CONFIG_FROM_LSMOD="${KERNEL_CONFIG_FROM_LSMOD:-}" - display_alert "localmodconfig INIT lsmod" "${KERNEL_CONFIG_FROM_LSMOD}" "warn" - - # If there, make sure it exists - local lsmod_file="${SRC}/userpatches/lsmod/${KERNEL_CONFIG_FROM_LSMOD}.lsmod" - if [[ ! -f "${lsmod_file}" ]]; then - exit_with_error "Can't find lsmod file ${lsmod_file}, configure with KERNEL_CONFIG_FROM_LSMOD=xxx" - fi -} - -# This needs much more love than this. can be used to make "light" versions of kernels, that compile 3x-5x faster or more -function custom_kernel_config_post_defconfig__apply_localmodconfig() { - if [[ "a${KERNEL_CONFIG_FROM_LSMOD}a" != "aa" ]]; then - display_alert "localmodconfig with lsmod" "${KERNEL_CONFIG_FROM_LSMOD}" "warn" - local lsmod_file="${SRC}/userpatches/lsmod/${KERNEL_CONFIG_FROM_LSMOD}.lsmod" - run_kernel_make "LSMOD=${lsmod_file}" localmodconfig "> /dev/null" # hide output, it's way too long. stderr still shows - fi -} diff --git a/extensions/lsmod.sh b/extensions/lsmod.sh new file mode 100644 index 0000000000..07cb096c7b --- /dev/null +++ b/extensions/lsmod.sh @@ -0,0 +1,23 @@ +function extension_prepare_config__prepare_localmodconfig() { + # If defined, ${LSMOD} can contain a lsmod to apply to the kernel configuration. + # to get a file for this run 'lsmod > my_machine.lsmod' and then put it in userpatches/lsmod/ + declare -g -r LSMOD="${LSMOD:-"${BOARD}"}" # default to the board name + display_alert "${EXTENSION}: lsmod enabled" "${LSMOD}" "warn" + + # If there, make sure it exists + declare -g -r lsmod_file="${SRC}/userpatches/lsmod/${LSMOD}.lsmod" + if [[ ! -f "${lsmod_file}" ]]; then + exit_with_error "Can't find lsmod file ${lsmod_file}, create it by running lsmod on target HW or configure with LSMOD=xxx" + fi +} + +# This needs much more love than this. can be used to make "light" versions of kernels, that compile 3x-5x faster or more +function custom_kernel_config_post_defconfig__apply_localmodconfig() { + if [[ -f "${lsmod_file}" ]]; then + display_alert "${EXTENSION}: running localmodconfig on Kernel tree" "${LSMOD}" "warn" + run_kernel_make "LSMOD=${lsmod_file}" localmodconfig "> /dev/null" # quoted redirect to hide output even from logfile, it's way too long. stderr still shows + else + display_alert "${EXTENSION}: lsmod file disappeared?" "${lsmod_file}" "err" + return 1 # exit with an error; this is not what the user expected + fi +}