system: add option to choose what /bin/sh points to
authorYann E. MORIN <yann.morin.1998@free.fr>
Sun, 12 Oct 2014 13:36:22 +0000 (15:36 +0200)
committerPeter Korsgaard <peter@korsgaard.com>
Sun, 12 Oct 2014 13:51:38 +0000 (15:51 +0200)
Not all our shells do install a pointer to /bin/sh. Besides, between
those that do and multiple ones are enabled, the last one to install
wins the the symlink.

Add a new config choice in the system sub-menu that allows the user to
explicitly select the shell to provide /bin/sh. If busybox is not
enabled, default to using dash, a POSIX shell.

Remove the symlink creation from bash.mk at the same time.

Note: for every shell, we select them, except busybox, on which we
depend, on the assumption that we do not want to force busybox in case
the user decided not to enable it.

[Peter: remove redundant !BR2_PACKAGE_BUSYBOX dependency]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Gustavo Zacarias <gustavo@zacarias.com.ar>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
package/bash/bash.mk
system/Config.in
system/system.mk

index 6510af5e9cbea79cd2721ae49a3320995f006cfe..34a3a739561da164ef9e2df580a228b7f5b3c557 100644 (file)
@@ -35,7 +35,6 @@ define BASH_INSTALL_TARGET_CMDS
        $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
                DESTDIR=$(TARGET_DIR) exec_prefix=/ install
        rm -f $(TARGET_DIR)/bin/bashbug
-       ln -sf bash $(TARGET_DIR)/bin/sh
 endef
 
 $(eval $(autotools-package))
index e7e146a305cb8ac118713f3b399b21526f653109..2465f798ea3dc02dd116829c82e64f534e1208ec 100644 (file)
@@ -211,6 +211,50 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD
          in the build log! Avoid using a valuable password if either the
          .config file or the build log may be distributed!
 
+choice
+       bool "/bin/sh"
+       default BR2_SYSTEM_BIN_SH_DASH if !BR2_PACKAGE_BUSYBOX
+       help
+         Select which shell will provide /bin/sh.
+
+# busybox has shells that work on noMMU
+config BR2_SYSTEM_BIN_SH_BUSYBOX
+       bool "busybox' default shell"
+       depends on BR2_PACKAGE_BUSYBOX
+
+config BR2_SYSTEM_BIN_SH_BASH
+       bool "bash"
+       depends on BR2_USE_MMU # bash
+       depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+       select BR2_PACKAGE_BASH
+
+config BR2_SYSTEM_BIN_SH_DASH
+       bool "dash"
+       depends on BR2_USE_MMU # dash
+       depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+       select BR2_PACKAGE_DASH
+
+config BR2_SYSTEM_BIN_SH_ZSH
+       bool "zsh"
+       depends on BR2_USE_MMU # zsh
+       depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+       select BR2_PACKAGE_ZSH
+
+comment "bash, dash, zsh need BR2_PACKAGE_BUSYBOX_SHOW_OTHERS"
+       depends on !BR2_PACKAGE_BUSYBOX_SHOW_OTHERS && BR2_PACKAGE_BUSYBOX
+
+config BR2_SYSTEM_BIN_SH_NONE
+       bool "none"
+
+endchoice # /bin/sh
+
+config BR2_SYSTEM_BIN_SH
+       string
+       default "/bin/busybox" if BR2_SYSTEM_BIN_SH_BUSYBOX
+       default "/bin/bash"    if BR2_SYSTEM_BIN_SH_BASH
+       default "/bin/dash"    if BR2_SYSTEM_BIN_SH_DASH
+       default "/bin/zsh"     if BR2_SYSTEM_BIN_SH_ZSH
+
 config BR2_TARGET_GENERIC_GETTY
        bool "Run a getty (login prompt) after boot"
        default y
index b6146158daf5c11724f0821f11c265e42ccda3be..5802e2d8f07d23c5966697b2ffb73fa414973750 100644 (file)
@@ -2,6 +2,7 @@ TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
 TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
 TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
 TARGET_GENERIC_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
+TARGET_GENERIC_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
 TARGET_GENERIC_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
 TARGET_GENERIC_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))
 TARGET_GENERIC_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
@@ -46,6 +47,17 @@ define SYSTEM_ROOT_PASSWD
 endef
 TARGET_FINALIZE_HOOKS += SYSTEM_ROOT_PASSWD
 
+ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
+define SYSTEM_BIN_SH
+       rm -f $(TARGET_DIR)/bin/sh
+endef
+else
+define SYSTEM_BIN_SH
+       ln -sf $(TARGET_GENERIC_BIN_SH) $(TARGET_DIR)/bin/sh
+endef
+endif
+TARGET_FINALIZE_HOOKS += SYSTEM_BIN_SH
+
 ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
 ifeq ($(BR2_PACKAGE_SYSVINIT),y)
 # In sysvinit inittab, the "id" must not be longer than 4 bytes, so we