|
| 1 | +%global debug_package %{nil} |
| 2 | +%global sha512hmac bash %{_sourcedir}/sha512hmac-openssl.sh |
| 3 | +%ifarch aarch64 |
| 4 | +%global buildarch aarch64 |
| 5 | +%endif |
| 6 | +%define uname_r %{version}-%{release} |
| 7 | +Summary: Signed Linux Kernel for %{buildarch} systems |
| 8 | +Name: kernel-64k-signed-%{buildarch} |
| 9 | +Version: 6.6.57.1 |
| 10 | +Release: 5%{?dist} |
| 11 | +License: GPLv2 |
| 12 | +Vendor: Microsoft Corporation |
| 13 | +Distribution: Azure Linux |
| 14 | +Group: System Environment/Kernel |
| 15 | +URL: https://github.com/microsoft/CBL-Mariner-Linux-Kernel |
| 16 | +# This package's "version" and "release" must reflect the unsigned version that |
| 17 | +# was signed. |
| 18 | +# An important consequence is that when making a change to this package, the |
| 19 | +# unsigned version/release must be increased to keep the two versions consistent. |
| 20 | +# Ideally though, this spec will not change much or at all, so the version will |
| 21 | +# just track the unsigned package's version/release. |
| 22 | +# |
| 23 | +# To populate these sources: |
| 24 | +# 1. Build the unsigned packages as normal |
| 25 | +# 2. Sign the desired binary |
| 26 | +# 3. Place the unsigned package and signed binary in this spec's folder |
| 27 | +# 4. Build this spec |
| 28 | +Source0: kernel-64k-%{version}-%{release}.%{buildarch}.rpm |
| 29 | +Source1: vmlinuz-%{uname_r} |
| 30 | +Source2: sha512hmac-openssl.sh |
| 31 | +BuildRequires: cpio |
| 32 | +BuildRequires: grub2-rpm-macros |
| 33 | +BuildRequires: openssl |
| 34 | +BuildRequires: sed |
| 35 | +%{?grub2_configuration_requires} |
| 36 | + |
| 37 | +%description |
| 38 | +This package contains the Linux kernel package with kernel signed with the production key |
| 39 | + |
| 40 | +%package -n kernel-64k |
| 41 | +Summary: Linux Kernel |
| 42 | +Group: System Environment/Kernel |
| 43 | +Requires: filesystem |
| 44 | +Requires: kmod |
| 45 | +Requires(post): coreutils |
| 46 | +Requires(postun): coreutils |
| 47 | + |
| 48 | +%description -n kernel-64k |
| 49 | +The kernel package contains the signed Linux kernel. |
| 50 | + |
| 51 | +%prep |
| 52 | + |
| 53 | +%build |
| 54 | +mkdir rpm_contents |
| 55 | +pushd rpm_contents |
| 56 | + |
| 57 | +# This spec's whole purpose is to inject the signed kernel binary |
| 58 | +rpm2cpio %{SOURCE0} | cpio -idmv |
| 59 | +cp %{SOURCE1} ./boot/vmlinuz-%{uname_r} |
| 60 | + |
| 61 | +popd |
| 62 | + |
| 63 | +%install |
| 64 | +pushd rpm_contents |
| 65 | + |
| 66 | +# Don't use * wildcard. It does not copy over hidden files in the root folder... |
| 67 | +cp -rp ./. %{buildroot}/ |
| 68 | + |
| 69 | +popd |
| 70 | + |
| 71 | +# Recalculate sha512hmac for FIPS |
| 72 | +%{sha512hmac} %{buildroot}/boot/vmlinuz-%{uname_r} | sed -e "s,$RPM_BUILD_ROOT,," > %{buildroot}/boot/.vmlinuz-%{uname_r}.hmac |
| 73 | +cp %{buildroot}/boot/.vmlinuz-%{uname_r}.hmac %{buildroot}/lib/modules/%{uname_r}/.vmlinuz.hmac |
| 74 | + |
| 75 | +%triggerin -n kernel-64k -- initramfs |
| 76 | +mkdir -p %{_localstatedir}/lib/rpm-state/initramfs/pending |
| 77 | +touch %{_localstatedir}/lib/rpm-state/initramfs/pending/%{uname_r} |
| 78 | +echo "initrd generation of kernel %{uname_r} will be triggered later" >&2 |
| 79 | + |
| 80 | +%triggerun -n kernel-64k -- initramfs |
| 81 | +rm -rf %{_localstatedir}/lib/rpm-state/initramfs/pending/%{uname_r} |
| 82 | +rm -rf /boot/initramfs-%{uname_r}.img |
| 83 | +echo "initrd of kernel %{uname_r} removed" >&2 |
| 84 | + |
| 85 | +%postun -n kernel-64k |
| 86 | +%grub2_postun |
| 87 | + |
| 88 | +%post -n kernel-64k |
| 89 | +/sbin/depmod -a %{uname_r} |
| 90 | +%grub2_post |
| 91 | + |
| 92 | +%files -n kernel-64k |
| 93 | +%defattr(-,root,root) |
| 94 | +%license COPYING |
| 95 | +/boot/System.map-%{uname_r} |
| 96 | +/boot/config-%{uname_r} |
| 97 | +/boot/vmlinuz-%{uname_r} |
| 98 | +/boot/.vmlinuz-%{uname_r}.hmac |
| 99 | +%defattr(0644,root,root) |
| 100 | +/lib/modules/%{uname_r}/* |
| 101 | +/lib/modules/%{uname_r}/.vmlinuz.hmac |
| 102 | +%exclude /lib/modules/%{uname_r}/build |
| 103 | +%exclude /lib/modules/%{uname_r}/kernel/drivers/gpu |
| 104 | +%exclude /lib/modules/%{uname_r}/kernel/sound |
| 105 | +%exclude /module_info.ld |
| 106 | + |
| 107 | +%changelog |
| 108 | +* Thu Nov 07 2024 Rachel Menge <rachelmenge@microsoft.com> - 6.6.57.1-5 |
| 109 | +- Original version for Azure Linux |
| 110 | +- Starting with release 5 to align with kernel release. |
| 111 | +- License verified |
0 commit comments