[PATCH v2 0/4] mbuto: Assorted fixes and simplifications
While debugging a problem Laurent Vivier was having with the passt test suite, I discovered mbuto's archivemount support is entirely broken: if archivemount is on the system, mbuto won't work. While fixing that, I discovered some slightly related simplfications that can be made. Here they all are. Changes since v1: * Updated commit message in 2/4 to clarify why the desired advantages of using archivemount can't be used in practice * Improve accuracy of comment on compress_select in 3/4 * Clarify removal of update existing archive functionality. David Gibson (4): ${wd} is always set, no need to test for it Remove stale archivemount support Split "auto" compression mode into its own path Remove unnecessary cpio_init function mbuto | 128 +++++++++++++++------------------------------------------- 1 file changed, 33 insertions(+), 95 deletions(-) -- 2.44.0
We unconditionally set ${wd} to a temporary directory, but there are some
places where we test if it is empty. This appears to be stale code from
some earlier version, so simply remove it.
Signed-off-by: David Gibson
mbuto has two ways of building the initramfs. One is the typical approach
of staging its contents in a temporary directory, then building the
initramfs with cpio. The other is to create an empty initramfs, mount
it with archivemount, and copy things into the mounted archive.
However, the archivemount approach is broken. I'm not entirely sure why,
but it appears not to properly unmount the archive and retrieve the final.
filled version. The upshot is that if archivemount is installed, then
mbuto generates an empty, gzip-compressed initramfs instead of whatever it
was supposed to.
It appears the archivemount approach was there to allow some later changes
to the archive without re-running mbuto. However, it's essentially
impossible to use this safely - if archivemount still has the archive open
for writing, it's not safe to read it concurrently. This appears to have
worked by accident with some earlier versions, but doesn't work now.
Just remove the archivemount approach entirely.
Reported-by: Laurent Vivier
mbuto supports "auto" compression mode where we detect the fastest to
decompress and use it. This is structured a bit oddly - cpio_compress()
first handles the case of an explicitly selected compressor, then handles
the auto-detected case, redundantly implementing the compression once it
has picked one.
Make this a bit clearer: first handle the "auto" case by calling out to
the testing code, and using that to set the parameter for the specific
compression path.
Signed-off-by: David Gibson
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
On Fri, 26 Apr 2024 12:01:08 +1000
David Gibson
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
--- 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
On Fri, 26 Apr 2024 12:01:04 +1000
David Gibson
While debugging a problem Laurent Vivier was having with the passt test suite, I discovered mbuto's archivemount support is entirely broken: if archivemount is on the system, mbuto won't work. While fixing that, I discovered some slightly related simplfications that can be made. Here they all are.
Changes since v1: * Updated commit message in 2/4 to clarify why the desired advantages of using archivemount can't be used in practice * Improve accuracy of comment on compress_select in 3/4 * Clarify removal of update existing archive functionality.
David Gibson (4): ${wd} is always set, no need to test for it Remove stale archivemount support Split "auto" compression mode into its own path Remove unnecessary cpio_init function
Applied, thanks. -- Stefano
participants (2)
-
David Gibson
-
Stefano Brivio