diff options
| author | Antonin Godard <antoningodard@pm.me> | 2023-01-09 09:04:53 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-26 23:39:06 +0000 |
| commit | 630974ec95912de1870d272d2a8f4fe492ae5fb4 (patch) | |
| tree | 935b09fc71a4c123e2235ca1edea2507a84b9560 /meta | |
| parent | 0f36c3511d9f67870d4778cc9a2b984bbb726a11 (diff) | |
| download | poky-630974ec95912de1870d272d2a8f4fe492ae5fb4.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: 6b38515e148cfd6657d8e10ffb6dc49abfea0c9f)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 6b4a0f063edcfe0a5a4f418842e86ac0c46d9cad)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/recipes-core/busybox/busybox.inc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc index 5f1c473d5e..dff4a5dec9 100644 --- a/meta/recipes-core/busybox/busybox.inc +++ b/meta/recipes-core/busybox/busybox.inc | |||
| @@ -138,19 +138,23 @@ do_configure () { | |||
| 138 | do_prepare_config | 138 | do_prepare_config |
| 139 | merge_config.sh -m .config ${@" ".join(find_cfgs(d))} | 139 | merge_config.sh -m .config ${@" ".join(find_cfgs(d))} |
| 140 | cml1_do_configure | 140 | cml1_do_configure |
| 141 | |||
| 142 | # Save a copy of .config and autoconf.h. | ||
| 143 | cp .config .config.orig | ||
| 144 | cp include/autoconf.h include/autoconf.h.orig | ||
| 141 | } | 145 | } |
| 142 | 146 | ||
| 143 | do_compile() { | 147 | do_compile() { |
| 144 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS | 148 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS |
| 145 | export KCONFIG_NOTIMESTAMP=1 | 149 | export KCONFIG_NOTIMESTAMP=1 |
| 146 | 150 | ||
| 151 | # Ensure we start do_compile with the original .config and autoconf.h. | ||
| 152 | # These files should always have matching timestamps. | ||
| 153 | cp .config.orig .config | ||
| 154 | cp include/autoconf.h.orig include/autoconf.h | ||
| 155 | |||
| 147 | if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then | 156 | if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then |
| 148 | # split the .config into two parts, and make two busybox binaries | 157 | # split the .config into two parts, and make two busybox binaries |
| 149 | if [ -e .config.orig ]; then | ||
| 150 | # Need to guard again an interrupted do_compile - restore any backup | ||
| 151 | cp .config.orig .config | ||
| 152 | fi | ||
| 153 | cp .config .config.orig | ||
| 154 | oe_runmake busybox.cfg.suid | 158 | oe_runmake busybox.cfg.suid |
| 155 | oe_runmake busybox.cfg.nosuid | 159 | oe_runmake busybox.cfg.nosuid |
| 156 | 160 | ||
| @@ -187,15 +191,18 @@ do_compile() { | |||
| 187 | bbfatal "busybox suid binary incorrectly provides /bin/sh" | 191 | bbfatal "busybox suid binary incorrectly provides /bin/sh" |
| 188 | fi | 192 | fi |
| 189 | 193 | ||
| 190 | # copy .config.orig back to .config, because the install process may check this file | ||
| 191 | cp .config.orig .config | ||
| 192 | # cleanup | 194 | # cleanup |
| 193 | rm .config.orig .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps | 195 | rm .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps |
| 194 | else | 196 | else |
| 195 | oe_runmake busybox_unstripped | 197 | oe_runmake busybox_unstripped |
| 196 | cp busybox_unstripped busybox | 198 | cp busybox_unstripped busybox |
| 197 | oe_runmake busybox.links | 199 | oe_runmake busybox.links |
| 198 | fi | 200 | fi |
| 201 | |||
| 202 | # restore original .config and autoconf.h, because the install process | ||
| 203 | # may check these files | ||
| 204 | cp .config.orig .config | ||
| 205 | cp include/autoconf.h.orig include/autoconf.h | ||
| 199 | } | 206 | } |
| 200 | 207 | ||
| 201 | do_install () { | 208 | do_install () { |
