Skip to content

Commit 3aee8a7

Browse files
danzattsayanchowdhury
authored andcommitted
sysext: Add OS-dependent sysext compression
We removed the sysext compression, because we double-compression is redundant for sysexts stored in already coimpressed BTRFS /usr. However, OS-dependent sysexts that are downloaded on-demand were now also uncompressed. This commit brings back the compression via SYSTEMD_REPART_MKFS_OPTIONS_EROFS option. Signed-off-by: Daniel Zatovic <[email protected]>
1 parent 8621e76 commit 3aee8a7

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

build_library/sysext_prod_builder

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ create_prod_sysext() {
6363
# The --install_root_basename="${name}-base-sysext-rootfs" flag is
6464
# important - it sets the name of a rootfs directory, which is used
6565
# to determine the package target in coreos/base/profile.bashrc
66+
#
67+
# Built-in sysexts are stored in the compressed /usr partition, so we
68+
# disable compression to avoid double-compression.
6669
sudo -E "FLATCAR_BUILD_ID=$FLATCAR_BUILD_ID" "${SCRIPTS_DIR}/build_sysext" \
6770
--board="${BOARD}" \
6871
--image_builddir="${workdir}/sysext-build" \
6972
--squashfs_base="${base_sysext}" \
7073
--generate_pkginfo \
74+
--compression=none \
7175
--install_root_basename="${name}-base-sysext-rootfs" \
7276
"${build_sysext_opts[@]}" \
7377
"${name}" "${grp_pkg[@]}"

build_library/vm_image_util.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,15 @@ install_oem_sysext() {
585585
# important - it sets the name of a rootfs directory, which is
586586
# used to determine the package target in
587587
# coreos/base/profile.bashrc
588+
#
589+
# OEM sysexts are stored in the compressed partition, so we disable
590+
# compression to avoid double-compression.
588591
local build_sysext_flags=(
589592
--board="${BOARD}"
590593
--squashfs_base="${VM_SRC_SYSEXT_IMG}"
591594
--image_builddir="${built_sysext_dir}"
592595
--metapkgs="${metapkg}"
596+
--compression=none
593597
--install_root_basename="${VM_IMG_TYPE}-oem-sysext-rootfs"
594598
)
595599
local overlay_path mangle_fs

build_sysext

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ DEFINE_boolean generate_pkginfo "${FLAGS_FALSE}" \
3535
"Generate an additional squashfs '<sysext_name>_pkginfo.raw' with portage package meta-information (/var/db ...). Useful for creating sysext dependencies; see 'base_pkginfo' below."
3636
DEFINE_string base_pkginfo "" \
3737
"Colon-separated list of pkginfo squashfs paths / files generated via 'generate_pkginfo' to base this sysext on. The corresponding base sysexts are expected to be merged with the sysext generated."
38-
DEFINE_string compression "zstd" \
39-
"Compression to use for sysext squashfs. One of 'gzip', 'lzo', 'lz4', 'xz', or 'zstd'. Must be supported by the Flatcar squashfs kernel module in order for the sysext to work."
40-
DEFINE_string mksquashfs_opts "" \
41-
"Additional command line options to pass to mksquashfs. See 'man 1 mksquashfs'. If <compression> is 'zstd' (the default), this option defaults to '-Xcompression-level 22 -b 512K'. Otherwise the default is empty."
38+
DEFINE_string compression "lz4hc" \
39+
"Compression to use for sysext EROFS image. Options: 'lz4', 'lz4hc', 'zstd', or 'none'. Default is 'lz4hc'."
40+
DEFINE_string mkerofs_opts "" \
41+
"Additional mkfs.erofs options to pass via SYSTEMD_REPART_MKFS_OPTIONS_EROFS. If not specified, defaults are used based on compression type."
4242
DEFINE_boolean ignore_version_mismatch "${FLAGS_FALSE}" \
4343
"Ignore version mismatch between SDK board packages and base squashfs. DANGEROUS."
4444
DEFINE_string install_root_basename "${default_install_root_basename}" \
@@ -112,10 +112,6 @@ fi
112112
BUILD_DIR=$(realpath "${FLAGS_image_builddir}")
113113
mkdir -p "${BUILD_DIR}"
114114

115-
if [[ "${FLAGS_compression}" = "zstd" && -z "${FLAGS_mksquashfs_opts}" ]] ; then
116-
FLAGS_mksquashfs_opts="-Xcompression-level 22 -b 512k"
117-
fi
118-
119115
source "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1
120116
source "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
121117
source "${BUILD_LIBRARY_DIR}/reports_util.sh" || exit 1
@@ -248,7 +244,7 @@ if [[ "$FLAGS_generate_pkginfo" = "${FLAGS_TRUE}" ]] ; then
248244
mkdir -p "${BUILD_DIR}/img-pkginfo/var/db"
249245
cp -R "${BUILD_DIR}/${FLAGS_install_root_basename}/var/db/pkg" "${BUILD_DIR}/img-pkginfo/var/db/"
250246
mksquashfs "${BUILD_DIR}/img-pkginfo" "${BUILD_DIR}/${SYSEXTNAME}_pkginfo.raw" \
251-
-noappend -xattrs-exclude '^btrfs.' -comp "${FLAGS_compression}" ${FLAGS_mksquashfs_opts}
247+
-noappend -xattrs-exclude '^btrfs.' -comp zstd -Xcompression-level 22 -b 512k
252248
fi
253249

254250
info "Writing ${SYSEXTNAME}_packages.txt"
@@ -304,6 +300,25 @@ if [[ -n "${invalid_files}" ]]; then
304300
die "Invalid file ownership: ${invalid_files}"
305301
fi
306302

303+
# Set up EROFS compression options based on compression type
304+
if [[ "${FLAGS_compression}" != "none" ]]; then
305+
export SYSTEMD_REPART_MKFS_OPTIONS_EROFS="-z${FLAGS_compression}"
306+
307+
if [[ -n "${FLAGS_mkerofs_opts}" ]]; then
308+
# User provided custom options
309+
export SYSTEMD_REPART_MKFS_OPTIONS_EROFS="${SYSTEMD_REPART_MKFS_OPTIONS_EROFS} ${FLAGS_mkerofs_opts}"
310+
elif [[ "${FLAGS_compression}" = "lz4hc" ]]; then
311+
# Default options for lz4hc
312+
export SYSTEMD_REPART_MKFS_OPTIONS_EROFS="${SYSTEMD_REPART_MKFS_OPTIONS_EROFS},12 -C65536 -Efragments,ztailpacking"
313+
elif [[ "${FLAGS_compression}" = "zstd" ]]; then
314+
# Default options for zstd
315+
export SYSTEMD_REPART_MKFS_OPTIONS_EROFS="${SYSTEMD_REPART_MKFS_OPTIONS_EROFS},level=22 -C524288 -Efragments,ztailpacking"
316+
fi
317+
info "Building sysext with ${FLAGS_compression} compression"
318+
else
319+
info "Building sysext without compression (built-in sysexts)"
320+
fi
321+
307322
systemd-repart \
308323
--private-key="${SYSEXT_SIGNING_KEY_DIR}/sysexts.key" \
309324
--certificate="${SYSEXT_SIGNING_KEY_DIR}/sysexts.crt" \

0 commit comments

Comments
 (0)