From 6736ce27ce34d791ff2f030df6162527bd383a3c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 30 Sep 2017 10:10:03 +0900 Subject: kbuild: rpm-pkg: remove ppc64 specific image handling This conditional was added by commit 1a0f3d422bb9 ("kbuild: fix make rpm for powerpc"). Its git-log explains the default kernel image is zImage, but obviously the current arch/powerpc/Makefile does not set KBUILD_IMAGE, so the image file is actually vmlinux. Moreover, since commit 09549aa1baa9 ("deb-pkg: Remove the KBUILD_IMAGE workaround"), all architectures are supposed to set the full path to the image in KBUILD_IMAGE. I see no good reason to differentiate ppc64 from others. Rip off the conditional. Signed-off-by: Masahiro Yamada --- scripts/package/mkspec | 5 ----- 1 file changed, 5 deletions(-) (limited to 'scripts/package') diff --git a/scripts/package/mkspec b/scripts/package/mkspec index f47f17aae135..ef007501effe 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -92,13 +92,8 @@ echo "%ifarch ia64" echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" echo "%else" -echo "%ifarch ppc64" -echo "cp vmlinux arch/powerpc/boot" -echo "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" -echo "%else" echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" echo "%endif" -echo "%endif" echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install' echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" -- cgit v1.2.3 From 81771ce2d1a9f9ce8739aac7af64bb03ff4b6a1a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 30 Sep 2017 10:10:04 +0900 Subject: kbuild: rpm-pkg: install vmlinux.bz2 unconditionally This conditional was added by commit fc370ecfdb37 ("kbuild: add vmlinux to kernel rpm"). Its git-log mentioned vmlinux.bz2 was necessary for debugging, but did not explain why ppc64 was an exception. I see no problem to copy vmlinux.bz2 all the time. Signed-off-by: Masahiro Yamada --- scripts/package/mkspec | 3 --- 1 file changed, 3 deletions(-) (limited to 'scripts/package') diff --git a/scripts/package/mkspec b/scripts/package/mkspec index ef007501effe..a026c089d773 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -99,11 +99,8 @@ echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= head echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" - -echo "%ifnarch ppc64" echo 'bzip2 -9 --keep vmlinux' echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" -echo "%endif" if ! $PREBUILT; then echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build" -- cgit v1.2.3 From 5289c322ba994c7b07a4780243dca1feb610954f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 30 Sep 2017 10:10:05 +0900 Subject: kbuild: rpm-pkg: clean up mkspec Clean up the mkspec without changing the behavior. - grep CONFIG_DRM=y more simply - move "EXCLUDE" out of the "%install" section because it can be computed when the spec file is generated - remove "BuildRoot:" field, which is now redundant - do not mkdir $RPM_BUILD_ROOT/lib/modules explicitly because it is automatically created by "make modules_install" - exclude "%package devel" from source package spec file because it does not make sense where "%files devel" is already excluded - exclude "%build" from source package spec file - remove unneeded "make clean" because we had already cleaned before making tar file - merge two %ifarch ia64 conditionals - replace KBUILD_IMAGE with direct use of $(make image_name) - remove trailing empty line from the spec file Signed-off-by: Masahiro Yamada --- scripts/package/mkspec | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'scripts/package') diff --git a/scripts/package/mkspec b/scripts/package/mkspec index a026c089d773..97feb60e6482 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -10,19 +10,21 @@ # # how we were called determines which rpms we build and how we build them -if [ "$1" = "prebuilt" ]; then +if [ "$1" = prebuilt ]; then PREBUILT=true else PREBUILT=false fi -# starting to output the spec -if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then +if grep -q CONFIG_DRM=y .config; then PROVIDES=kernel-drm fi PROVIDES="$PROVIDES kernel-$KERNELRELEASE" -__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"` +__KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g") +EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \ +--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \ +--exclude=.config.old --exclude=.missing-syscalls.d" echo "Name: kernel" echo "Summary: The Linux Kernel" @@ -37,7 +39,6 @@ if ! $PREBUILT; then echo "Source: kernel-$__KERNELRELEASE.tar.gz" fi -echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root" echo "Provides: $PROVIDES" echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" echo "%define debug_package %{nil}" @@ -57,6 +58,8 @@ echo "header files define structures and constants that are needed for" echo "building most standard programs and are also needed for rebuilding the" echo "glibc package." echo "" + +if ! $PREBUILT; then echo "%package devel" echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel" echo "Group: System Environment/Kernel" @@ -65,39 +68,26 @@ echo "%description -n kernel-devel" echo "This package provides kernel headers and makefiles sufficient to build modules" echo "against the $__KERNELRELEASE kernel package." echo "" - -if ! $PREBUILT; then echo "%prep" echo "%setup -q" echo "" -fi - echo "%build" - -if ! $PREBUILT; then -echo "make clean && make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}" +echo "make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}" echo "" fi echo "%install" -echo 'KBUILD_IMAGE=$(make image_name)' +echo 'mkdir -p $RPM_BUILD_ROOT/boot' echo "%ifarch ia64" -echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' -echo "%else" -echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules' -echo "%endif" - -echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install' -echo "%ifarch ia64" -echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" +echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi' +echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" echo "%else" -echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" +echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" echo "%endif" - +echo 'make %{?_smp_mflags} INSTALL_MOD_PATH=$RPM_BUILD_ROOT KBUILD_SRC= modules_install' echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install' echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" - echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" echo 'bzip2 -9 --keep vmlinux' echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" @@ -106,8 +96,7 @@ if ! $PREBUILT; then echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build" echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source" echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" -echo "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude .config.old --exclude .missing-syscalls.d\"" -echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)" +echo "tar cf - . $EXCLUDES | tar xf - -C "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE" echo "ln -sf /usr/src/kernels/$KERNELRELEASE build" echo "ln -sf /usr/src/kernels/$KERNELRELEASE source" @@ -146,12 +135,11 @@ echo "" echo "%files headers" echo '%defattr (-, root, root)' echo "/usr/include" -echo "" if ! $PREBUILT; then +echo "" echo "%files devel" echo '%defattr (-, root, root)' echo "/usr/src/kernels/$KERNELRELEASE" echo "/lib/modules/$KERNELRELEASE/build" echo "/lib/modules/$KERNELRELEASE/source" -echo "" fi -- cgit v1.2.3 From 8c5d4b648b46b3f5b721b9aff021c9f639d42c35 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 30 Sep 2017 10:10:06 +0900 Subject: kbuild: rpm-pkg: refactor mkspec with here doc The repeat of echo is unreadable. The here-document is a well-known device for such scripts. One difficulty is we have a bunch of PREBUILT conditionals that would split the here-document. My idea is to add "$S" annotatation to lines only for the source package spec file, then post-process it by sed. I hope it will make our life easier than repeat of "cat < --- scripts/package/mkspec | 218 ++++++++++++++++++++++++------------------------- 1 file changed, 105 insertions(+), 113 deletions(-) (limited to 'scripts/package') diff --git a/scripts/package/mkspec b/scripts/package/mkspec index 97feb60e6482..b341d5d8e793 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -11,9 +11,9 @@ # how we were called determines which rpms we build and how we build them if [ "$1" = prebuilt ]; then - PREBUILT=true + S=DEL else - PREBUILT=false + S= fi if grep -q CONFIG_DRM=y .config; then @@ -26,120 +26,112 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \ --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \ --exclude=.config.old --exclude=.missing-syscalls.d" -echo "Name: kernel" -echo "Summary: The Linux Kernel" -echo "Version: $__KERNELRELEASE" -echo "Release: $(cat .version 2>/dev/null || echo 1)" -echo "License: GPL" -echo "Group: System Environment/Kernel" -echo "Vendor: The Linux Community" -echo "URL: http://www.kernel.org" +# 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 +sed -e '/^DEL/d' -e 's/^\t*//' </dev/null || echo 1) + License: GPL + Group: System Environment/Kernel + Vendor: The Linux Community + URL: http://www.kernel.org +$S Source: kernel-$__KERNELRELEASE.tar.gz + Provides: $PROVIDES + %define __spec_install_post /usr/lib/rpm/brp-compress || : + %define debug_package %{nil} -if ! $PREBUILT; then -echo "Source: kernel-$__KERNELRELEASE.tar.gz" -fi + %description + The Linux Kernel, the operating system core itself -echo "Provides: $PROVIDES" -echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" -echo "%define debug_package %{nil}" -echo "" -echo "%description" -echo "The Linux Kernel, the operating system core itself" -echo "" -echo "%package headers" -echo "Summary: Header files for the Linux kernel for use by glibc" -echo "Group: Development/System" -echo "Obsoletes: kernel-headers" -echo "Provides: kernel-headers = %{version}" -echo "%description headers" -echo "Kernel-headers includes the C header files that specify the interface" -echo "between the Linux kernel and userspace libraries and programs. The" -echo "header files define structures and constants that are needed for" -echo "building most standard programs and are also needed for rebuilding the" -echo "glibc package." -echo "" + %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 ! $PREBUILT; then -echo "%package devel" -echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel" -echo "Group: System Environment/Kernel" -echo "AutoReqProv: no" -echo "%description -n kernel-devel" -echo "This package provides kernel headers and makefiles sufficient to build modules" -echo "against the $__KERNELRELEASE kernel package." -echo "" -echo "%prep" -echo "%setup -q" -echo "" -echo "%build" -echo "make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}" -echo "" -fi +$S %package devel +$S Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel +$S Group: System Environment/Kernel +$S AutoReqProv: no +$S %description -n kernel-devel +$S This package provides kernel headers and makefiles sufficient to build modules +$S against the $__KERNELRELEASE kernel package. +$S +$S %prep +$S %setup -q +$S +$S %build +$S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release} +$S + %install + mkdir -p \$RPM_BUILD_ROOT/boot + %ifarch ia64 + mkdir -p \$RPM_BUILD_ROOT/boot/efi + cp \$(make image_name) \$RPM_BUILD_ROOT/boot/efi/vmlinuz-$KERNELRELEASE + ln -s efi/vmlinuz-$KERNELRELEASE \$RPM_BUILD_ROOT/boot/ + %else + cp \$(make image_name) \$RPM_BUILD_ROOT/boot/vmlinuz-$KERNELRELEASE + %endif + make %{?_smp_mflags} INSTALL_MOD_PATH=\$RPM_BUILD_ROOT KBUILD_SRC= modules_install + make %{?_smp_mflags} INSTALL_HDR_PATH=\$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install + cp System.map \$RPM_BUILD_ROOT/boot/System.map-$KERNELRELEASE + cp .config \$RPM_BUILD_ROOT/boot/config-$KERNELRELEASE + bzip2 -9 --keep vmlinux + mv vmlinux.bz2 \$RPM_BUILD_ROOT/boot/vmlinux-$KERNELRELEASE.bz2 +$S rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/build +$S rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/source +$S mkdir -p \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE +$S tar cf - . $EXCLUDES | tar xf - -C \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE +$S cd \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE +$S ln -sf /usr/src/kernels/$KERNELRELEASE build +$S ln -sf /usr/src/kernels/$KERNELRELEASE source -echo "%install" -echo 'mkdir -p $RPM_BUILD_ROOT/boot' -echo "%ifarch ia64" -echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi' -echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" -echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" -echo "%else" -echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" -echo "%endif" -echo 'make %{?_smp_mflags} INSTALL_MOD_PATH=$RPM_BUILD_ROOT KBUILD_SRC= modules_install' -echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install' -echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" -echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" -echo 'bzip2 -9 --keep vmlinux' -echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" + %clean + rm -rf \$RPM_BUILD_ROOT -if ! $PREBUILT; then -echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build" -echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source" -echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" -echo "tar cf - . $EXCLUDES | tar xf - -C "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" -echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE" -echo "ln -sf /usr/src/kernels/$KERNELRELEASE build" -echo "ln -sf /usr/src/kernels/$KERNELRELEASE source" -fi + %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 -echo "" -echo "%clean" -echo 'rm -rf $RPM_BUILD_ROOT' -echo "" -echo "%post" -echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then" -echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm" -echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm" -echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE" -echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" -echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" -echo "fi" -echo "" -echo "%preun" -echo "if [ -x /sbin/new-kernel-pkg ]; then" -echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img" -echo "fi" -echo "" -echo "%postun" -echo "if [ -x /sbin/update-bootloader ]; then" -echo "/sbin/update-bootloader --remove $KERNELRELEASE" -echo "fi" -echo "" -echo "%files" -echo '%defattr (-, root, root)' -echo "/lib/modules/$KERNELRELEASE" -echo "%exclude /lib/modules/$KERNELRELEASE/build" -echo "%exclude /lib/modules/$KERNELRELEASE/source" -echo "/boot/*" -echo "" -echo "%files headers" -echo '%defattr (-, root, root)' -echo "/usr/include" -if ! $PREBUILT; then -echo "" -echo "%files devel" -echo '%defattr (-, root, root)' -echo "/usr/src/kernels/$KERNELRELEASE" -echo "/lib/modules/$KERNELRELEASE/build" -echo "/lib/modules/$KERNELRELEASE/source" -fi + %preun + if [ -x /sbin/new-kernel-pkg ]; then + new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img + 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 +$S +$S %files devel +$S %defattr (-, root, root) +$S /usr/src/kernels/$KERNELRELEASE +$S /lib/modules/$KERNELRELEASE/build +$S /lib/modules/$KERNELRELEASE/source +EOF -- cgit v1.2.3 From 0b7f12f5912de636a9c1671ee343f31f21c42b2f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 30 Sep 2017 10:10:07 +0900 Subject: kbuild: rpm-pkg: fix build error when CONFIG_MODULES is disabled When CONFIG_MODULES is disabled, make rpm-pkg / binrpm-pkg fails with the following message: The present kernel configuration has modules disabled. Type 'make config' and enable loadable module support. Then build a kernel with module support enabled. Do not install modules in the case. Also, omit the devel package. Signed-off-by: Masahiro Yamada --- scripts/package/mkspec | 57 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 25 deletions(-) (limited to 'scripts/package') diff --git a/scripts/package/mkspec b/scripts/package/mkspec index b341d5d8e793..d352a0188770 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -16,6 +16,12 @@ else S= fi +if grep -q CONFIG_MODULES=y .config; then + M= +else + M=DEL +fi + if grep -q CONFIG_DRM=y .config; then PROVIDES=kernel-drm fi @@ -30,6 +36,7 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \ # # 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*//' < Date: Sat, 30 Sep 2017 10:10:08 +0900 Subject: kbuild: rpm-pkg: replace $RPM_BUILD_ROOT with %{buildroot} $RPM_BUILD_ROOT must be escaped to prevent shell from expanding it when generating the spec file. %{build_root} is more readable than \$RPM_BUILD_ROOT. Signed-off-by: Masahiro Yamada --- scripts/package/mkspec | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'scripts/package') diff --git a/scripts/package/mkspec b/scripts/package/mkspec index d352a0188770..280027fad991 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -81,30 +81,30 @@ $S %build $S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release} $S %install - mkdir -p \$RPM_BUILD_ROOT/boot + mkdir -p %{buildroot}/boot %ifarch ia64 - mkdir -p \$RPM_BUILD_ROOT/boot/efi - cp \$(make image_name) \$RPM_BUILD_ROOT/boot/efi/vmlinuz-$KERNELRELEASE - ln -s efi/vmlinuz-$KERNELRELEASE \$RPM_BUILD_ROOT/boot/ + mkdir -p %{buildroot}/boot/efi + cp \$(make image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE + ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/ %else - cp \$(make image_name) \$RPM_BUILD_ROOT/boot/vmlinuz-$KERNELRELEASE + cp \$(make image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE %endif -$M make %{?_smp_mflags} INSTALL_MOD_PATH=\$RPM_BUILD_ROOT KBUILD_SRC= modules_install - make %{?_smp_mflags} INSTALL_HDR_PATH=\$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install - cp System.map \$RPM_BUILD_ROOT/boot/System.map-$KERNELRELEASE - cp .config \$RPM_BUILD_ROOT/boot/config-$KERNELRELEASE +$M make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} KBUILD_SRC= modules_install + make %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr KBUILD_SRC= headers_install + cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE + cp .config %{buildroot}/boot/config-$KERNELRELEASE bzip2 -9 --keep vmlinux - mv vmlinux.bz2 \$RPM_BUILD_ROOT/boot/vmlinux-$KERNELRELEASE.bz2 -$S$M rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/build -$S$M rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/source -$S$M mkdir -p \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE -$S$M tar cf - . $EXCLUDES | tar xf - -C \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE -$S$M cd \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE + mv vmlinux.bz2 %{buildroot}/boot/vmlinux-$KERNELRELEASE.bz2 +$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 \$RPM_BUILD_ROOT + rm -rf %{buildroot} %post if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then -- cgit v1.2.3 From 606625be47bc87b6fab0af10cd57aaa675cb9e42 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 30 Sep 2017 10:10:09 +0900 Subject: kbuild: rpm-pkg: fix jobserver unavailable warning If "make rpm-pkg" or "make binrpm-pkg" is run with -j[jobs] option, the following warning message is displayed. warning: jobserver unavailable: using -j1. Add '+' to parent make rule. Follow the suggestion. Signed-off-by: Masahiro Yamada --- scripts/package/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/package') diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 73f9f3192b9f..b559671d28ca 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -50,7 +50,7 @@ rpm-pkg rpm: FORCE $(MAKE) clean $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec $(call cmd,src_tar,$(KERNELPATH),kernel.spec) - rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz + +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz rm $(KERNELPATH).tar.gz kernel.spec # binrpm-pkg @@ -58,7 +58,7 @@ rpm-pkg rpm: FORCE binrpm-pkg: FORCE $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec - rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ + +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ $(UTS_MACHINE) -bb $(objtree)/binkernel.spec rm binkernel.spec -- cgit v1.2.3 From af60e207087975d069858741c44ed4f450330ac4 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 30 Sep 2017 10:10:10 +0900 Subject: kbuild: rpm-pkg: keep spec file until make mrproper If build fails during (bin)rpm-pkg, the spec file is not cleaned by anyone until the next successful build of the package. We do not have to immediately delete the spec file in case somebody may want to take a look at it. Instead, make them ignored by git, and cleaned up by make mrproper. Signed-off-by: Masahiro Yamada --- .gitignore | 5 +++++ scripts/package/Makefile | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts/package') diff --git a/.gitignore b/.gitignore index 0c39aa20b6ba..4f034b853d7d 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,11 @@ Module.symvers /System.map /Module.markers +# +# RPM spec file (make rpm-pkg) +# +/*.spec + # # Debian directory (make deb-pkg) # diff --git a/scripts/package/Makefile b/scripts/package/Makefile index b559671d28ca..70eea1ed8c9c 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -51,7 +51,6 @@ rpm-pkg rpm: FORCE $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec $(call cmd,src_tar,$(KERNELPATH),kernel.spec) +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz - rm $(KERNELPATH).tar.gz kernel.spec # binrpm-pkg # --------------------------------------------------------------------------- @@ -60,7 +59,8 @@ binrpm-pkg: FORCE $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ $(UTS_MACHINE) -bb $(objtree)/binkernel.spec - rm binkernel.spec + +clean-files += $(objtree)/*.spec # Deb target # --------------------------------------------------------------------------- -- cgit v1.2.3 From 8a16a070abaa61e95354755a320ca37cee544209 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 30 Sep 2017 10:10:11 +0900 Subject: kbuild: rpm-pkg: do not force -jN in submake The spec file always passes %{?_smp_mflags}, but we have two problems here. [1] "make -jN rpm-pkg" emits the following warning message: make[2]: warning: -jN forced in submake: disabling jobserver mode. [2] We can not specify the number of jobs that run in parallel. Whether we give -jN or not from the top Makefile, the spec file always passes ${?_smp_mflags} to the build commands. ${?_smp_mflags} will be useful when we run rpmbuild by hand. When we invoke it from Makefile, -jN is propagated down to submake; it should not be overridden because we want to respect the number of jobs given by the user. Set _smp_mflags to empty string in this case. Signed-off-by: Masahiro Yamada --- scripts/package/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/package') diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 70eea1ed8c9c..9ed96aefc72d 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -50,7 +50,8 @@ rpm-pkg rpm: FORCE $(MAKE) clean $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec $(call cmd,src_tar,$(KERNELPATH),kernel.spec) - +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz + +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \ + --define='_smp_mflags %{nil}' # binrpm-pkg # --------------------------------------------------------------------------- -- cgit v1.2.3 From bace64800bae72c563bab66f23c7221fddaae142 Mon Sep 17 00:00:00 2001 From: Sven Joachim Date: Thu, 9 Nov 2017 19:27:06 +0100 Subject: builddeb: Pass the kernel:debarch substvar to dpkg-genchanges At the end of "make bindeb-pkg" I noticed the following warning: dpkg-genchanges: warning: unknown substitution variable ${kernel:debarch} It turns out that since dpkg version 1.19.0 dpkg-genchanges honors substitution variables in the Description field, while earlier versions silently left them alone, see https://bugs.debian.org/856547. The result is an incomplete description of the linux-headers package in the generated .changes file. Fix it by passing the kernel:debarch substitution variable to dpkg-genchanges. Signed-off-by: Sven Joachim Signed-off-by: Masahiro Yamada --- scripts/package/builddeb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/package') diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 0bc87473f68f..b4f0f2b3f8d2 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -408,9 +408,9 @@ EOF dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \ -b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz mv ${sourcename}_${packageversion}*dsc .. - dpkg-genchanges > ../${sourcename}_${packageversion}_${debarch}.changes + dpkg-genchanges -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes else - dpkg-genchanges -b > ../${sourcename}_${packageversion}_${debarch}.changes + dpkg-genchanges -b -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes fi exit 0 -- cgit v1.2.3