From mboxrd@z Thu Jan 1 00:00:00 1970 From: Baruch Siach Date: Thu, 17 Sep 2015 22:04:24 +0300 Subject: [Buildroot] [PATCH 1/2] Add dependency on bash to gzip for runtime In-Reply-To: <20150917192315.6db18115@free-electrons.com> References: <1442501193-6059-1-git-send-email-yba@tkos.co.il> <20150917150112.GR11632@tarshish> <20150917162003.GT11632@tarshish> <20150917192315.6db18115@free-electrons.com> Message-ID: <20150917190424.GU11632@tarshish> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net Hi Thomas, On Thu, Sep 17, 2015 at 07:23:15PM +0200, Thomas Petazzoni wrote: > On Thu, 17 Sep 2015 19:33:24 +0300 (IDT), Jonathan Ben Avraham wrote: > > > > 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/ /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? > > 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)/$@.in >$@-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). 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 -- 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 -