aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2020-08-01 15:48:43 +0200
committerThomas Deutschmann <whissi@gentoo.org>2020-08-01 22:35:00 +0200
commitc8624437130d318d93596453d0057f8fdfbe1ed2 (patch)
tree0cebf1236b99fe28daf6c4693b3af9349ccbe881
parentgenkernel: Move grep/zgrep check to determine_real_args() (diff)
downloadgenkernel-c8624437.tar.gz
genkernel-c8624437.tar.bz2
genkernel-c8624437.zip
Unify 'confgrep' handling via new get_grep_cmd_for_file() function
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rwxr-xr-xgen_configkernel.sh10
-rwxr-xr-xgen_funcs.sh21
-rwxr-xr-xgen_package.sh10
-rwxr-xr-xgenkernel14
4 files changed, 28 insertions, 27 deletions
diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index ba6d401..666f525 100755
--- a/gen_configkernel.sh
+++ b/gen_configkernel.sh
@@ -16,14 +16,8 @@ determine_kernel_config_file() {
gen_die "--kernel-config file '${KERNEL_CONFIG}' does not exist!"
fi
- if isTrue "$(is_gzipped "${KERNEL_CONFIG}")"
- then
- local CONFGREP=zgrep
- else
- local CONFGREP=grep
- fi
-
- if ! ${CONFGREP} -qE '^CONFIG_.*=' "${KERNEL_CONFIG}" &>/dev/null
+ local confgrep_cmd=$(get_grep_cmd_for_file "${KERNEL_CONFIG}")
+ if ! "${confgrep_cmd}" -qE '^CONFIG_.*=' "${KERNEL_CONFIG}" &>/dev/null
then
gen_die "--kernel-config file '${KERNEL_CONFIG}' does not look like a valid kernel config: File does not contain any CONFIG_* value!"
fi
diff --git a/gen_funcs.sh b/gen_funcs.sh
index b9aa510..f2f075a 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -440,6 +440,27 @@ gen_die() {
exit 1
}
+get_grep_cmd_for_file() {
+ [[ ${#} -ne 1 ]] \
+ && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!"
+
+ local config_file=${1}
+
+ local grep_cmd=${GREP_CMD}
+ if isTrue "$(is_gzipped "${config_file}")"
+ then
+ grep_cmd=${ZGREP_CMD}
+ fi
+
+ # zgrep for example is optional
+ if [ -z "${grep_cmd}" ]
+ then
+ gen_die "$(get_useful_function_stack "${FUNCNAME}")No grep implementation found which can process '${config_file}'!"
+ fi
+
+ echo "${grep_cmd}"
+}
+
# @FUNCTION: get_indent
# @USAGE: <level>
# @DESCRIPTION:
diff --git a/gen_package.sh b/gen_package.sh
index aad52de..271f038 100755
--- a/gen_package.sh
+++ b/gen_package.sh
@@ -259,14 +259,8 @@ gen_kerncache_is_valid() {
local test1=$(grep -v "^#" "${TEMP}/${GK_FILENAME_TEMP_CONFIG}" | md5sum | cut -d " " -f 1)
fi
- if isTrue "$(is_gzipped "${KERNEL_CONFIG}")"
- then
- # Support --kernel-config=/proc/config.gz, mainly
- local CONFGREP=zgrep
- else
- local CONFGREP=grep
- fi
- local test2=$("${CONFGREP}" -v "^#" "${KERNEL_CONFIG}" | md5sum | cut -d " " -f 1)
+ local confgrep_cmd=$(get_grep_cmd_for_file "${KERNEL_CONFIG}")
+ local test2=$("${confgrep_cmd}" -v "^#" "${KERNEL_CONFIG}" | md5sum | cut -d " " -f 1)
if [[ "${test1}" == "${test2}" ]]
then
diff --git a/genkernel b/genkernel
index c7b90d8..b96e388 100755
--- a/genkernel
+++ b/genkernel
@@ -530,22 +530,14 @@ then
print_warning 1 '"man genkernel" explains "dozfs" in detail.'
fi
- if isTrue "$(is_gzipped "${KERNEL_CONFIG}")"
- then
- # Support --kernel-config=/proc/config.gz, mainly
- CONFGREP=zgrep
- else
- CONFGREP=grep
- fi
-
- if [ $(${CONFGREP} 'CONFIG_EXT[0-9]_FS=' "${KERNEL_CONFIG}" | wc -l) -ge 2 ]
+ CONFGREP_CMD=$(get_grep_cmd_for_file "${KERNEL_CONFIG}")
+ if [ $("${CONFGREP_CMD}" 'CONFIG_EXT[0-9]_FS=' "${KERNEL_CONFIG}" | wc -l) -ge 2 ]
then
print_warning 1 ''
print_warning 1 'With support for several ext* filesystems available, it may be needed to'
print_warning 1 'add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.'
fi
-
- unset CONFGREP
+ unset CONFGREP_CMD
fi
isTrue "${CMD_INSTALL}" && restore_boot_mount_state