commit: 66be1d9d8f1fc241de0e8d033f616735e5cb5d1e
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 29 04:03:57 2019 +0000
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Fri Mar 29 04:13:05 2019 +0000
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=66be1d9d
Add special value "default" for --kernel-config parameter
--kernel-config=default will make genkernel to ignoring all user
kernel configurations so that genkernel will use default kernel
configuration shipped with genkernel to build a kernel.
Useful to start from scratch if needed or for debugging.
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
doc/genkernel.8.txt | 4 +++-
gen_cmdline.sh | 5 ++++-
gen_configkernel.sh | 38 +++++++++++++++++++++++++++-----------
3 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 04633cf..15d5454 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -181,11 +181,13 @@ KERNEL LOCATIONS
This specifies the location of the kernel sources; the default
is '/usr/src/linux'.
-*--kernel-config*=<file>::
+*--kernel-config*=<file|default>::
This specifies a kernel configuration file to use for compilation;
by default genkernel uses the config from the previous
build of the same kernel version or a default kernel config if
there isn't a previous config.
+ Use the special value 'default' to force usage of default kernel
+ config.
*--module-prefix*=<dir>::
Prefix to kernel module destination, modules will be installed in
diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 8971c51..795c2c6 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -63,7 +63,10 @@ longusage() {
echo " --no-static Do not build a static (monolithic
kernel)."
echo " Kernel settings"
echo " --kerneldir=<dir> Location of the kernel sources"
- echo " --kernel-config=<file> Kernel configuration file to use for
compilation"
+ echo " --kernel-config=<file|default>"
+ echo " Kernel configuration file to use for
compilation."
+ echo " Use 'default' to explicitly start from
scratch"
+ echo " using genkernel defaults."
echo " --module-prefix=<dir> Prefix to kernel module destination,
modules"
echo " will be installed in
<prefix>/lib/modules"
echo " Low-Level Compile settings"
diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index 34fdbe1..063c9ac 100755
--- a/gen_configkernel.sh
+++ b/gen_configkernel.sh
@@ -4,7 +4,8 @@
# Fills variable KERNEL_CONFIG
determine_config_file() {
print_info 2 "Checking for suitable kernel configuration..."
- if [ -n "${CMD_KERNEL_CONFIG}" ]
+
+ if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" != "default" ]
then
KERNEL_CONFIG=$(expand_file "${CMD_KERNEL_CONFIG}")
if [ -z "${KERNEL_CONFIG}" ]
@@ -15,13 +16,21 @@ determine_config_file() {
gen_die "${error_msg}"
fi
else
- for f in \
- "/etc/kernels/kernel-config-${ARCH}-${KV}" \
- "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" \
- "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" \
- "${GK_SHARE}/arch/${ARCH}/generated-config" \
- "${GK_SHARE}/arch/${ARCH}/kernel-config" \
- "${DEFAULT_KERNEL_CONFIG}"
+ local -a kconfig_candidates
+ kconfig_candidates+=(
"${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" )
+ kconfig_candidates+=(
"${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" )
+ kconfig_candidates+=(
"${GK_SHARE}/arch/${ARCH}/generated-config" )
+ kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/kernel-config" )
+ kconfig_candidates+=( "${DEFAULT_KERNEL_CONFIG}" )
+
+ if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" =
"default" ]
+ then
+ print_info 1 "Default configuration was forced. Will
ignore any user kernel configuration!"
+ else
+ kconfig_candidates=(
"/etc/kernels/kernel-config-${ARCH}-${KV}" ${kconfig_candidates[@]} )
+ fi
+
+ for f in "${kconfig_candidates[@]}"
do
[ -z "${f}" ] && continue
@@ -49,7 +58,7 @@ determine_config_file() {
# Validate the symlink result if any
if [ -z "${KERNEL_CONFIG}" -o ! -f "${KERNEL_CONFIG}" ]
then
- if [ -n "${CMD_KERNEL_CONFIG}" ]
+ if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" !=
"default" ]
then
error_msg="No kernel .config: File
'${CMD_KERNEL_CONFIG}' not found! "
error_msg+="Check --kernel-config value or unset "
@@ -77,21 +86,28 @@ config_kernel() {
print_info 1 "$(getIndent 1)>> --clean is disabled; not running
'make clean'."
fi
- if isTrue "${MRPROPER}"
+ if isTrue "${MRPROPER}" || [ -n "${CMD_KERNEL_CONFIG}" -a
"${CMD_KERNEL_CONFIG}" = "default" ]
then
# Backup current kernel .config
if [ -f "${KERNEL_OUTPUTDIR}/.config" ]
then
# Current .config is different then one we are going to
use
- if ! diff -q "${KERNEL_OUTPUTDIR}"/.config
"${KERNEL_CONFIG}" > /dev/null
+ if [ -n "${CMD_KERNEL_CONFIG}" -a
"${CMD_KERNEL_CONFIG}" = "default" ] || \
+ ! diff -q "${KERNEL_OUTPUTDIR}"/.config
"${KERNEL_CONFIG}" > /dev/null
then
NOW=`date +--%Y-%m-%d--%H-%M-%S`
cp "${KERNEL_OUTPUTDIR}/.config"
"${KERNEL_OUTPUTDIR}/.config${NOW}.bak" \
|| gen_die "Could not backup kernel
config (${KERNEL_OUTPUTDIR}/.config)"
print_info 1 "$(getIndent 1)>> Previous config
backed up to .config${NOW}.bak"
+
+ [ -n "${CMD_KERNEL_CONFIG}" -a
"${CMD_KERNEL_CONFIG}" = "default" ] &&
+ rm "${KERNEL_OUTPUTDIR}/.config" >
/dev/null
fi
fi
+ fi
+ if isTrue "${MRPROPER}"
+ then
print_info 1 "$(getIndent 1)>> Running mrproper..."
compile_generic mrproper kernel
else