Add dependency on bash to gzip for runtime
PATCH 1/2 Add dependency on bash to gzip for runtime
From: Jonathan Ben Avraham <[email protected]>
The GNU gzip package provides eleven executable files, all but one of which are bash shell scripts. If we allow inclusion of gzip without bash, then on executing commands such as lxc-checkconfig that actually use these shell scripts, you will get errors like 'zgrep: not found', even though the zgrep executable is in PATH.
This patch also sharpens up the help text and eliminates the claim to provide gzcat.
--- package/gzip/Config.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
package/gzip/Config.in +8 -5
@@ -1,11 +1,14 @@ config BR2_PACKAGE_GZIP bool "gzip" - depends on BR2_USE_WCHAR + depends on BR2_USE_WCHAR && BR2_PACKAGE_BASH help - Standard GNU compressor. Provides things like gzip, - gunzip, gzcat, etc... + The GNU implementation of gzip (http://www.gzip.org). + Provides: gunzip, gzexe, gzip, zcat, zcmp, zdiff, zforce, + zgrep, zless, zmore, and znew. All of the executables except + gzip are Bourne-Again shell scripts. Busybox provides a gzip + applet. http://www.gnu.org/software/gzip/gzip.html -comment "gzip needs a toolchain w/ wchar" - depends on !BR2_USE_WCHAR +comment "gzip needs bash and a toolchain w/ wchar" + depends on !BR2_USE_WCHAR || !BR2_PACKAGE_BASH
Signature · 1 line
1.7.9.5
PATCH 2/2 Add dependency on gzip to lxc for runtime
From: Jonathan Ben Avraham <[email protected]>
lxc executables such as lxc-checkconfig require scripts provided by gzip such as zgrep.
--- package/lxc/Config.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
package/lxc/Config.in +4 -2
@@ -9,6 +9,7 @@ config BR2_PACKAGE_LXC depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201305 depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201405 depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 # libcap + depends on BR2_PACKAGE_GZIP help Linux Containers (LXC), provides the ability to group and isolate of a set of processes in a jail by virtualizing and accounting the
@@ -16,10 +17,11 @@ config BR2_PACKAGE_LXC https://linuxcontainers.org/ -comment "lxc needs a toolchain w/ threads, headers >= 3.0, dynamic library" +comment "lxc needs gzip, toolchain w/ threads, headers >= 3.0, dynamic library" depends on BR2_USE_MMU depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201305 depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201405 depends on !BR2_TOOLCHAIN_HAS_THREADS \ || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 \ - || BR2_STATIC_LIBS + || BR2_STATIC_LIBS \ + || !BR2_PACKAGE_GZIP
Signature · 1 line
1.7.9.5
PATCH 2/2 Add dependency on gzip to lxc for runtime
Hi Yonatan,
Quoted 15 lines · Jonathan Ben-Avraham
From: Jonathan Ben Avraham <[email protected]>
lxc executables such as lxc-checkconfig require scripts provided by gzip such as zgrep.
Signed-off-by Jonathan Ben Avraham <[email protected]>--- package/lxc/Config.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)package/lxc/Config.in +0
-0
package/lxc/Config.in config BR2_PACKAGE_LXC · line 12
Quoted 4 lines
package/lxc/Config.in +1
-0@@ -9,6 +9,7 @@ config BR2_PACKAGE_LXC depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201305 depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201405 depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 # libcap + depends on BR2_PACKAGE_GZIP
We generally use 'select' for non obvious dependencies like this one. You'll also need to propagate the wchar dependency of gzip here.
baruch
Quoted 17 lines
package/lxc/Config.in +3
-2help Linux Containers (LXC), provides the ability to group and isolate of a set of processes in a jail by virtualizing and accounting the@@ -16,10 +17,11 @@ config BR2_PACKAGE_LXC https://linuxcontainers.org/ -comment "lxc needs a toolchain w/ threads, headers >= 3.0, dynamic library" +comment "lxc needs gzip, toolchain w/ threads, headers >= 3.0, dynamic library" depends on BR2_USE_MMU depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201305 depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201405 depends on !BR2_TOOLCHAIN_HAS_THREADS \ || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 \ - || BR2_STATIC_LIBS + || BR2_STATIC_LIBS \ + || !BR2_PACKAGE_GZIP
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH 2/2 Add dependency on gzip to lxc for runtime
Hi Baruch,
See inlines...
Quoted 19 lines · Baruch Siach
Date: Thu, 17 Sep 2015 18:03:53 +0300
From: Baruch Siach <[email protected]>
To: Jonathan Ben-Avraham <[email protected]>
Cc: buildroot at buildroot.org
Subject: Re: [Buildroot] [PATCH 2/2] Add dependency on gzip to lxc for runtimeHi Yonatan,
Quoted 10 lines · Jonathan Ben-Avraham
From: Jonathan Ben Avraham <[email protected]>
lxc executables such as lxc-checkconfig require scripts provided by gzip such as zgrep.
Signed-off-by Jonathan Ben Avraham <[email protected]>--- package/lxc/Config.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 12 lines
package/lxc/Config.in config BR2_PACKAGE_LXC · line 12
Quoted 9 lines
package/lxc/Config.in +1
-0@@ -9,6 +9,7 @@ config BR2_PACKAGE_LXC depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201305 depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201405 depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 # libcap + depends on BR2_PACKAGE_GZIPWe generally use 'select' for non obvious dependencies like this one. You'll also need to propagate the wchar dependency of gzip here.
I didn't use 'select' because of its implicit, sneaky nature. Bash is too heavy to just "select" it into a rootfs without the user explicitly putting an 'X' in the checkbox.
- yba
Quoted 21 lines
baruch
Quoted 17 lines
package/lxc/Config.in +3
-2help Linux Containers (LXC), provides the ability to group and isolate of a set of processes in a jail by virtualizing and accounting the@@ -16,10 +17,11 @@ config BR2_PACKAGE_LXC https://linuxcontainers.org/ -comment "lxc needs a toolchain w/ threads, headers >= 3.0, dynamic library" +comment "lxc needs gzip, toolchain w/ threads, headers >= 3.0, dynamic library" depends on BR2_USE_MMU depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201305 depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201405 depends on !BR2_TOOLCHAIN_HAS_THREADS \ || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 \ - || BR2_STATIC_LIBS + || BR2_STATIC_LIBS \ + || !BR2_PACKAGE_GZIP
Signature · 3 lines
9590 8E58 D30D 1660 C349 673D B205 4FC4 B8F5 B7F9 ~. .~ Tk Open Systems
=}-------- Jonathan Ben-Avraham ("yba") ----------ooO--U--Ooo------------{=
mailto:yba at tkos.co.il tel:+972.52.486.3386 http://tkos.co.il skype:benavrhmPATCH 2/2 Add dependency on gzip to lxc for runtime
Hello,
Quoted 32 lines · Jonathan Ben Avraham
Quoted 19 lines
Date: Thu, 17 Sep 2015 18:03:53 +0300
From: Baruch Siach <[email protected]>
To: Jonathan Ben-Avraham <[email protected]>
Cc: buildroot at buildroot.org
Subject: Re: [Buildroot] [PATCH 2/2] Add dependency on gzip to lxc for runtimeHi Yonatan,
Quoted 10 lines · Jonathan Ben-Avraham
From: Jonathan Ben Avraham <[email protected]>
lxc executables such as lxc-checkconfig require scripts provided by gzip such as zgrep.
Signed-off-by Jonathan Ben Avraham <[email protected]>--- package/lxc/Config.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)Quoted 12 lines
package/lxc/Config.in config BR2_PACKAGE_LXC · line 12
Quoted 9 lines
package/lxc/Config.in +1
-0@@ -9,6 +9,7 @@ config BR2_PACKAGE_LXC depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201305 depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII201405 depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 # libcap + depends on BR2_PACKAGE_GZIPWe generally use 'select' for non obvious dependencies like this one. You'll also need to propagate the wchar dependency of gzip here.
Quoted 3 lines
I didn't use 'select' because of its implicit, sneaky nature. Bash is too heavy to just "select" it into a rootfs without the user explicitly putting an 'X' in the checkbox.
Still, we want such dependencies to use a "select" like Baruch said. They should even be noted this way:
select BR2_PACKAGE_GZIP # runtime dep only
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/2 Add dependency on bash to gzip for runtime
In reply to Jonathan Ben-AvrahamHi Yonatan,
Quoted 7 lines · Jonathan Ben-Avraham
From: Jonathan Ben Avraham <[email protected]>
The GNU gzip package provides eleven executable files, all but one of which are bash shell scripts. If we allow inclusion of gzip without bash, then on executing commands such as lxc-checkconfig that actually use these shell scripts, you will get errors like 'zgrep: not found', even though the zgrep executable is in PATH.
Which /bin/sh shell show this problem?
On my host the command
busybox sh /bin/zgrep pattern file.gz
and also
dash /bin/zgrep pattern file.gz
work as expected.
baruch
Quoted 32 lines
This patch also sharpens up the help text and eliminates the claim to provide gzcat.
Signed-off-by Jonathan Ben Avraham <[email protected]>--- package/gzip/Config.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)package/gzip/Config.in +8
-5@@ -1,11 +1,14 @@ config BR2_PACKAGE_GZIP bool "gzip" - depends on BR2_USE_WCHAR + depends on BR2_USE_WCHAR && BR2_PACKAGE_BASH help - Standard GNU compressor. Provides things like gzip, - gunzip, gzcat, etc... + The GNU implementation of gzip (http://www.gzip.org). + Provides: gunzip, gzexe, gzip, zcat, zcmp, zdiff, zforce, + zgrep, zless, zmore, and znew. All of the executables except + gzip are Bourne-Again shell scripts. Busybox provides a gzip + applet. http://www.gnu.org/software/gzip/gzip.html -comment "gzip needs a toolchain w/ wchar" - depends on !BR2_USE_WCHAR +comment "gzip needs bash and a toolchain w/ wchar" + depends on !BR2_USE_WCHAR || !BR2_PACKAGE_BASH
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH 1/2 Add dependency on bash to gzip for runtime
Hi Baruch,
See inlines...
Quoted 22 lines · Baruch Siach
Date: Thu, 17 Sep 2015 18:01:12 +0300
From: Baruch Siach <[email protected]>
To: Jonathan Ben-Avraham <[email protected]>
Cc: buildroot at buildroot.org
Subject: Re: [Buildroot] [PATCH 1/2] Add dependency on bash to gzip for
runtimeHi Yonatan,
Quoted 7 lines · Jonathan Ben-Avraham
From: Jonathan Ben Avraham <[email protected]>
The GNU gzip package provides eleven executable files, all but one of which are bash shell scripts. If we allow inclusion of gzip without bash, then on executing commands such as lxc-checkconfig that actually use these shell scripts, you will get errors like 'zgrep: not found', even though the zgrep executable is in PATH.
Which
/bin/shshell show this problem?On my host the command
Quoted 7 lines
busybox sh
/bin/zgreppattern file.gzand also
dash
/bin/zgreppattern file.gzwork as expected.
You tested *all* of the scripts or just this one? What if ash breaks even *one*?
- yba
Quoted 36 lines
baruch
Quoted 32 lines
This patch also sharpens up the help text and eliminates the claim to provide gzcat.
Signed-off-by Jonathan Ben Avraham <[email protected]>--- package/gzip/Config.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)package/gzip/Config.in +8
-5@@ -1,11 +1,14 @@ config BR2_PACKAGE_GZIP bool "gzip" - depends on BR2_USE_WCHAR + depends on BR2_USE_WCHAR && BR2_PACKAGE_BASH help - Standard GNU compressor. Provides things like gzip, - gunzip, gzcat, etc... + The GNU implementation of gzip (http://www.gzip.org). + Provides: gunzip, gzexe, gzip, zcat, zcmp, zdiff, zforce, + zgrep, zless, zmore, and znew. All of the executables except + gzip are Bourne-Again shell scripts. Busybox provides a gzip + applet. http://www.gnu.org/software/gzip/gzip.html -comment "gzip needs a toolchain w/ wchar" - depends on !BR2_USE_WCHAR +comment "gzip needs bash and a toolchain w/ wchar" + depends on !BR2_USE_WCHAR || !BR2_PACKAGE_BASH
Signature · 3 lines
9590 8E58 D30D 1660 C349 673D B205 4FC4 B8F5 B7F9 ~. .~ Tk Open Systems
=}-------- Jonathan Ben-Avraham ("yba") ----------ooO--U--Ooo------------{=
mailto:yba at tkos.co.il tel:+972.52.486.3386 http://tkos.co.il skype:benavrhmPATCH 1/2 Add dependency on bash to gzip for runtime
Hi Yonatan,
Quoted 24 lines · Jonathan Ben Avraham
Quoted 22 lines · Baruch Siach
Date: Thu, 17 Sep 2015 18:01:12 +0300
From: Baruch Siach <[email protected]>
To: Jonathan Ben-Avraham <[email protected]>
Cc: buildroot at buildroot.org
Subject: Re: [Buildroot] [PATCH 1/2] Add dependency on bash to gzip for
runtimeQuoted 7 lines · Jonathan Ben-Avraham
From: Jonathan Ben Avraham <[email protected]>
The GNU gzip package provides eleven executable files, all but one of which are bash shell scripts. If we allow inclusion of gzip without bash, then on executing commands such as lxc-checkconfig that actually use these shell scripts, you will get errors like 'zgrep: not found', even though the zgrep executable is in PATH.
Which
/bin/shshell show this problem?On my host the command
busybox sh
/bin/zgreppattern file.gz
Quoted 7 lines
Quoted 5 lines
and also
dash
/bin/zgreppattern file.gzwork as expected.
You tested *all* of the scripts or just this one?
I didn't test all of them. I'm just trying to reproduce the 'zgrep: not found' problem that you report in the commit log, to see what went wrong.
Quoted 1 line
What if ash breaks even *one*?
Then we should probably patch the problem and send upstream. gzip bundled scripts are pretty trivial, and AFAICS, should work under any POSIX-like shell.
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH 1/2 Add dependency on bash to gzip for runtime
Hi Baruch,
See inlines...
Quoted 42 lines · Baruch Siach
Date: Thu, 17 Sep 2015 19:20:03 +0300
From: Baruch Siach <[email protected]>
To: Jonathan Ben Avraham <[email protected]>
Cc: buildroot at buildroot.org
Subject: Re: [Buildroot] [PATCH 1/2] Add dependency on bash to gzip for
runtimeHi Yonatan,
Quoted 24 lines · Jonathan Ben Avraham
Quoted 22 lines · Baruch Siach
Date: Thu, 17 Sep 2015 18:01:12 +0300
From: Baruch Siach <[email protected]>
To: Jonathan Ben-Avraham <[email protected]>
Cc: buildroot at buildroot.org
Subject: Re: [Buildroot] [PATCH 1/2] Add dependency on bash to gzip for
runtimeQuoted 7 lines · Jonathan Ben-Avraham
From: Jonathan Ben Avraham <[email protected]>
The GNU gzip package provides eleven executable files, all but one of which are bash shell scripts. If we allow inclusion of gzip without bash, then on executing commands such as lxc-checkconfig that actually use these shell scripts, you will get errors like 'zgrep: not found', even though the zgrep executable is in PATH.
Which
/bin/shshell show this problem?On my host the command
busybox sh
/bin/zgreppattern file.gzQuoted 7 lines
Quoted 5 lines
and also
dash
/bin/zgreppattern file.gzwork as expected.
You tested *all* of the scripts or just this one?
Quoted 8 lines
I didn't test all of them. I'm just trying to reproduce the 'zgrep: not found' problem that you report in the commit log, to see what went wrong.
Quoted 1 line
What if ash breaks even *one*?
Then we should probably patch the problem and send upstream. gzip bundled scripts are pretty trivial, and AFAICS, should work under any POSIX-like shell.
But we would at least need to ln -s /bin/<ash|dash> /bin/bash in Buildroot, no? so maybe the upstream fix is to change the hashbangs from /bin/bash to /bin/sh. Do you really think that the gzip upstream would accept this?
- yba
Quoted 3 lines
baruch
Signature · 3 lines
9590 8E58 D30D 1660 C349 673D B205 4FC4 B8F5 B7F9 ~. .~ Tk Open Systems
=}-------- Jonathan Ben-Avraham ("yba") ----------ooO--U--Ooo------------{=
mailto:yba at tkos.co.il tel:+972.52.486.3386 http://tkos.co.il skype:benavrhmPATCH 1/2 Add dependency on bash to gzip for runtime
Dear Jonathan Ben Avraham,
Quoted 8 lines · Jonathan Ben Avraham
Quoted 3 lines
Then we should probably patch the problem and send upstream. gzip bundled scripts are pretty trivial, and AFAICS, should work under any POSIX-like shell.
But we would at least need to ln -s /bin/<ash|dash>
/bin/bashin Buildroot, no? so maybe the upstream fix is to change the hashbangs from/bin/bashto/bin/sh. Do you really think that the gzip upstream would accept this?
All the gzip scripts are in fact generated. zgrep is generated from zgrep.in. zgrep.in contains:
#!/bin/sh
which gets replaced by the gzip Makefile.am by the value of $(SHELL):
SUFFIXES = .in
.in:
$(AM_V_GEN)sed \
-e 's|/bin/sh|$(SHELL)|g' \
-e 's|[@]bindir@|'\''$(bindir)'\''|g' \
-e 's|[@]GREP@|$(GREP)|g' \
-e 's|[@]VERSION@|$(VERSION)|g' \
$(srcdir)/[email protected] >$@-t \
&& chmod a+x $@-t \
&& mv $@-t $@Which is completely wrong, because it makes the assumption that $(SHELL) on your build machine is going to be available on your target.
So your patch is in fact wrong I believe, because if someone is using zsh, or tcsh or some other shell on their build machine, $(SHELL) will point to this shell and not to bash, and the scripts generated by gzip will use zsh/tcsh, etc. on the target.
So the proper way is most likely to adjust the gzip build system so that we can pass at configure time a different value for the shell path on the target (and it would default to $(SHELL) is not passed).
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/2 Add dependency on bash to gzip for runtime
Hi Thomas,
Quoted 32 lines · Thomas Petazzoni
Quoted 8 lines · Jonathan Ben Avraham
Quoted 3 lines
Then we should probably patch the problem and send upstream. gzip bundled scripts are pretty trivial, and AFAICS, should work under any POSIX-like shell.
But we would at least need to ln -s /bin/<ash|dash>
/bin/bashin Buildroot, no? so maybe the upstream fix is to change the hashbangs from/bin/bashto/bin/sh. Do you really think that the gzip upstream would accept this?All the gzip scripts are in fact generated. zgrep is generated from zgrep.in. zgrep.in contains:
#!/bin/sh
which gets replaced by the gzip Makefile.am by the value of $(SHELL):
SUFFIXES = .in
.in:$(AM_V_GEN)sed \ -e 's|/bin/sh|$(SHELL)|g' \ -e 's|[@]bindir@|'\''$(bindir)'\''|g' \ -e 's|[@]GREP@|$(GREP)|g' \ -e 's|[@]VERSION@|$(VERSION)|g' \ $(srcdir)/[email protected] >$@-t \ && chmod a+x $@-t \ && mv $@-t $@Which is completely wrong, because it makes the assumption that $(SHELL) on your build machine is going to be available on your target.
Quoted 8 lines
So your patch is in fact wrong I believe, because if someone is using zsh, or tcsh or some other shell on their build machine, $(SHELL) will point to this shell and not to bash, and the scripts generated by gzip will use zsh/tcsh, etc. on the target.
So the proper way is most likely to adjust the gzip build system so that we can pass at configure time a different value for the shell path on the target (and it would default to $(SHELL) is not passed).
Based on the following snippet from Buildroot top level Makefile I would assume that $(SHELL) is /bin/bash on my host machine:
# we want bash as shell
SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi; fi)However, 'make printvars' shows
SHELL=/bin/sh (/bin/sh)
$(SHELL) expands to /bin/sh in the gzip Makefile, and generated scripts carry the /bin/sh shebang. I have no idea how.
As for the original problem, I managed to override the environment $(SHELL) as indicated in the gzip INSTALL file:
GZIP_CONF_ENV = CONFIG_SHELL=/bin/bash
So the right fix, I guess, is just
GZIP_CONF_ENV = CONFIG_SHELL=/bin/sh
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH 1/2 Add dependency on bash to gzip for runtime
Baruch,
Quoted 11 lines · Baruch Siach
Based on the following snippet from Buildroot top level
MakefileI would assume that $(SHELL) is/bin/bashon my host machine:# we want bash as shell SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi; fi)However, 'make printvars' shows
SHELL=/bin/sh (/bin/sh)
Here:
SHELL=/bin/bash (/bin/bash)
Quoted 11 lines
$(SHELL) expands to
/bin/shin the gzipMakefile, and generated scripts carry the/bin/shshebang. I have no idea how.As for the original problem, I managed to override the environment $(SHELL) as indicated in the gzip INSTALL file:
GZIP_CONF_ENV=CONFIG_SHELL=/bin/bashSo the right fix, I guess, is just
GZIP_CONF_ENV=CONFIG_SHELL=/bin/sh
It is not a completely correct fix. According to
https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/config_002estatus-Invocation.html,CONFIG_SHELL is:
"""
The shell with which to run configure. It must be Bourne-compatible, and the absolute name of the shell should be passed. The default is a shell that supports LINENO if available, and /bin/sh otherwise. """
I believe there is no proper way with the current gzip build system to fix the problem. It is inherently wrong to assume that the $(SHELL) used on the host will be available on the target. The only sane option I believe is to have a --with-shell=<foo> option, which if not given defaults to $(SHELL) to retain the existing behavior.
Another simpler option is to simply add a post-install target hook that will adjust the shebang of the shell scripts installed by gzip.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/2 Add dependency on bash to gzip for runtime
Hi Thomas,
See inline comment below.
Quoted 49 lines · Thomas Petazzoni
Date: Thu, 17 Sep 2015 22:15:46 +0200
From: Thomas Petazzoni <[email protected]>
To: Baruch Siach <[email protected]>
Cc: Jonathan Ben Avraham <[email protected]>, buildroot at buildroot.org
Subject: Re: [Buildroot] [PATCH 1/2] Add dependency on bash to gzip for
runtimeBaruch,
Quoted 11 lines · Baruch Siach
Based on the following snippet from Buildroot top level
MakefileI would assume that $(SHELL) is/bin/bashon my host machine:# we want bash as shell SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi; fi)However, 'make printvars' shows
SHELL=/bin/sh (/bin/sh)Here:
SHELL=/bin/bash (
/bin/bash)Quoted 11 lines
$(SHELL) expands to
/bin/shin the gzipMakefile, and generated scripts carry the/bin/shshebang. I have no idea how.As for the original problem, I managed to override the environment $(SHELL) as indicated in the gzip INSTALL file:
GZIP_CONF_ENV=CONFIG_SHELL=/bin/bashSo the right fix, I guess, is just
GZIP_CONF_ENV=CONFIG_SHELL=/bin/shIt is not a completely correct fix. According to
https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/config_002estatus-Invocation.html,CONFIG_SHELLis:"""
The shell with which to run configure. It must be Bourne-compatible, and the absolute name of the shell should be passed. The default is a shell that supports LINENO if available, and/bin/shotherwise. """
Quoted 5 lines
I believe there is no proper way with the current gzip build system to fix the problem. It is inherently wrong to assume that the $(SHELL) used on the host will be available on the target. The only sane option I believe is to have a --with-shell=<foo> option, which if not given defaults to $(SHELL) to retain the existing behavior.
If I understand correctly you mean that the correct fix would require submitting a patch to the gzip maintainer to add the --with-shell configure option. This would not obviate the post-install hook you suggest below because we would need a heuristic to use with gzip --with-shell option.
Quoted 2 lines
Another simpler option is to simply add a post-install target hook that will adjust the shebang of the shell scripts installed by gzip.
In order to do this post-install hook we would need to know the shells that the user selected and choose one of them using some heuristic rule such as:
1. If the user chose the bash package, then use /bin/bash
2. If the user chose Busybox and not bash then use /bin/ash
3. If the user chose neither Busybox nor bash then use /bin/sh and hope for the best
If the user then changes the configuration and un-selects bash we would need to cause the gzip package to be re-built.
I wonder if all of this is worth it. IMHO it would be enough to note in the gzip package help text that the user might need to adjust the hashbangs of the scripts in some post-build script.
- yba
Quoted 4 lines
Best regards,
Thomas
Signature · 3 lines
9590 8E58 D30D 1660 C349 673D B205 4FC4 B8F5 B7F9 ~. .~ Tk Open Systems
=}-------- Jonathan Ben-Avraham ("yba") ----------ooO--U--Ooo------------{=
mailto:yba at tkos.co.il tel:+972.52.486.3386 http://tkos.co.il skype:benavrhmPATCH 1/2 Add dependency on bash to gzip for runtime
Jonathan,
Quoted 9 lines · Jonathan Ben Avraham
Quoted 5 lines
I believe there is no proper way with the current gzip build system to fix the problem. It is inherently wrong to assume that the $(SHELL) used on the host will be available on the target. The only sane option I believe is to have a --with-shell=<foo> option, which if not given defaults to $(SHELL) to retain the existing behavior.
If I understand correctly you mean that the correct fix would require submitting a patch to the gzip maintainer to add the --with-shell configure option.
Correct.
Quoted 3 lines
This would not obviate the post-install hook you suggest below because we would need a heuristic to use with gzip --with-shell option.
I'm not sure to follow you. We would just have to do:
GZIP_CONF_ENV += --with-shell=/the/right/value
Quoted 11 lines
In order to do this post-install hook we would need to know the shells that the user selected and choose one of them using some heuristic rule such as:
1. If the user chose the bash package, then use
/bin/bash
2. If the user chose Busybox and not bash then use/bin/ash
3. If the user chose neither Busybox nor bash then use/bin/shand hope for the bestIf the user then changes the configuration and un-selects bash we would need to cause the gzip package to be re-built.
No: we don't handle such automatic rebuilds after configuration changes. See
http://buildroot.org/downloads/manual/manual.html#full-rebuild.
Quoted 4 lines
I wonder if all of this is worth it. IMHO it would be enough to note in the gzip package help text that the user might need to adjust the hashbangs of the scripts in some post-build script.
There's some logic in the skeleton package that guarantees that /bin/sh points to the system shell selected by the user in his configuration. So forcing /bin/sh as the shebang should be fine.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/2 Add dependency on bash to gzip for runtime
Quoted 3 lines · Thomas Petazzoni
Jonathan,
On Sat, 19 Sep 2015 23:36:47 +0300 (IDT), Jonathan Ben Avraham wrote:
[snip]
Quoted 7 lines
Quoted 3 lines
I wonder if all of this is worth it. IMHO it would be enough to note in the gzip package help text that the user might need to adjust the hashbangs of the scripts in some post-build script.
There's some logic in the skeleton package that guarantees that
/bin/shpoints to the system shell selected by the user in his configuration. So forcing/bin/shas the shebang should be fine.
Well, if the scripts indeed require Bourne extensions, then possibly ash and
dash will not work... And I have no idea about zsh either.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/2 Add dependency on bash to gzip for runtime
Hello,
Quoted 6 lines · Arnout Vandecappelle
Quoted 3 lines
There's some logic in the skeleton package that guarantees that
/bin/shpoints to the system shell selected by the user in his configuration. So forcing/bin/shas the shebang should be fine.Well, if the scripts indeed require Bourne extensions, then possibly ash and
dash will not work... And I have no idea about zsh either.
I think Baruch said he had tried, and the script were working fine with the Busybox shell.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/2 Add dependency on bash to gzip for runtime
Hi Thomas,
Quoted 10 lines · Thomas Petazzoni
Quoted 6 lines · Arnout Vandecappelle
Quoted 3 lines
There's some logic in the skeleton package that guarantees that
/bin/shpoints to the system shell selected by the user in his configuration. So forcing/bin/shas the shebang should be fine.Well, if the scripts indeed require Bourne extensions, then possibly ash and
dash will not work... And I have no idea about zsh either.I think Baruch said he had tried, and the script were working fine with the Busybox shell.
I only tried zgrep. But as I said, all these scripts look pretty trivial, and I can't find any mention of shell dependencies in gzip sources. On Debian all of these scrips use the /bin/sh shebang, and AFAIK Debian does not guarantee /bin/sh to point to bash. I think we can safely assume that any POSIX-like shell will work.
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -