Skip to content

Conversation

@hnez
Copy link
Member

@hnez hnez commented Dec 10, 2025

This draft PR implements the change suggested in #320. It is a draftbecause the tests currently fail for at least Ubuntu 22.04 with the message: /bin/sh: 0: Illegal option -o pipefail.


This ensures that the whole call to systemp fails if one commands in a command line consisting of multiple commands joined by pipes fails.

This is for example relevant for the cpio backend, where the cpio command is called and its output is piped to gzip.
If the cpio command fails or is not found at all a .cpio.gz file will be created containing just the gzip header and genimage will return a successful exit status anyways.

This change assumes that all relevant /bin/sh implementations support the -o pipefail option. We know that at least bash, dash and busybox ash do.

Fixes #320.

hnez added 2 commits December 10, 2025 14:01
Genimage will currently exit with a success exit code when generating a
cpio archive fails due to a missing `cpio` util.
This is due to a pipe in the `systemp` call and the `pipefail` option not
being set.

See this issue[1] for mor information.

Add a test that checks if genimage fails if the cpio util is missing
(which it currently does not but should).

[1]: pengutronix#320

Signed-off-by: Leonard Göhrs <[email protected]>
This ensures that the whole call to `systemp` fails if one commands in a
command line consisting of multiple commands joined by pipes fails.

This is for example relevant for the `cpio` backend, where the `cpio`
command is called and its output is piped to `gzip`.
If the `cpio` command fails or is not found at all a `.cpio.gz` file
will be created containing just the gzip header and genimage will
return a successful exit status anyways.

This change assumes that all relevant `/bin/sh` implementations support
the `-o pipefail` option. We know that at least bash, dash and busybox ash
do.

Signed-off-by: Leonard Göhrs <[email protected]>
@Bastian-Krause
Copy link
Member

Bastian-Krause commented Dec 11, 2025

Ubuntu uses dash by default. dash learnt pipefail only recently in v0.5.13. Ubuntu 22.04 includes dash 0.5.11+git20210903+057cd650a4ed-3build1). Looks like this was backported in Ubuntu's 0.5.12-7, but Ubuntu 24.04 is still on 0.5.12-6ubuntu5.

See also koalaman/shellcheck#2555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cpio image generation silently fails if cpio cli tool not installed

2 participants