From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 3D112138334 for ; Sun, 21 Jul 2019 16:26:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B03A0E086C; Sun, 21 Jul 2019 16:26:41 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 76DBBE086C for ; Sun, 21 Jul 2019 16:26:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4C0DB3483D7 for ; Sun, 21 Jul 2019 16:26:40 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 42B8572B for ; Sun, 21 Jul 2019 16:26:37 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1563724070.cf851385321976893fc44c12cc0672ad6e8a9689.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: /, defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/linuxrc gen_initramfs.sh X-VCS-Directories: defaults/ / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: cf851385321976893fc44c12cc0672ad6e8a9689 X-VCS-Branch: master Date: Sun, 21 Jul 2019 16:26:37 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 7e32852d-d387-483a-9ba6-d6daf3e752b8 X-Archives-Hash: 82276417497211535c07e01ca7bce142 commit: cf851385321976893fc44c12cc0672ad6e8a9689 Author: Thomas Deutschmann gentoo org> AuthorDate: Sat Jul 20 20:59:09 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Sun Jul 21 15:47:50 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=cf851385 initramfs: Don't call mknod when --busybox is used This will basically allow us to run genkernel as user. Signed-off-by: Thomas Deutschmann gentoo.org> defaults/linuxrc | 8 +++++++ gen_initramfs.sh | 68 +++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 25 deletions(-) diff --git a/defaults/linuxrc b/defaults/linuxrc index 41a53fc..4113b63 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -9,6 +9,14 @@ splash() { [ -e /etc/initrd.splash ] && . /etc/initrd.splash +# Basic /dev content, we need it as fast as possible. +[ ! -e /dev/console ] && mknod /dev/console c 5 1 +[ ! -e /dev/null ] && mknod /dev/null c 1 3 +[ ! -e /dev/tty ] && mknod /dev/tty c 5 0 +[ ! -e /dev/urandom ] && mknod /dev/urandom c 1 9 +[ ! -e /dev/random ] && mknod /dev/random c 1 8 +[ ! -e /dev/zero ] && mknod /dev/zero c 1 5 + # Clean input/output exec >${CONSOLE} <${CONSOLE} 2>&1 diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 8419a20..55cf295 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -178,34 +178,52 @@ log_future_cpio_content() { } append_devices() { - local TFILE="${TEMP}/initramfs-base-temp.devices" - if [ -f "${TFILE}" ] + if isTrue "${BUSYBOX}" then - rm "${TFILE}" || gen_die "Failed to clean out existing '${TFILE}'!" - fi + local TDIR="${TEMP}/initramfs-devices-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi - if [[ ! -x "${KERNEL_OUTPUTDIR}/usr/gen_init_cpio" ]]; then - compile_gen_init_cpio - fi + mkdir -p "${TDIR}/dev" || gen_die "Failed to create '${TDIR}/dev'!" + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - # WARNING, does NOT support appending to cpio! - cat >"${TFILE}" <<-EOF - dir /dev 0755 0 0 - nod /dev/console 660 0 0 c 5 1 - nod /dev/null 666 0 0 c 1 3 - nod /dev/zero 666 0 0 c 1 5 - nod /dev/tty0 600 0 0 c 4 0 - nod /dev/tty1 600 0 0 c 4 1 - nod /dev/ttyS0 600 0 0 c 4 64 - EOF + chmod 0755 dev || gen_die "Failed to chmod of '${TDIR}/dev' to 0755!" - print_info 3 "=================================================================" 1 0 1 - print_info 3 "Adding the following devices to cpio:" 1 0 1 - print_info 3 "$(cat "${TFILE}")" 1 0 1 - print_info 3 "=================================================================" 1 0 1 + log_future_cpio_content + find . -print0 | cpio ${CPIO_ARGS} -F "${CPIO}" \ + || gen_die "Failed to append devices to cpio!" + else + local TFILE="${TEMP}/initramfs-base-temp.devices" + if [ -f "${TFILE}" ] + then + rm "${TFILE}" || gen_die "Failed to clean out existing '${TFILE}'!" + fi + + if [[ ! -x "${KERNEL_OUTPUTDIR}/usr/gen_init_cpio" ]]; then + compile_gen_init_cpio + fi - "${KERNEL_OUTPUTDIR}"/usr/gen_init_cpio "${TFILE}" >"${CPIO}" \ - || gen_die "Failed to append devices to cpio!" + # WARNING, does NOT support appending to cpio! + cat >"${TFILE}" <<-EOF + dir /dev 0755 0 0 + nod /dev/console 660 0 0 c 5 1 + nod /dev/null 666 0 0 c 1 3 + nod /dev/zero 666 0 0 c 1 5 + nod /dev/tty0 600 0 0 c 4 0 + nod /dev/tty1 600 0 0 c 4 1 + nod /dev/ttyS0 600 0 0 c 4 64 + EOF + + print_info 3 "=================================================================" 1 0 1 + print_info 3 "Adding the following devices to cpio:" 1 0 1 + print_info 3 "$(cat "${TFILE}")" 1 0 1 + print_info 3 "=================================================================" 1 0 1 + + "${KERNEL_OUTPUTDIR}"/usr/gen_init_cpio "${TFILE}" >"${CPIO}" \ + || gen_die "Failed to append devices to cpio!" + fi } append_base_layout() { @@ -383,7 +401,7 @@ append_busybox() { done # Set up a few default symlinks - local required_applets='[ ash sh mount uname echo cut cat' + local required_applets='[ ash sh mknod mount uname echo cut cat' local required_applet= for required_applet in ${required_applets} do @@ -1576,7 +1594,7 @@ create_initramfs() { # TODO: maybe replace this with: # http://search.cpan.org/~pixel/Archive-Cpio-0.07/lib/Archive/Cpio.pm # as then we can dedupe ourselves... - if [[ $UID -eq 0 ]] + if isTrue "${BUSYBOX}" || [[ ${UID} -eq 0 ]] then print_info 1 "$(get_indent 1)>> Deduping cpio ..." local TDIR="${TEMP}/initramfs-final"