Skip to content

Commit 704f0cd

Browse files
danzattJohn15321
authored andcommitted
Revert PR #3534 "sysext: Add OS-dependent sysext compression"
Revert PR #3162 "Signed OS-dependent sysexts" Signed-off-by: Daniel Zatovic <[email protected]>
1 parent ccd27d8 commit 704f0cd

File tree

7 files changed

+21
-118
lines changed

7 files changed

+21
-118
lines changed

build_library/prod_image_util.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ EOF
170170
# Remove source locale data, only need to ship the compiled archive.
171171
sudo rm -rf ${root_fs_dir}/usr/share/i18n/
172172

173-
# Inject ephemeral sysext signing certificate
174-
sudo mkdir -p "${root_fs_dir}/usr/lib/verity.d"
175-
sudo cp "${SYSEXT_SIGNING_KEY_DIR}/sysexts.crt" "${root_fs_dir}/usr/lib/verity.d"
176-
177173
# Finish image will move files from /etc to /usr/share/flatcar/etc.
178174
# Note that image filesystem contents generated by finish_image will not
179175
# include sysext contents (only the sysext squashfs files themselves).

build_library/sysext_prod_builder

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,11 @@ 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.
69-
sudo -E "FLATCAR_BUILD_ID=$FLATCAR_BUILD_ID" "${SCRIPTS_DIR}/build_sysext" \
66+
sudo "FLATCAR_BUILD_ID=$FLATCAR_BUILD_ID" "${SCRIPTS_DIR}/build_sysext" \
7067
--board="${BOARD}" \
7168
--image_builddir="${workdir}/sysext-build" \
7269
--squashfs_base="${base_sysext}" \
7370
--generate_pkginfo \
74-
--compression=none \
7571
--install_root_basename="${name}-base-sysext-rootfs" \
7672
"${build_sysext_opts[@]}" \
7773
"${name}" "${grp_pkg[@]}"
@@ -103,14 +99,6 @@ sysext_mountdir="${BUILD_DIR}/prod-sysext-work/mounts"
10399
sysext_base="${sysext_workdir}/base-os.squashfs"
104100

