summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2023-07-22 13:48:01 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2023-07-25 00:59:33 +0900
commit2a291fc315b6aec2f209aa44da90515ddd4f89d0 (patch)
tree70c72e9defe482b28514c01fd1591e9922e3f3f2 /scripts
parentb537925fdd689ca33b6d9eed4569bc625550b3ef (diff)
kbuild: rpm-pkg: introduce %{with_devel} switch to select devel package
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>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.package2
-rwxr-xr-xscripts/package/mkspec53
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