diff options
author | Antonin Godard <antoningodard@pm.me> | 2023-02-15 10:55:38 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-02-24 16:41:42 +0000 |
commit | b4802e2fdb2b583608d50c4e45ab41d621c50e84 (patch) | |
tree | 84d8bc0e365a68dfb67ec229bbed0ac6b9dbfe58 /meta/recipes-core/busybox/busybox.inc | |
parent | 0d3339a23ac6f14cb71440cb30c1fb4a25c33216 (diff) | |
download | poky-b4802e2fdb2b583608d50c4e45ab41d621c50e84.tar.gz |
busybox: always start do_compile with orig config files
When compiling busybox a second time (e.g. with `compile -f`), busybox
can use an altered autoconf.h file for compiling, which can ultimately
produces different and unwanted binaries.
This can produce errors like this one:
ERROR: busybox-1.35.0-r0 do_package: Error executing a python function in exec_func_python() autogenerated:
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
0001:
*** 0002:ptest_update_alternatives(d)
0003:
File: '…/poky/meta/classes/ptest.bbclass', lineno: 100, function: ptest_update_alternatives
0096: for alt_name, alt_link, alt_target, _ in alternatives:
0097: # Some alternatives are for man pages,
0098: # check if the alternative is in PATH
0099: if os.path.dirname(alt_link) in bin_paths:
*** 0100: os.symlink(alt_target, os.path.join(ptest_bindir, alt_name))
0101:}
0102:
0103:do_configure_ptest_base[dirs] = "${B}"
0104:do_compile_ptest_base[dirs] = "${B}"
Exception: FileExistsError: [Errno 17] File exists: '/bin/busybox.suid' -> '…/busybox/1.35.0-r0/package/usr/lib/busybox/ptest/bin/login'
This happens because ALTERNATIVE:busybox contains `/bin/login` twice,
initially that's because `/bin/login` is present in both
busybox.links.suid and busybox.links.nosuid. The reason for that is
because of the altered autoconf.h.
Steps to reproduce above error:
<add ptest to distro configs>
bitbake busybox -c clean
bitbake busybox -c package -f
bitbake busybox -c compile -f
bitbake busybox -c package -f
This patch guards against potential bugs by:
- making a backup of .config and autoconf.h that have matching
timestamps.
- make sure do_compile always starts with these files.
- restore .config and autoconf.h at the end of do_compile.
(From OE-Core rev: 7ef76eaf5b68d52afdc4292bbe20309e29bb464a)
Signed-off-by: Antonin Godard <antoningodard@pm.me>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/busybox/busybox.inc')
-rw-r--r-- | meta/recipes-core/busybox/busybox.inc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc index 3553376582..616a23258a 100644 --- a/meta/recipes-core/busybox/busybox.inc +++ b/meta/recipes-core/busybox/busybox.inc | |||
@@ -139,6 +139,10 @@ do_configure () { | |||
139 | do_prepare_config | 139 | do_prepare_config |
140 | merge_config.sh -m .config ${@" ".join(find_cfgs(d))} | 140 | merge_config.sh -m .config ${@" ".join(find_cfgs(d))} |
141 | cml1_do_configure | 141 | cml1_do_configure |
142 | |||
143 | # Save a copy of .config and autoconf.h. | ||
144 | cp .config .config.orig | ||
145 | cp include/autoconf.h include/autoconf.h.orig | ||
142 | } | 146 | } |
143 | 147 | ||
144 | do_compile() { | 148 | do_compile() { |
@@ -146,13 +150,14 @@ do_compile() { | |||
146 | if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then | 150 | if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then |
147 | export KCONFIG_NOTIMESTAMP=1 | 151 | export KCONFIG_NOTIMESTAMP=1 |
148 | fi | 152 | fi |
153 | |||
154 | # Ensure we start do_compile with the original .config and autoconf.h. | ||
155 | # These files should always have matching timestamps. | ||
156 | cp .config.orig .config | ||
157 | cp include/autoconf.h.orig include/autoconf.h | ||
158 | |||
149 | if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then | 159 | if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then |
150 | # split the .config into two parts, and make two busybox binaries | 160 | # split the .config into two parts, and make two busybox binaries |
151 | if [ -e .config.orig ]; then | ||
152 | # Need to guard again an interrupted do_compile - restore any backup | ||
153 | cp .config.orig .config | ||
154 | fi | ||
155 | cp .config .config.orig | ||
156 | oe_runmake busybox.cfg.suid | 161 | oe_runmake busybox.cfg.suid |
157 | oe_runmake busybox.cfg.nosuid | 162 | oe_runmake busybox.cfg.nosuid |
158 | 163 | ||
@@ -189,15 +194,18 @@ do_compile() { | |||
189 | bbfatal "busybox suid binary incorrectly provides /bin/sh" | 194 | bbfatal "busybox suid binary incorrectly provides /bin/sh" |
190 | fi | 195 | fi |
191 | 196 | ||
192 | # copy .config.orig back to .config, because the install process may check this file | ||
193 | cp .config.orig .config | ||
194 | # cleanup | 197 | # cleanup |
195 | rm .config.orig .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps | 198 | rm .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps |
196 | else | 199 | else |
197 | oe_runmake busybox_unstripped | 200 | oe_runmake busybox_unstripped |
198 | cp busybox_unstripped busybox | 201 | cp busybox_unstripped busybox |
199 | oe_runmake busybox.links | 202 | oe_runmake busybox.links |
200 | fi | 203 | fi |
204 | |||
205 | # restore original .config and autoconf.h, because the install process | ||
206 | # may check these files | ||
207 | cp .config.orig .config | ||
208 | cp include/autoconf.h.orig include/autoconf.h | ||
201 | } | 209 | } |
202 | 210 | ||
203 | do_install () { | 211 | do_install () { |