aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorGravatar Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>2020-02-05 13:55:18 +0100
committerGravatar Peter Korsgaard <peter@korsgaard.com>2020-02-05 15:57:56 +0100
commitc4dce0ae0f5d5d7fecb6f493e974e131a6df43da (patch)
treea63a08ee80e159d08ec1d3875b19cb3cde919b81 /system
parentca328f80da2da66c0c6940cd4908ab868025f670 (diff)
downloadbuildroot-c4dce0ae0f5d5d7fecb6f493e974e131a6df43da.tar.gz
buildroot-c4dce0ae0f5d5d7fecb6f493e974e131a6df43da.tar.bz2
system: don't attempt swapon/swapoff in inittab if not available
The default inittab files added by busybox and sysvinit run 'swapon -a' during init and 'swapoff -a' during shutdown. But, the swapon/swapoff programs are not guaranteed to be available. For the busybox versions, it is steered by CONFIG_SWAPON/CONFIG_SWAPOFF. For the util-linux versions, it is steered by BR2_PACKAGE_UTIL_LINUX_BINARIES. In a case where swapon/swapoff is not available but the inittab tries to execute them, the boot log would be polluted by error messages like: swapon: not found Avoid this by commenting out the swapon/swapoff lines if the swapon/swapoff binaries are not available. Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> [Peter: test with -x] Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'system')
-rw-r--r--system/system.mk13
1 files changed, 13 insertions, 0 deletions
diff --git a/system/system.mk b/system/system.mk
index 8fe2c138b0..6f1f5c27b1 100644
--- a/system/system.mk
+++ b/system/system.mk
@@ -96,6 +96,19 @@ define SYSTEM_REMOUNT_ROOT_INITTAB
endef
endif
+define SYSTEM_UPDATE_SWAPON_SWAPOFF_INITTAB
+ if [ -x $(TARGET_DIR)/sbin/swapon ]; then \
+ $(SED) '\%:/sbin/swapon%s/^#*//' $(TARGET_DIR)/etc/inittab ; \
+ else \
+ $(SED) '\%:/sbin/swapon%s/^#*/#/' $(TARGET_DIR)/etc/inittab ; \
+ fi
+ if [ -x $(TARGET_DIR)/sbin/swapoff ]; then \
+ $(SED) '\%:/sbin/swapoff%s/^#*//' $(TARGET_DIR)/etc/inittab ; \
+ else \
+ $(SED) '\%:/sbin/swapoff%s/^#*/#/' $(TARGET_DIR)/etc/inittab ; \
+ fi
+endef
+
ifeq ($(BR_BUILDING)$(BR2_SYSTEM_DEFAULT_PATH),y"")
$(error BR2_SYSTEM_DEFAULT_PATH can't be empty)
endif