2023-07-22 13:48:02 +09:00
|
|
|
# _arch is undefined if /usr/lib/rpm/platform/*/macros was not included.
|
|
|
|
|
%{!?_arch: %define _arch dummy}
|
|
|
|
|
%{!?make: %define make make}
|
|
|
|
|
%define makeflags %{?_smp_mflags} ARCH=%{ARCH}
|
|
|
|
|
|
|
|
|
|
Name: kernel
|
|
|
|
|
Summary: The Linux Kernel
|
|
|
|
|
Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g')
|
|
|
|
|
Release: %{pkg_release}
|
|
|
|
|
License: GPL
|
|
|
|
|
Group: System Environment/Kernel
|
|
|
|
|
Vendor: The Linux Community
|
|
|
|
|
URL: https://www.kernel.org
|
|
|
|
|
Source0: linux.tar.gz
|
|
|
|
|
Source1: config
|
|
|
|
|
Source2: diff.patch
|
|
|
|
|
Provides: kernel-%{KERNELRELEASE}
|
|
|
|
|
BuildRequires: bc binutils bison dwarves
|
2025-04-22 18:54:02 +08:00
|
|
|
BuildRequires: (elfutils-devel or libdw-devel)
|
2023-07-22 13:48:02 +09:00
|
|
|
BuildRequires: (elfutils-libelf-devel or libelf-devel) flex
|
|
|
|
|
BuildRequires: gcc make openssl openssl-devel perl python3 rsync
|
|
|
|
|
|
|
|
|
|
%description
|
|
|
|
|
The Linux Kernel, the operating system core itself
|
|
|
|
|
|
|
|
|
|
%package headers
|
|
|
|
|
Summary: Header files for the Linux kernel for use by glibc
|
|
|
|
|
Group: Development/System
|
2024-06-11 17:11:21 -04:00
|
|
|
Obsoletes: kernel-headers < %{version}
|
2023-07-22 13:48:02 +09:00
|
|
|
Provides: kernel-headers = %{version}
|
|
|
|
|
%description headers
|
|
|
|
|
Kernel-headers includes the C header files that specify the interface
|
|
|
|
|
between the Linux kernel and userspace libraries and programs. The
|
|
|
|
|
header files define structures and constants that are needed for
|
|
|
|
|
building most standard programs and are also needed for rebuilding the
|
|
|
|
|
glibc package.
|
|
|
|
|
|
|
|
|
|
%if %{with_devel}
|
|
|
|
|
%package devel
|
|
|
|
|
Summary: Development package for building kernel modules to match the %{version} kernel
|
|
|
|
|
Group: System Environment/Kernel
|
|
|
|
|
AutoReqProv: no
|
|
|
|
|
%description -n kernel-devel
|
|
|
|
|
This package provides kernel headers and makefiles sufficient to build modules
|
|
|
|
|
against the %{version} kernel package.
|
|
|
|
|
%endif
|
|
|
|
|
|
kbuild: rpm-pkg: build a debuginfo RPM
The rpm-pkg make target currently suffers from a few issues related to
debuginfo:
1. debuginfo for things built into the kernel (vmlinux) is not available
in any RPM produced by make rpm-pkg. This makes using tools like
systemtap against a make rpm-pkg kernel impossible.
2. debug source for the kernel is not available. This means that
commands like 'disas /s' in gdb, which display source intermixed with
assembly, can only print file names/line numbers which then must be
painstakingly resolved to actual source in a separate editor.
3. debuginfo for modules is available, but it remains bundled with the
.ko files that contain module code, in the main kernel RPM. This is a
waste of space for users who do not need to debug the kernel (i.e.
most users).
Address all of these issues by additionally building a debuginfo RPM
when the kernel configuration allows for it, in line with standard
patterns followed by RPM distributors. With these changes:
1. systemtap now works (when these changes are backported to 6.11, since
systemtap lags a bit behind in compatibility), as verified by the
following simple test script:
# stap -e 'probe kernel.function("do_sys_open").call { printf("%s\n", $$parms); }'
dfd=0xffffffffffffff9c filename=0x7fe18800b160 flags=0x88800 mode=0x0
...
2. disas /s works correctly in gdb, with source and disassembly
interspersed:
# gdb vmlinux --batch -ex 'disas /s blk_op_str'
Dump of assembler code for function blk_op_str:
block/blk-core.c:
125 {
0xffffffff814c8740 <+0>: endbr64
127
128 if (op < ARRAY_SIZE(blk_op_name) && blk_op_name[op])
0xffffffff814c8744 <+4>: mov $0xffffffff824a7378,%rax
0xffffffff814c874b <+11>: cmp $0x23,%edi
0xffffffff814c874e <+14>: ja 0xffffffff814c8768 <blk_op_str+40>
0xffffffff814c8750 <+16>: mov %edi,%edi
126 const char *op_str = "UNKNOWN";
0xffffffff814c8752 <+18>: mov $0xffffffff824a7378,%rdx
127
128 if (op < ARRAY_SIZE(blk_op_name) && blk_op_name[op])
0xffffffff814c8759 <+25>: mov -0x7dfa0160(,%rdi,8),%rax
126 const char *op_str = "UNKNOWN";
0xffffffff814c8761 <+33>: test %rax,%rax
0xffffffff814c8764 <+36>: cmove %rdx,%rax
129 op_str = blk_op_name[op];
130
131 return op_str;
132 }
0xffffffff814c8768 <+40>: jmp 0xffffffff81d01360 <__x86_return_thunk>
End of assembler dump.
3. The size of the main kernel package goes down substantially,
especially if many modules are built (quite typical). Here is a
comparison of installed size of the kernel package (configured with
allmodconfig, dwarf4 debuginfo, and module compression turned off)
before and after this patch:
# rpm -qi kernel-6.13* | grep -E '^(Version|Size)'
Version : 6.13.0postpatch+
Size : 1382874089
Version : 6.13.0prepatch+
Size : 17870795887
This is a ~92% size reduction.
Note that a debuginfo package can only be produced if the following
configs are set:
- CONFIG_DEBUG_INFO=y
- CONFIG_MODULE_COMPRESS=n
- CONFIG_DEBUG_INFO_SPLIT=n
The first of these is obvious - we can't produce debuginfo if the build
does not generate it. The second two requirements can in principle be
removed, but doing so is difficult with the current approach, which uses
a generic rpmbuild script find-debuginfo.sh that processes all packaged
executables. If we want to remove those requirements the best path
forward is likely to add some debuginfo extraction/installation logic to
the modules_install target (controllable by flags). That way, it's
easier to operate on modules before they're compressed, and the logic
can be reused by all packaging targets.
Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2025-03-31 16:46:32 -06:00
|
|
|
%if %{with_debuginfo}
|
|
|
|
|
# list of debuginfo-related options taken from distribution kernel.spec
|
|
|
|
|
# files
|
|
|
|
|
%undefine _include_minidebuginfo
|
|
|
|
|
%undefine _find_debuginfo_dwz_opts
|
|
|
|
|
%undefine _unique_build_ids
|
|
|
|
|
%undefine _unique_debug_names
|
|
|
|
|
%undefine _unique_debug_srcs
|
|
|
|
|
%undefine _debugsource_packages
|
|
|
|
|
%undefine _debuginfo_subpackages
|
|
|
|
|
%global _find_debuginfo_opts -r
|
|
|
|
|
%global _missing_build_ids_terminate_build 1
|
|
|
|
|
%global _no_recompute_build_ids 1
|
|
|
|
|
%{debug_package}
|
|
|
|
|
%endif
|
|
|
|
|
# some (but not all) versions of rpmbuild emit %%debug_package with
|
|
|
|
|
# %%install. since we've already emitted it manually, that would cause
|
|
|
|
|
# a package redefinition error. ensure that doesn't happen
|
|
|
|
|
%define debug_package %{nil}
|
|
|
|
|
|
|
|
|
|
# later, we make all modules executable so that find-debuginfo.sh strips
|
|
|
|
|
# them up. but they don't actually need to be executable, so remove the
|
|
|
|
|
# executable bit, taking care to do it _after_ find-debuginfo.sh has run
|
|
|
|
|
%define __spec_install_post \
|
|
|
|
|
%{?__debug_package:%{__debug_install_post}} \
|
|
|
|
|
%{__arch_install_post} \
|
|
|
|
|
%{__os_install_post} \
|
|
|
|
|
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \\\
|
|
|
|
|
| xargs --no-run-if-empty chmod u-x
|
|
|
|
|
|
2023-07-22 13:48:02 +09:00
|
|
|
%prep
|
|
|
|
|
%setup -q -n linux
|
|
|
|
|
cp %{SOURCE1} .config
|
|
|
|
|
patch -p1 < %{SOURCE2}
|
|
|
|
|
|
|
|
|
|
%build
|
|
|
|
|
%{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release}
|
|
|
|
|
|
|
|
|
|
%install
|
kbuild: rpm-pkg: simplify installkernel %post
The new installkernel application that is now included in systemd-udev
package allows installation although destination files are already present
in the boot directory of the kernel package, but is failing with the
implemented workaround for the old installkernel application from grubby
package.
For the new installkernel application, as Davide says:
<<The %post currently does a shuffling dance before calling installkernel.
This isn't actually necessary afaict, and the current implementation
ends up triggering downstream issues such as
https://github.com/systemd/systemd/issues/29568
This commit simplifies the logic to remove the shuffling. For reference,
the original logic was added in commit 3c9c7a14b627("rpm-pkg: add %post
section to create initramfs and grub hooks").>>
But we need to keep the old behavior as well, because the old installkernel
application from grubby package, does not allow this simplification and
we need to be backward compatible to avoid issues with the different
packages.
Mimic Fedora shipping process and store vmlinuz, config amd System.map
in the module directory instead of the boot directory. In this way, we will
avoid the commented problem for all the cases, because the new destination
files are not going to exist in the boot directory of the kernel package.
Replace installkernel tool with kernel-install tool, because the latter is
more complete.
Besides, after installkernel tool execution, check to complete if the
correct package files vmlinuz, System.map and config files are present
in /boot directory, and if necessary, copy manually for install operation.
In this way, take into account if files were not previously copied from
/usr/lib/kernel/install.d/* scripts and if the suitable files for the
requested package are present (it could be others if the rpm files were
replace with a new pacakge with the same release and a different build).
Tested with Fedora 38, Fedora 39, RHEL 9, Oracle Linux 9.3,
openSUSE Tumbleweed and openMandrive ROME, using dnf/zypper and rpm tools.
cc: stable@vger.kernel.org
Co-Developed-by: Davide Cavalca <dcavalca@meta.com>
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2024-01-29 10:28:19 +01:00
|
|
|
mkdir -p %{buildroot}/lib/modules/%{KERNELRELEASE}
|
|
|
|
|
cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinuz
|
2024-06-18 20:08:43 +09:00
|
|
|
# DEPMOD=true makes depmod no-op. We do not package depmod-generated files.
|
|
|
|
|
%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} DEPMOD=true modules_install
|
2023-07-22 13:48:02 +09:00
|
|
|
%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
|
kbuild: rpm-pkg: simplify installkernel %post
The new installkernel application that is now included in systemd-udev
package allows installation although destination files are already present
in the boot directory of the kernel package, but is failing with the
implemented workaround for the old installkernel application from grubby
package.
For the new installkernel application, as Davide says:
<<The %post currently does a shuffling dance before calling installkernel.
This isn't actually necessary afaict, and the current implementation
ends up triggering downstream issues such as
https://github.com/systemd/systemd/issues/29568
This commit simplifies the logic to remove the shuffling. For reference,
the original logic was added in commit 3c9c7a14b627("rpm-pkg: add %post
section to create initramfs and grub hooks").>>
But we need to keep the old behavior as well, because the old installkernel
application from grubby package, does not allow this simplification and
we need to be backward compatible to avoid issues with the different
packages.
Mimic Fedora shipping process and store vmlinuz, config amd System.map
in the module directory instead of the boot directory. In this way, we will
avoid the commented problem for all the cases, because the new destination
files are not going to exist in the boot directory of the kernel package.
Replace installkernel tool with kernel-install tool, because the latter is
more complete.
Besides, after installkernel tool execution, check to complete if the
correct package files vmlinuz, System.map and config files are present
in /boot directory, and if necessary, copy manually for install operation.
In this way, take into account if files were not previously copied from
/usr/lib/kernel/install.d/* scripts and if the suitable files for the
requested package are present (it could be others if the rpm files were
replace with a new pacakge with the same release and a different build).
Tested with Fedora 38, Fedora 39, RHEL 9, Oracle Linux 9.3,
openSUSE Tumbleweed and openMandrive ROME, using dnf/zypper and rpm tools.
cc: stable@vger.kernel.org
Co-Developed-by: Davide Cavalca <dcavalca@meta.com>
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2024-01-29 10:28:19 +01:00
|
|
|
cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
|
|
|
|
|
cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
|
2024-03-11 17:22:38 +01:00
|
|
|
if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
|
|
|
|
|
%{make} %{makeflags} INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb dtbs_install
|
|
|
|
|
fi
|
2023-07-22 13:48:02 +09:00
|
|
|
ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
|
|
|
|
|
%if %{with_devel}
|
|
|
|
|
%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
|
|
|
|
|
%endif
|
|
|
|
|
|
2024-02-02 22:35:17 +09:00
|
|
|
{
|
2024-06-18 20:08:43 +09:00
|
|
|
echo "/lib/modules/%{KERNELRELEASE}"
|
2024-02-02 22:35:17 +09:00
|
|
|
|
|
|
|
|
for x in alias alias.bin builtin.alias.bin builtin.bin dep dep.bin \
|
2024-07-26 11:00:26 +02:00
|
|
|
devname softdep symbols symbols.bin weakdep; do
|
2024-02-02 22:35:17 +09:00
|
|
|
echo "%ghost /lib/modules/%{KERNELRELEASE}/modules.${x}"
|
|
|
|
|
done
|
|
|
|
|
|
2024-02-02 22:35:18 +09:00
|
|
|
for x in System.map config vmlinuz; do
|
|
|
|
|
echo "%ghost /boot/${x}-%{KERNELRELEASE}"
|
|
|
|
|
done
|
|
|
|
|
|
2024-03-11 17:22:38 +01:00
|
|
|
if [ -d "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" ];then
|
|
|
|
|
find "%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb" -printf "%%%ghost /boot/dtb-%{KERNELRELEASE}/%%P\n"
|
|
|
|
|
fi
|
|
|
|
|
|
2024-02-02 22:35:17 +09:00
|
|
|
echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
|
|
|
|
|
} > %{buildroot}/kernel.list
|
|
|
|
|
|
kbuild: rpm-pkg: build a debuginfo RPM
The rpm-pkg make target currently suffers from a few issues related to
debuginfo:
1. debuginfo for things built into the kernel (vmlinux) is not available
in any RPM produced by make rpm-pkg. This makes using tools like
systemtap against a make rpm-pkg kernel impossible.
2. debug source for the kernel is not available. This means that
commands like 'disas /s' in gdb, which display source intermixed with
assembly, can only print file names/line numbers which then must be
painstakingly resolved to actual source in a separate editor.
3. debuginfo for modules is available, but it remains bundled with the
.ko files that contain module code, in the main kernel RPM. This is a
waste of space for users who do not need to debug the kernel (i.e.
most users).
Address all of these issues by additionally building a debuginfo RPM
when the kernel configuration allows for it, in line with standard
patterns followed by RPM distributors. With these changes:
1. systemtap now works (when these changes are backported to 6.11, since
systemtap lags a bit behind in compatibility), as verified by the
following simple test script:
# stap -e 'probe kernel.function("do_sys_open").call { printf("%s\n", $$parms); }'
dfd=0xffffffffffffff9c filename=0x7fe18800b160 flags=0x88800 mode=0x0
...
2. disas /s works correctly in gdb, with source and disassembly
interspersed:
# gdb vmlinux --batch -ex 'disas /s blk_op_str'
Dump of assembler code for function blk_op_str:
block/blk-core.c:
125 {
0xffffffff814c8740 <+0>: endbr64
127
128 if (op < ARRAY_SIZE(blk_op_name) && blk_op_name[op])
0xffffffff814c8744 <+4>: mov $0xffffffff824a7378,%rax
0xffffffff814c874b <+11>: cmp $0x23,%edi
0xffffffff814c874e <+14>: ja 0xffffffff814c8768 <blk_op_str+40>
0xffffffff814c8750 <+16>: mov %edi,%edi
126 const char *op_str = "UNKNOWN";
0xffffffff814c8752 <+18>: mov $0xffffffff824a7378,%rdx
127
128 if (op < ARRAY_SIZE(blk_op_name) && blk_op_name[op])
0xffffffff814c8759 <+25>: mov -0x7dfa0160(,%rdi,8),%rax
126 const char *op_str = "UNKNOWN";
0xffffffff814c8761 <+33>: test %rax,%rax
0xffffffff814c8764 <+36>: cmove %rdx,%rax
129 op_str = blk_op_name[op];
130
131 return op_str;
132 }
0xffffffff814c8768 <+40>: jmp 0xffffffff81d01360 <__x86_return_thunk>
End of assembler dump.
3. The size of the main kernel package goes down substantially,
especially if many modules are built (quite typical). Here is a
comparison of installed size of the kernel package (configured with
allmodconfig, dwarf4 debuginfo, and module compression turned off)
before and after this patch:
# rpm -qi kernel-6.13* | grep -E '^(Version|Size)'
Version : 6.13.0postpatch+
Size : 1382874089
Version : 6.13.0prepatch+
Size : 17870795887
This is a ~92% size reduction.
Note that a debuginfo package can only be produced if the following
configs are set:
- CONFIG_DEBUG_INFO=y
- CONFIG_MODULE_COMPRESS=n
- CONFIG_DEBUG_INFO_SPLIT=n
The first of these is obvious - we can't produce debuginfo if the build
does not generate it. The second two requirements can in principle be
removed, but doing so is difficult with the current approach, which uses
a generic rpmbuild script find-debuginfo.sh that processes all packaged
executables. If we want to remove those requirements the best path
forward is likely to add some debuginfo extraction/installation logic to
the modules_install target (controllable by flags). That way, it's
easier to operate on modules before they're compressed, and the logic
can be reused by all packaging targets.
Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2025-03-31 16:46:32 -06:00
|
|
|
# make modules executable so that find-debuginfo.sh strips them. this
|
|
|
|
|
# will be undone later in %%__spec_install_post
|
|
|
|
|
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \
|
|
|
|
|
| xargs --no-run-if-empty chmod u+x
|
|
|
|
|
|
|
|
|
|
%if %{with_debuginfo}
|
|
|
|
|
# copying vmlinux directly to the debug directory means it will not get
|
|
|
|
|
# stripped (but its source paths will still be collected + fixed up)
|
|
|
|
|
mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
|
|
|
|
|
cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
|
|
|
|
|
%endif
|
|
|
|
|
|
2023-07-22 13:48:02 +09:00
|
|
|
%clean
|
|
|
|
|
rm -rf %{buildroot}
|
kbuild: rpm-pkg: build a debuginfo RPM
The rpm-pkg make target currently suffers from a few issues related to
debuginfo:
1. debuginfo for things built into the kernel (vmlinux) is not available
in any RPM produced by make rpm-pkg. This makes using tools like
systemtap against a make rpm-pkg kernel impossible.
2. debug source for the kernel is not available. This means that
commands like 'disas /s' in gdb, which display source intermixed with
assembly, can only print file names/line numbers which then must be
painstakingly resolved to actual source in a separate editor.
3. debuginfo for modules is available, but it remains bundled with the
.ko files that contain module code, in the main kernel RPM. This is a
waste of space for users who do not need to debug the kernel (i.e.
most users).
Address all of these issues by additionally building a debuginfo RPM
when the kernel configuration allows for it, in line with standard
patterns followed by RPM distributors. With these changes:
1. systemtap now works (when these changes are backported to 6.11, since
systemtap lags a bit behind in compatibility), as verified by the
following simple test script:
# stap -e 'probe kernel.function("do_sys_open").call { printf("%s\n", $$parms); }'
dfd=0xffffffffffffff9c filename=0x7fe18800b160 flags=0x88800 mode=0x0
...
2. disas /s works correctly in gdb, with source and disassembly
interspersed:
# gdb vmlinux --batch -ex 'disas /s blk_op_str'
Dump of assembler code for function blk_op_str:
block/blk-core.c:
125 {
0xffffffff814c8740 <+0>: endbr64
127
128 if (op < ARRAY_SIZE(blk_op_name) && blk_op_name[op])
0xffffffff814c8744 <+4>: mov $0xffffffff824a7378,%rax
0xffffffff814c874b <+11>: cmp $0x23,%edi
0xffffffff814c874e <+14>: ja 0xffffffff814c8768 <blk_op_str+40>
0xffffffff814c8750 <+16>: mov %edi,%edi
126 const char *op_str = "UNKNOWN";
0xffffffff814c8752 <+18>: mov $0xffffffff824a7378,%rdx
127
128 if (op < ARRAY_SIZE(blk_op_name) && blk_op_name[op])
0xffffffff814c8759 <+25>: mov -0x7dfa0160(,%rdi,8),%rax
126 const char *op_str = "UNKNOWN";
0xffffffff814c8761 <+33>: test %rax,%rax
0xffffffff814c8764 <+36>: cmove %rdx,%rax
129 op_str = blk_op_name[op];
130
131 return op_str;
132 }
0xffffffff814c8768 <+40>: jmp 0xffffffff81d01360 <__x86_return_thunk>
End of assembler dump.
3. The size of the main kernel package goes down substantially,
especially if many modules are built (quite typical). Here is a
comparison of installed size of the kernel package (configured with
allmodconfig, dwarf4 debuginfo, and module compression turned off)
before and after this patch:
# rpm -qi kernel-6.13* | grep -E '^(Version|Size)'
Version : 6.13.0postpatch+
Size : 1382874089
Version : 6.13.0prepatch+
Size : 17870795887
This is a ~92% size reduction.
Note that a debuginfo package can only be produced if the following
configs are set:
- CONFIG_DEBUG_INFO=y
- CONFIG_MODULE_COMPRESS=n
- CONFIG_DEBUG_INFO_SPLIT=n
The first of these is obvious - we can't produce debuginfo if the build
does not generate it. The second two requirements can in principle be
removed, but doing so is difficult with the current approach, which uses
a generic rpmbuild script find-debuginfo.sh that processes all packaged
executables. If we want to remove those requirements the best path
forward is likely to add some debuginfo extraction/installation logic to
the modules_install target (controllable by flags). That way, it's
easier to operate on modules before they're compressed, and the logic
can be reused by all packaging targets.
Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2025-03-31 16:46:32 -06:00
|
|
|
rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \
|
|
|
|
|
elfbins.list
|
2023-07-22 13:48:02 +09:00
|
|
|
|
|
|
|
|
%post
|
kbuild: rpm-pkg: simplify installkernel %post
The new installkernel application that is now included in systemd-udev
package allows installation although destination files are already present
in the boot directory of the kernel package, but is failing with the
implemented workaround for the old installkernel application from grubby
package.
For the new installkernel application, as Davide says:
<<The %post currently does a shuffling dance before calling installkernel.
This isn't actually necessary afaict, and the current implementation
ends up triggering downstream issues such as
https://github.com/systemd/systemd/issues/29568
This commit simplifies the logic to remove the shuffling. For reference,
the original logic was added in commit 3c9c7a14b627("rpm-pkg: add %post
section to create initramfs and grub hooks").>>
But we need to keep the old behavior as well, because the old installkernel
application from grubby package, does not allow this simplification and
we need to be backward compatible to avoid issues with the different
packages.
Mimic Fedora shipping process and store vmlinuz, config amd System.map
in the module directory instead of the boot directory. In this way, we will
avoid the commented problem for all the cases, because the new destination
files are not going to exist in the boot directory of the kernel package.
Replace installkernel tool with kernel-install tool, because the latter is
more complete.
Besides, after installkernel tool execution, check to complete if the
correct package files vmlinuz, System.map and config files are present
in /boot directory, and if necessary, copy manually for install operation.
In this way, take into account if files were not previously copied from
/usr/lib/kernel/install.d/* scripts and if the suitable files for the
requested package are present (it could be others if the rpm files were
replace with a new pacakge with the same release and a different build).
Tested with Fedora 38, Fedora 39, RHEL 9, Oracle Linux 9.3,
openSUSE Tumbleweed and openMandrive ROME, using dnf/zypper and rpm tools.
cc: stable@vger.kernel.org
Co-Developed-by: Davide Cavalca <dcavalca@meta.com>
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2024-01-29 10:28:19 +01:00
|
|
|
if [ -x /usr/bin/kernel-install ]; then
|
|
|
|
|
/usr/bin/kernel-install add %{KERNELRELEASE} /lib/modules/%{KERNELRELEASE}/vmlinuz
|
2023-07-22 13:48:02 +09:00
|
|
|
fi
|
kbuild: rpm-pkg: simplify installkernel %post
The new installkernel application that is now included in systemd-udev
package allows installation although destination files are already present
in the boot directory of the kernel package, but is failing with the
implemented workaround for the old installkernel application from grubby
package.
For the new installkernel application, as Davide says:
<<The %post currently does a shuffling dance before calling installkernel.
This isn't actually necessary afaict, and the current implementation
ends up triggering downstream issues such as
https://github.com/systemd/systemd/issues/29568
This commit simplifies the logic to remove the shuffling. For reference,
the original logic was added in commit 3c9c7a14b627("rpm-pkg: add %post
section to create initramfs and grub hooks").>>
But we need to keep the old behavior as well, because the old installkernel
application from grubby package, does not allow this simplification and
we need to be backward compatible to avoid issues with the different
packages.
Mimic Fedora shipping process and store vmlinuz, config amd System.map
in the module directory instead of the boot directory. In this way, we will
avoid the commented problem for all the cases, because the new destination
files are not going to exist in the boot directory of the kernel package.
Replace installkernel tool with kernel-install tool, because the latter is
more complete.
Besides, after installkernel tool execution, check to complete if the
correct package files vmlinuz, System.map and config files are present
in /boot directory, and if necessary, copy manually for install operation.
In this way, take into account if files were not previously copied from
/usr/lib/kernel/install.d/* scripts and if the suitable files for the
requested package are present (it could be others if the rpm files were
replace with a new pacakge with the same release and a different build).
Tested with Fedora 38, Fedora 39, RHEL 9, Oracle Linux 9.3,
openSUSE Tumbleweed and openMandrive ROME, using dnf/zypper and rpm tools.
cc: stable@vger.kernel.org
Co-Developed-by: Davide Cavalca <dcavalca@meta.com>
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2024-01-29 10:28:19 +01:00
|
|
|
for file in vmlinuz System.map config; do
|
|
|
|
|
if ! cmp --silent "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"; then
|
|
|
|
|
cp "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"
|
|
|
|
|
fi
|
|
|
|
|
done
|
2024-03-11 17:22:38 +01:00
|
|
|
if [ -d "/lib/modules/%{KERNELRELEASE}/dtb" ] && \
|
|
|
|
|
! diff -rq "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}" >/dev/null 2>&1; then
|
|
|
|
|
rm -rf "/boot/dtb-%{KERNELRELEASE}"
|
|
|
|
|
cp -r "/lib/modules/%{KERNELRELEASE}/dtb" "/boot/dtb-%{KERNELRELEASE}"
|
|
|
|
|
fi
|
2024-02-02 22:35:17 +09:00
|
|
|
if [ ! -e "/lib/modules/%{KERNELRELEASE}/modules.dep" ]; then
|
|
|
|
|
/usr/sbin/depmod %{KERNELRELEASE}
|
|
|
|
|
fi
|
2023-07-22 13:48:02 +09:00
|
|
|
|
|
|
|
|
%preun
|
2024-02-02 22:35:20 +09:00
|
|
|
if [ -x /usr/bin/kernel-install ]; then
|
2023-07-22 13:48:02 +09:00
|
|
|
kernel-install remove %{KERNELRELEASE}
|
|
|
|
|
fi
|
|
|
|
|
|
2024-02-02 22:35:17 +09:00
|
|
|
%files -f %{buildroot}/kernel.list
|
2023-07-22 13:48:02 +09:00
|
|
|
%defattr (-, root, root)
|
2024-02-02 22:35:17 +09:00
|
|
|
%exclude /kernel.list
|
2023-07-22 13:48:02 +09:00
|
|
|
|
|
|
|
|
%files headers
|
|
|
|
|
%defattr (-, root, root)
|
|
|
|
|
/usr/include
|
|
|
|
|
|
|
|
|
|
%if %{with_devel}
|
|
|
|
|
%files devel
|
|
|
|
|
%defattr (-, root, root)
|
|
|
|
|
/usr/src/kernels/%{KERNELRELEASE}
|
|
|
|
|
/lib/modules/%{KERNELRELEASE}/build
|
|
|
|
|
%endif
|