mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>
Subject: [PATCH 14/19] kbuild: rpm-pkg: introduce %{with_devel} switch to select devel package
Date: Sat, 22 Jul 2023 13:48:01 +0900	[thread overview]
Message-ID: <20230722044806.3867434-14-masahiroy@kernel.org> (raw)
In-Reply-To: <20230722044806.3867434-1-masahiroy@kernel.org>

scripts/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.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.package |  2 +-
 scripts/package/mkspec   | 53 +++++++++++++++++++---------------------
 2 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 8373644a0473..c36ae03d6002 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -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
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 2613e85cd844..511cae46a90d 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -10,11 +10,7 @@
 #
 
 # how we were called determines which rpms we build and how we build them
-if [ "$1" = prebuilt ]; then
-	S=DEL
-else
-	S=
-
+if [ -z "$1" ]; then
 	mkdir -p rpmbuild/SOURCES
 	cp linux.tar.gz rpmbuild/SOURCES
 	cp "${KCONFIG_CONFIG}" rpmbuild/SOURCES/config
@@ -22,17 +18,12 @@ else
 fi
 
 if grep -q CONFIG_MODULES=y include/config/auto.conf; then
-	M=
+echo '%define with_devel %{?_without_devel: 0} %{?!_without_devel: 1}'
 else
-	M=DEL
+echo '%define with_devel 0'
 fi
 
-# We can label the here-doc lines for conditional output to the spec file
-#
-# Labels:
-#  $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
+cat<<-EOF
 %define ARCH ${ARCH}
 %define KERNELRELEASE ${KERNELRELEASE}
 %define pkg_release $("${srctree}/init/build-version")
@@ -76,14 +67,16 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
 	building most standard programs and are also needed for rebuilding the
 	glibc package.
 
-$S$M	%package devel
-$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 %{version} kernel package.
-$S$M
+	%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
@@ -107,7 +100,9 @@ $S$M
 	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
-$S$M	%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='\${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
+	%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}
@@ -143,10 +138,12 @@ $S$M	%{make} %{makeflags} run-command KBUILD_RUN_COMMAND='\${srctree}/scripts/pa
 	%files headers
 	%defattr (-, root, root)
 	/usr/include
-$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
+
+	%if %{with_devel}
+	%files devel
+	%defattr (-, root, root)
+	/usr/src/kernels/%{KERNELRELEASE}
+	/lib/modules/%{KERNELRELEASE}/build
+	/lib/modules/%{KERNELRELEASE}/source
+	%endif
 EOF
-- 
2.39.2


  parent reply	other threads:[~2023-07-22  4:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-22  4:47 [PATCH 01/19] kbuild: rpm-pkg: define _arch conditionally Masahiro Yamada
2023-07-22  4:47 ` [PATCH 02/19] kbuild: rpm-pkg: remove unneeded '-f $srctree/Makefile' in spec file Masahiro Yamada
2023-07-22  4:47 ` [PATCH 03/19] kbuild: rpm-pkg: do not hard-code $MAKE " Masahiro Yamada
2023-07-22  4:47 ` [PATCH 04/19] kbuild: rpm-pkg: use %{makeflags} to pass common Make options Masahiro Yamada
2023-07-22  4:47 ` [PATCH 05/19] kbuild: rpm-pkg: record ARCH option in spec file Masahiro Yamada
2023-07-22  4:47 ` [PATCH 06/19] kbuild: rpm-pkg: replace $__KERNELRELEASE in spec file with %{version} Masahiro Yamada
2023-07-22  4:47 ` [PATCH 07/19] kbuild: rpm-pkg: replace $KERNELRELEASE in spec file with %{KERNELRELEASE} Masahiro Yamada
2023-07-22  4:47 ` [PATCH 08/19] kbuild: add a phony target to run a command with Kbuild env vars Masahiro Yamada
2023-07-24 19:53   ` Nicolas Schier
2023-07-22  4:47 ` [PATCH 09/19] kbuild: refactor kernel-devel RPM package and linux-headers Deb package Masahiro Yamada
2023-07-22  4:47 ` [PATCH 10/19] kbuild: rpm-pkg: derive the Version from %{KERNELRELEASE} Masahiro Yamada
2023-07-22  4:47 ` [PATCH 11/19] kbuild: rpm-pkg: use a dummy string for _arch when undefined Masahiro Yamada
2023-09-12  7:09   ` chenxiang (M)
2023-09-14  4:58     ` Masahiro Yamada
2023-07-22  4:47 ` [PATCH 12/19] kbuild: rpm-pkg: invoke the kernel build from rpmbuild for binrpm-pkg Masahiro Yamada
2023-07-22  4:48 ` [PATCH 13/19] kbuild: rpm-pkg: run modules_install for non-modular kernel Masahiro Yamada
2023-07-22  4:48 ` Masahiro Yamada [this message]
2023-07-22  4:48 ` [PATCH 15/19] kbuild: rpm-pkg: split out the body of spec file Masahiro Yamada
2023-07-22  4:48 ` [PATCH 16/19] kbuild: rpm-pkg: rename binkernel.spec to kernel.spec Masahiro Yamada
2023-07-22  4:48 ` [PATCH 17/19] kbuild: rpm-pkg: build the kernel in-place for rpm-pkg Masahiro Yamada
2023-07-22  4:48 ` [PATCH 18/19] kbuild: rpm-pkg: refactor *rpm-pkg targets Masahiro Yamada
2023-07-22  4:48 ` [PATCH 19/19] kbuild: rpm-pkg: skip build dependency check on non-rpm systems Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230722044806.3867434-14-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®