From patchwork Thu Feb 6 17:32:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 1234475 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=I08hGvu0; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48D59V67B1z9sRR for ; Fri, 7 Feb 2020 04:32:46 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id DC3DB87ADB; Thu, 6 Feb 2020 17:32:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yqeoe3oTrQFn; Thu, 6 Feb 2020 17:32:43 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id EDD6B87B8E; Thu, 6 Feb 2020 17:32:42 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 655551BF326 for ; Thu, 6 Feb 2020 17:32:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 62DCD86126 for ; Thu, 6 Feb 2020 17:32:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JyLqNXxQQCbw for ; Thu, 6 Feb 2020 17:32:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 3299A86119 for ; Thu, 6 Feb 2020 17:32:39 +0000 (UTC) Received: by mail-qv1-f54.google.com with SMTP id m5so3238812qvv.4 for ; Thu, 06 Feb 2020 09:32:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G3auouUbLtKkY41sdBPOPFWZqHBRpv0xLVFSuRHw9OY=; b=I08hGvu0GSn+RnWCrTllhS+shE1dsgOXNuiwwRHo46nw7lbYcKB44sKwgRjCd7IQep 2oQ+3EU9ONydtzk+2+3928i3+Eya1b+bCh3o1Oxo7hq9evJKvcqmgMjQnviN2TdaOMuM Ibcg9oNhgaxVuVXa2v6EUx7kqzA+NIOilY9jsiaPoUtW1dVYYuBodI4nJv7C/pLBsvGr AOWlA2YKzCw196/p9RCpDa3woM+PKU34YolJTdqfa+YYOjEFTerwNuuI1AwgnC9lYBvk 2VdUNYsV3SbNGcIdCmxqyDwFw/lSYu1/30h8I8z7n7dAgYs+afrsmLwqKKlKLegVWWM3 kdTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G3auouUbLtKkY41sdBPOPFWZqHBRpv0xLVFSuRHw9OY=; b=tx7vRbcVyfDPbH+p/ng9Hbiu65Y5RpgqVq7kasH5QRgp6PFthozkXTKHBdPD0T/XSc +eO436ByQB0OhhOSbC4kL8Wtbkv/j6zaaaGaNKF5JK01F2eKduG8JYWc1lMSrIYD+Xs/ 7UC8SdAKGbdyCuB50ZXRaRXAB5BAmrpHTZ1eOSVFwaMb3zXp1uRmE/mYDHeHdzWc62PE CRkQTJuvqnc6nRkWDAkwsl0eGfo3eeyVWQheeFjz20jWpRb8yVn7iDKMLWkCqqY0b2WF h/r0xC25WEZz24Vbspr2JHC9Gq84PZtOAPEPZ9I3CIanmQ2joIXRm8fxQZj7jl0FgMTu /bCQ== X-Gm-Message-State: APjAAAUUudJAwYbLczCYcuDSd/GNWBaCDk3svzbfxXmXJXVXHZpXKWSk oJXzkAYe79oLK6X+X76EaEz9V1Ul5eQ= X-Google-Smtp-Source: APXvYqyu59Mc5CO92seRKuw9LvMIg6daa/iKLDl9yCuOSPAseixhl/nQFzbKWlcgnQSqthzguz91JQ== X-Received: by 2002:a05:6214:4f2:: with SMTP id cl18mr3364897qvb.89.1581010357852; Thu, 06 Feb 2020 09:32:37 -0800 (PST) Received: from casantos.remote.com ([179.181.67.11]) by smtp.gmail.com with ESMTPSA id d20sm1968417qto.2.2020.02.06.09.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2020 09:32:37 -0800 (PST) From: unixmania@gmail.com To: buildroot@buildroot.org Date: Thu, 6 Feb 2020 14:32:25 -0300 Message-Id: <20200206173225.25677-3-unixmania@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200206173225.25677-1-unixmania@gmail.com> References: <20200206173225.25677-1-unixmania@gmail.com> Subject: [Buildroot] [PATCH 2/2] package/skeleton-init-sysv: conditionally enable swapon/swapoff in inittab X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Carlos Santos , Peter Korsgaard , Thomas De Schampheleire , Adam Duskett MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Carlos Santos The default inittab files added by busybox and sysvinit run 'swapon -a' during init and 'swapoff -a' during shutdown but those programs are not guaranteed to be available, so the boot log may become polluted by error messages like this: swapon: not found To avoid this, make the swapon/swapoff lines in inittab optional. - Add a BR2_SYSTEM_HAS_SWAPON_SWAPOFF config to inform that swapon and swapoff are available. - Add a BR2_PACKAGE_BUSYBOX_SWAPON_SWAPOFF config that depends on BR2_USE_MMU and selects BR2_SYSTEM_HAS_SWAPON_SWAPOFF. Build the Busybox swapon/swapoff utilities based on this new option. - Make UTIL_LINUX_BINARIES select BR2_SYSTEM_HAS_SWAPON_SWAPOFF config. - Add a targe-finalize hook to skeleton-init-sysv that comments-out or enables the swapon/swapoff lines in /etc/inittab, based on the value of BR2_SYSTEM_HAS_SWAPON_SWAPOFF. Based on a previous patch sent by Thomas De Schampheleire. Signed-off-by: Carlos Santos --- CC: Thomas De Schampheleire CC: Peter Korsgaard --- package/busybox/Config.in | 6 ++++++ package/busybox/busybox.mk | 14 ++++++++++++++ package/skeleton-init-sysv/skeleton-init-sysv.mk | 12 ++++++++++++ package/util-linux/Config.in | 1 + system/Config.in | 6 ++++++ 5 files changed, 39 insertions(+) diff --git a/package/busybox/Config.in b/package/busybox/Config.in index 5e5c586762..9103256494 100644 --- a/package/busybox/Config.in +++ b/package/busybox/Config.in @@ -68,6 +68,12 @@ config BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES comment "Busybox individual binaries need a toolchain w/ dynamic library" depends on BR2_STATIC_LIBS +config BR2_PACKAGE_BUSYBOX_SWAPON_SWAPOFF + bool + default y + depends on BR2_USE_MMU + select BR2_SYSTEM_HAS_SWAPON_SWAPOFF # used by skeleton-init-sysv + config BR2_PACKAGE_BUSYBOX_WATCHDOG bool "Install the watchdog daemon startup script" help diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk index 6283bc96ea..920ba55237 100644 --- a/package/busybox/busybox.mk +++ b/package/busybox/busybox.mk @@ -248,6 +248,19 @@ define BUSYBOX_INSTALL_INDIVIDUAL_BINARIES endef endif +ifeq ($(BR2_PACKAGE_BUSYBOX_SWAPON_SWAPOFF),y) +define BUSYBOX_SET_SWAPON_SWAPOFF + $(call KCONFIG_ENABLE_OPT,CONFIG_SWAPON,$(BUSYBOX_BUILD_CONFIG)) + $(call KCONFIG_ENABLE_OPT,CONFIG_SWAPOFF,$(BUSYBOX_BUILD_CONFIG)) + $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_SWAPONOFF_LABEL,$(BUSYBOX_BUILD_CONFIG)) +endef +else +define BUSYBOX_SET_SWAPON_SWAPOFF + $(call KCONFIG_DISABLE_OPT,CONFIG_SWAPON,$(BUSYBOX_BUILD_CONFIG)) + $(call KCONFIG_DISABLE_OPT,CONFIG_SWAPOFF,$(BUSYBOX_BUILD_CONFIG)) +endef +endif + # Only install our logging scripts if no other package does it. ifeq ($(BR2_PACKAGE_SYSKLOGD)$(BR2_PACKAGE_RSYSLOG)$(BR2_PACKAGE_SYSLOG_NG),) define BUSYBOX_INSTALL_LOGGING_SCRIPT @@ -339,6 +352,7 @@ define BUSYBOX_KCONFIG_FIXUP_CMDS $(BUSYBOX_SET_WATCHDOG) $(BUSYBOX_SET_SELINUX) $(BUSYBOX_SET_INDIVIDUAL_BINARIES) + $(BUSYBOX_SET_SWAPON_SWAPOFF) endef define BUSYBOX_BUILD_CMDS diff --git a/package/skeleton-init-sysv/skeleton-init-sysv.mk b/package/skeleton-init-sysv/skeleton-init-sysv.mk index c89c2dc1fd..50d05c85cb 100644 --- a/package/skeleton-init-sysv/skeleton-init-sysv.mk +++ b/package/skeleton-init-sysv/skeleton-init-sysv.mk @@ -19,4 +19,16 @@ define SKELETON_INIT_SYSV_INSTALL_TARGET_CMDS $(call SYSTEM_RSYNC,$(SKELETON_INIT_SYSV_PKGDIR)/skeleton,$(TARGET_DIR)) endef +ifeq ($(BR2_SYSTEM_HAS_SWAPON_SWAPOFF),y) +define SKELETON_INIT_SYSV_SWAPON_SWAPOFF_INITTAB + $(SED) '/^#.*\/sbin\/swap/s/^#\+[[:blank:]]*//' $(TARGET_DIR)/etc/inittab +endef +else +define SKELETON_INIT_SYSV_SWAPON_SWAPOFF_INITTAB + $(SED) '/^[^#].*\/sbin\/swap/s/^/#/' $(TARGET_DIR)/etc/inittab +endef +endif + +SKELETON_INIT_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_INIT_SYSV_SWAPON_SWAPOFF_INITTAB + $(eval $(generic-package)) diff --git a/package/util-linux/Config.in b/package/util-linux/Config.in index 996f0cd7fa..0401ba12ee 100644 --- a/package/util-linux/Config.in +++ b/package/util-linux/Config.in @@ -49,6 +49,7 @@ config BR2_PACKAGE_UTIL_LINUX_BINARIES select BR2_PACKAGE_UTIL_LINUX_LIBFDISK select BR2_PACKAGE_UTIL_LINUX_LIBSMARTCOLS select BR2_PACKAGE_UTIL_LINUX_LIBUUID + select BR2_SYSTEM_HAS_SWAPON_SWAPOFF # used by skeleton-init-sysv help Install the basic set of util-linux binaries. diff --git a/system/Config.in b/system/Config.in index c8c5be40e0..dd7ca7cf63 100644 --- a/system/Config.in +++ b/system/Config.in @@ -305,6 +305,12 @@ config BR2_SYSTEM_BIN_SH default "mksh" if BR2_SYSTEM_BIN_SH_MKSH default "zsh" if BR2_SYSTEM_BIN_SH_ZSH +# swapon/swapoff can be provided by either busybox or util-linux. +# This is used by skeleton-init-sysv to enable/disable swapon/swapoff in +# /etc/inittab. +config BR2_SYSTEM_HAS_SWAPON_SWAPOFF + bool + menuconfig BR2_TARGET_GENERIC_GETTY bool "Run a getty (login prompt) after boot" default y