Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:master commit in: /, defaults/, doc/
Date: Sun, 12 Jan 2020 14:59:32
Message-Id: 1578772480.da5a5fa797a5fffa6c4d694cbfe2edc83bab4890.whissi@gentoo
1 commit: da5a5fa797a5fffa6c4d694cbfe2edc83bab4890
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jan 10 17:10:08 2020 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 11 19:54:40 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=da5a5fa7
7
8 --module-rebuild: Call emerge with --ignore-default-opts
9
10 It's possible that user has set conflicting emerge options like
11 "--ask" in EMERGE_DEFAULT_OPTS which could break genkernel.
12 Calling emerge with --ignore-default-opts will allow us to
13 avoid such scenarios.
14
15 In addition, --module-rebuild-cmd (MODULEREBUILD_CMD) option was
16 added to allow user to alter default command.
17
18 Closes: https://bugs.gentoo.org/705082
19 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
20
21 defaults/config.sh | 2 ++
22 doc/genkernel.8.txt | 15 +++++++++++----
23 gen_cmdline.sh | 6 ++++++
24 gen_compile.sh | 18 ++++++++----------
25 gen_determineargs.sh | 12 ++++++++++++
26 5 files changed, 39 insertions(+), 14 deletions(-)
27
28 diff --git a/defaults/config.sh b/defaults/config.sh
29 index d9ea32c..678c0f9 100644
30 --- a/defaults/config.sh
31 +++ b/defaults/config.sh
32 @@ -34,6 +34,8 @@ DEFAULT_COMPRESS_INITRD_TYPE=best
33 PORTAGE_MAKEOPTS="$(portageq envvar MAKEOPTS)"
34 DEFAULT_MAKEOPTS="${PORTAGE_MAKEOPTS:- -j2}"
35
36 +DEFAULT_MODULEREBUILD_CMD="emerge --ignore-default-opts --quiet @module-rebuild"
37 +
38 DEFAULT_KERNEL_MAKE=make
39 DEFAULT_UTILS_MAKE=make
40
41
42 diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
43 index 6c4c155..e9076a4 100644
44 --- a/doc/genkernel.8.txt
45 +++ b/doc/genkernel.8.txt
46 @@ -196,10 +196,17 @@ specified.
47 Copies or does not copy all kernel modules to the initrd.
48
49 *--*[*no-*]*module-rebuild*::
50 - Runs, or does not run "emerge @module-rebuild" to build out-of-tree
51 - modules when possible, i.e. when non-static kernel and modules will be
52 - build, installed, no custom INSTALL_MOD_PATH is set,
53 - '/var/lib/module-rebuild/moduledb' exists and is not empty.
54 + Runs, or does not run "emerge --ignore-default-opts --quiet @module-rebuild"
55 + to build out-of-tree modules when possible, i.e. when non-static
56 + kernel and modules will be build, installed, no custom
57 + 'INSTALL_MOD_PATH' is set, '/var/lib/module-rebuild/moduledb' exists
58 + and is not empty.
59 +
60 +NOTE: Command can be customized using '--module-rebuild-cmd' command-line
61 +argument or 'MODULEREBUILD_CMD' in '/etc/genkernel.conf'.
62 +
63 +*--module-rebuild-cmd*=<...>::
64 + Overwrite default *--module-rebuild* command.
65
66 *--callback*=<...>::
67 Run the specified arguments in the current environment after the
68
69 diff --git a/gen_cmdline.sh b/gen_cmdline.sh
70 index 025187f..db9c1f8 100755
71 --- a/gen_cmdline.sh
72 +++ b/gen_cmdline.sh
73 @@ -65,6 +65,8 @@ longusage() {
74 echo " --module-rebuild Automatically run 'emerge @module-rebuild' when"
75 echo " necessary (and possible)"
76 echo " --no-module-rebuild Don't automatically run 'emerge @module-rebuild'"
77 + echo " --module-rebuild-cmd=<...>"
78 + echo " Overwrite default --module-rebuild command"
79 echo " --callback=<...> Run the specified arguments after the"
80 echo " kernel and modules have been compiled"
81 echo " --static Build a static (monolithic kernel)"
82 @@ -606,6 +608,10 @@ parse_cmdline() {
83 CMD_MODULEREBUILD=$(parse_optbool "$*")
84 print_info 3 "CMD_MODULEREBUILD: ${CMD_MODULEREBUILD}"
85 ;;
86 + --module-rebuild-cmd=*)
87 + CMD_MODULEREBUILD_CMD="${*#--module-rebuild-cmd=}"
88 + print_info 3 "CMD_MODULEREBUILD_CMD: ${CMD_MODULEREBUILD_CMD}"
89 + ;;
90 --callback=*)
91 CMD_CALLBACK="${*#*=}"
92 print_info 3 "CMD_CALLBACK: ${CMD_CALLBACK}/$*"
93
94 diff --git a/gen_compile.sh b/gen_compile.sh
95 index 3f10adb..3b96f48 100755
96 --- a/gen_compile.sh
97 +++ b/gen_compile.sh
98 @@ -2,53 +2,51 @@
99 # $Id$
100
101 compile_external_modules() {
102 - local command="emerge --quiet @module-rebuild 2>&1"
103 -
104 if ! isTrue "${CMD_MODULEREBUILD}"
105 then
106 - print_info 3 "$(get_indent 1)>> --no-module-rebuild set; Skipping 'emerge @module-rebuild' ..."
107 + print_info 3 "$(get_indent 1)>> --no-module-rebuild set; Skipping '${MODULEREBUILD_CMD}' ..."
108 return
109 fi
110
111 if isTrue "$(tc-is-cross-compiler)"
112 then
113 - print_info 3 "$(get_indent 1)>> Cross-compilation detected; Skipping 'emerge @module-rebuild' ..."
114 + print_info 3 "$(get_indent 1)>> Cross-compilation detected; Skipping '${MODULEREBUILD_CMD}' ..."
115 return
116 fi
117
118 if ! isTrue "${CMD_INSTALL}"
119 then
120 - print_info 3 "$(get_indent 1)>> --no-install set; Skipping 'emerge @module-rebuild' ..."
121 + print_info 3 "$(get_indent 1)>> --no-install set; Skipping '${MODULEREBUILD_CMD}' ..."
122 return
123 fi
124
125 if [ -n "${INSTALL_MOD_PATH}" ]
126 then
127 # emerge would install to a different location
128 - print_warning 1 "$(get_indent 1)>> INSTALL_MOD_PATH set; Skipping 'emerge @module-rebuild' ..."
129 + print_warning 1 "$(get_indent 1)>> INSTALL_MOD_PATH set; Skipping '${MODULEREBUILD_CMD}' ..."
130 return
131 fi
132
133 local modulesdb_file="/var/lib/module-rebuild/moduledb"
134 if [ ! -s "${modulesdb_file}" ]
135 then
136 - print_info 2 "$(get_indent 1)>> '${modulesdb_file}' does not exist or is empty; Skipping 'emerge @module-rebuild' ..."
137 + print_info 2 "$(get_indent 1)>> '${modulesdb_file}' does not exist or is empty; Skipping '${MODULEREBUILD_CMD}' ..."
138 return
139 fi
140
141 local -x KV_OUT_DIR="${KERNEL_OUTPUTDIR}"
142
143 print_info 1 "$(get_indent 1)>> Compiling out-of-tree module(s) ..."
144 - print_info 3 "COMMAND: ${command}" 1 0 1
145 + print_info 3 "COMMAND: ${MODULEREBUILD_CMD}" 1 0 1
146
147 if [ "${LOGLEVEL}" -gt 3 ]
148 then
149 # Output to stdout and logfile
150 - eval ${command} | tee -a "${LOGFILE}"
151 + eval ${MODULEREBUILD_CMD} 2>&1 | tee -a "${LOGFILE}"
152 RET=${PIPESTATUS[0]}
153 else
154 # Output to logfile only
155 - eval ${command} >> "${LOGFILE}"
156 + eval ${MODULEREBUILD_CMD} 2>&1 >> "${LOGFILE}"
157 RET=$?
158 fi
159
160
161 diff --git a/gen_determineargs.sh b/gen_determineargs.sh
162 index 616f4fe..61521d6 100755
163 --- a/gen_determineargs.sh
164 +++ b/gen_determineargs.sh
165 @@ -317,6 +317,7 @@ determine_real_args() {
166 set_config_with_override STRING MINKERNPACKAGE CMD_MINKERNPACKAGE
167 set_config_with_override STRING MODULESPACKAGE CMD_MODULESPACKAGE
168 set_config_with_override BOOL MODULEREBUILD CMD_MODULEREBUILD "yes"
169 + set_config_with_override STRING MODULEREBUILD_CMD CMD_MODULEREBUILD_CMD "${DEFAULT_MODULEREBUILD_CMD}"
170 set_config_with_override STRING KERNCACHE CMD_KERNCACHE
171 set_config_with_override BOOL RAMDISKMODULES CMD_RAMDISKMODULES "yes"
172 set_config_with_override BOOL ALLRAMDISKMODULES CMD_ALLRAMDISKMODULES "no"
173 @@ -781,6 +782,17 @@ determine_real_args() {
174 # Kernel Makefile doesn't support spaces in outputdir path...
175 gen_die "--kernel-outputdir '${KERNEL_OUTPUTDIR}' contains space character(s) which are not supported!"
176 fi
177 +
178 + if isTrue "${CMD_MODULEREBUILD}"
179 + then
180 + if [ -z "${MODULEREBUILD_CMD}" ]
181 + then
182 + gen_die "--module-rebuild-cmd cannot be empty when --module-rebuild is set!"
183 + elif [[ "${MODULEREBUILD_CMD}" == *[\$\&\|\>\(\)]* ]]
184 + then
185 + gen_die "--module-rebuild-cmd '${MODULEREBUILD_CMD}' contains at least one of the following disallowed characters: '\$&|>()'!"
186 + fi
187 + fi
188 fi
189
190 if isTrue "${BUILD_RAMDISK}"