1 |
commit: c8624437130d318d93596453d0057f8fdfbe1ed2 |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Aug 1 13:48:43 2020 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Aug 1 20:35:00 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c8624437 |
7 |
|
8 |
Unify 'confgrep' handling via new get_grep_cmd_for_file() function |
9 |
|
10 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
11 |
|
12 |
gen_configkernel.sh | 10 ++-------- |
13 |
gen_funcs.sh | 21 +++++++++++++++++++++ |
14 |
gen_package.sh | 10 ++-------- |
15 |
genkernel | 14 +++----------- |
16 |
4 files changed, 28 insertions(+), 27 deletions(-) |
17 |
|
18 |
diff --git a/gen_configkernel.sh b/gen_configkernel.sh |
19 |
index ba6d401..666f525 100755 |
20 |
--- a/gen_configkernel.sh |
21 |
+++ b/gen_configkernel.sh |
22 |
@@ -16,14 +16,8 @@ determine_kernel_config_file() { |
23 |
gen_die "--kernel-config file '${KERNEL_CONFIG}' does not exist!" |
24 |
fi |
25 |
|
26 |
- if isTrue "$(is_gzipped "${KERNEL_CONFIG}")" |
27 |
- then |
28 |
- local CONFGREP=zgrep |
29 |
- else |
30 |
- local CONFGREP=grep |
31 |
- fi |
32 |
- |
33 |
- if ! ${CONFGREP} -qE '^CONFIG_.*=' "${KERNEL_CONFIG}" &>/dev/null |
34 |
+ local confgrep_cmd=$(get_grep_cmd_for_file "${KERNEL_CONFIG}") |
35 |
+ if ! "${confgrep_cmd}" -qE '^CONFIG_.*=' "${KERNEL_CONFIG}" &>/dev/null |
36 |
then |
37 |
gen_die "--kernel-config file '${KERNEL_CONFIG}' does not look like a valid kernel config: File does not contain any CONFIG_* value!" |
38 |
fi |
39 |
|
40 |
diff --git a/gen_funcs.sh b/gen_funcs.sh |
41 |
index b9aa510..f2f075a 100755 |
42 |
--- a/gen_funcs.sh |
43 |
+++ b/gen_funcs.sh |
44 |
@@ -440,6 +440,27 @@ gen_die() { |
45 |
exit 1 |
46 |
} |
47 |
|
48 |
+get_grep_cmd_for_file() { |
49 |
+ [[ ${#} -ne 1 ]] \ |
50 |
+ && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!" |
51 |
+ |
52 |
+ local config_file=${1} |
53 |
+ |
54 |
+ local grep_cmd=${GREP_CMD} |
55 |
+ if isTrue "$(is_gzipped "${config_file}")" |
56 |
+ then |
57 |
+ grep_cmd=${ZGREP_CMD} |
58 |
+ fi |
59 |
+ |
60 |
+ # zgrep for example is optional |
61 |
+ if [ -z "${grep_cmd}" ] |
62 |
+ then |
63 |
+ gen_die "$(get_useful_function_stack "${FUNCNAME}")No grep implementation found which can process '${config_file}'!" |
64 |
+ fi |
65 |
+ |
66 |
+ echo "${grep_cmd}" |
67 |
+} |
68 |
+ |
69 |
# @FUNCTION: get_indent |
70 |
# @USAGE: <level> |
71 |
# @DESCRIPTION: |
72 |
|
73 |
diff --git a/gen_package.sh b/gen_package.sh |
74 |
index aad52de..271f038 100755 |
75 |
--- a/gen_package.sh |
76 |
+++ b/gen_package.sh |
77 |
@@ -259,14 +259,8 @@ gen_kerncache_is_valid() { |
78 |
local test1=$(grep -v "^#" "${TEMP}/${GK_FILENAME_TEMP_CONFIG}" | md5sum | cut -d " " -f 1) |
79 |
fi |
80 |
|
81 |
- if isTrue "$(is_gzipped "${KERNEL_CONFIG}")" |
82 |
- then |
83 |
- # Support --kernel-config=/proc/config.gz, mainly |
84 |
- local CONFGREP=zgrep |
85 |
- else |
86 |
- local CONFGREP=grep |
87 |
- fi |
88 |
- local test2=$("${CONFGREP}" -v "^#" "${KERNEL_CONFIG}" | md5sum | cut -d " " -f 1) |
89 |
+ local confgrep_cmd=$(get_grep_cmd_for_file "${KERNEL_CONFIG}") |
90 |
+ local test2=$("${confgrep_cmd}" -v "^#" "${KERNEL_CONFIG}" | md5sum | cut -d " " -f 1) |
91 |
|
92 |
if [[ "${test1}" == "${test2}" ]] |
93 |
then |
94 |
|
95 |
diff --git a/genkernel b/genkernel |
96 |
index c7b90d8..b96e388 100755 |
97 |
--- a/genkernel |
98 |
+++ b/genkernel |
99 |
@@ -530,22 +530,14 @@ then |
100 |
print_warning 1 '"man genkernel" explains "dozfs" in detail.' |
101 |
fi |
102 |
|
103 |
- if isTrue "$(is_gzipped "${KERNEL_CONFIG}")" |
104 |
- then |
105 |
- # Support --kernel-config=/proc/config.gz, mainly |
106 |
- CONFGREP=zgrep |
107 |
- else |
108 |
- CONFGREP=grep |
109 |
- fi |
110 |
- |
111 |
- if [ $(${CONFGREP} 'CONFIG_EXT[0-9]_FS=' "${KERNEL_CONFIG}" | wc -l) -ge 2 ] |
112 |
+ CONFGREP_CMD=$(get_grep_cmd_for_file "${KERNEL_CONFIG}") |
113 |
+ if [ $("${CONFGREP_CMD}" 'CONFIG_EXT[0-9]_FS=' "${KERNEL_CONFIG}" | wc -l) -ge 2 ] |
114 |
then |
115 |
print_warning 1 '' |
116 |
print_warning 1 'With support for several ext* filesystems available, it may be needed to' |
117 |
print_warning 1 'add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.' |
118 |
fi |
119 |
- |
120 |
- unset CONFGREP |
121 |
+ unset CONFGREP_CMD |
122 |
fi |
123 |
|
124 |
isTrue "${CMD_INSTALL}" && restore_boot_mount_state |