diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2020-01-10 18:10:08 +0100 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2020-01-11 20:54:40 +0100 |
commit | da5a5fa797a5fffa6c4d694cbfe2edc83bab4890 (patch) | |
tree | af1d957fe64ad52eab51ec50f1d65d5ed21477d8 | |
parent | Rework ZFS unlock (diff) | |
download | genkernel-da5a5fa797a5fffa6c4d694cbfe2edc83bab4890.tar.gz genkernel-da5a5fa797a5fffa6c4d694cbfe2edc83bab4890.tar.bz2 genkernel-da5a5fa797a5fffa6c4d694cbfe2edc83bab4890.zip |
--module-rebuild: Call emerge with --ignore-default-opts
It's possible that user has set conflicting emerge options like
"--ask" in EMERGE_DEFAULT_OPTS which could break genkernel.
Calling emerge with --ignore-default-opts will allow us to
avoid such scenarios.
In addition, --module-rebuild-cmd (MODULEREBUILD_CMD) option was
added to allow user to alter default command.
Closes: https://bugs.gentoo.org/705082
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rw-r--r-- | defaults/config.sh | 2 | ||||
-rw-r--r-- | doc/genkernel.8.txt | 15 | ||||
-rwxr-xr-x | gen_cmdline.sh | 6 | ||||
-rwxr-xr-x | gen_compile.sh | 18 | ||||
-rwxr-xr-x | gen_determineargs.sh | 12 |
5 files changed, 39 insertions, 14 deletions
diff --git a/defaults/config.sh b/defaults/config.sh index d9ea32c..678c0f9 100644 --- a/defaults/config.sh +++ b/defaults/config.sh @@ -34,6 +34,8 @@ DEFAULT_COMPRESS_INITRD_TYPE=best PORTAGE_MAKEOPTS="$(portageq envvar MAKEOPTS)" DEFAULT_MAKEOPTS="${PORTAGE_MAKEOPTS:- -j2}" +DEFAULT_MODULEREBUILD_CMD="emerge --ignore-default-opts --quiet @module-rebuild" + DEFAULT_KERNEL_MAKE=make DEFAULT_UTILS_MAKE=make diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt index 6c4c155..e9076a4 100644 --- a/doc/genkernel.8.txt +++ b/doc/genkernel.8.txt @@ -196,10 +196,17 @@ specified. Copies or does not copy all kernel modules to the initrd. *--*[*no-*]*module-rebuild*:: - Runs, or does not run "emerge @module-rebuild" to build out-of-tree - modules when possible, i.e. when non-static kernel and modules will be - build, installed, no custom INSTALL_MOD_PATH is set, - '/var/lib/module-rebuild/moduledb' exists and is not empty. + Runs, or does not run "emerge --ignore-default-opts --quiet @module-rebuild" + to build out-of-tree modules when possible, i.e. when non-static + kernel and modules will be build, installed, no custom + 'INSTALL_MOD_PATH' is set, '/var/lib/module-rebuild/moduledb' exists + and is not empty. + +NOTE: Command can be customized using '--module-rebuild-cmd' command-line +argument or 'MODULEREBUILD_CMD' in '/etc/genkernel.conf'. + +*--module-rebuild-cmd*=<...>:: + Overwrite default *--module-rebuild* command. *--callback*=<...>:: Run the specified arguments in the current environment after the diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 025187f..db9c1f8 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -65,6 +65,8 @@ longusage() { echo " --module-rebuild Automatically run 'emerge @module-rebuild' when" echo " necessary (and possible)" echo " --no-module-rebuild Don't automatically run 'emerge @module-rebuild'" + echo " --module-rebuild-cmd=<...>" + echo " Overwrite default --module-rebuild command" echo " --callback=<...> Run the specified arguments after the" echo " kernel and modules have been compiled" echo " --static Build a static (monolithic kernel)" @@ -606,6 +608,10 @@ parse_cmdline() { CMD_MODULEREBUILD=$(parse_optbool "$*") print_info 3 "CMD_MODULEREBUILD: ${CMD_MODULEREBUILD}" ;; + --module-rebuild-cmd=*) + CMD_MODULEREBUILD_CMD="${*#--module-rebuild-cmd=}" + print_info 3 "CMD_MODULEREBUILD_CMD: ${CMD_MODULEREBUILD_CMD}" + ;; --callback=*) CMD_CALLBACK="${*#*=}" print_info 3 "CMD_CALLBACK: ${CMD_CALLBACK}/$*" diff --git a/gen_compile.sh b/gen_compile.sh index 3f10adb..3b96f48 100755 --- a/gen_compile.sh +++ b/gen_compile.sh @@ -2,53 +2,51 @@ # $Id$ compile_external_modules() { - local command="emerge --quiet @module-rebuild 2>&1" - if ! isTrue "${CMD_MODULEREBUILD}" then - print_info 3 "$(get_indent 1)>> --no-module-rebuild set; Skipping 'emerge @module-rebuild' ..." + print_info 3 "$(get_indent 1)>> --no-module-rebuild set; Skipping '${MODULEREBUILD_CMD}' ..." return fi if isTrue "$(tc-is-cross-compiler)" then - print_info 3 "$(get_indent 1)>> Cross-compilation detected; Skipping 'emerge @module-rebuild' ..." + print_info 3 "$(get_indent 1)>> Cross-compilation detected; Skipping '${MODULEREBUILD_CMD}' ..." return fi if ! isTrue "${CMD_INSTALL}" then - print_info 3 "$(get_indent 1)>> --no-install set; Skipping 'emerge @module-rebuild' ..." + print_info 3 "$(get_indent 1)>> --no-install set; Skipping '${MODULEREBUILD_CMD}' ..." return fi if [ -n "${INSTALL_MOD_PATH}" ] then # emerge would install to a different location - print_warning 1 "$(get_indent 1)>> INSTALL_MOD_PATH set; Skipping 'emerge @module-rebuild' ..." + print_warning 1 "$(get_indent 1)>> INSTALL_MOD_PATH set; Skipping '${MODULEREBUILD_CMD}' ..." return fi local modulesdb_file="/var/lib/module-rebuild/moduledb" if [ ! -s "${modulesdb_file}" ] then - print_info 2 "$(get_indent 1)>> '${modulesdb_file}' does not exist or is empty; Skipping 'emerge @module-rebuild' ..." + print_info 2 "$(get_indent 1)>> '${modulesdb_file}' does not exist or is empty; Skipping '${MODULEREBUILD_CMD}' ..." return fi local -x KV_OUT_DIR="${KERNEL_OUTPUTDIR}" print_info 1 "$(get_indent 1)>> Compiling out-of-tree module(s) ..." - print_info 3 "COMMAND: ${command}" 1 0 1 + print_info 3 "COMMAND: ${MODULEREBUILD_CMD}" 1 0 1 if [ "${LOGLEVEL}" -gt 3 ] then # Output to stdout and logfile - eval ${command} | tee -a "${LOGFILE}" + eval ${MODULEREBUILD_CMD} 2>&1 | tee -a "${LOGFILE}" RET=${PIPESTATUS[0]} else # Output to logfile only - eval ${command} >> "${LOGFILE}" + eval ${MODULEREBUILD_CMD} 2>&1 >> "${LOGFILE}" RET=$? fi diff --git a/gen_determineargs.sh b/gen_determineargs.sh index 616f4fe..61521d6 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -317,6 +317,7 @@ determine_real_args() { set_config_with_override STRING MINKERNPACKAGE CMD_MINKERNPACKAGE set_config_with_override STRING MODULESPACKAGE CMD_MODULESPACKAGE set_config_with_override BOOL MODULEREBUILD CMD_MODULEREBUILD "yes" + set_config_with_override STRING MODULEREBUILD_CMD CMD_MODULEREBUILD_CMD "${DEFAULT_MODULEREBUILD_CMD}" set_config_with_override STRING KERNCACHE CMD_KERNCACHE set_config_with_override BOOL RAMDISKMODULES CMD_RAMDISKMODULES "yes" set_config_with_override BOOL ALLRAMDISKMODULES CMD_ALLRAMDISKMODULES "no" @@ -781,6 +782,17 @@ determine_real_args() { # Kernel Makefile doesn't support spaces in outputdir path... gen_die "--kernel-outputdir '${KERNEL_OUTPUTDIR}' contains space character(s) which are not supported!" fi + + if isTrue "${CMD_MODULEREBUILD}" + then + if [ -z "${MODULEREBUILD_CMD}" ] + then + gen_die "--module-rebuild-cmd cannot be empty when --module-rebuild is set!" + elif [[ "${MODULEREBUILD_CMD}" == *[\$\&\|\>\(\)]* ]] + then + gen_die "--module-rebuild-cmd '${MODULEREBUILD_CMD}' contains at least one of the following disallowed characters: '\$&|>()'!" + fi + fi fi if isTrue "${BUILD_RAMDISK}" |