Bug 1822280

Summary: lvm2: set -o pipefail in tools/Makefile.in is a bashism
Product: [Community] LVM and device-mapper Reporter: Michael Orlitzky <michael>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: Compilation, building and portability QA Contact: cluster-qe <cluster-qe>
Status: POST --- Docs Contact:
Severity: medium    
Priority: unspecified CC: agk, heinzm, jbrassow, prajnoha, zkabelac
Version: 2.02.185Flags: pm-rhel: lvm-technical-solution?
pm-rhel: lvm-test-coverage?
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
0001-tools-Makefile.in-only-set-o-pipefail-if-the-shell-i.patch
none
0002-tools-Makefile.in-use-printf-instead-of-non-portable.patch none

Description Michael Orlitzky 2020-04-08 16:37:47 UTC
The subject more or less explains it: set -o pipefail in tools/Makefile.in causes the build to fail with (for example) the dash shell. Autotools uses /bin/sh which is presumed to be POSIX compatible, but not (much) more. I see workarounds for this in other places, like

  test/lib/aux.sh:test -n "$BASH" && set -euE -o pipefail

so presumably this one remaining instance is just an oversight.

Comment 1 Zdenek Kabelac 2020-04-08 20:45:50 UTC
lvm2 building basically depends on bash & gcc.

If there is anyone who wants to provide global patch fixing all the 'bashism' everywhere - it might be pushed upstream if the code will behave in the same way.

Comment 2 Michael Orlitzky 2020-04-08 20:48:25 UTC
(In reply to Zdenek Kabelac from comment #1)
> lvm2 building basically depends on bash & gcc.
> 

That's a valid choice, but in that case, can you set SHELL=bash rather than using /bin/sh and just praying that it points to bash?

Comment 3 Zdenek Kabelac 2020-04-08 20:51:24 UTC
Please provide tested patch - so it can be considered for upstreaming.

Comment 4 Michael Orlitzky 2020-04-08 21:44:28 UTC
Created attachment 1677380 [details]
0001-tools-Makefile.in-only-set-o-pipefail-if-the-shell-i.patch

Comment 5 Michael Orlitzky 2020-04-08 21:45:29 UTC
Created attachment 1677381 [details]
0002-tools-Makefile.in-use-printf-instead-of-non-portable.patch

I had to fix a few "echo" calls after guarding "set -o pipefail" behind a bash test, too. The resulting command-count.h and command-lines-input.h are unchanged for me.

Comment 7 Zdenek Kabelac 2023-02-10 21:40:51 UTC
Fixed with different solution to avoid using pipe - which is hard to catch when it fail without 'set -o pipefail'

https://listman.redhat.com/archives/lvm-devel/2023-February/024582.html


Will likely go upstream with lvm2 2.03.19  with some more MuslC/dash fixes as well.