From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 90130138359 for ; Sat, 1 Aug 2020 21:41:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2D8B0E0A7E; Sat, 1 Aug 2020 21:41:54 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0ADEDE0A7E for ; Sat, 1 Aug 2020 21:41:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2A7A034F323 for ; Sat, 1 Aug 2020 21:41:52 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A62F92FD for ; Sat, 1 Aug 2020 21:41:47 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1596314100.c8624437130d318d93596453d0057f8fdfbe1ed2.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: / X-VCS-Repository: proj/genkernel X-VCS-Files: gen_configkernel.sh gen_funcs.sh gen_package.sh genkernel X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: c8624437130d318d93596453d0057f8fdfbe1ed2 X-VCS-Branch: master Date: Sat, 1 Aug 2020 21:41:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 25d0f2de-12d4-467c-a6bd-a384fab67f93 X-Archives-Hash: a90ce2dd01c6857bac4e8a1fe57f0b92 commit: c8624437130d318d93596453d0057f8fdfbe1ed2 Author: Thomas Deutschmann gentoo org> AuthorDate: Sat Aug 1 13:48:43 2020 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Sat Aug 1 20:35:00 2020 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c8624437 Unify 'confgrep' handling via new get_grep_cmd_for_file() function Signed-off-by: Thomas Deutschmann gentoo.org> gen_configkernel.sh | 10 ++-------- gen_funcs.sh | 21 +++++++++++++++++++++ gen_package.sh | 10 ++-------- genkernel | 14 +++----------- 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: # @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