build_library/vm_image_util: Fix squashfs creation for pxe

The pxe disk is a cpio file that, among other things, contains a
squashfs image.

The image has contents of `/usr` directory, so the image's toplevel
directories are `lib`, `lib64`, `share` and so on. The first fix was
to change the `/usr/share/flatcar/update.conf` path in pseudofile
listing to `/share/flatcar/update.conf`. Otherwise mksquashfs started
complaining that `usr` directory does not exists in the image, so some
of the pseudofiles won't be installed.

Second fix is still related to the same file. It already exists in the
image, so the pseudofile wanting to be installed there won't be,
because mksquashfs stopped liking overwriting the files already
present in the image. I added `-e share/flatcar/update.conf` to avoid
adding the file into the image, so that pseudofile can be created
there. It was actually a suggestion printed by mksquashfs.
This commit is contained in:
Krzesimir Nowak 2025-07-01 15:55:11 +02:00
parent b33263dfa9
commit c022d43709

View File

@ -714,13 +714,23 @@ _write_cpio_common() {
echo "/.noupdate f 444 root root echo -n" >"${VM_TMP_DIR}/extra"
# Set correct group for PXE/ISO, which has no writeable /etc
echo /usr/share/flatcar/update.conf f 644 root root \
echo /share/flatcar/update.conf f 644 root root \
"sed -e 's/GROUP=.*$/GROUP=${VM_GROUP}/' ${base_dir}/share/flatcar/update.conf" \
>> "${VM_TMP_DIR}/extra"
local -a mksquashfs_opts=(
-pf "${VM_TMP_DIR}/extra"
-xattrs-exclude '^btrfs.'
# mksquashfs doesn't like overwriting existing files with
# pseudo-files, so tell it to ignore the existing file instead
#
# also, this must be the last option
-e share/flatcar/update.conf
)
# Build the squashfs, embed squashfs into a gzipped cpio
pushd "${cpio_target}" >/dev/null
sudo mksquashfs "${base_dir}" "./usr.squashfs" -pf "${VM_TMP_DIR}/extra" -xattrs-exclude '^btrfs.'
sudo mksquashfs "${base_dir}" "./usr.squashfs" "${mksquashfs_opts[@]}"
find . | cpio -o -H newc | gzip > "$2"
popd >/dev/null