105101
function cleanup() {
106-
IFS=':' read -r -a mounted_sysexts <<< "$sysext_lowerdirs"
107-
# skip the rootfs
108-
mounted_sysexts=("${mounted_sysexts[@]:1}")
109-
110-
for sysext in "${mounted_sysexts[@]}"; do
111-
sudo systemd-dissect --umount --rmdir "$sysext"
112-
done
113-
114102
sudo umount "${sysext_mountdir}"/* || true
115103
rm -rf "${sysext_workdir}" || true
116104
}
@@ -128,7 +116,6 @@ sudo mksquashfs "${root_fs_dir}" "${sysext_base}" -noappend -xattrs-exclude '^bt
128116
# for combined overlay later.
129117
prev_pkginfo=""
130118
sysext_lowerdirs="${sysext_mountdir}/rootfs-lower"
131-
mkdir -p "${sysext_mountdir}"
132119
for sysext in ${sysexts_list//,/ }; do
133120
# format is "<name>:<group>/<package>"
134121
name="${sysext%|*}"
@@ -142,21 +129,12 @@ for sysext in ${sysexts_list//,/ }; do
142129
"${grp_pkg}" \
143130
"${prev_pkginfo}"
144131

145-
sudo systemd-dissect \
146-
--read-only \
147-
--mount \
148-
--mkdir \
149-
--image-policy='root=encrypted+unprotected+absent:usr=encrypted+unprotected+absent' \
150-
"${sysext_output_dir}/${name}.raw" \
151-
"${sysext_mountdir}/${name}"
152-
153-
sudo systemd-dissect \
154-
--read-only \
155-
--mount \
156-
--mkdir \
157-
--image-policy='root=encrypted+unprotected+absent:usr=encrypted+unprotected+absent' \
158-
"${sysext_output_dir}/${name}_pkginfo.raw" \
159-
"${sysext_mountdir}/${name}_pkginfo"
132+
mkdir -p "${sysext_mountdir}/${name}" \
133+
"${sysext_mountdir}/${name}_pkginfo"
134+
sudo mount -rt squashfs -o loop,nodev "${sysext_output_dir}/${name}.raw" \
135+
"${sysext_mountdir}/${name}"
136+
sudo mount -rt squashfs -o loop,nodev "${sysext_output_dir}/${name}_pkginfo.raw" \
137+
"${sysext_mountdir}/${name}_pkginfo"
160138

161139
sysext_lowerdirs="${sysext_lowerdirs}:${sysext_mountdir}/${name}"
162140
sysext_lowerdirs="${sysext_lowerdirs}:${sysext_mountdir}/${name}_pkginfo"

build_library/vm_image_util.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,15 +585,11 @@ 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.
591588
local build_sysext_flags=(
592589
--board="${BOARD}"
593590
--squashfs_base="${VM_SRC_SYSEXT_IMG}"
594591
--image_builddir="${built_sysext_dir}"
595592
--metapkgs="${metapkg}"
596-
--compression=none
597593
--install_root_basename="${VM_IMG_TYPE}-oem-sysext-rootfs"
598594
)
599595
local overlay_path mangle_fs
@@ -606,7 +602,7 @@ install_oem_sysext() {
606602
fi
607603

608604
mkdir -p "${built_sysext_dir}"
609-
sudo -E "${build_sysext_env[@]}" "${SCRIPT_ROOT}/build_sysext" "${build_sysext_flags[@]}" "${oem_sysext}"
605+
sudo "${build_sysext_env[@]}" "${SCRIPT_ROOT}/build_sysext" "${build_sysext_flags[@]}" "${oem_sysext}"
610606

611607
local installed_sysext_oem_dir='/oem/sysext'
612608
local installed_sysext_file_prefix="${oem_sysext}-${version}"

build_sysext

Lines changed: 13 additions & 39 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 "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."
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."
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,6 +112,10 @@ 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+
115119
source "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1
116120
source "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
117121
source "${BUILD_LIBRARY_DIR}/reports_util.sh" || exit 1
@@ -244,7 +248,7 @@ if [[ "$FLAGS_generate_pkginfo" = "${FLAGS_TRUE}" ]] ; then
244248
mkdir -p "${BUILD_DIR}/img-pkginfo/var/db"
245249
cp -R "${BUILD_DIR}/${FLAGS_install_root_basename}/var/db/pkg" "${BUILD_DIR}/img-pkginfo/var/db/"
246250
mksquashfs "${BUILD_DIR}/img-pkginfo" "${BUILD_DIR}/${SYSEXTNAME}_pkginfo.raw" \
247-
-noappend -xattrs-exclude '^btrfs.' -comp zstd -Xcompression-level 22 -b 512k
251+
-noappend -xattrs-exclude '^btrfs.' -comp "${FLAGS_compression}" ${FLAGS_mksquashfs_opts}
248252
fi
249253

250254
info "Writing ${SYSEXTNAME}_packages.txt"
@@ -300,44 +304,14 @@ if [[ -n "${invalid_files}" ]]; then
300304
die "Invalid file ownership: ${invalid_files}"
301305
fi
302306

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-
322-
systemd-repart \
323-
--private-key="${SYSEXT_SIGNING_KEY_DIR}/sysexts.key" \
324-
--certificate="${SYSEXT_SIGNING_KEY_DIR}/sysexts.crt" \
325-
--make-ddi=sysext \
326-
--copy-source="${BUILD_DIR}/${FLAGS_install_root_basename}" \
327-
"${BUILD_DIR}/${SYSEXTNAME}.raw"
328-
307+
mksquashfs "${BUILD_DIR}/${FLAGS_install_root_basename}" "${BUILD_DIR}/${SYSEXTNAME}.raw" \
308+
-noappend -xattrs-exclude '^btrfs.' -comp "${FLAGS_compression}" ${FLAGS_mksquashfs_opts}
329309
rm -rf "${BUILD_DIR}"/{fs-root,"${FLAGS_install_root_basename}",workdir}
330310

331311
# Generate reports
332312
mkdir "${BUILD_DIR}/img-rootfs"
333-
systemd-dissect --read-only \
334-
--mount \
335-
--mkdir \
336-
--image-policy='root=encrypted+unprotected+absent:usr=encrypted+unprotected+absent' \
337-
"${BUILD_DIR}/${SYSEXTNAME}.raw" \
338-
"${BUILD_DIR}/img-rootfs"
339-
313+
mount -rt squashfs -o loop,nodev "${BUILD_DIR}/${SYSEXTNAME}.raw" "${BUILD_DIR}/img-rootfs"
340314
write_contents "${BUILD_DIR}/img-rootfs" "${BUILD_DIR}/${SYSEXTNAME}_contents.txt"
341315
write_contents_with_technical_details "${BUILD_DIR}/img-rootfs" "${BUILD_DIR}/${SYSEXTNAME}_contents_wtd.txt"
342316
write_disk_space_usage_in_paths "${BUILD_DIR}/img-rootfs" "${BUILD_DIR}/${SYSEXTNAME}_disk_usage.txt"
343-
systemd-dissect --umount --rmdir "${BUILD_DIR}/img-rootfs"
317+
umount "${BUILD_DIR}/img-rootfs"

changelog/changes/2025-11-05-signed-os-dependent-sysexts.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

sdk_container/src/third_party/coreos-overlay/profiles/coreos/targets/sdk/package.use

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,3 @@ x11-libs/pixman static-libs
3232

3333
# Get latest EDK2 firmware for Secure Boot on arm64.
3434
app-emulation/qemu -pin-upstream-blobs
35-
36-
# Needed for signed sysexts using systemd-repart
37-
sys-apps/systemd cryptsetup

sdk_lib/sdk_entry.sh

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -88,43 +88,6 @@ if ! grep -q 'export MODULE_SIGNING_KEY_DIR=' /home/sdk/.bashrc; then
8888
fi
8989
fi
9090

91-
# Ensure sysext signing keys exist; regenerate if directory or files missing
92-
if grep -q 'export SYSEXT_SIGNING_KEY_DIR' /home/sdk/.bashrc; then
93-
_existing_sysext_dir=$(source /home/sdk/.bashrc 2>/dev/null; echo "$SYSEXT_SIGNING_KEY_DIR")
94-
if [[ -z "$_existing_sysext_dir" || ! -d "$_existing_sysext_dir" || ! -s "$_existing_sysext_dir/sysexts.key" || ! -s "$_existing_sysext_dir/sysexts.crt" ]]; then
95-
# Drop stale export so block below regenerates
96-
sed -i -e '/export SYSEXT_SIGNING_KEY_DIR=/d' /home/sdk/.bashrc
97-
fi
98-
fi
99-
grep -q 'export SYSEXT_SIGNING_KEY_DIR' /home/sdk/.bashrc || {
100-
if [[ ${COREOS_OFFICIAL:-0} -eq 1 ]]; then
101-
SYSEXT_SIGNING_KEY_DIR=$(su sdk -c "mktemp -d")
102-
else
103-
SYSEXT_SIGNING_KEY_DIR="/home/sdk/.sysext-signing-keys"
104-
su sdk -c "mkdir -p ${SYSEXT_SIGNING_KEY_DIR@Q}"
105-
fi
106-
if [[ ! "$SYSEXT_SIGNING_KEY_DIR" || ! -d "$SYSEXT_SIGNING_KEY_DIR" ]]; then
107-
echo "Failed to create directory for sysext signing keys."
108-
else
109-
echo "export SYSEXT_SIGNING_KEY_DIR='$SYSEXT_SIGNING_KEY_DIR'" >> /home/sdk/.bashrc
110-
fi
111-
pushd "$SYSEXT_SIGNING_KEY_DIR" > /dev/null
112-
build_id=$(source "/mnt/host/source/.repo/manifests/version.txt"; echo "$FLATCAR_BUILD_ID")
113-
# Generate sysext signing key only if missing or empty
114-
if [[ ! -s sysexts.key || ! -s sysexts.crt ]]; then
115-
su sdk -c "openssl req -new -nodes -utf8 \
116-
-x509 -batch -sha256 \
117-
-days 36000 \
118-
-outform PEM \
119-
-out sysexts.crt \
120-
-keyout sysexts.key \
121-
-newkey 4096 \
122-
-subj '/CN=Flatcar sysext key/OU=$build_id'" \
123-
|| echo "Generating sysext signing key failed"
124-
fi
125-
popd > /dev/null
126-
}
127-
12891
# This is ugly.
12992
# We need to sudo su - sdk -c so the SDK user gets a fresh login.
13093
# 'sdk' is member of multiple groups, and plain docker USER only

0 commit comments

Comments
 (0)