Skip to contentSkip to conversation

package/grep: fix egrep/fgrep shebang

PATCH New Angelo Compagnucci 2 participants 4 messages Feb 4, 2020 – Mar 10, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/grep: fix egrep/fgrep shebang

egrep/fgrep are using autotools SHELL variable to exec the grep executable with correct options, SHELL is defaulted to /bin/bash which we usually don't have on target. This patch defaults on /bin/sh, when /bin/sh is not available on target, we simply remove the aliases.

---
Changelog:
v1 -> v2:
* Handling the corner case when BR2_SYSTEM_BIN_SH_NONE as suggested by Yann

 package/grep/Config.in | 2 ++
 package/grep/grep.mk   | 9 +++++++++
 2 files changed, 11 insertions(+)
package/grep/Config.in +2 -0
index 5b0471b..47ced41 100644
@@ -5,6 +5,8 @@ config BR2_PACKAGE_GREP
 	help
 	  The GNU regular expression matcher.
 
+	  egrep/fgrep aliases need /bin/sh to be available.
+
 	  http://www.gnu.org/software/grep/grep.html
 
 comment "grep needs a toolchain w/ wchar"
package/grep/grep.mk +9 -0
index be3e53b..02d8b50 100644
@@ -12,6 +12,15 @@ GREP_LICENSE_FILES = COPYING
 GREP_DEPENDENCIES = $(TARGET_NLS_DEPENDENCIES)
 GREP_CONF_OPTS = --exec-prefix=/
 
+ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
+define GREP_REMOVE_ALIAS
+	$(RM) $(TARGET_DIR)/bin/[fe]grep
+endef
+GREP_POST_INSTALL_TARGET_HOOKS += GREP_REMOVE_ALIAS
+else
+GREP_CONF_OPTS += SHELL=/bin/sh
+endif
+
 # link with iconv if enabled
 ifeq ($(BR2_PACKAGE_LIBICONV),y)
 GREP_CONF_ENV += LIBS=-liconv
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 package/grep: fix egrep/fgrep shebang

Quoted 37 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Angelo" == Angelo Compagnucci <[email protected]> writes:

egrep/fgrep are using autotools SHELL variable to exec the grep executable with correct options, SHELL is defaulted to /bin/bash which we usually don't have on target. This patch defaults on /bin/sh, when /bin/sh is not available on target, we simply remove the aliases.

---
Changelog:
v1 -> v2:
* Handling the corner case when BR2_SYSTEM_BIN_SH_NONE as suggested by Yann

 package/grep/Config.in | 2 ++
 package/grep/grep.mk   | 9 +++++++++
 2 files changed, 11 insertions(+)
package/grep/Config.in +2 -0
index 5b0471b..47ced41 100644
@@ -5,6 +5,8 @@ config BR2_PACKAGE_GREP
 	help
 	  The GNU regular expression matcher.
 
+	  egrep/fgrep aliases need /bin/sh to be available.
+
 	  http://www.gnu.org/software/grep/grep.html
 
 comment "grep needs a toolchain w/ wchar"
package/grep/grep.mk +0 -0
index be3e53b..02d8b50 100644

package/grep/grep.mk GREP_LICENSE_FILES = COPYING · line 21

Quoted 10 lines
package/grep/grep.mk +7 -0
@@ -12,6 +12,15 @@ GREP_LICENSE_FILES = COPYING
 GREP_DEPENDENCIES = $(TARGET_NLS_DEPENDENCIES)
 GREP_CONF_OPTS = --exec-prefix=/
 
+ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
+define GREP_REMOVE_ALIAS
+	$(RM) $(TARGET_DIR)/bin/[fe]grep
+endef
+GREP_POST_INSTALL_TARGET_HOOKS += GREP_REMOVE_ALIAS
+else
+GREP_CONF_OPTS += SHELL=/bin/sh

It is a bit odd to not do this unconditionally. Such environment variables normally go in _CONF_ENV, so I changed that, reworded the commit message a bit and committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH v2 1/1 package/grep: fix egrep/fgrep shebang

Quoted 8 lines

package/grep/grep.mk GREP_LICENSE_FILES = COPYING · line 21

Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Peter" == Peter Korsgaard <[email protected]> writes:

package/grep/grep.mk +2 -0
+else
+GREP_CONF_OPTS += SHELL=/bin/sh

It is a bit odd to not do this unconditionally. Such environment variables normally go in _CONF_ENV, so I changed that, reworded the commit message a bit and committed, thanks.

Except that it doesn't work, so in the end I changed it to just sed s/bash/sh/ in a post-install hook. That way it will not break if the configure script / Makefile ever start using bashisms.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v2 1/1 package/grep: fix egrep/fgrep shebang

In reply to Peter Korsgaard
Quoted 41 lines
Quoted 40 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

"Peter" == Peter Korsgaard <[email protected]> writes:

"Angelo" == Angelo Compagnucci <[email protected]> writes:

egrep/fgrep are using autotools SHELL variable to exec the grep executable with correct options, SHELL is defaulted to /bin/bash which we usually don't have on target. This patch defaults on /bin/sh, when /bin/sh is not available on target, we simply remove the aliases.

---
Changelog:
v1 -> v2:
* Handling the corner case when BR2_SYSTEM_BIN_SH_NONE as suggested by Yann

package/grep/Config.in | 2 ++
package/grep/grep.mk | 9 +++++++++

2 files changed, 11 insertions(+)
package/grep/Config.in +0 -0
index 5b0471b..47ced41 100644
@@ -5,6 +5,8 @@ config BR2_PACKAGE_GREP

help
The GNU regular expression matcher.

package/grep/Config.in +2 -0
+	  egrep/fgrep aliases need /bin/sh to be available.
+

http://www.gnu.org/software/grep/grep.html

comment "grep needs a toolchain w/ wchar"

package/grep/grep.mk +0 -0
index be3e53b..02d8b50 100644
@@ -12,6 +12,15 @@ GREP_LICENSE_FILES = COPYING
 GREP_DEPENDENCIES = $(TARGET_NLS_DEPENDENCIES)

GREP_CONF_OPTS = --exec-prefix=/

Quoted 11 lines

package/grep/grep.mk GREP_LICENSE_FILES = COPYING · line 21

Quoted 7 lines
package/grep/grep.mk +7 -0
+ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
+define GREP_REMOVE_ALIAS
+	$(RM) $(TARGET_DIR)/bin/[fe]grep
+endef
+GREP_POST_INSTALL_TARGET_HOOKS += GREP_REMOVE_ALIAS
+else
+GREP_CONF_OPTS += SHELL=/bin/sh

It is a bit odd to not do this unconditionally. Such environment variables normally go in _CONF_ENV, so I changed that, reworded the commit message a bit and committed, thanks.

Committed to 2019.02.x and 2019.11.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard