Skip to content

Commit

Permalink
kernel-6.1: also provide uncompressed devel files
Browse files Browse the repository at this point in the history
When using erofs as the root filesystem, we want to avoid other forms
of compression, such as the squashfs used for the kernel development
files.

Include the uncompressed version of these files when the erofs image
feature is set, and override the configuration for the mount unit to
do a simple bind mount instead.

Signed-off-by: Ben Cressey <[email protected]>
  • Loading branch information
bcressey committed Sep 21, 2024
1 parent 640e21d commit 76af8be
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
34 changes: 33 additions & 1 deletion packages/kernel-6.1/kernel-6.1.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Source200: check-fips-modules.drop-in.conf.in
Source201: fipsmodules-x86_64
Source202: fipsmodules-aarch64

# Adjust kernel-devel mount behavior if not squashfs.
Source210: var-lib-kernel-devel-lower.mount.drop-in.conf.in

# Bootconfig snippets to adjust the default kernel command line for the platform.
Source300: bootconfig-aws.conf
Source301: bootconfig-vmware.conf
Expand Down Expand Up @@ -70,10 +73,24 @@ Requires: (%{name}-fips if %{_cross_os}image-feature(fips))

%package devel
Summary: Configured Linux kernel source for module building
Requires: (%{name}-devel-squashed if %{_cross_os}image-feature(no-erofs-root-partition))
Requires: (%{name}-devel-unpacked if %{_cross_os}image-feature(erofs-root-partition))

%description devel
%{summary}.

%package devel-squashed
Summary: Configured Linux kernel source for module building (squashed)

%description devel-squashed
%{summary}.

%package devel-unpacked
Summary: Configured Linux kernel source for module building (unpacked)

%description devel-unpacked
%{summary}.

%package archive
Summary: Archived Linux kernel source for module building

Expand Down Expand Up @@ -265,6 +282,10 @@ mkdir -p src_squashfs/%{version}
tar c -T kernel_devel_files | tar x -C src_squashfs/%{version}
mksquashfs src_squashfs kernel-devel.squashfs ${SQUASHFS_OPTS}

# Create an uncompressed set of kernel-devel files in the standard location.
install -d %{buildroot}%{_cross_datadir}/bottlerocket/kernel-devel/%{version}
tar c -T kernel_devel_files | tar x -C %{buildroot}%{_cross_datadir}/bottlerocket/kernel-devel/%{version}

# Create a tarball of the same files, for use outside the running system.
# In theory we could extract these files with `unsquashfs`, but we do not want
# to require it to be installed on the build host, and it errors out when run
Expand Down Expand Up @@ -300,6 +321,11 @@ for fipsmod in $(cat %{_sourcedir}/fipsmodules-%{_cross_arch}) ; do
(( i+=1 ))
done

LOWERPATH=$(systemd-escape --path %{_cross_sharedstatedir}/kernel-devel/.overlay/lower)
mkdir -p %{buildroot}%{_cross_unitdir}/"${LOWERPATH}.mount.d"
sed -e 's|PREFIX|%{_cross_prefix}|g' %{S:210} \
> %{buildroot}%{_cross_unitdir}/"${LOWERPATH}.mount.d"/no-squashfs.conf

# Install platform-specific bootconfig snippets.
install -d %{buildroot}%{_cross_bootconfigdir}
install -p -m 0644 %{S:300} %{buildroot}%{_cross_bootconfigdir}/05-aws.conf
Expand Down Expand Up @@ -338,10 +364,16 @@ install -p -m 0644 %{S:302} %{buildroot}%{_cross_bootconfigdir}/05-metal.conf

%files devel
%dir %{_cross_ksrcdir}
%{_cross_datadir}/bottlerocket/kernel-devel.squashfs
%{_cross_kmoddir}/source
%{_cross_kmoddir}/build

%files devel-squashed
%{_cross_datadir}/bottlerocket/kernel-devel.squashfs

%files devel-unpacked
%{_cross_datadir}/bottlerocket/kernel-devel
%{_cross_unitdir}/*kernel*devel*.mount.d/no-squashfs.conf

%files archive
%{_cross_datadir}/bottlerocket/kernel-devel.tar.xz

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Mount]
What=PREFIX/share/bottlerocket/kernel-devel
Type=none
Options=rbind,rshared

0 comments on commit 76af8be

Please sign in to comment.