kbuild: rpm-pkg: define _arch conditionally
PATCH 1/19 kbuild: rpm-pkg: define _arch conditionally
Commit 3089b2be0cce ("kbuild: rpm-pkg: fix build error when _arch is undefined") does not work as intended; _arch is always defined as $UTS_MACHINE.
The intention was to define _arch to $UTS_MACHINE only when it is not defined.
---
scripts/package/mkspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/mkspec +1 -1
@@ -57,7 +57,7 @@ $S BuildRequires: gcc make openssl openssl-devel perl python3 rsync # $UTS_MACHINE as a fallback of _arch in case # /usr/lib/rpm/platform/*/macros was not included. - %define _arch %{?_arch:$UTS_MACHINE} + %{!?_arch: %define _arch $UTS_MACHINE} %define __spec_install_post /usr/lib/rpm/brp-compress || : %define debug_package %{nil}
Signature · 1 line
2.39.2
PATCH 2/19 kbuild: rpm-pkg: remove unneeded '-f $srctree/Makefile' in spec file
This is unneeded because the Makefile in the output directory wraps the top-level Makefile in the srctree.
Just run $MAKE irrespective of the build location.
---
scripts/package/mkspec | 1 - 1 file changed, 1 deletion(-)
scripts/package/mkspec +0 -1
@@ -12,7 +12,6 @@ # how we were called determines which rpms we build and how we build them if [ "$1" = prebuilt ]; then S=DEL - MAKE="$MAKE -f $srctree/Makefile" else S=
Signature · 1 line
2.39.2
PATCH 3/19 kbuild: rpm-pkg: do not hard-code $MAKE in spec file
In reply to Masahiro YamadaCurrently, $MAKE will expand to the GNU Make program that created the source RPM. This is problematic if you carry it to a different build host to run 'rpmbuild' there.
Consider this command:
$ /path/to/my/custom/make srcrpm-pkg
The spec file in the SRPM will record '/path/to/my/custom/make', which exists only on that build environment.
To create a portable SRPM, the spec file should avoid hard-coding $MAKE.
---
scripts/Makefile.package | 5 +++-- scripts/package/mkspec | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-)
scripts/Makefile.package +3 -2
@@ -72,7 +72,7 @@ PHONY += rpm-pkg rpm-pkg: srpm = $(shell rpmspec --srpm --query --queryformat='%{name}-%{VERSION}-%{RELEASE}.src.rpm' kernel.spec) rpm-pkg: srcrpm-pkg +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -rb $(srpm) \ - --define='_smp_mflags %{nil}' + --define='_smp_mflags %{nil}' --define='make $(MAKE)' # srcrpm-pkg # ---------------------------------------------------------------------------
@@ -89,7 +89,8 @@ binrpm-pkg: $(MAKE) -f $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ - $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec + $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec \ + --define='make $(MAKE)' # deb-pkg srcdeb-pkg bindeb-pkg # ---------------------------------------------------------------------------
scripts/package/mkspec +7 -5
@@ -38,6 +38,8 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \ # $S: this line is enabled only when building source package # $M: this line is enabled only when CONFIG_MODULES is enabled sed -e '/^DEL/d' -e 's/^\t*//' <<EOF +%{!?make: %define make make} + Name: kernel Summary: The Linux Kernel Version: $__KERNELRELEASE
@@ -89,19 +91,19 @@ $S cp %{SOURCE1} .config $S patch -p1 < %{SOURCE2} $S $S %build -$S $MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release} +$S %{make} %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release} $S %install mkdir -p %{buildroot}/boot %ifarch ia64 mkdir -p %{buildroot}/boot/efi - cp \$($MAKE -s image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE + cp \$(%{make} -s image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/ %else - cp \$($MAKE -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE + cp \$(%{make} -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE %endif -$M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install - $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install +$M %{make} %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install + %{make} %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE cp .config %{buildroot}/boot/config-$KERNELRELEASE $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
Signature · 1 line
2.39.2
PATCH 4/19 kbuild: rpm-pkg: use %{makeflags} to pass common Make options
In reply to Masahiro YamadaThis is useful to pass more common Make options.
---
scripts/package/mkspec | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
scripts/package/mkspec +6 -5
@@ -39,6 +39,7 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \ # $M: this line is enabled only when CONFIG_MODULES is enabled sed -e '/^DEL/d' -e 's/^\t*//' <<EOF %{!?make: %define make make} +%define makeflags %{?_smp_mflags} Name: kernel Summary: The Linux Kernel
@@ -91,19 +92,19 @@ $S cp %{SOURCE1} .config $S patch -p1 < %{SOURCE2} $S $S %build -$S %{make} %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release} +$S %{make} %{makeflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release} $S %install mkdir -p %{buildroot}/boot %ifarch ia64 mkdir -p %{buildroot}/boot/efi - cp \$(%{make} -s image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE + cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/ %else - cp \$(%{make} -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE + cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE %endif -$M %{make} %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install - %{make} %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install +$M %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install + %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE cp .config %{buildroot}/boot/config-$KERNELRELEASE $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
Signature · 1 line
2.39.2
PATCH 5/19 kbuild: rpm-pkg: record ARCH option in spec file
In reply to Masahiro YamadaCurrently, we rely on the top Makefile defining ARCH option when we run 'make rpm-pkg' or 'make binrpm-pkg'.
It does not apply when we run 'make srcrpm-pkg', and separately run 'rpmbuild' for the generated SRPM. This is a problem for cross-build.
Just like the Debian package, save the value of ARCH in the spec file.
---
scripts/package/mkspec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/package/mkspec +3 -1
@@ -38,8 +38,10 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \ # $S: this line is enabled only when building source package # $M: this line is enabled only when CONFIG_MODULES is enabled sed -e '/^DEL/d' -e 's/^\t*//' <<EOF +%define ARCH ${ARCH} + %{!?make: %define make make} -%define makeflags %{?_smp_mflags} +%define makeflags %{?_smp_mflags} ARCH=%{ARCH} Name: kernel Summary: The Linux Kernel
Signature · 1 line
2.39.2
PATCH 6/19 kbuild: rpm-pkg: replace $__KERNELRELEASE in spec file with %{version}
In reply to Masahiro Yamada${version} will be replaced with the value of the Version field.
---
scripts/package/mkspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/package/mkspec +2 -2
@@ -81,12 +81,12 @@ $S BuildRequires: gcc make openssl openssl-devel perl python3 rsync glibc package. $S$M %package devel -$S$M Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel +$S$M Summary: Development package for building kernel modules to match the %{version} kernel $S$M Group: System Environment/Kernel $S$M AutoReqProv: no $S$M %description -n kernel-devel $S$M This package provides kernel headers and makefiles sufficient to build modules -$S$M against the $__KERNELRELEASE kernel package. +$S$M against the %{version} kernel package. $S$M $S %prep $S %setup -q -n linux
Signature · 1 line
2.39.2
PATCH 7/19 kbuild: rpm-pkg: replace $KERNELRELEASE in spec file with %{KERNELRELEASE}
In reply to Masahiro YamadaAvoid hard-coding the value of KERNELRELEASE in the generated spec file.
---
scripts/package/mkspec | 59 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 29 deletions(-)
scripts/package/mkspec +30 -29
@@ -39,6 +39,7 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \ # $M: this line is enabled only when CONFIG_MODULES is enabled sed -e '/^DEL/d' -e 's/^\t*//' <<EOF %define ARCH ${ARCH} +%define KERNELRELEASE ${KERNELRELEASE} %{!?make: %define make make} %define makeflags %{?_smp_mflags} ARCH=%{ARCH}
@@ -54,7 +55,7 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF $S Source0: linux.tar.gz $S Source1: config $S Source2: diff.patch - Provides: kernel-$KERNELRELEASE + Provides: kernel-%{KERNELRELEASE} $S BuildRequires: bc binutils bison dwarves $S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex $S BuildRequires: gcc make openssl openssl-devel perl python3 rsync
@@ -94,58 +95,58 @@ $S cp %{SOURCE1} .config $S patch -p1 < %{SOURCE2} $S $S %build -$S %{make} %{makeflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release} +$S %{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release} $S %install mkdir -p %{buildroot}/boot %ifarch ia64 mkdir -p %{buildroot}/boot/efi - cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE - ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/ + cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-%{KERNELRELEASE} + ln -s efi/vmlinuz-%{KERNELRELEASE} %{buildroot}/boot/ %else - cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE + cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE} %endif $M %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install - cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE - cp .config %{buildroot}/boot/config-$KERNELRELEASE -$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build -$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source -$S$M mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE -$S$M tar cf - $EXCLUDES . | tar xf - -C %{buildroot}/usr/src/kernels/$KERNELRELEASE -$S$M cd %{buildroot}/lib/modules/$KERNELRELEASE -$S$M ln -sf /usr/src/kernels/$KERNELRELEASE build -$S$M ln -sf /usr/src/kernels/$KERNELRELEASE source + cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} + cp .config %{buildroot}/boot/config-%{KERNELRELEASE} +$S$M rm -f %{buildroot}/lib/modules/%{KERNELRELEASE}/build +$S$M rm -f %{buildroot}/lib/modules/%{KERNELRELEASE}/source +$S$M mkdir -p %{buildroot}/usr/src/kernels/%{KERNELRELEASE} +$S$M tar cf - $EXCLUDES . | tar xf - -C %{buildroot}/usr/src/kernels/%{KERNELRELEASE} +$S$M cd %{buildroot}/lib/modules/%{KERNELRELEASE} +$S$M ln -sf /usr/src/kernels/%{KERNELRELEASE} build +$S$M ln -sf /usr/src/kernels/%{KERNELRELEASE} source %clean rm -rf %{buildroot} %post - if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then - cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm - cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm - rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE - /sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm - rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm + if [ -x /sbin/installkernel -a -r /boot/vmlinuz-%{KERNELRELEASE} -a -r /boot/System.map-%{KERNELRELEASE} ]; then + cp /boot/vmlinuz-%{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm + cp /boot/System.map-%{KERNELRELEASE} /boot/.System.map-%{KERNELRELEASE}-rpm + rm -f /boot/vmlinuz-%{KERNELRELEASE} /boot/System.map-%{KERNELRELEASE} + /sbin/installkernel %{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm + rm -f /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm fi %preun if [ -x /sbin/new-kernel-pkg ]; then - new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img + new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img elif [ -x /usr/bin/kernel-install ]; then - kernel-install remove $KERNELRELEASE + kernel-install remove %{KERNELRELEASE} fi %postun if [ -x /sbin/update-bootloader ]; then - /sbin/update-bootloader --remove $KERNELRELEASE + /sbin/update-bootloader --remove %{KERNELRELEASE} fi %files %defattr (-, root, root) -$M /lib/modules/$KERNELRELEASE -$M %exclude /lib/modules/$KERNELRELEASE/build -$M %exclude /lib/modules/$KERNELRELEASE/source +$M /lib/modules/%{KERNELRELEASE} +$M %exclude /lib/modules/%{KERNELRELEASE}/build +$M %exclude /lib/modules/%{KERNELRELEASE}/source /boot/* %files headers
@@ -154,7 +155,7 @@ $M %exclude /lib/modules/$KERNELRELEASE/source $S$M $S$M %files devel $S$M %defattr (-, root, root) -$S$M /usr/src/kernels/$KERNELRELEASE -$S$M /lib/modules/$KERNELRELEASE/build -$S$M /lib/modules/$KERNELRELEASE/source +$S$M /usr/src/kernels/%{KERNELRELEASE} +$S$M /lib/modules/%{KERNELRELEASE}/build +$S$M /lib/modules/%{KERNELRELEASE}/source EOF
Signature · 1 line
2.39.2
PATCH 8/19 kbuild: add a phony target to run a command with Kbuild env vars
In reply to Masahiro YamadaThere are some cases where we want to run a command with the same environment variables as Kbuild uses. For example, 'make coccicheck' invokes scripts/coccicheck from the top Makefile so that the script can reference to ${LINUXINCLUDE}, ${KBUILD_EXTMOD}, etc. The top Makefile defines several phony targets that run a script.
We do it also for an internally used script, which results in a somewhat complex call graph.
One example:
debian/rules binary-arch
-> make intdeb-pkg
-> scripts/package/builddeb
It is also tedious to add a dedicated target like 'intdeb-pkg' for each use case.
Add a generic target 'run-command' to run an arbitrary command in an environment with all Kbuild variables set.
The usage is:
$ make run-command KBUILD_RUN_COMMAND=<command>
The concept is similar to:
$ dpkg-architecture -c <command>
This executes <command> in an environment which has all DEB_* variables defined.
Convert the existing 'make intdeb-pkg'.
Another possible usage is to interrogate a Make variable.
$ make run-command KBUILD_RUN_COMMAND='echo $(KBUILD_CFLAGS)'
might be useful to see KBUILD_CFLAGS set by the top Makefile.
---
Makefile | 4 ++++ scripts/Makefile.package | 4 ---- scripts/package/mkdebian | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-)
Makefile +4 -0
@@ -2133,6 +2133,10 @@ kernelversion: image_name: @echo $(KBUILD_IMAGE) +PHONY += run-command +run-command: + $(Q)$(KBUILD_RUN_COMMAND) + quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) cmd_rmfiles = rm -rf $(rm-files)
scripts/Makefile.package +0 -4
@@ -146,10 +146,6 @@ deb-pkg srcdeb-pkg bindeb-pkg: --no-check-builddeps) \ $(DPKG_FLAGS)) -PHONY += intdeb-pkg -intdeb-pkg: - +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb - # snap-pkg # --------------------------------------------------------------------------- PHONY += snap-pkg
scripts/package/mkdebian +2 -1
@@ -283,7 +283,8 @@ build: build-arch binary-indep: binary-arch: build-arch \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \ - KERNELRELEASE=\$(KERNELRELEASE) intdeb-pkg + KERNELRELEASE=\$(KERNELRELEASE) \ + run-command KBUILD_RUN_COMMAND=+\$(srctree)/scripts/package/builddeb clean: rm -rf debian/files debian/linux-*
Signature · 1 line
2.39.2
Re: [PATCH 08/19] kbuild: add a phony target to run a command with Kbuild env vars
Quoted 29 lines · On Sat, Jul 22, 2023 at 01:47:55PM +0900 Masahiro Yamada wrote:
There are some cases where we want to run a command with the same environment variables as
Kbuilduses. For example, 'make coccicheck' invokesscripts/coccicheckfrom the topMakefileso that the script can reference to ${LINUXINCLUDE}, ${KBUILD_EXTMOD}, etc. The topMakefiledefines several phony targets that run a script.We do it also for an internally used script, which results in a somewhat complex call graph.
One example:
debian/rules binary-arch
-> make intdeb-pkg-> scripts/package/builddebIt is also tedious to add a dedicated target like 'intdeb-pkg' for each use case.
Add a generic target 'run-command' to run an arbitrary command in an environment with all
Kbuildvariables set.The usage is:
$ make run-command KBUILD_RUN_COMMAND=<command>The concept is similar to:
$ dpkg-architecture -c <command>
Quoted 8 lines
This executes <command> in an environment which has all DEB_* variables defined.
Convert the existing 'make intdeb-pkg'.
Another possible usage is to interrogate a Make variable.
$ make run-command KBUILD_RUN_COMMAND='echo $(KBUILD_CFLAGS)'
nice idea, I like that.
Quoted 57 lines
might be useful to see
KBUILD_CFLAGSset by the topMakefile.Signed-off-by Masahiro Yamada <[email protected]>---
Makefile | 4 ++++ scripts/Makefile.package | 4 ---- scripts/package/mkdebian | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-)Makefile +4
-0@@ -2133,6 +2133,10 @@ kernelversion: image_name: @echo $(KBUILD_IMAGE) +PHONY += run-command +run-command: + $(Q)$(KBUILD_RUN_COMMAND) + quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) cmd_rmfiles = rm -rf $(rm-files)scripts/Makefile.package +0
-4@@ -146,10 +146,6 @@ deb-pkg srcdeb-pkg bindeb-pkg: --no-check-builddeps) \ $(DPKG_FLAGS)) -PHONY += intdeb-pkg -intdeb-pkg: - +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb - # snap-pkg # --------------------------------------------------------------------------- PHONY += snap-pkgscripts/package/mkdebian +2
-1@@ -283,7 +283,8 @@ build: build-arch binary-indep: binary-arch: build-arch \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \ - KERNELRELEASE=\$(KERNELRELEASE) intdeb-pkg + KERNELRELEASE=\$(KERNELRELEASE) \ + run-command KBUILD_RUN_COMMAND=+\$(srctree)/scripts/package/builddeb clean: rm -rf debian/files debian/linux-*Signature · 1 line
2.39.2
Signature · 3 lines
epost|xmpp: [email protected] irc://oftc.net/nsc ↳ gpg: 18ed 52db e34f 860e e9fb c82b 7d97 0932 55a0 ce7f -- frykten for herren er opphav til kunnskap --
PATCH 9/19 kbuild: refactor kernel-devel RPM package and linux-headers Deb package
In reply to Masahiro YamadaThe kernel-devel RPM package and the linux-headers Debian package provide headers and scripts needed for building external modules.
They copy the necessary files in slightly different ways - the RPM copies almost everything except some exclude patterns, while the Debian copies less number of files. There is no need to maintain different code to do the same thing.
Split the Debian code out to scripts/package/install-extmod-build, which is called from both of the packages.
---
scripts/package/builddeb | 29 +-------------------- scripts/package/install-extmod-build | 39 ++++++++++++++++++++++++++++ scripts/package/mkspec | 6 +---- 3 files changed, 41 insertions(+), 33 deletions(-) create mode 100755 scripts/package/install-extmod-build
scripts/package/builddeb +1 -28
@@ -162,34 +162,7 @@ install_kernel_headers () { rm -rf $pdir - ( - cd $srctree - find . arch/$SRCARCH -maxdepth 1 -name Makefile\* - find include scripts -type f -o -type l - find arch/$SRCARCH -name Kbuild.platforms -o -name Platform - find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f - ) > debian/hdrsrcfiles - - { - if is_enabled CONFIG_OBJTOOL; then - echo tools/objtool/objtool - fi - - find arch/$SRCARCH/include Module.symvers include scripts -type f - - if is_enabled CONFIG_GCC_PLUGINS; then - find scripts/gcc-plugins -name \*.so - fi - } > debian/hdrobjfiles - - destdir=$pdir/usr/src/linux-headers-$version - mkdir -p $destdir - tar -c -f - -C $srctree -T debian/hdrsrcfiles | tar -xf - -C $destdir - tar -c -f - -T debian/hdrobjfiles | tar -xf - -C $destdir - rm -f debian/hdrsrcfiles debian/hdrobjfiles - - # copy .config manually to be where it's expected to be - cp $KCONFIG_CONFIG $destdir/.config + "${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}" mkdir -p $pdir/lib/modules/$version/ ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build
scripts/package/install-extmod-build new file +39 -0
@@ -0,0 +1,39 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only + +set -e + +destdir=${1} + +test -n "${srctree}" +test -n "${SRCARCH}" + +is_enabled() { + grep -q "^$1=y" include/config/auto.conf +} + +mkdir -p "${destdir}" + +( + cd "${srctree}" + echo Makefile + find "arch/${SRCARCH}" -maxdepth 1 -name 'Makefile*' + find include scripts -type f -o -type l + find "arch/${SRCARCH}" -name Kbuild.platforms -o -name Platform + find "$(find "arch/${SRCARCH}" -name include -o -name scripts -type d)" -type f +) | tar -c -f - -C "${srctree}" -T - | tar -xf - -C "${destdir}" + +{ + if is_enabled CONFIG_OBJTOOL; then + echo tools/objtool/objtool + fi + + find "arch/${SRCARCH}/include" Module.symvers include scripts -type f + + if is_enabled CONFIG_GCC_PLUGINS; then + find scripts/gcc-plugins -name '*.so' + fi +} | tar -c -f - -T - | tar -xf - -C "${destdir}" + +# copy .config manually to be where it's expected to be +cp "${KCONFIG_CONFIG}" "${destdir}/.config"
scripts/package/mkspec +1 -5
@@ -28,9 +28,6 @@ else fi __KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g") -EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \ ---exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \ ---exclude=.config.old --exclude=.missing-syscalls.d --exclude=*.s" # We can label the here-doc lines for conditional output to the spec file #
@@ -112,8 +109,7 @@ $M %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install cp .config %{buildroot}/boot/config-%{KERNELRELEASE} $S$M rm -f %{buildroot}/lib/modules/%{KERNELRELEASE}/build $S$M rm -f %{buildroot}/lib/modules/%{KERNELRELEASE}/source -$S$M mkdir -p %{buildroot}/usr/src/kernels/%{KERNELRELEASE} -$S$M tar cf - $EXCLUDES . | tar xf - -C %{buildroot}/usr/src/kernels/%{KERNELRELEASE} +$S$M %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='\${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' $S$M cd %{buildroot}/lib/modules/%{KERNELRELEASE} $S$M ln -sf /usr/src/kernels/%{KERNELRELEASE} build $S$M ln -sf /usr/src/kernels/%{KERNELRELEASE} source
Signature · 1 line
2.39.2
PATCH 10/19 kbuild: rpm-pkg: derive the Version from %{KERNELRELEASE}
In reply to Masahiro YamadaAvoid hard-coding the Version field in the generated spec file.
---
scripts/package/mkspec | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
scripts/package/mkspec +1 -3
@@ -27,8 +27,6 @@ else M=DEL fi -__KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g") - # We can label the here-doc lines for conditional output to the spec file # # Labels:
@@ -43,7 +41,7 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF Name: kernel Summary: The Linux Kernel - Version: $__KERNELRELEASE + Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g') Release: $(cat .version 2>/dev/null || echo 1) License: GPL Group: System Environment/Kernel
Signature · 1 line
2.39.2
PATCH 11/19 kbuild: rpm-pkg: use a dummy string for _arch when undefined
In reply to Masahiro YamadaIf this affects only %{buildroot}, it should be enough to use a fixed string for _arch when it is undefined.
---
scripts/package/mkspec | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
scripts/package/mkspec +2 -3
@@ -36,6 +36,8 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF %define ARCH ${ARCH} %define KERNELRELEASE ${KERNELRELEASE} +# _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}
@@ -55,9 +57,6 @@ $S BuildRequires: bc binutils bison dwarves $S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex $S BuildRequires: gcc make openssl openssl-devel perl python3 rsync - # $UTS_MACHINE as a fallback of _arch in case - # /usr/lib/rpm/platform/*/macros was not included. - %{!?_arch: %define _arch $UTS_MACHINE} %define __spec_install_post /usr/lib/rpm/brp-compress || : %define debug_package %{nil}
Signature · 1 line
2.39.2
Re: [PATCH 11/19] kbuild: rpm-pkg: use a dummy string for _arch when undefined
Hi,
I build the latest kernel (6.6-rc1) for arm64 platform on x86 server (with cross complile), and the complile command is as following:
export PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin/ export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make -j64 Image (ok)
make binrpm-pkg -j64 (failed)
But when complile binrpm-pkg, it is failed and the error info is as following:
rpmbuild -bb kernel.spec --define='_topdir /home/chenxiang/kernel/mainline/linux-next/rpmbuild' --target aarch64-linux --build-in-place --noprep --define='_smp_mflags %{nil}' $(rpm -q rpm >/dev/null 2>&1 || echo --nodeps) --without devel
rpmbuild: --build-in-place: unknown option
make[2]: *** [scripts/Makefile.package:92: binrpm-pkg] Error 1
make[1]: *** [/home/chenxiang/kernel/mainline/linux-next/Makefile:1538: binrpm-pkg] Error 2
make: *** [Makefile:234: __sub-make] Error 2
But it is ok with v6.5-rc7, so i bisect the kernel code and find the patch (kbuild: rpm-pkg: use a dummy string for _arch when undefined):
706a741595047797872e (v6.6-rc1) good
0bb80ecc33a8fb5a6(v6.5-rc7) bad
[461f35f014466c4e26dca6be0f431f57297df3f2] Merge tag 'drm-next-2023-08-30' of git://anongit.freedesktop.org/drm/drm good [e925992671907314b7db6793a28eb39b36bc21a4] Merge tag 'staging-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging good
[3c31041e37324e143bee98604bb31481e905b4b3] Merge tag 'printk-for-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux good
[4a0fc73da97efd23a383ca839e6fe86410268f6b] Merge tag 's390-6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux bad [61401a8724c2ce912b243ef95427a9b2e5a1ed50] Merge tag 'kbuild-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild bad
[2be6bc48df59c99d35aab16a51d4a814e9bb8c35] Merge tag 'leds-next-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds good
[3f86ed6ec0b390c033eae7f9c487a3fea268e027] Merge tag 'arc-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc good [4cdb71b6ba3283fb2b7eaccc333f8f2c5b81797b] sparc: replace #include <asm/export.h> with #include <linux/export.h> bad
[975667d02d134f7b48d15ee7ff0d49e69a6774cf] kbuild: rpm-pkg: rename binkernel.spec to kernel.spec bad
[a06d9ef897d59f719102e2890abd8a2b91e29a60] kbuild: rpm-pkg: record ARCH option in spec file good
[d5d2d4cc60888f02dd4a6b2bfb03ff2fd7be4fc2] kbuild: rpm-pkg: derive the Version from %{KERNELRELEASE} good
[b537925fdd689ca33b6d9eed4569bc625550b3ef] kbuild: rpm-pkg: run modules_install for non-modular kernel bad
[1789fc9125414bd9ca4d50a8966752ee6103d547] kbuild: rpm-pkg: invoke the kernel build from rpmbuild for binrpm-pkg bad [d4f651277e9208b580b55da212e17ddd309c91e7] kbuild: rpm-pkg: use a dummy string for _arch when undefined
Do you have any idea about this issue?
Thanks
Xiang Chen
Quoted 32 lines · Masahiro Yamada
If this affects only %{buildroot}, it should be enough to use a fixed string for
_archwhen it is undefined.Signed-off-by Masahiro Yamada <[email protected]>---
scripts/package/mkspec | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)scripts/package/mkspec +2
-3@@ -36,6 +36,8 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF %define ARCH ${ARCH} %define KERNELRELEASE ${KERNELRELEASE} +# _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}@@ -55,9 +57,6 @@ $S BuildRequires: bc binutils bison dwarves $S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex $S BuildRequires: gcc make openssl openssl-devel perl python3 rsync - # $UTS_MACHINE as a fallback of _arch in case - # /usr/lib/rpm/platform/*/macros was not included. - %{!?_arch: %define _arch $UTS_MACHINE} %define __spec_install_post /usr/lib/rpm/brp-compress || : %define debug_package %{nil}
Re: [PATCH 11/19] kbuild: rpm-pkg: use a dummy string for _arch when undefined
Quoted 15 lines · chenxiang (M)
Hi,
I build the latest kernel (6.6-rc1) for arm64 platform on x86 server (with cross complile), and the complile command is as following:
export PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin/ export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-make -j64 Image (ok)
make binrpm-pkg -j64 (failed)
Quoted 8 lines
But when complile binrpm-pkg, it is failed and the error info is as following:
rpmbuild -bb kernel.spec --define='_topdir
/home/chenxiang/kernel/mainline/linux-next/rpmbuild' --target aarch64-linux --build-in-place --noprep --define='_smp_mflags %{nil}' $(rpm -q rpm >/dev/null 2>&1 || echo --nodeps) --without devel
rpmbuild: --build-in-place: unknown option
I cannot reproduce it on my build environment,
but the error message:
rpmbuild: --build-in-place: unknown option
describes the issue.
Which version of rpmbuild did you use?
Using a newer version fixes the issue?
--
Best Regards
Masahiro Yamada
PATCH 12/19 kbuild: rpm-pkg: invoke the kernel build from rpmbuild for binrpm-pkg
In reply to Masahiro YamadaTo reduce the preprocess of the spec file, invoke the kernel build from rpmbuild.
Run init/build-version to increment the release number not only for binrpm-pkg but also for srcrpm-pkg and rpm-pkg.
---
scripts/Makefile.package | 2 +- scripts/package/mkspec | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-)
scripts/Makefile.package +1 -1
@@ -86,10 +86,10 @@ srcrpm-pkg: linux.tar.gz # --------------------------------------------------------------------------- PHONY += binrpm-pkg binrpm-pkg: - $(MAKE) -f $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec \ + --build-in-place --noprep --define='_smp_mflags %{nil}' \ --define='make $(MAKE)' # deb-pkg srcdeb-pkg bindeb-pkg
scripts/package/mkspec +16 -15
@@ -35,6 +35,7 @@ fi sed -e '/^DEL/d' -e 's/^\t*//' <<EOF %define ARCH ${ARCH} %define KERNELRELEASE ${KERNELRELEASE} +%define pkg_release $("${srctree}/init/build-version") # _arch is undefined if /usr/lib/rpm/platform/*/macros was not included. %{!?_arch: %define _arch dummy}
@@ -44,18 +45,18 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF Name: kernel Summary: The Linux Kernel Version: %(echo %{KERNELRELEASE} | sed -e 's/-/_/g') - Release: $(cat .version 2>/dev/null || echo 1) + Release: %{pkg_release} License: GPL Group: System Environment/Kernel Vendor: The Linux Community URL: https://www.kernel.org -$S Source0: linux.tar.gz -$S Source1: config -$S Source2: diff.patch + Source0: linux.tar.gz + Source1: config + Source2: diff.patch Provides: kernel-%{KERNELRELEASE} -$S BuildRequires: bc binutils bison dwarves -$S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex -$S BuildRequires: gcc make openssl openssl-devel perl python3 rsync + BuildRequires: bc binutils bison dwarves + BuildRequires: (elfutils-libelf-devel or libelf-devel) flex + BuildRequires: gcc make openssl openssl-devel perl python3 rsync %define __spec_install_post /usr/lib/rpm/brp-compress || : %define debug_package %{nil}
@@ -83,14 +84,14 @@ $S$M %description -n kernel-devel $S$M This package provides kernel headers and makefiles sufficient to build modules $S$M against the %{version} kernel package. $S$M -$S %prep -$S %setup -q -n linux -$S cp %{SOURCE1} .config -$S patch -p1 < %{SOURCE2} -$S -$S %build -$S %{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release} -$S + %prep + %setup -q -n linux + cp %{SOURCE1} .config + patch -p1 < %{SOURCE2} + + %build + %{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release} + %install mkdir -p %{buildroot}/boot %ifarch ia64
Signature · 1 line
2.39.2
PATCH 13/19 kbuild: rpm-pkg: run modules_install for non-modular kernel
In reply to Masahiro YamadaFor the same reason as commit 4243afdb9326 ("kbuild: builddeb: always make modules_install, to install modules.builtin*"), run modules_install even when CONFIG_MODULES=n to install modules.builtin*.
---
scripts/package/mkspec | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
scripts/package/mkspec +6 -9
@@ -101,16 +101,13 @@ $S$M %else cp \$(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE} %endif -$M %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install + %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} cp .config %{buildroot}/boot/config-%{KERNELRELEASE} -$S$M rm -f %{buildroot}/lib/modules/%{KERNELRELEASE}/build -$S$M rm -f %{buildroot}/lib/modules/%{KERNELRELEASE}/source + ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build + ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/source $S$M %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='\${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' -$S$M cd %{buildroot}/lib/modules/%{KERNELRELEASE} -$S$M ln -sf /usr/src/kernels/%{KERNELRELEASE} build -$S$M ln -sf /usr/src/kernels/%{KERNELRELEASE} source %clean rm -rf %{buildroot}
@@ -138,9 +135,9 @@ $S$M ln -sf /usr/src/kernels/%{KERNELRELEASE} source %files %defattr (-, root, root) -$M /lib/modules/%{KERNELRELEASE} -$M %exclude /lib/modules/%{KERNELRELEASE}/build -$M %exclude /lib/modules/%{KERNELRELEASE}/source + /lib/modules/%{KERNELRELEASE} + %exclude /lib/modules/%{KERNELRELEASE}/build + %exclude /lib/modules/%{KERNELRELEASE}/source /boot/* %files headers
Signature · 1 line
2.39.2
PATCH 14/19 kbuild: rpm-pkg: introduce %{with_devel} switch to select devel package
In reply to Masahiro Yamadascripts/package/mkspec preprocesses the spec file by sed, but it is unreadable. This commit removes the last portion of the sed scripting.
Remove the $S$M prefixes from the conditionally generated lines. Instead, surround the code with %if %{with_devel} ... %endif.
---
scripts/Makefile.package | 2 +- scripts/package/mkspec | 53 +++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 29 deletions(-)
scripts/Makefile.package +1 -1
@@ -89,7 +89,7 @@ binrpm-pkg: $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec \ - --build-in-place --noprep --define='_smp_mflags %{nil}' \ + --build-in-place --noprep --define='_smp_mflags %{nil}' --without devel \ --define='make $(MAKE)' # deb-pkg srcdeb-pkg bindeb-pkg
scripts/package/mkspec +25 -28
84 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH 15/19 kbuild: rpm-pkg: split out the body of spec file
In reply to Masahiro YamadaMost of the lines in the spec file are independent of any build condition.
Split the body of the spec file into scripts/package/kernel.spec. scripts/package/mkspec will prepend some env-dependent variables.
---
scripts/package/kernel.spec | 117 ++++++++++++++++++++++++++++++++++ scripts/package/mkspec | 123 +----------------------------------- 2 files changed, 120 insertions(+), 120 deletions(-) create mode 100644 scripts/package/kernel.spec
scripts/package/kernel.spec new file +117 -0
@@ -0,0 +1,117 @@ +# _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} +%define __spec_install_post /usr/lib/rpm/brp-compress || : +%define debug_package %{nil} + +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 +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 +Obsoletes: kernel-headers +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 + +%prep +%setup -q -n linux +cp %{SOURCE1} .config +patch -p1 < %{SOURCE2} + +%build +%{make} %{makeflags} KERNELRELEASE=%{KERNELRELEASE} KBUILD_BUILD_VERSION=%{release} + +%install +mkdir -p %{buildroot}/boot +%ifarch ia64 +mkdir -p %{buildroot}/boot/efi +cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/efi/vmlinuz-%{KERNELRELEASE} +ln -s efi/vmlinuz-%{KERNELRELEASE} %{buildroot}/boot/ +%else +cp $(%{make} %{makeflags} -s image_name) %{buildroot}/boot/vmlinuz-%{KERNELRELEASE} +%endif +%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} modules_install +%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install +cp System.map %{buildroot}/boot/System.map-%{KERNELRELEASE} +cp .config %{buildroot}/boot/config-%{KERNELRELEASE} +ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build +ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/source +%if %{with_devel} +%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}' +%endif + +%clean +rm -rf %{buildroot} + +%post +if [ -x /sbin/installkernel -a -r /boot/vmlinuz-%{KERNELRELEASE} -a -r /boot/System.map-%{KERNELRELEASE} ]; then +cp /boot/vmlinuz-%{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm +cp /boot/System.map-%{KERNELRELEASE} /boot/.System.map-%{KERNELRELEASE}-rpm +rm -f /boot/vmlinuz-%{KERNELRELEASE} /boot/System.map-%{KERNELRELEASE} +/sbin/installkernel %{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm +rm -f /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm +fi + +%preun +if [ -x /sbin/new-kernel-pkg ]; then +new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img +elif [ -x /usr/bin/kernel-install ]; then +kernel-install remove %{KERNELRELEASE} +fi + +%postun +if [ -x /sbin/update-bootloader ]; then +/sbin/update-bootloader --remove %{KERNELRELEASE} +fi + +%files +%defattr (-, root, root) +/lib/modules/%{KERNELRELEASE} +%exclude /lib/modules/%{KERNELRELEASE}/build +%exclude /lib/modules/%{KERNELRELEASE}/source +/boot/* + +%files headers +%defattr (-, root, root) +/usr/include + +%if %{with_devel} +%files devel +%defattr (-, root, root) +/usr/src/kernels/%{KERNELRELEASE} +/lib/modules/%{KERNELRELEASE}/build +/lib/modules/%{KERNELRELEASE}/source +%endif
scripts/package/mkspec +3 -120
130 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH 16/19 kbuild: rpm-pkg: rename binkernel.spec to kernel.spec
In reply to Masahiro YamadaNow kernel.spec and binkernel.spec have the exactly same contents.
Use kernel.spec for binrpm-pkg as well.
---
.gitignore | 2 +- Makefile | 2 +- scripts/Makefile.package | 4 ++-- scripts/remove-stale-files | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-)
.gitignore +1 -1
@@ -74,7 +74,7 @@ modules.order # # RPM spec file (make rpm-pkg) # -/*.spec +/kernel.spec /rpmbuild/ #
Makefile +1 -1
@@ -1595,7 +1595,7 @@ MRPROPER_FILES += include/config include/generated \ certs/signing_key.pem \ certs/x509.genkey \ vmlinux-gdb.py \ - *.spec rpmbuild \ + kernel.spec rpmbuild \ rust/libmacros.so # clean - Delete most, but leave enough to build external modules
scripts/Makefile.package +2 -2
@@ -86,9 +86,9 @@ srcrpm-pkg: linux.tar.gz # --------------------------------------------------------------------------- PHONY += binrpm-pkg binrpm-pkg: - $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec + $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/kernel.spec +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ - $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec \ + $(UTS_MACHINE)-linux -bb $(objtree)/kernel.spec \ --build-in-place --noprep --define='_smp_mflags %{nil}' --without devel \ --define='make $(MAKE)'
scripts/remove-stale-files +2 -0
@@ -37,3 +37,5 @@ rm -f .scmversion rm -rf include/ksym find . -name '*.usyms' | xargs rm -f + +rm -f binkernel.spec
Signature · 1 line
2.39.2
PATCH 17/19 kbuild: rpm-pkg: build the kernel in-place for rpm-pkg
In reply to Masahiro YamadaCurrently, 'make rpm-pkg' always builds the kernel from the pristine source tree in the ~/rpmbuild/BUILD/ directory.
Build the kernel incrementally just like 'make binrpm-pkg'.
---
scripts/Makefile.package | 1 + 1 file changed, 1 insertion(+)
scripts/Makefile.package +1 -0
@@ -72,6 +72,7 @@ PHONY += rpm-pkg rpm-pkg: srpm = $(shell rpmspec --srpm --query --queryformat='%{name}-%{VERSION}-%{RELEASE}.src.rpm' kernel.spec) rpm-pkg: srcrpm-pkg +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -rb $(srpm) \ + --build-in-place --noprep \ --define='_smp_mflags %{nil}' --define='make $(MAKE)' # srcrpm-pkg
Signature · 1 line
2.39.2
PATCH 18/19 kbuild: rpm-pkg: refactor *rpm-pkg targets
In reply to Masahiro YamadaMerge the similar build targets.
Also, make the output location consistent.
Previously, source packages were created in the build directory, while binary packages under ~/rpmbuild/RPMS/.
Now, Kbuild creates the rpmbuild/ directory in the build directory, and saves all packages under it.
---
scripts/Makefile.package | 52 +++++++++++++++++++++------------------- scripts/package/mkspec | 8 ------- 2 files changed, 28 insertions(+), 32 deletions(-)
scripts/Makefile.package +28 -24
@@ -11,7 +11,6 @@ TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \ samples scripts security sound tools usr virt \ .config Makefile \ Kbuild Kconfig COPYING $(wildcard localversion*) -MKSPEC := $(srctree)/scripts/package/mkspec quiet_cmd_src_tar = TAR $(2).tar.gz cmd_src_tar = \
@@ -66,32 +65,37 @@ $(linux-tarballs): archive-args = --prefix=linux/ $$(cat $<) $(linux-tarballs): .tmp_HEAD FORCE $(call if_changed,archive) -# rpm-pkg +# rpm-pkg srcrpm-pkg binrpm-pkg # --------------------------------------------------------------------------- -PHONY += rpm-pkg -rpm-pkg: srpm = $(shell rpmspec --srpm --query --queryformat='%{name}-%{VERSION}-%{RELEASE}.src.rpm' kernel.spec) -rpm-pkg: srcrpm-pkg - +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -rb $(srpm) \ - --build-in-place --noprep \ - --define='_smp_mflags %{nil}' --define='make $(MAKE)' -# srcrpm-pkg -# --------------------------------------------------------------------------- -PHONY += srcrpm-pkg -srcrpm-pkg: linux.tar.gz - $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec - +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -bs kernel.spec \ - --define='_smp_mflags %{nil}' --define='_sourcedir rpmbuild/SOURCES' --define='_srcrpmdir .' +quiet_cmd_mkspec = GEN $@ + cmd_mkspec = $(srctree)/scripts/package/mkspec > $@ -# binrpm-pkg -# --------------------------------------------------------------------------- -PHONY += binrpm-pkg -binrpm-pkg: - $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/kernel.spec - +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ - $(UTS_MACHINE)-linux -bb $(objtree)/kernel.spec \ - --build-in-place --noprep --define='_smp_mflags %{nil}' --without devel \ - --define='make $(MAKE)' +kernel.spec: FORCE + $(call cmd,mkspec) + +PHONY += rpm-sources +rpm-sources: linux.tar.gz + $(Q)mkdir -p rpmbuild/SOURCES + $(Q)ln -f linux.tar.gz rpmbuild/SOURCES/linux.tar.gz + $(Q)cp $(KCONFIG_CONFIG) rpmbuild/SOURCES/config + $(Q)$(srctree)/scripts/package/gen-diff-patch rpmbuild/SOURCES/diff.patch + +PHONY += rpm-pkg srcrpm-pkg binrpm-pkg + +rpm-pkg: private build-type := a +srcrpm-pkg: private build-type := s +binrpm-pkg: private build-type := b + +rpm-pkg srcrpm-pkg: rpm-sources +rpm-pkg srcrpm-pkg binrpm-pkg: kernel.spec + +$(strip rpmbuild -b$(build-type) kernel.spec \ + --define='_topdir $(abspath rpmbuild)' \ + $(if $(filter a b, $(build-type)), \ + --target $(UTS_MACHINE)-linux --build-in-place --noprep --define='_smp_mflags %{nil}') \ + $(if $(filter b, $(build-type)), \ + --without devel) \ + $(RPMOPTS)) # deb-pkg srcdeb-pkg bindeb-pkg # ---------------------------------------------------------------------------
scripts/package/mkspec +0 -8
@@ -9,14 +9,6 @@ # Patched for non-x86 by Opencon (L) 2002 <[email protected]> # -# how we were called determines which rpms we build and how we build them -if [ -z "$1" ]; then - mkdir -p rpmbuild/SOURCES - cp linux.tar.gz rpmbuild/SOURCES - cp "${KCONFIG_CONFIG}" rpmbuild/SOURCES/config - "${srctree}/scripts/package/gen-diff-patch" rpmbuild/SOURCES/diff.patch -fi - if grep -q CONFIG_MODULES=y include/config/auto.conf; then echo '%define with_devel %{?_without_devel: 0} %{?!_without_devel: 1}' else
Signature · 1 line
2.39.2
PATCH 19/19 kbuild: rpm-pkg: skip build dependency check on non-rpm systems
In reply to Masahiro YamadaCommit 8818039f959b ("kbuild: add ability to make source rpm buildable using koji") added the BuildRequires: field.
Checking the build dependency is fine, but one annoyance is that 'make (bin)rpm-pkg' fails on non-rpm systems [1]. For example, Debian provides rpmbuild via 'apt install rpm', but of course cannot meet the requirement listed in the BuildRequires: field.
It is possible to pass RPMOPTS=--nodeps to work around it, but it is reasonable to do it automatically.
If 'rpm -q rpm' fails, it is not an RPM-managed system. (The command 'rpm' is not installed at all, or was installed by other means.)
In that case, pass --nodeps to skip the build dependency check.
[1]: https://lore.kernel.org/linux-kbuild/[email protected]/
---
scripts/Makefile.package | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/Makefile.package +2 -1
@@ -92,7 +92,8 @@ rpm-pkg srcrpm-pkg binrpm-pkg: kernel.spec +$(strip rpmbuild -b$(build-type) kernel.spec \ --define='_topdir $(abspath rpmbuild)' \ $(if $(filter a b, $(build-type)), \ - --target $(UTS_MACHINE)-linux --build-in-place --noprep --define='_smp_mflags %{nil}') \ + --target $(UTS_MACHINE)-linux --build-in-place --noprep --define='_smp_mflags %{nil}' \ + $$(rpm -q rpm >/dev/null 2>&1 || echo --nodeps)) \ $(if $(filter b, $(build-type)), \ --without devel) \ $(RPMOPTS))
Signature · 1 line
2.39.2