From patchwork Sat Aug 31 12:08:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3347 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3557B3FA6C for ; Sat, 31 Aug 2024 14:08:46 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5bedba9894dsf2061050a12.1 for ; Sat, 31 Aug 2024 05:08:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1725106126; cv=pass; d=google.com; s=arc-20240605; b=faqFn1bJGadadGUTLJZPl7F6rmCnBJqvlv9x+j2n16Vg3WWXrN717zFr4lj97R5R+5 IA/KK06n05hUIlytX239OoD0JYE2CImElbyqcorBBDteBPdInVlZ0bmGV3dpTejNX7ir KAWzYuGnFE5OzjGHuOzj0NeVo6RSUQb8E/EISAEIT5uZaDddHJ7TYrFofdNWRc4UMIgn 7Y6FxGWcALEa2P/U62C5v75GNA6kzZvCHt4k0cRHMM6KtPE1jjkb0gCMiw6lr+kY91// yNZvAJpkAs1MHyCq+PyMsyWSMHPvWdyqG5Y2+kp22lE7mmi0Jf1bDcl/pva2nQ13LbY5 8eiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=5ZM0odIZBMh/zlmrjFG2sd8Uw84p9R7AEhzpP4miOZA=; fh=Zk27musWEfpGYnsQUfZx4PesgmfFL2ZXbW2RMSzPitI=; b=Bd9IVqgZk5KBZn0L0ttWnlw4MiSlFBVfoqqAFi76XnFEN0XKC30D73MpuPCG6JcJzJ 7415X0v/Ag+CAUeremgTE3bF0PffOKPr+ECmbd1OrV+I+s4mEoUIrEMzSax2fI7a7uOD rG9ODqu0jzw/Wjhd+qStYp0UA80ihYFTvMFcgPZmcDRWNcT/C0UtJuBYTMQaQ4NStGi7 gynLdR9dhLYbYV4IPsJ3TTT/3zVecNhd3/xwRcafd9dOH5zmQFpECnBDspdYN0j6JXsi jS93ge1zKJGmnVQ0/XrDSW9XCiqLgvHxRrJK85eQaNUwkAKX+ocpEfXW34tuVsVtgCBh LySQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T+anrrr0; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1725106126; x=1725710926; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=5ZM0odIZBMh/zlmrjFG2sd8Uw84p9R7AEhzpP4miOZA=; b=n4EGal5KNeGfPa/kEAmmRWcEP/BlsaZvREropjK0xnIiK+U0MFhfcV4Qar3PnJirO/ Ht/2VjSFB3sDRxb3Ao9xDNbLencVmcibWEGo5k8u1JtlpHPq3wGDypR63HUwoR2LqQu6 +FA93RORqNo9KtS4vcgsvs3bQlpanpHSYtd8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725106126; x=1725710926; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5ZM0odIZBMh/zlmrjFG2sd8Uw84p9R7AEhzpP4miOZA=; b=qB5XUT+9d6YG4Jgn9sIGM/Gg85xNue30e0eWez6b2/a3B+BU6ql75gD39HDYk1BdFs BhxTuS3oVdlFeeezNHCnJsr8bWdPsUwShFJYJuQ/07FUCqKU9MfEapIBjX/myfZnVrNB A2dLVjsAr6vPKWVMWHSn4VJcuUnhONUVFn6JgKl58TtN3djVDEpcDBYWt3hMTw9M6p/7 INdk2ZCc8eE5yrqkdE8eXkk2aE8HT5WiZiyKppCMCm3S2+X6ymm9o7HSd9ufjLUAm8NN wjHWlUH+iZgM0WxVhLv4H3O621em8UfUmHfL+4qq3AawV4TS9MZ1PsUSByx89X46k8zk idEg== X-Forwarded-Encrypted: i=2; AJvYcCXjLH1DvQ4u7dmMQnkQ0l8Ul1xXzOLPGWxW6Wp9TgViDuBytSaW5P80IZkNd5lYuF64rM3NKYlk6DvAbs7v@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yy/eQ8W9DArDfchm431qJTazOieLTJ/dJ1iWJn0RAEkTdUkEg31 Ak5CsR4/ZUaB5KRn/0SKYMkQCMocaZxlbixQCzD6B/ttXyp0Yfj0TKINEkgbDuFitQ== X-Google-Smtp-Source: AGHT+IFwh/JipE8XUkSw/CD1+bGX/8OBANGwJAW1srKCIb5AnH1AhLEZxl+z4xbaqFxgU8QWYtFyDA== X-Received: by 2002:a05:6402:40d6:b0:5bf:80d:e11d with SMTP id 4fb4d7f45d1cf-5c21ed3e30dmr8285778a12.12.1725106125584; Sat, 31 Aug 2024 05:08:45 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:3592:b0:5be:ef89:e7a6 with SMTP id 4fb4d7f45d1cf-5c21ec50939ls578748a12.2.-pod-prod-04-eu; Sat, 31 Aug 2024 05:08:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWRQESbls2+u5zRJ0yOngI6GS4ue8rriIW4BeYNussvxF4mYAimGuGIUxRrGRQXvRZvZMYdPyAkj3a4r5rk@amarulasolutions.com X-Received: by 2002:a17:907:36c5:b0:a86:6968:3b93 with SMTP id a640c23a62f3a-a89d879c32dmr59690266b.33.1725106123822; Sat, 31 Aug 2024 05:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725106123; cv=none; d=google.com; s=arc-20160816; b=TMKZebZZEQGNyTI26FBqlXwKnz04Og42HHV353G41H4p3XX+tIFSrVNd2bYvTtyk4N av/5gVMjjLABZ7FnHcq+szZSRbDC6Koqz6cXfnuFemuKoYzKpapJkHenC0O87Md4L7SC CqsxD0SFCIe6xFo+kFqDZ4boDno9EBRf1NUpDBUfX8OVkW07FwzaPp0GFdaR0beUv8o0 u94fqMlz/KwNCJkiHV5WanOG2a/+R0cU4NsxePs/XAEnpwpb15LO7+vqoTdLbkfjnR6g kjx/is3vaYbxXnBpnwoUmHxg+kKBD/7X0eakzrlos90CUhZz4CSTwA5/yUZWmJZtGoEj 6f9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=vjJfoEd6aJRxK/ZXd9KzrdJcvsoV07mC6Y5AbeT3mhQ=; fh=gzUZ213RKc1NvS5aIOoW991MQjEKl/IDuALsO7T6j3M=; b=KGi7gKNPyx1M/CJGS7oHOy2ySc6HqcfiuATIfrlv6uFn6yOLHjw/RtsTmeus5FKubl 1QjQn54rpB3+U+5Z8BXAEoI7dOofIzKsSUHojLWSl4sFyAHQPo5E1TA6zkWtPSO5T/8+ o/PGawxFUcv0Bofq0YV8nxhrQH8urquaIb3umgmjq03vyEGu6Sx3Xh/8hsQtkLXgKlfX bElM7x/Jg+cYbhGDDWLNTQAihwJIkKjTpsFyvHDUsdnq7Gc3MU9tmldORTSYcywUP21H 73xHfIp7+p7jvjAUDNGEURXaC3zjV4bGsSsefIbtkKMdL2SmLrYZJNcvMvND33cahgQG e/mw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T+anrrr0; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id a640c23a62f3a-a89890915b7sor169261566b.7.2024.08.31.05.08.43 for (Google Transport Security); Sat, 31 Aug 2024 05:08:43 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Forwarded-Encrypted: i=1; AJvYcCW0um2VjgvSvnMyMZurj8YA7D6fs/zBdd4HAJSSmPWdvnyUua7qXYrvYECQb5bidU6SSaNNdG7qwhvXE36r@amarulasolutions.com X-Received: by 2002:a05:6402:2792:b0:5c2:4a98:7520 with SMTP id 4fb4d7f45d1cf-5c24a987b9emr853788a12.31.1725106123293; Sat, 31 Aug 2024 05:08:43 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-48-52-249.retail.telecomitalia.it. [82.48.52.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c226ce4f47sm2938178a12.88.2024.08.31.05.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Aug 2024 05:08:42 -0700 (PDT) From: Dario Binacchi To: buildroot@buildroot.org Cc: Damien Le Moal , Dario Binacchi , Thomas Petazzoni , "Yann E . MORIN" , linux-amarula@amarulasolutions.com Subject: [PATCH v4 1/3] package/tinyinit: new package Date: Sat, 31 Aug 2024 14:08:31 +0200 Message-ID: <20240831120833.2915529-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240831120833.2915529-1-dario.binacchi@amarulasolutions.com> References: <20240831120833.2915529-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T+anrrr0; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This package contains a Linux init script suitable for resource-limited systems which can be used as an alternative to the one provided by Busybox. Signed-off-by: Dario Binacchi Cc: Yann E. MORIN Cc: Thomas Petazzoni Reviewed-by: Damien Le Moal --- Changes v3 -> v4: - Add tinyinit to Busybox dependencies - Add a comment to the tinyinit.mk just before the statements creating the symlink - Drop the comment from package/tinyinit/Config.in - Add the entry in the init selection in system/Config.in. Changes v2 -> v3: - Add the init script - Drop the entry in the init selection in system/Config.in. Changes v1 -> v2: - Rename tinit to tinyinit. - Put the script inside the tinyinit package without the need to use a github repo. - Update the commit message. DEVELOPERS | 1 + package/Config.in | 1 + package/busybox/busybox.mk | 1 + package/tinyinit/Config.in | 8 ++++++++ package/tinyinit/init | 32 ++++++++++++++++++++++++++++++++ package/tinyinit/tinyinit.mk | 13 +++++++++++++ system/Config.in | 9 +++++++++ 7 files changed, 65 insertions(+) create mode 100644 package/tinyinit/Config.in create mode 100644 package/tinyinit/init create mode 100644 package/tinyinit/tinyinit.mk diff --git a/DEVELOPERS b/DEVELOPERS index 0b590f0ec20c..cf62d0ed65ae 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -791,6 +791,7 @@ F: configs/imx8mn_bsh_smm_s2_defconfig F: configs/imx8mn_bsh_smm_s2_pro_defconfig F: configs/stm32f769_disco_sd_defconfig F: package/sscep/ +F: package/tinyinit/ F: package/uuu/ N: Dario Binacchi diff --git a/package/Config.in b/package/Config.in index 211080345adc..af7f13a75f7e 100644 --- a/package/Config.in +++ b/package/Config.in @@ -2868,6 +2868,7 @@ menu "System tools" source "package/tar/Config.in" source "package/tealdeer/Config.in" source "package/thermald/Config.in" + source "package/tinyinit/Config.in" source "package/tpm-tools/Config.in" source "package/tpm2-abrmd/Config.in" source "package/tpm2-tools/Config.in" diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk index 204ebe0106ee..942875ee0e12 100644 --- a/package/busybox/busybox.mk +++ b/package/busybox/busybox.mk @@ -68,6 +68,7 @@ BUSYBOX_DEPENDENCIES = \ $(if $(BR2_PACKAGE_UNZIP),unzip) \ $(if $(BR2_PACKAGE_USBUTILS),usbutils) \ $(if $(BR2_PACKAGE_UTIL_LINUX),util-linux) \ + $(if $(BR2_PACKAGE_TINYINIT),tinyinit) \ $(if $(BR2_PACKAGE_VIM),vim) \ $(if $(BR2_PACKAGE_WATCHDOG),watchdog) \ $(if $(BR2_PACKAGE_WGET),wget) \ diff --git a/package/tinyinit/Config.in b/package/tinyinit/Config.in new file mode 100644 index 000000000000..f68b030e7e0f --- /dev/null +++ b/package/tinyinit/Config.in @@ -0,0 +1,8 @@ +config BR2_PACKAGE_TINYINIT + bool "tinyinit" + depends on BR2_INIT_TINYINIT + imply BR2_PACKAGE_BUSYBOX + help + A Linux tiny initialization script suitable for resource + limited systems, which can be used as an alternative to the + one provided by Busybox. diff --git a/package/tinyinit/init b/package/tinyinit/init new file mode 100644 index 000000000000..fbcb481010c2 --- /dev/null +++ b/package/tinyinit/init @@ -0,0 +1,32 @@ +#!/bin/sh + +# This script replaces the default busybox init process to avoid having that +# process staying alive and sleeping in the background, (uselessly) consuming +# precious memory. + +# Mount procfs and sysfs +/bin/mount -t proc proc /proc +/bin/mount -t sysfs sysfs /sys + +# When the kernel is directly booted, devtmpfs is not automatically mounted. +# Manually mount it if needed. +devmnt=$(mount | grep -c devtmpfs) +if [ "${devmnt}" -eq 0 ]; then + /bin/mount -t devtmpfs devtmpfs /dev +fi + +# Use the /dev/console device node from devtmpfs if possible to not +# confuse glibc's ttyname_r(). +# This may fail (E.G. booted with console=), and errors from exec will +# terminate the shell, so use a subshell for the test +if (exec 0/dev/null; then + exec 0/dev/console + exec 2>/dev/console +fi + +# Clear memory to reduce page fragmentation +echo 3 > /proc/sys/vm/drop_caches + +# Finally, let's start an interactive shell +exec /bin/sh diff --git a/package/tinyinit/tinyinit.mk b/package/tinyinit/tinyinit.mk new file mode 100644 index 000000000000..ac1f0f736e38 --- /dev/null +++ b/package/tinyinit/tinyinit.mk @@ -0,0 +1,13 @@ +################################################################################ +# +# tinyinit +# +################################################################################ + +define TINYINIT_INSTALL_TARGET_CMDS + $(INSTALL) -m 0755 -D $(TINYINIT_PKGDIR)/init $(TARGET_DIR)/sbin/init + # Downside: In non-initramfs systems the symlink isn't used/needed + (cd $(TARGET_DIR); ln -sf /sbin/init init) +endef + +$(eval $(generic-package)) diff --git a/system/Config.in b/system/Config.in index d7d59db47db7..974152bd23e6 100644 --- a/system/Config.in +++ b/system/Config.in @@ -165,6 +165,15 @@ config BR2_INIT_TINI https://github.com/krallin/tini +config BR2_INIT_TINYINIT + bool "tiny init" + select BR2_PACKAGE_TINYINIT + select BR2_PACKAGE_SKELETON_INIT_NONE if BR2_ROOTFS_SKELETON_DEFAULT + help + A Linux tiny initialization script suitable for resource + limited systems, which can be used as an alternative to the + one provided by Busybox. + config BR2_INIT_NONE bool "Custom (none)" select BR2_PACKAGE_SKELETON_INIT_NONE if BR2_ROOTFS_SKELETON_DEFAULT