Skip to content

Commit c022d43

Browse files
committed
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.
1 parent b33263d commit c022d43

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

build_library/vm_image_util.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,13 +714,23 @@ _write_cpio_common() {
714714
echo "/.noupdate f 444 root root echo -n" >"${VM_TMP_DIR}/extra"
715715

716716
# Set correct group for PXE/ISO, which has no writeable /etc
717-
echo /usr/share/flatcar/update.conf f 644 root root \
717+
echo /share/flatcar/update.conf f 644 root root \
718718
"sed -e 's/GROUP=.*$/GROUP=${VM_GROUP}/' ${base_dir}/share/flatcar/update.conf" \
719719
>> "${VM_TMP_DIR}/extra"
720720

721+
local -a mksquashfs_opts=(
722+
-pf "${VM_TMP_DIR}/extra"
723+
-xattrs-exclude '^btrfs.'
724+
# mksquashfs doesn't like overwriting existing files with
725+
# pseudo-files, so tell it to ignore the existing file instead
726+
#
727+
# also, this must be the last option
728+
-e share/flatcar/update.conf
729+
)
730+
721731
# Build the squashfs, embed squashfs into a gzipped cpio
722732
pushd "${cpio_target}" >/dev/null
723-
sudo mksquashfs "${base_dir}" "./usr.squashfs" -pf "${VM_TMP_DIR}/extra" -xattrs-exclude '^btrfs.'
733+
sudo mksquashfs "${base_dir}" "./usr.squashfs" "${mksquashfs_opts[@]}"
724734
find . | cpio -o -H newc | gzip > "$2"
725735
popd >/dev/null
726736

0 commit comments

Comments
 (0)