On Fri, 26 Apr 2024 12:01:08 +1000 David Gibson <david(a)gibson.dropbear.id.au> wrote:The cpio_init function is now only every called with the "discard" option. But, moreover, what it does is create an initial mostly empty archive which will just get overwritten by the final archive. So, it's entirely unnecessary except for one subtlety. Our use of realpath when generating the final output requires that a file already exist in the output location. We can fix that by shuffling some things out of a subshell, removing the need for realpath. This removes functionality to modify an existing initramfs image. However that was already broken in a several ways. Just remove it, and update the help messages to match. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- mbuto | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/mbuto b/mbuto index eb559fb..247b63d 100755 --- a/mbuto +++ b/mbuto @@ -544,28 +544,6 @@ subopts_get() { ### CPIO ####################################################################### -# cpio_init() - Source existing CPIO archive, or create if needed -# $1: Path to CPIO archive, might exist, might be discarded if existing -cpio_init() { - if [ -f "${OUT}" ] && [ "${1}" != "discard" ]; then - info "Sourcing CPIO archive from ${OUT}" - - if ! "${GZIP}" -dfc "${OUT}" | - "${CPIO}" --quiet -iD "${wd}"; then - err "Invalid CPIO archive ${OUT}" - fi - else - info "Creating new CPIO archive" - - if [ -z "${OUT}" ]; then - OUT="$("${MKTEMP}")"Actually, this broke something rather fundamental: if you start mbuto without arguments, ${OUT} is not set anymore and we'll fail without a real error message. See the demo on the left at https://mbuto.sh/ for why I find that running it without arguments is quite convenient. I'll try to add this back in a while unless you do that first. -- Stefano