1 |
commit: 33394fef9f712ca0854eca248fe85863771ca04a |
2 |
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon May 16 19:31:34 2022 +0000 |
4 |
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon May 16 19:33:25 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=33394fef |
7 |
|
8 |
linuxrc: do not rely on chroot evaluating PATH |
9 |
|
10 |
When trying to install a new kernel on catbus.sparc.dev.gentoo.org, the |
11 |
newly built initrd consistently claimed that it could not find init, and |
12 |
dropped to the rescue shell. |
13 |
|
14 |
However, init was there just fine in /newroot (as before). |
15 |
|
16 |
I dug out the command that is actually run inside linuxrc, |
17 |
|
18 |
elif ! chroot "${CHROOT}" test -x /${init#/} 1>/dev/null 2>&1 |
19 |
|
20 |
and tried to run that manually, which led to a rather strange error message |
21 |
|
22 |
rescueshell / # chroot /newroot test -x /lib/systemd/systemd |
23 |
chroot: can't execute 'test': File name too long |
24 |
|
25 |
Some more research led me to the busybox manpage (where here chroot comes |
26 |
from): |
27 |
https://busybox.net/downloads/BusyBox.html#chroot |
28 |
|
29 |
chroot |
30 |
chroot NEWROOT [PROG [ARGS]] |
31 |
Run PROG with root directory set to NEWROOT |
32 |
|
33 |
Note, the third argument is *not* a command (as with usual chroot, see the |
34 |
manpage from coreutils chroot) but a program! |
35 |
|
36 |
Bug: https://bugs.gentoo.org/842027 |
37 |
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org> |
38 |
|
39 |
defaults/linuxrc | 2 +- |
40 |
1 file changed, 1 insertion(+), 1 deletion(-) |
41 |
|
42 |
diff --git a/defaults/linuxrc b/defaults/linuxrc |
43 |
index ff08ba2..15fbf7c 100644 |
44 |
--- a/defaults/linuxrc |
45 |
+++ b/defaults/linuxrc |
46 |
@@ -1376,7 +1376,7 @@ do |
47 |
if ! mountpoint "${CHROOT}" 1>/dev/null 2>&1 |
48 |
then |
49 |
bad_msg "${CHROOT} is not a mountpoint; Was root device (${REAL_ROOT}) not mounted?" |
50 |
- elif ! chroot "${CHROOT}" test -x /${init#/} 1>/dev/null 2>&1 |
51 |
+ elif ! chroot "${CHROOT}" /usr/bin/test -x /${init#/} 1>/dev/null 2>&1 |
52 |
then |
53 |
mounted_root_device=$(mountpoint -n /newroot 2>/dev/null | awk '{ print $1 }') |
54 |
bad_msg "init (${init}) not found in mounted root device (${mounted_root_device})!" |