From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1397490-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id D1516158090
	for <garchives@archives.gentoo.org>; Mon, 16 May 2022 19:33:57 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 04501E0826;
	Mon, 16 May 2022 19:33:57 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 8892EE0826
	for <gentoo-commits@lists.gentoo.org>; Mon, 16 May 2022 19:33:56 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 330B5341BEB
	for <gentoo-commits@lists.gentoo.org>; Mon, 16 May 2022 19:33:55 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 7B506DC
	for <gentoo-commits@lists.gentoo.org>; Mon, 16 May 2022 19:33:53 +0000 (UTC)
From: "Andreas K. Hüttel" <dilfridge@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Andreas K. Hüttel" <dilfridge@gentoo.org>
Message-ID: <1652729605.33394fef9f712ca0854eca248fe85863771ca04a.dilfridge@gentoo>
Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/
X-VCS-Repository: proj/genkernel
X-VCS-Files: defaults/linuxrc
X-VCS-Directories: defaults/
X-VCS-Committer: dilfridge
X-VCS-Committer-Name: Andreas K. Hüttel
X-VCS-Revision: 33394fef9f712ca0854eca248fe85863771ca04a
X-VCS-Branch: master
Date: Mon, 16 May 2022 19:33:53 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: c42b77d3-a44e-446b-a918-789510875a7b
X-Archives-Hash: 1a4d145448721ef58012fd2ba25867f3

commit:     33394fef9f712ca0854eca248fe85863771ca04a
Author:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Mon May 16 19:31:34 2022 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Mon May 16 19:33:25 2022 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=33394fef

linuxrc: do not rely on chroot evaluating PATH

When trying to install a new kernel on catbus.sparc.dev.gentoo.org, the
newly built initrd consistently claimed that it could not find init, and
dropped to the rescue shell.

However, init was there just fine in /newroot (as before).

I dug out the command that is actually run inside linuxrc,

        elif ! chroot "${CHROOT}" test -x /${init#/} 1>/dev/null 2>&1

and tried to run that manually, which led to a rather strange error message

rescueshell / # chroot /newroot test -x /lib/systemd/systemd
chroot: can't execute 'test': File name too long

Some more research led me to the busybox manpage (where here chroot comes
from):
https://busybox.net/downloads/BusyBox.html#chroot

chroot
    chroot NEWROOT [PROG [ARGS]]
    Run PROG with root directory set to NEWROOT

Note, the third argument is *not* a command (as with usual chroot, see the
manpage from coreutils chroot) but a program!

Bug: https://bugs.gentoo.org/842027
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 defaults/linuxrc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index ff08ba2..15fbf7c 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -1376,7 +1376,7 @@ do
 	if  ! mountpoint "${CHROOT}" 1>/dev/null 2>&1
 	then
 		bad_msg "${CHROOT} is not a mountpoint; Was root device (${REAL_ROOT}) not mounted?"
-	elif ! chroot "${CHROOT}" test -x /${init#/} 1>/dev/null 2>&1
+	elif ! chroot "${CHROOT}" /usr/bin/test -x /${init#/} 1>/dev/null 2>&1
 	then
 		mounted_root_device=$(mountpoint -n /newroot 2>/dev/null | awk '{ print $1 }')
 		bad_msg "init (${init}) not found in mounted root device (${mounted_root_device})!"