Diffstat (limited to 'kernel-surface.spec')
| -rw-r--r-- | kernel-surface.spec | 237 |
1 files changed, 237 insertions, 0 deletions
diff --git a/kernel-surface.spec b/kernel-surface.spec new file mode 100644 index 0000000..dc29ae3 --- /dev/null +++ b/kernel-surface.spec @@ -0,0 +1,237 @@ +# Vanilla upstream kernel plus the Surface Pro 12" (Snapdragon X1P-42-100) +# patch set from the miasvanklei Gentoo overlay, packaged for Fedora. +# +# Build inputs are produced by make-sources.sh in this directory; see README.md. + +# Upstream tarball version. For a release candidate this is the git.kernel.org +# snapshot name (linux-7.3-rc1); for a stable release it is the tarball name +# from cdn.kernel.org (linux-7.2.3). +# +# Both versions here are defaults, for a build driven straight off a checkout. +# The release pipeline reads them out of the git tag it was triggered by and +# passes them in with --define, which takes precedence -- so keep the plain +# `%%global <name> <value>` shape, which make-sources.sh reads with awk. +%if %{undefined upstream_ver} +%global upstream_ver 7.2.3 +%endif + +# Bumped whenever the patch tarball changes without the upstream version moving. +%if %{undefined patchset_ver} +%global patchset_ver 1 +%endif + +# rpm gives - to the version-release separator, so it cannot appear in Version +# itself. A release candidate's own Makefile reports the version it leads up to +# anyway -- 7.3-rc1 builds 7.3.0 -- and %%prep drops the EXTRAVERSION that would +# otherwise carry the -rcN into uname -r. A stable version passes through. +%global kversion %(echo %{upstream_ver} | sed -e 's/-rc[0-9]*$/.0/') + +# The kernel's own release string: what uname -r reports and what names +# /usr/lib/modules/<...>. Matches Fedora's <version>-<release>.<arch> convention. +%global kverrel %{version}-%{release}.%{_target_cpu} + +# No -debuginfo: modules are stripped at install time via INSTALL_MOD_STRIP. +%global debug_package %{nil} +%global _missing_build_ids_terminate_build 0 + +# rpm's kernel module file attribute would decorate every .ko with +# kernel(<symbol>) provides and requires, which only Fedora's own split kernel +# packaging can satisfy. Keep the module tree out of the dependency generator +# entirely; the dependencies this package really has are declared by hand below. +%global __provides_exclude_from ^/usr/lib/(modules|surface-dtb)/.*$ +%global __requires_exclude_from ^/usr/lib/(modules|surface-dtb)/.*$ + +Name: kernel-surface +Version: %{kversion} +Release: %{patchset_ver}%{?dist} +Summary: Linux kernel for the Microsoft Surface Pro 12-inch (Snapdragon X1P-42-100) +License: GPL-2.0-only +URL: https://github.com/miasvanklei/Gentoo-overlay + +ExclusiveArch: aarch64 + +Source0: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/snapshot/linux-%{upstream_ver}.tar.gz +Source1: kernel-surface-patches-%{upstream_ver}-%{patchset_ver}.tar.gz +Source2: base-aarch64.config +Source3: surface.config +Source4: live-image.config +Source5: no-debug-info.config + +BuildRequires: bc +BuildRequires: binutils +BuildRequires: bison +BuildRequires: bzip2 +BuildRequires: diffutils +BuildRequires: elfutils-devel +BuildRequires: elfutils-libelf-devel +BuildRequires: findutils +BuildRequires: flex +BuildRequires: gcc +BuildRequires: gzip +BuildRequires: hostname +BuildRequires: kmod +BuildRequires: make +BuildRequires: openssl-devel +BuildRequires: patch +BuildRequires: perl-interpreter +BuildRequires: python3 +BuildRequires: rsync +BuildRequires: tar +BuildRequires: xz +BuildRequires: zstd + +Requires: dracut +Requires: kmod +Requires: linux-firmware +Requires: systemd >= 254 + +# This package stands in for the whole of Fedora's split kernel packaging, so +# anything with a plain `Requires: kernel-core` (anaconda, dracut config, +# desktop groups) resolves against it. It deliberately does not Obsolete the +# Fedora packages: the KIWI description picks this one by name and <ignore>s +# the Fedora ones, which keeps the repo safe to enable on a normal system. +Provides: kernel = %{version}-%{release} +Provides: kernel-core = %{version}-%{release} +Provides: kernel-modules = %{version}-%{release} +Provides: kernel-modules-core = %{version}-%{release} +Provides: kernel-modules-extra = %{version}-%{release} +Provides: kernel-uname-r = %{kverrel} +Provides: kernel-core-uname-r = %{kverrel} +Provides: kernel-modules-uname-r = %{kverrel} +Provides: kernel-modules-core-uname-r = %{kverrel} +Provides: kernel-modules-extra-uname-r = %{kverrel} +Provides: installonlypkg(kernel) + +# Fedora's kernel-uki-dtbloader carries ~3000 boards' device trees and conflicts +# with a plain kernel image package; this board is not in its database anyway. +Conflicts: kernel-uki-dtbloader + +%description +The Linux kernel built from vanilla upstream sources with the Microsoft Surface +Pro 12-inch (Snapdragon X1P-42-100) patch set from the miasvanklei Gentoo +overlay applied. + +Beyond the device tree for the board, the patch set adds a Surface Aggregator +Module RTC driver, a suspend workaround for the aggregator controller, CAMSS +and CSI-2 D-PHY support for the tablet's cameras, remoteproc attach support for +the already-running DSPs, and assorted clock, PCI and interrupt controller +fixes for the platform. + +This package provides kernel, kernel-core, kernel-modules and +kernel-modules-extra, so it can be installed in place of Fedora's kernel +packages. + +%prep +%setup -q -n linux-%{upstream_ver} -a 1 + +# Apply every patch directory in the order given by patch-order.txt, which +# make-sources.sh encoded into the tarball's directory names. +# +# The patch flags are Portage's eapply flags (patch -p1 -f -g0 +# --no-backup-if-mismatch), which is what the overlay's patches are maintained +# against: they carry stale context lines from before upstream refactors and +# only apply at GNU patch's default fuzz of 2. Forcing --fuzz=0 here rejects +# roughly a fifth of the set. What guards against a silently mis-applied patch +# is not the fuzz level but the .config and kernelrelease assertions below. +for patchdir in patches/*/; do + for patchfile in "${patchdir}"*.patch; do + [ -e "${patchfile}" ] || continue + echo "Applying ${patchfile}" + patch -p1 -f -g0 --no-backup-if-mismatch -i "${patchfile}" + done +done +rm -rf patches + +# Fold the -rcN suffix into the package release instead of carrying it in +# uname -r, so the module directory is named the way Fedora names it. +sed -i 's/^EXTRAVERSION[[:space:]]*=.*/EXTRAVERSION =/' Makefile + +cp -f %{SOURCE2} .config + +# The base config still carries Fedora's own build salt, which feeds the +# kernel's build ID; reset it so this kernel does not share one with the +# Fedora build it was seeded from. +cat > .release.config <<EOF +CONFIG_LOCALVERSION="-%{release}.%{_target_cpu}" +CONFIG_BUILD_SALT="%{kverrel}" +EOF + +ARCH=arm64 scripts/kconfig/merge_config.sh -m -O . \ + .config .release.config %{SOURCE3} %{SOURCE4} %{SOURCE5} +make ARCH=arm64 olddefconfig + +# merge_config.sh is only advisory about symbols it could not set, so check the +# ones that exist solely because the patch set applied. +for sym in CONFIG_RTC_DRV_SURFACE CONFIG_PHY_QCOM_MIPI_CSI2; do + grep -q "^${sym}=" .config || { + echo "ERROR: ${sym} missing from .config; the patch set did not apply" + exit 1 + } +done + +# The build derives /usr/lib/modules/<...> from CONFIG_LOCALVERSION. A mismatch +# here means it would not be the directory %%files and the scriptlets name, +# which otherwise only shows up as a broken package. +kernelrelease=$(make -s ARCH=arm64 kernelrelease | tail -n1) +test "${kernelrelease}" = "%{kverrel}" || { + echo "ERROR: kernelrelease is ${kernelrelease}, expected %{kverrel}" + exit 1 +} + +%build +%make_build ARCH=arm64 Image modules dtbs + +%install +%make_build ARCH=arm64 \ + INSTALL_MOD_PATH=%{buildroot}/usr INSTALL_MOD_STRIP=1 \ + modules_install + +%make_build ARCH=arm64 \ + INSTALL_DTBS_PATH=%{buildroot}/usr/lib/modules/%{kverrel}/dtb \ + dtbs_install + +# modules_install leaves symlinks into the build tree, which does not exist on +# the installed system. +rm -f %{buildroot}/usr/lib/modules/%{kverrel}/build +rm -f %{buildroot}/usr/lib/modules/%{kverrel}/source + +# GRUB loads the aarch64 kernel as an EFI application, so this is the +# uncompressed Image, not Image.gz. kernel-install copies it into /boot. +install -Dm644 arch/arm64/boot/Image \ + %{buildroot}/usr/lib/modules/%{kverrel}/vmlinuz +install -Dm644 System.map \ + %{buildroot}/usr/lib/modules/%{kverrel}/System.map +install -Dm644 .config \ + %{buildroot}/usr/lib/modules/%{kverrel}/config +install -Dm644 arch/arm64/boot/dts/qcom/x1p42100-microsoft-sp12in.dtb \ + %{buildroot}/usr/lib/surface-dtb/x1p42100-microsoft-sp12in.dtb + +%post +/usr/sbin/depmod -a %{kverrel} || : + +%posttrans +# Same as Fedora's kernel-core: hand the kernel to kernel-install, which +# generates the initramfs, copies vmlinuz into /boot and writes the BLS loader +# entry. +if [ -x /usr/bin/kernel-install ]; then + /usr/bin/kernel-install add %{kverrel} \ + /usr/lib/modules/%{kverrel}/vmlinuz || : +fi + +%preun +if [ -x /usr/bin/kernel-install ]; then + /usr/bin/kernel-install remove %{kverrel} || : +fi + +%files +%license COPYING +/usr/lib/modules/%{kverrel}/ +/usr/lib/surface-dtb/x1p42100-microsoft-sp12in.dtb +%ghost %attr(0644,root,root) /boot/config-%{kverrel} +%ghost %attr(0644,root,root) /boot/initramfs-%{kverrel}.img +%ghost %attr(0600,root,root) /boot/System.map-%{kverrel} +%ghost %attr(0644,root,root) /boot/vmlinuz-%{kverrel} + +%changelog +* Sun Sep 06 2026 Saya Andy 7.2.3-1 +- Initial package: vanilla 7.2.3 with the overlay's Surface Pro 12" patch set |