Skip to content

build.sh continues even if cpio command fails #233

@detly

Description

@detly

I attempted to build an image from the branch for PR #231 in a debian:bookworm-slim Docker container, and ended up with an initramfs that was 20 bytes:

root@2521e248c037:~/raspberrypi-ua-netinst# stat build_dir/bootfs/raspberrypi-ua-netinst/initramfs.gz 
  File: build_dir/bootfs/raspberrypi-ua-netinst/initramfs.gz
  Size: 20        	Blocks: 8          IO Block: 4096   regular file

This was because cpio was missing, but build.sh happily continued after the point it was needed, despite the set -e that I presume is to prevent exactly such a thing:

 Adding dependency libffi.so.8 => tmp/usr/lib/arm-linux-gnueabihf/libffi.so.8
 Adding dependency libgcc_s.so.1 => tmp/lib/arm-linux-gnueabihf/libgcc_s.so.1
./build.sh: line 463: cpio: command not found
  adding: COPYING.linux (deflated 62%)
  adding: LICENCE.broadcom (deflated 45%)

My understanding is that because the cpio command is in a pipe, its result is considered "used" and any errors from it are thus ignored even with set -e:

(cd rootfs && find . | cpio -H newc -ov | gzip --best > $INITRAMFS)

However, I don't know whether a blanket set -o pipefail would be wise for the whole script (if that is indeed what's required), or whether you need something more precise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions