unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#40641: Building from git breaks when /bin/sh isn't bash
@ 2020-04-15  9:06 elaexuotee--- via Bug reports for GNU Guix
  2020-04-15 12:21 ` pelzflorian (Florian Pelz)
  0 siblings, 1 reply; 8+ messages in thread
From: elaexuotee--- via Bug reports for GNU Guix @ 2020-04-15  9:06 UTC (permalink / raw)
  To: 40641


[-- Attachment #1.1: Type: text/plain, Size: 1041 bytes --]

When building from git, ./bootstrap ends up generating (via automake) several
Makefiles that set SHELL = /bin/sh. However, some targets contain rules that
make use of bashisms. This leads to breakage when /bin/sh is something other
than bash.

In particular, I am building from a foreign distro which links /bin/sh to dash.
Currently, this ends up breaking the build, the details of which I reported
to guix-devel in [0].

As a workaround, at the moment we have to force make's SHELL to point to bash.
The cleanest way to do this is probably as follows:

    $ make SHELL=$(command -v sh)

since from within guix environment --pure guix, sh ends up pointing to bash.
Just for clarity, here is how this looks for me, currently:

    $ git rev-parse HEAD
    2708ae3d69b54d8323ca84fd9a7fb108a6ee96ba
    $ guix environment --pure guix
    $ readlink -f $(command -v sh)
    /gnu/store/29jhbbg1hf557x8j53f9sxd9imlmf02a-bash-minimal-5.0.7/bin/bash

[0]:https://lists.gnu.org/archive/html/guix-devel/2020-04/msg00232.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#40641: Building from git breaks when /bin/sh isn't bash
  2020-04-15  9:06 bug#40641: Building from git breaks when /bin/sh isn't bash elaexuotee--- via Bug reports for GNU Guix
@ 2020-04-15 12:21 ` pelzflorian (Florian Pelz)
  2020-04-17 14:57   ` elaexuotee--- via Bug reports for GNU Guix
  0 siblings, 1 reply; 8+ messages in thread
From: pelzflorian (Florian Pelz) @ 2020-04-15 12:21 UTC (permalink / raw)
  To: elaexuotee; +Cc: 40641

On Wed, Apr 15, 2020 at 06:06:25PM +0900, elaexuotee--- via Bug reports for GNU Guix wrote:
> When building from git, ./bootstrap ends up generating (via automake) several
> Makefiles that set SHELL = /bin/sh. However, some targets contain rules that
> make use of bashisms. This leads to breakage when /bin/sh is something other
> than bash.
> 
> In particular, I am building from a foreign distro which links /bin/sh to dash.
> Currently, this ends up breaking the build, the details of which I reported
> to guix-devel in [0].

<https://bugs.gnu.org/25258> is related.  Your workaround may be more welcome.

Regards,
Florian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#40641: Building from git breaks when /bin/sh isn't bash
  2020-04-15 12:21 ` pelzflorian (Florian Pelz)
@ 2020-04-17 14:57   ` elaexuotee--- via Bug reports for GNU Guix
  2022-06-10  0:34     ` Maxim Cournoyer
  0 siblings, 1 reply; 8+ messages in thread
From: elaexuotee--- via Bug reports for GNU Guix @ 2020-04-17 14:57 UTC (permalink / raw)
  To: pelzflorian (Florian Pelz); +Cc: 40641


