From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/3] package/bash: add option to keep or remove loadable examples
Date: Fri, 23 Apr 2021 22:23:54 +0200 [thread overview]
Message-ID: <20210423202356.37681-2-thomas.petazzoni@bootlin.com> (raw)
In-Reply-To: <20210423202356.37681-1-thomas.petazzoni@bootlin.com>
bash has a concept of "loadables", which are "plugins" that can be
loaded at runtime by bash to add new builtin. For example:
whoami is /usr/bin/whoami
root
whoami is a shell builtin
root
bash comes with a set of example loadables, installed in
/usr/lib/bash/. They take 312 KB on ARM32, and are by default not
used, and provide builtins that are for the most part already
available as external commands in Busybox/coreutils:
Makefile.inc finfo mkfifo realpath sync
accept head mktemp rm tee
basename id mypid rmdir truefalse
csv ln pathchk seq tty
cut loadables.h print setpgid uname
dirname logname printenv sleep unlink
fdflags mkdir push strftime whoami
So instead of having them unconditionally installed, add an option to
enable/disable their installation (their build apparently cannot be
disabled via a configure option).
Normally, we try to keep backward compatibility by preserving the
existing behavior. In this case, this would have meant making this
option "default y". But this also breaks our principle of "being
minimal by default", and in this case, it feels preferable to be
"minimal by default" than preserving existing behavior.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
---
package/bash/Config.in | 14 ++++++++++++++
package/bash/bash.mk | 13 +++++++++++++
2 files changed, 27 insertions(+)
diff --git a/package/bash/Config.in b/package/bash/Config.in
index 5a9ebb8d02..0212df6bfd 100644
--- a/package/bash/Config.in
+++ b/package/bash/Config.in
@@ -9,3 +9,17 @@ config BR2_PACKAGE_BASH
The standard GNU Bourne again shell.
http://tiswww.case.edu/php/chet/bash/bashtop.html
+
+if BR2_PACKAGE_BASH
+
+config BR2_PACKAGE_BASH_LOADABLE_EXAMPLES
+ bool "loadable examples"
+ depends on !BR2_STATIC_LIBS
+ help
+ This option will enable the installation of the "loadable"
+ examples, which are dynamically loadable extension providing
+ additional built-ins commands to bash. There are typically
+ not needed as they are provided as regular, external
+ commands.
+
+endif
diff --git a/package/bash/bash.mk b/package/bash/bash.mk
index 996c6a6097..6913ccafd8 100644
--- a/package/bash/bash.mk
+++ b/package/bash/bash.mk
@@ -48,6 +48,19 @@ define BASH_REMOVE_UNUSED_FILES
endef
BASH_POST_INSTALL_TARGET_HOOKS += BASH_REMOVE_UNUSED_FILES
+ifeq ($(BR2_PACKAGE_BASH_LOADABLE_EXAMPLES),y)
+define BASH_REMOVE_LOADABLE_UNUSED_FILES
+ rm -f $(TARGET_DIR)/usr/lib/bash/Makefile.inc
+ rm -f $(TARGET_DIR)/usr/lib/bash/loadables.h
+endef
+BASH_POST_INSTALL_TARGET_HOOKS += BASH_REMOVE_LOADABLE_UNUSED_FILES
+else
+define BASH_REMOVE_LOADABLE_EXAMPLES
+ rm -rf $(TARGET_DIR)/usr/lib/bash
+endef
+BASH_POST_INSTALL_TARGET_HOOKS += BASH_REMOVE_LOADABLE_EXAMPLES
+endif
+
# Add /bin/bash to /etc/shells otherwise some login tools like dropbear
# can reject the user connection. See man shells.
define BASH_ADD_MKSH_TO_SHELLS
--
2.30.2
next prev parent reply other threads:[~2021-04-23 20:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-23 20:23 [Buildroot] [PATCH 1/3] package/bash: use --bindir instead of exec_prefix= Thomas Petazzoni
2021-04-23 20:23 ` Thomas Petazzoni [this message]
2021-04-24 7:47 ` [Buildroot] [PATCH 2/3] package/bash: add option to keep or remove loadable examples Yann E. MORIN
2021-04-24 9:25 ` Thomas Petazzoni
2021-04-23 20:23 ` [Buildroot] [PATCH 3/3] package/bash: drop SHOBJ_STATUS from BASH_CONF_ENV Thomas Petazzoni
2021-04-24 7:46 ` Yann E. MORIN
2021-04-26 19:08 ` Peter Korsgaard
2021-04-24 7:46 ` [Buildroot] [PATCH 1/3] package/bash: use --bindir instead of exec_prefix= Yann E. MORIN
2021-04-26 19:02 ` Peter Korsgaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210423202356.37681-2-thomas.petazzoni@bootlin.com \
--to=thomas.petazzoni@bootlin.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox