What can cause this script to fail in Factory/Tumbleweed.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

What can cause this script to fail in Factory/Tumbleweed.

Dave Plater lst
I'm having a problem dvdisaster's bash-based-configure script where it
checks for make. It fails in Factory but passes in 42.2 downwards. This
is it:

# Check for tools
#

function REQUIRE_GMAKE()
{
    if test -n "$cfg_help_mode"; then
       return 0
    fi

    echo -n "Checking for gmake: "

    if (gmake -v | grep "GNU Make") > /dev/null 2>&1 ;
      then echo "yes"
           echo "MAKE = `which gmake`" >>Makefile.config
           return 0
    fi;

    if (make -v | grep "GNU Make") > /dev/null 2>&1 ;
      then echo "yes"
           echo "MAKE = `which make`" >>Makefile.config
           return 0
    fi;

    echo "no"
    echo "This package requires GNU make (gmake)."
    exit 1;
}
The output of make -v is identical in Tumbleweed and 42.2 all I can
think  of is either bash or grep have changed. I worked around the
problem by patching in "echo "MAKE = `which make`" >>Makefile.config" as
an else statement but I'd love to know what is actually wrong.

Thanks

Dave P

--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: What can cause this script to fail in Factory/Tumbleweed.

Bernhard Voelker
On 01/05/2017 01:17 PM, Dave Plater wrote:

> I'm having a problem dvdisaster's bash-based-configure script where it checks for make. It fails in Factory but passes in 42.2 downwards. This is it:
>
> # Check for tools
> #
>
> function REQUIRE_GMAKE()
> {
>    if test -n "$cfg_help_mode"; then
>       return 0
>    fi
>
>    echo -n "Checking for gmake: "
>
>    if (gmake -v | grep "GNU Make") > /dev/null 2>&1 ;
>      then echo "yes"
>           echo "MAKE = `which gmake`" >>Makefile.config
>           return 0
>    fi;
>
>    if (make -v | grep "GNU Make") > /dev/null 2>&1 ;
>      then echo "yes"
>           echo "MAKE = `which make`" >>Makefile.config
>           return 0
>    fi;
>
>    echo "no"
>    echo "This package requires GNU make (gmake)."
>    exit 1;
> }
> The output of make -v is identical in Tumbleweed and 42.2 all I can think  of is either bash or grep have changed. I worked around the problem by patching in "echo "MAKE = `which make`"
>>>Makefile.config" as an else statement but I'd love to know what is actually wrong.
>
> Thanks
>
> Dave P
>

It seems that gmake behaves differently in this construct if stderr is pointing
to the same file descriptor as stdout:

  $ ( gmake -v | grep GNU ) >/dev/null 2>/dev/null && echo OK || echo FAIL
  OK

  $ ( gmake -v | grep GNU ) >/dev/null 2>&1        && echo OK || echo FAIL
  FAIL

Really odd ... could be a bash-4.4 bug/feature.

For your case, I'd personally go with something like for now:

  if gmake -v 2>/dev/null | grep -qF "GNU Make"; then
    echo "yes"
    echo "MAKE = $(which make)" >>Makefile.config
    return 0
  fi

as the additional subshell is redundant, and you'd probably want to be informed
about grep errors, won't you?

Have a nice day,
Berny

--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: What can cause this script to fail in Factory/Tumbleweed.

Brüns, Stefan
In reply to this post by Dave Plater lst
On Donnerstag, 5. Januar 2017 14:17:09 CET Dave Plater wrote:

> I'm having a problem dvdisaster's bash-based-configure script where it
> checks for make. It fails in Factory but passes in 42.2 downwards. This
> is it:
>
> # Check for tools
> #
>
> function REQUIRE_GMAKE()
> {
>     if test -n "$cfg_help_mode"; then
>        return 0
>     fi
>
>     echo -n "Checking for gmake: "
>
>     if (gmake -v | grep "GNU Make") > /dev/null 2>&1 ;

(gmake -v | grep "GNU Make") > /dev/null ; echo $?
0

(gmake -v | grep "GNU Make") > /dev/null 2>&1 ; echo $?
2

The culprit seems to be a failing call to splice() in grep:

LANG=C strace -edup2,close,open,splice,read,write,execve,lseek  -s 150  -f
bash -c '(/usr/bin/gmake -v | /usr/bin/grep "GNU Make") > /dev/null 2>&1'

[pid  3756] write(1, "GNU Make 4.2.1\n", 15) = 15
[pid  3757] <... read resumed> "GNU Make 4.2.1\n", 32768) = 15
[pid  3756] write(1, "Built for x86_64-suse-linux-gnu\n", 32 <unfinished ...>
[pid  3757] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE <unfinished ...>
[pid  3756] <... write resumed> )       = 32
[pid  3757] <... splice resumed> )      = -1 EINVAL (Invalid argument)
[pid  3756] write(1, "Copyright (C) 1988-2016 Free Software Foundation, Inc.
\n", 55) = 55
[pid  3757] write(2, "/usr/bin/grep: ", 15 <unfinished ...>
[pid  3756] write(1, "License GPLv3+: GNU GPL version 3 or later <http://
gnu.org/licenses/gpl.html>\n", 78 <unfinished ...>
[pid  3757] <... write resumed> )       = 15
[pid  3756] <... write resumed> )       = 78
[pid  3757] write(2, "(standard input)", 16 <unfinished ...>
[pid  3756] write(1, "This is free software: you are free to change and
redistribute it.\n", 67 <unfinished ...>
[pid  3757] <... write resumed> )       = 16
[pid  3756] <... write resumed> )       = 67
[pid  3757] write(2, ": Invalid argument", 18 <unfinished ...>
[pid  3756] write(1, "There is NO WARRANTY, to the extent permitted by law.
\n", 54 <unfinished ...>
[pid  3757] <... write resumed> )       = 18
[pid  3756] <... write resumed> )       = 54
[pid  3757] write(2, "\n", 1)           = 1
[pid  3757] close(1)                    = 0
[pid  3757] close(2 <unfinished ...>
[pid  3756] close(1 <unfinished ...>
[pid  3757] <... close resumed> )       = 0
[pid  3756] <... close resumed> )       = 0
[pid  3757] +++ exited with 2 +++

3756 is gmake, 3757 is grep.

Can anyone test the above strace call with 42.2?

Kind regards,

Stefan

--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: What can cause this script to fail in Factory/Tumbleweed.

Dave Plater lst
In reply to this post by Bernhard Voelker


On 05/01/2017 16:26, Bernhard Voelker wrote:

> On 01/05/2017 01:17 PM, Dave Plater wrote:
>> I'm having a problem dvdisaster's bash-based-configure script where it checks for make. It fails in Factory but passes in 42.2 downwards. This is it:
>>
>> # Check for tools
>> #
>>
>> function REQUIRE_GMAKE()
>> {
>>     if test -n "$cfg_help_mode"; then
>>        return 0
>>     fi
>>
>>     echo -n "Checking for gmake: "
>>
>>     if (gmake -v | grep "GNU Make") > /dev/null 2>&1 ;
>>       then echo "yes"
>>            echo "MAKE = `which gmake`" >>Makefile.config
>>            return 0
>>     fi;
>>
>>     if (make -v | grep "GNU Make") > /dev/null 2>&1 ;
>>       then echo "yes"
>>            echo "MAKE = `which make`" >>Makefile.config
>>            return 0
>>     fi;
>>
>>     echo "no"
>>     echo "This package requires GNU make (gmake)."
>>     exit 1;
>> }
>> The output of make -v is identical in Tumbleweed and 42.2 all I can think  of is either bash or grep have changed. I worked around the problem by patching in "echo "MAKE = `which make`"
>>>> Makefile.config" as an else statement but I'd love to know what is actually wrong.
>> Thanks
>>
>> Dave P
>>
> It seems that gmake behaves differently in this construct if stderr is pointing
> to the same file descriptor as stdout:
>
>    $ ( gmake -v | grep GNU ) >/dev/null 2>/dev/null && echo OK || echo FAIL
>    OK
>
>    $ ( gmake -v | grep GNU ) >/dev/null 2>&1        && echo OK || echo FAIL
>    FAIL
>
> Really odd ... could be a bash-4.4 bug/feature.
>
> For your case, I'd personally go with something like for now:
>
>    if gmake -v 2>/dev/null | grep -qF "GNU Make"; then
>      echo "yes"
>      echo "MAKE = $(which make)" >>Makefile.config
>      return 0
>    fi
>
> as the additional subshell is redundant, and you'd probably want to be informed
> about grep errors, won't you?
>
> Have a nice day,
> Berny
>
Thanks for your confirmation, I'll know where to look the next time I
get a misbehaving script in a package,
I'm going to go with "if gmake -v >/dev/null", the script doesn't even
check make's version and if make's not there by some remote chance, it
outputs "make: command not found".
Thanks
Dave P
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: What can cause this script to fail in Factory/Tumbleweed.

Bernhard Voelker
In reply to this post by Brüns, Stefan
On 01/05/2017 04:16 PM, Brüns, Stefan wrote:
> The culprit seems to be a failing call to splice() in grep:
>
> LANG=C strace -edup2,close,open,splice,read,write,execve,lseek  -s 150  -f
> bash -c '(/usr/bin/gmake -v | /usr/bin/grep "GNU Make") > /dev/null 2>&1'

Sounds like
https://git.sv.gnu.org/cgit/grep.git/commit/?id=7ad47abbcb

Have a nice day,
Berny
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: What can cause this script to fail in Factory/Tumbleweed.

Brüns, Stefan
On Donnerstag, 5. Januar 2017 17:39:48 CET you wrote:

> On 01/05/2017 04:16 PM, Brüns, Stefan wrote:
> > The culprit seems to be a failing call to splice() in grep:
> >
> > LANG=C strace -edup2,close,open,splice,read,write,execve,lseek  -s 150  -f
> > bash -c '(/usr/bin/gmake -v | /usr/bin/grep "GNU Make") > /dev/null 2>&1'
>
> Sounds like
> https://git.sv.gnu.org/cgit/grep.git/commit/?id=7ad47abbcb
>
> Have a nice day,
> Berny

Executing the testcase added with that commit:

strace -esplice -f bash -c ' echo abc | grep b >>/dev/null '
strace: Process 9494 attached
strace: Process 9495 attached
[pid  9494] +++ exited with 0 +++
[pid  9495] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = -1 EINVAL
(Invalid argument)
grep: (Standardeingabe): Das Argument ist ungültig
[pid  9495] +++ exited with 2 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=9494, si_uid=1000,
si_status=0, si_utime=0, si_stime=0} ---
+++ exited with 2 +++

So this seems to match ...

Kind regards,

Stefan--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: What can cause this script to fail in Factory/Tumbleweed.

Dave Plater lst
In reply to this post by Dave Plater lst


On 05/01/2017 14:17, Dave Plater wrote:

> I'm having a problem dvdisaster's bash-based-configure script where it
> checks for make. It fails in Factory but passes in 42.2 downwards.
> This is it:
>
> # Check for tools
> #
>
> function REQUIRE_GMAKE()
> {
>    if test -n "$cfg_help_mode"; then
>       return 0
>    fi
>
>    echo -n "Checking for gmake: "
>
>    if (gmake -v | grep "GNU Make") > /dev/null 2>&1 ;
>      then echo "yes"
>           echo "MAKE = `which gmake`" >>Makefile.config
>           return 0
>    fi;
>
>    if (make -v | grep "GNU Make") > /dev/null 2>&1 ;
>      then echo "yes"
>           echo "MAKE = `which make`" >>Makefile.config
>           return 0
>    fi;
>
>    echo "no"
>    echo "This package requires GNU make (gmake)."
>    exit 1;
> }
> The output of make -v is identical in Tumbleweed and 42.2 all I can
> think  of is either bash or grep have changed. I worked around the
> problem by patching in "echo "MAKE = `which make`" >>Makefile.config"
> as an else statement but I'd love to know what is actually wrong.
>
> Thanks
>
> Dave P
>
The interesting part of all this is that the next bash function to find
gcc doesn't fail although it uses the same syntax. See the file at
http://pastebin.com/tRLyMCqh

Dave P
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: What can cause this script to fail in Factory/Tumbleweed.

Bernhard Voelker
In reply to this post by Brüns, Stefan
On 01/05/2017 05:57 PM, Brüns, Stefan wrote:

> On Donnerstag, 5. Januar 2017 17:39:48 CET you wrote:
>> On 01/05/2017 04:16 PM, Brüns, Stefan wrote:
>>> The culprit seems to be a failing call to splice() in grep:
>>>
>>> LANG=C strace -edup2,close,open,splice,read,write,execve,lseek  -s 150  -f
>>> bash -c '(/usr/bin/gmake -v | /usr/bin/grep "GNU Make") > /dev/null 2>&1'
>>
>> Sounds like
>> https://git.sv.gnu.org/cgit/grep.git/commit/?id=7ad47abbcb
>>
>> Have a nice day,
>> Berny
>
> Executing the testcase added with that commit:
>
> strace -esplice -f bash -c ' echo abc | grep b >>/dev/null '
> strace: Process 9494 attached
> strace: Process 9495 attached
> [pid  9494] +++ exited with 0 +++
> [pid  9495] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = -1 EINVAL
> (Invalid argument)
> grep: (Standardeingabe): Das Argument ist ungültig
> [pid  9495] +++ exited with 2 +++
> --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=9494, si_uid=1000,
> si_status=0, si_utime=0, si_stime=0} ---
> +++ exited with 2 +++
>
> So this seems to match ...

Thanks for confirming.

@Andreas: would you like to cherry-pick this for oS:F/grep?

Have a nice day,
Berny
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: What can cause this script to fail in Factory/Tumbleweed.

Bernhard Voelker
On 01/05/2017 11:13 PM, Bernhard Voelker wrote:

> On 01/05/2017 05:57 PM, Brüns, Stefan wrote:
>> On Donnerstag, 5. Januar 2017 17:39:48 CET you wrote:
>>> On 01/05/2017 04:16 PM, Brüns, Stefan wrote:
>>>> The culprit seems to be a failing call to splice() in grep:
>>>>
>>>> LANG=C strace -edup2,close,open,splice,read,write,execve,lseek  -s 150  -f
>>>> bash -c '(/usr/bin/gmake -v | /usr/bin/grep "GNU Make") > /dev/null 2>&1'
>>>
>>> Sounds like
>>> https://git.sv.gnu.org/cgit/grep.git/commit/?id=7ad47abbcb
>>>
>>> Have a nice day,
>>> Berny
>>
>> Executing the testcase added with that commit:
>>
>> strace -esplice -f bash -c ' echo abc | grep b >>/dev/null '
>> strace: Process 9494 attached
>> strace: Process 9495 attached
>> [pid  9494] +++ exited with 0 +++
>> [pid  9495] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = -1 EINVAL
>> (Invalid argument)
>> grep: (Standardeingabe): Das Argument ist ungültig
>> [pid  9495] +++ exited with 2 +++
>> --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=9494, si_uid=1000,
>> si_status=0, si_utime=0, si_stime=0} ---
>> +++ exited with 2 +++
>>
>> So this seems to match ...
>
> Thanks for confirming.
>
> @Andreas: would you like to cherry-pick this for oS:F/grep?

@Stefan: as you already added the patch locally - would you mind
to submit this to Base:System/grep?

Have a nice day,
Berny
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]