HomeClusterLabs Projects

Build: spec: bail out on failure in %check properly

Description

Build: spec: bail out on failure in %check properly

For the purpose of running %check scriptlet, RPM's building utility
(i.e. rpmbuild) relies on several macros that in vanilla distribution
combine into "/bin/sh -e <tmp-file-with-decorated-scriptlet>"
execution. Assuming /bin/sh resolves to POSIX conforming shell
(as it does with GNU Bash in Fedora/EL world), there's a subtle
detail when running with "errexit" option (sh -e) enabled [1]:

The -e setting shall be ignored when executing [...] any command
of an AND-OR list other than the last.

This would pose no issue in itself if one could rely on the usual "exit
status of the last execution equals the overall one". Unfortunately,
22b889815 previously missed the catch that <decorated-scriptlet> ends
with "exit 0" -- result of expanding the appended, other vanilla macro.
In effect, any such non-zero exit status of the last execution that
would otherwise be passed to the script caller (unless short-circuited
with -e magic suffering from the limits like the stated one above!)
is, somewhat counterintuitively[2], neutralized.

So fix this with explicit "false" built-in utility command OR-ed
to the AND-OR list at the terminal position (~ exactly the last
to-be-conditionally-executed, assuredly failing command, hence
fulfilling the requirement for the intended error [short] circuitry
with "errexit" option per above, avoiding any interferences with
artificial epilogues mangling with exit status propagation).

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set

(see also similar issue demonstrated in Application Usage:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_25_16)

[2] https://github.com/rpm-software-management/rpm/pull/249

Details

Provenance
Jan Pokorný <jpokorny@redhat.com>Authored on Jul 7 2017, 6:35 PM
Parents
rPc1623f12d4d7: Merge pull request #1301 from kgaillot/fixes
Branches
Unknown
Tags
Unknown

Event Timeline