kbuild: add ability to make source rpm buildable using koji
authorIvan Vecera <ivecera@redhat.com>
Mon, 21 Nov 2022 14:48:45 +0000 (09:48 -0500)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 23 Nov 2022 15:23:44 +0000 (00:23 +0900)
Changes:
- added new target 'srcrpm-pkg' to generate source rpm
- added required build tools to spec file
- removed locally compiled host tools to force their re-compile

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
Acked-by: Íñigo Huguet <ihuguet@redhat.com>
Tested-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/Makefile.package
scripts/package/mkspec

index 8bbcced67c221e1e14e34a34005e5b2e993e678d..1290f1c631fb67f189ad1ba920349ecb2ac361e5 100644 (file)
@@ -62,6 +62,16 @@ rpm-pkg:
        +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ta $(KERNELPATH).tar.gz \
        --define='_smp_mflags %{nil}'
 
+# srcrpm-pkg
+# ---------------------------------------------------------------------------
+PHONY += srcrpm-pkg
+srcrpm-pkg:
+       $(MAKE) clean
+       $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
+       $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
+       +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ts $(KERNELPATH).tar.gz \
+       --define='_smp_mflags %{nil}' --define='_srcrpmdir $(srctree)'
+
 # binrpm-pkg
 # ---------------------------------------------------------------------------
 PHONY += binrpm-pkg
index 70392fd2fd29c19534cb1f0054ee2e0551a2f7ec..dda00a948a01df3da7a32288a6767727a41b1c57 100755 (executable)
@@ -33,6 +33,8 @@ 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"
 
+test -n "$LOCALVERSION" && MAKE="$MAKE LOCALVERSION=$LOCALVERSION"
+
 # We can label the here-doc lines for conditional output to the spec file
 #
 # Labels:
@@ -49,6 +51,9 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
        URL: https://www.kernel.org
 $S     Source: kernel-$__KERNELRELEASE.tar.gz
        Provides: $PROVIDES
+$S     BuildRequires: bc binutils bison dwarves elfutils-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.
        %define _arch %{?_arch:$UTS_MACHINE}
@@ -80,6 +85,8 @@ $S$M  against the $__KERNELRELEASE kernel package.
 $S$M
 $S     %prep
 $S     %setup -q
+$S     rm -f scripts/basic/fixdep scripts/kconfig/conf
+$S     rm -f tools/objtool/{fixdep,objtool}
 $S
 $S     %build
 $S     $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}