[-- Attachment #1.1: Type: text/plain, Size: 1760 bytes --]

"pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> wrote:
> On Wed, Apr 15, 2020 at 06:06:25PM +0900, elaexuotee--- via Bug reports for GNU Guix wrote:
> > When building from git, ./bootstrap ends up generating (via automake) several
> > Makefiles that set SHELL = /bin/sh. However, some targets contain rules that
> > make use of bashisms. This leads to breakage when /bin/sh is something other
> > than bash.
> > 
> > In particular, I am building from a foreign distro which links /bin/sh to dash.
> > Currently, this ends up breaking the build, the details of which I reported
> > to guix-devel in [0].
> 
> <https://bugs.gnu.org/25258> is related.  Your workaround may be more welcome.
> 
> Regards,
> Florian


Florian,

Thanks for the pointer. I ended up doing a little bit of sleuthing and think
I figured out a relatively clean fix---a simple one-liner in configure.ac.
Attached is a proof-of-concept patch against master (974bf81776).

Currently, autoconf sets make's shell to whatever it thinks is best. On a
foreign distribution, this often ends up something external to guix profile.
However, when this isn't bash, we run into problems.

The patch's idea is to let make use its hard-coded default shell. A guix-built
make will correctly fallback to whichever sh is in the profile, so for `guix
environment guix' this effectively becomes $GUIX_ENVIRONMENT/bin/sh. For
example,

    $ echo '$(info $(SHELL))' | make -f -
    /gnu/store/29jhbbg1hf557x8j53f9sxd9imlmf02a-bash-minimal-5.0.7/bin/sh
    make: *** No targets.  Stop.

I belive this should do the Right Thing. However, is there anything I am
missing? Perhaps this change would break build scenaries I am not thinking of?

Cheers,
B. Wilson


[-- Attachment #1.2: 0001-build-Let-make-use-its-hard-coded-default-shell.patch --]
[-- Type: text/plain, Size: 866 bytes --]

From 6a5533fde0580a777a10f1155714f23a003003d9 Mon Sep 17 00:00:00 2001
From: "B. Wilson" <elaexuotee@wilsonb.com>
Date: Thu, 16 Apr 2020 17:02:06 +0900
Subject: [PATCH] build: Let make use its hard-coded default shell
To: guix-patches@gnu.org

* configure.ac: Set AM_SUBST_NOTMAKE([SHELL])
---
 configure.ac | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/configure.ac b/configure.ac
index 6a6a020585..dbb06f2258 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,6 +11,10 @@ AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([1.14 gnu silent-rules subdir-objects \
  color-tests parallel-tests -Woverride -Wno-portability])
 
+# Use make's hard-coded default shell. The make in a guix profile
+# defaults to the Right Thing, e.g. $GUIX_ENVIRONMENT/bin/sh
+AM_SUBST_NOTMAKE([SHELL])
+
 # Enable silent rules by default.
 AM_SILENT_RULES([yes])
 
-- 
2.26.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#40641: Building from git breaks when /bin/sh isn't bash
  2020-04-17 14:57   ` elaexuotee--- via Bug reports for GNU Guix
@ 2022-06-10  0:34     ` Maxim Cournoyer
  2022-06-13 14:40       ` pelzflorian (Florian Pelz)
  0 siblings, 1 reply; 8+ messages in thread
From: Maxim Cournoyer @ 2022-06-10  0:34 UTC (permalink / raw)
  To: elaexuotee; +Cc: 40641, pelzflorian (Florian Pelz)

Hello,

elaexuotee@wilsonb.com writes:

> "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> wrote:
>> On Wed, Apr 15, 2020 at 06:06:25PM +0900, elaexuotee--- via Bug reports for GNU Guix wrote:
>> > When building from git, ./bootstrap ends up generating (via automake) several
>> > Makefiles that set SHELL = /bin/sh. However, some targets contain rules that
>> > make use of bashisms. This leads to breakage when /bin/sh is something other
>> > than bash.
>> > 
>> > In particular, I am building from a foreign distro which links /bin/sh to dash.
>> > Currently, this ends up breaking the build, the details of which I reported
>> > to guix-devel in [0].
>> 
>> <https://bugs.gnu.org/25258> is related.  Your workaround may be more welcome.
>> 
>> Regards,
>> Florian
>
>
> Florian,
>
> Thanks for the pointer. I ended up doing a little bit of sleuthing and think
> I figured out a relatively clean fix---a simple one-liner in configure.ac.
> Attached is a proof-of-concept patch against master (974bf81776).
>
> Currently, autoconf sets make's shell to whatever it thinks is best. On a
> foreign distribution, this often ends up something external to guix profile.
> However, when this isn't bash, we run into problems.
>
> The patch's idea is to let make use its hard-coded default shell. A guix-built
> make will correctly fallback to whichever sh is in the profile, so for `guix
> environment guix' this effectively becomes $GUIX_ENVIRONMENT/bin/sh. For
> example,
>
>     $ echo '$(info $(SHELL))' | make -f -
>     /gnu/store/29jhbbg1hf557x8j53f9sxd9imlmf02a-bash-minimal-5.0.7/bin/sh
>     make: *** No targets.  Stop.
>
> I belive this should do the Right Thing. However, is there anything I am
> missing? Perhaps this change would break build scenaries I am not thinking of?

This seems odd to me.  Perhaps it'd be cleaner to detect which shell is
used at configure time to detect when /bin/sh != Bash, and warn that if
there are issues, the user should set the SHELL variable to Bash.

Or if the Bashisms are scarce enough, perhaps we can rewrite the
routines in POSIXly correct shell, although this being a GNU project I
don't really see the merit of forcing lesser shells (and less readable
code) on ourselves.

Could you provide a list of the problematic targets?  Or if my
suggestion sounds good, give it a shot?

Thanks :-)

Maxim




^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#40641: Building from git breaks when /bin/sh isn't bash
  2022-06-10  0:34     ` Maxim Cournoyer
@ 2022-06-13 14:40       ` pelzflorian (Florian Pelz)
  2022-06-14 16:09         ` Maxim Cournoyer
  0 siblings, 1 reply; 8+ messages in thread
From: pelzflorian (Florian Pelz) @ 2022-06-13 14:40 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: 40641, elaexuotee

Only the tests are affected, as far as I can tell.  make runs fine.
The issue with “gnu/local.mk” from [1] got fixed in 2019 via
92d00ca4661e186022732a47956a2bc0ef16be96.

But Makefile.am has 

SH_LOG_COMPILER = $(top_builddir)/test-env $(SHELL)
AM_SH_LOG_FLAGS = -x -e

Probably autoconf can be made to detect if $(SHELL) is bash or zsh
somehow™.  But I suppose it is not important and I won’t fix it.

Regards,
Florian




^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#40641: Building from git breaks when /bin/sh isn't bash
  2022-06-13 14:40       ` pelzflorian (Florian Pelz)
@ 2022-06-14 16:09         ` Maxim Cournoyer
  2022-06-21  0:20           ` elaexuotee--- via Bug reports for GNU Guix
  0 siblings, 1 reply; 8+ messages in thread
From: Maxim Cournoyer @ 2022-06-14 16:09 UTC (permalink / raw)
  To: pelzflorian (Florian Pelz); +Cc: 40641, elaexuotee

Hello,

"pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> writes:

> Only the tests are affected, as far as I can tell.  make runs fine.
> The issue with “gnu/local.mk” from [1] got fixed in 2019 via
> 92d00ca4661e186022732a47956a2bc0ef16be96.
>
> But Makefile.am has 
>
> SH_LOG_COMPILER = $(top_builddir)/test-env $(SHELL)
> AM_SH_LOG_FLAGS = -x -e
>
> Probably autoconf can be made to detect if $(SHELL) is bash or zsh
> somehow™.  But I suppose it is not important and I won’t fix it.

Wilson, could you confirm whether there's still something to fix here?
Else, let's close this ticket and move on.

Thanks,

Maxim




^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#40641: Building from git breaks when /bin/sh isn't bash
  2022-06-14 16:09         ` Maxim Cournoyer
@ 2022-06-21  0:20           ` elaexuotee--- via Bug reports for GNU Guix
  2022-06-21  9:02             ` pelzflorian (Florian Pelz)
  0 siblings, 1 reply; 8+ messages in thread
From: elaexuotee--- via Bug reports for GNU Guix @ 2022-06-21  0:20 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: 40641, pelzflorian (Florian Pelz)

> Wilson, could you confirm whether there's still something to fix here?
> Else, let's close this ticket and move on.

The original issue arose on a Void Linux foreign distro installation. I have
long since converted to Guix System, so cannot easily test the original
environment.

However, Void just runs dash as it's default sh, so you could be able to sanity
check with something like

    $ guix shell -C dash guix make <etc>
    $ ln -s $(command -v dash) /bin/sh
    $ ./configure --localstatedir && make




^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#40641: Building from git breaks when /bin/sh isn't bash
  2022-06-21  0:20           ` elaexuotee--- via Bug reports for GNU Guix
@ 2022-06-21  9:02             ` pelzflorian (Florian Pelz)
  0 siblings, 0 replies; 8+ messages in thread
From: pelzflorian (Florian Pelz) @ 2022-06-21  9:02 UTC (permalink / raw)
  To: elaexuotee; +Cc: 40641, Maxim Cournoyer

Thank you for getting back to the bug.  I am in the same situation in
that I use Guix System now. :D

On Tue, Jun 21, 2022 at 09:20:28AM +0900, elaexuotee@wilsonb.com wrote:
> so you could be able to sanity
> check with something like
> 
>     $ guix shell -C dash guix make <etc>
>     $ ln -s $(command -v dash) /bin/sh
>     $ ./configure --localstatedir && make

I had done exactly this.

guix shell --container --network dash git pkg-config gnutls guile guile-avahi guile-gcrypt guile-json guile-lib guile-sqlite3 guile-zlib guile-lzlib guile-zstd guile-ssh guile-git autoconf automake gettext texinfo graphviz help2man po4a findutils sed coreutils tar xz m4 diffutils grep gcc-toolchain sqlite libgcrypt gawk make glibc-locales -- dash

Many tests fail because of the container though, so I’m not sure how
big the effect is.  At least tests/guix-package.sh still use type -P
which is not POSIX, but I don’t think it should be changed nor should
there be a check if $SHELL can do what we need, because we don’t know
which bash features we need.

Regards,
Florian




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-21  9:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15  9:06 bug#40641: Building from git breaks when /bin/sh isn't bash elaexuotee--- via Bug reports for GNU Guix
2020-04-15 12:21 ` pelzflorian (Florian Pelz)
2020-04-17 14:57   ` elaexuotee--- via Bug reports for GNU Guix
2022-06-10  0:34     ` Maxim Cournoyer
2022-06-13 14:40       ` pelzflorian (Florian Pelz)
2022-06-14 16:09         ` Maxim Cournoyer
2022-06-21  0:20           ` elaexuotee--- via Bug reports for GNU Guix
2022-06-21  9:02             ` pelzflorian (Florian Pelz)

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).