kbuild: Integrate with new-kernel-pkg
PATCH 1/6 kbuild: Integrate with new-kernel-pkg
Handles mkinitrd, updating the bootloader among other things.
--- scripts/package/mkspec | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
scripts/package/mkspec +13 -0
@@ -94,6 +94,19 @@ echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" echo 'mv vmlinux.orig vmlinux' echo "%endif" +echo 'rm -rf $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/{build,source}" +echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" +echo "rsync -avz --exclude '.git/' --exclude '*vmlinux*' --exclude '.*' --exclude '*.o' --exclude '*.so' --exclude '*.ko' . "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE/" +echo 'pushd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"' && ln -s build source && ln -s '"/usr/src/kernels/$KERNELRELEASE"' build && popd' + +echo "" +echo "%preun" +echo '/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove '"$KERNELRELEASE"' || exit $?' + +echo "" +echo "%post" +echo '/sbin/new-kernel-pkg --mkinitrd --depmod --install --make-default '"$KERNELRELEASE"' || exit $?' + echo "" echo "%clean" echo 'rm -rf $RPM_BUILD_ROOT'
Signature · 1 line
1.7.4
PATCH 2/6 kbuild: Add a kernel-devel package
Useful for building modules without having kernel sources
--- scripts/package/mkspec | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
scripts/package/mkspec +12 -0
@@ -47,6 +47,14 @@ echo "" echo "%description" echo "The Linux Kernel, the operating system core itself" echo "" +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 "" if ! $PREBUILT; then echo "%prep"
@@ -118,3 +126,7 @@ echo "/lib/modules/$KERNELRELEASE" echo "/lib/firmware" echo "/boot/*" echo "" +echo "%files devel" +echo '%defattr (-, root, root)' +echo "/usr/src/kernels/$KERNELRELEASE" +echo ""
Signature · 1 line
1.7.4
PATCH 3/6 kbuild: Create a kernel-headers RPM
In reply to Arun SharmaTo compile binaries which depend on new kernel interfaces, we need a kernel-headers RPM
--- scripts/package/mkspec | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
scripts/package/mkspec +16 -0
@@ -55,6 +55,17 @@ 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 "%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." if ! $PREBUILT; then echo "%prep"
@@ -91,6 +102,7 @@ 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 headers_install' echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
@@ -130,3 +142,7 @@ echo "%files devel" echo '%defattr (-, root, root)' echo "/usr/src/kernels/$KERNELRELEASE" echo "" +echo "%files headers" +echo '%defattr (-, root, root)' +echo "/usr/include" +echo ""
Signature · 1 line
1.7.4
PATCH 5/6 kbuild: Append RPM release to $KERNELRELEASE
In reply to Arun SharmaProvide the same consistency as distributor kernels. uname -r matches RPM name (includes the release)
Glossary:
KERNELRELEASE = what users see ___KERNELRELEASE = KERNELRELEASE without RPM release __KERNELRELEASE = ___KERNELRELEASE with s/-/_/g
--- Makefile | 9 ++++++--- scripts/package/Makefile | 2 +- scripts/package/mkspec | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-)
Makefile +6 -3
@@ -367,11 +367,14 @@ KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds -# Read KERNELRELEASE from include/config/kernel.release (if it exists) -KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +# Read ___KERNELRELEASE from include/config/kernel.release (if it exists) +___KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +# Append the release version only once. +# Note: .version could change during the build. +KERNELRELEASE ?= $(___KERNELRELEASE)-$(shell /bin/sh scripts/mkversion) KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) -export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION +export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION ___KERNELRELEASE export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE
scripts/package/Makefile +1 -1
@@ -26,7 +26,7 @@ RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi) # Remove hyphens since they have special meaning in RPM filenames -KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) +KERNELPATH := kernel-$(subst -,_,$(___KERNELRELEASE)) MKSPEC := $(srctree)/scripts/package/mkspec PREV := set -e; cd ..;
scripts/package/mkspec +1 -1
@@ -22,7 +22,7 @@ if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then fi PROVIDES="$PROVIDES kernel-$KERNELRELEASE" -__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"` +__KERNELRELEASE=`echo $___KERNELRELEASE | sed -e "s/-/_/g"` echo "Name: kernel" echo "Summary: The Linux Kernel"
Signature · 1 line
1.7.4
PATCH 4/6 kbuild: Move firmware images to a separate RPM
In reply to Arun SharmaThis allows multiple kernel RPMs to be installed without namespace conflicts.
--- scripts/package/mkspec | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
scripts/package/mkspec +12 -1
@@ -66,6 +66,13 @@ 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 "" +echo "%package firmware" +echo "Summary: Set of firmware images in the kernel tree" +echo "Group: Development/System" +echo "%description firmware" +echo "Firmware images in the kernel tree provided for backward compability" +echo "" if ! $PREBUILT; then echo "%prep"
@@ -90,6 +97,7 @@ echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' echo "%endif" echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install' +echo 'make %{?_smp_mflags} INSTALL_FW_PATH=$RPM_BUILD_ROOT/lib/firmware KBUILD_SRC= firmware_install' echo "%ifarch ia64" echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
@@ -135,7 +143,6 @@ echo "%files" echo '%defattr (-, root, root)' echo "%dir /lib/modules" echo "/lib/modules/$KERNELRELEASE" -echo "/lib/firmware" echo "/boot/*" echo "" echo "%files devel"
@@ -146,3 +153,7 @@ echo "%files headers" echo '%defattr (-, root, root)' echo "/usr/include" echo "" +echo "%files firmware" +echo '%defattr (-, root, root)' +echo "/lib/firmware" +echo ""
Signature · 1 line
1.7.4
PATCH 6/6 kbuild: cleanup the rpm buildroot
In reply to Arun Sharma--- scripts/package/mkspec | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
scripts/package/mkspec +1 -0
@@ -81,6 +81,7 @@ echo "" fi echo "%build" +echo 'rm -rf $RPM_BUILD_ROOT' if ! $PREBUILT; then echo "make clean && make %{?_smp_mflags}"
Signature · 1 line
1.7.4
Re: [PATCH 5/6] kbuild: Append RPM release to $KERNELRELEASE
In reply to Arun SharmaQuoted 2 lines · Arun Sharma
Provide the same consistency as distributor kernels. uname -r matches RPM name (includes the release)
Not all of the patches in this series may be appropriate for inclusion into kbuild. But I wanted to send them out anyway to get feedback on how things can be improved.
This patch in particular changes the rpm name and might need to be an opt-in feature.
-Arun
Quoted 1 line · Arun Sharma
Handles mkinitrd, updating the bootloader among other things.
This is a Fedora/RHEL specific script, please keep the mkspec script work on any rpm distribution.
Michal
Re: [PATCH 5/6] kbuild: Append RPM release to $KERNELRELEASE
In reply to Arun SharmaQuoted 21 lines · Arun Sharma
Provide the same consistency as distributor kernels. uname -r matches RPM name (includes the release)
Glossary:
KERNELRELEASE = what users see
___KERNELRELEASE= KERNELRELEASE without RPM release__KERNELRELEASE=___KERNELRELEASEwith s/-/_/gSigned-off-by Arun Sharma <[email protected]>--- Makefile | 9 ++++++--- scripts/package/Makefile | 2 +- scripts/package/mkspec | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-)Makefile +0
-0
Makefile KBUILD_AFLAGS_MODULE := -DMODULE · line 374
Quoted 10 lines
Makefile +5
-2@@ -367,11 +367,14 @@ KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds -# Read KERNELRELEASE from include/config/kernel.release (if it exists) -KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +# Read ___KERNELRELEASE from include/config/kernel.release (if it exists) +___KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +# Append the release version only once. +# Note: .version could change during the build. +KERNELRELEASE ?= $(___KERNELRELEASE)-$(shell /bin/sh scripts/mkversion)
Please stop decorating the kernel release string for the sake of make rpm, thanks. If you really want the kernel release string match rpm's %{version}-%{release}, how about this: Let the user set CONFIG_LOCALVERSION=-<number> and check in make rpm if $KERNELRELEASE ends with -<number>. If so, use <number> in the Release: field and the rest in Version:, otherwise use the same scheme as before. That way, you won't force a new kernel release numbering scheme on anyone.
Michal
Quoted 5 lines · Michal Marek
Quoted 1 line · Arun Sharma
Handles mkinitrd, updating the bootloader among other things.
This is a Fedora/RHEL specific script, please keep the mkspec script work on any rpm distribution.
One alternative is to surround it with:
if [ -x /sbin/new-kernel-pkg ]; then
...
fi
and have similar stanzas for other popular rpm based distros.
-Arun
Quoted 7 lines · Arun Sharma
Quoted 5 lines · Michal Marek
Quoted 1 line · Arun Sharma
Handles mkinitrd, updating the bootloader among other things.
This is a Fedora/RHEL specific script, please keep the mkspec script work on any rpm distribution.
Quoted 7 lines
One alternative is to surround it with:
if [ -x
/sbin/new-kernel-pkg]; then
...
fiand have similar stanzas for other popular rpm based distros.
Or use /sbin/installkernel and let distros handle it.
Michal
Quoted 3 lines · Michal Marek
Quoted 1 line
and have similar stanzas for other popular rpm based distros.
Or use
/sbin/installkerneland let distros handle it.
There is no /sbin/uninstallkernel though :)
Also installkernel doesn't seem to have a way of making the newly installed rpm the default kernel.
I'm ok with either approach (go with the least common denominator or have parallel distro specific code).
-Arun
Re: [PATCH 5/6] kbuild: Append RPM release to $KERNELRELEASE
In reply to Michal MarekQuoted 8 lines · Michal Marek
Please stop decorating the kernel release string for the sake of make rpm, thanks. If you really want the kernel release string match rpm's %{version}-%{release}, how about this: Let the user set
CONFIG_LOCALVERSION=-<number> and check in make rpm if $KERNELRELEASE ends with -<number>. If so, use <number> in the Release: field and the rest in Version:, otherwise use the same scheme as before. That way, you won't force a new kernel release numbering scheme on anyone.
Turns out that even this patch isn't sufficient for what we were trying to do. Let's drop this patch for now. The other patches are independent and should still apply.
-Arun
Re: [PATCH 3/6] kbuild: Create a kernel-headers RPM
In reply to Arun SharmaQuoted 7 lines · Arun Sharma
To compile binaries which depend on new kernel interfaces, we need a kernel-headers RPM
Signed-off-by Arun Sharma <[email protected]>--- scripts/package/mkspec | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
Pushed to kbuild-2.6.git#packaging.
Thanks,
Michal
Re: [PATCH 4/6] kbuild: Move firmware images to a separate RPM
In reply to Arun SharmaQuoted 1 line · Arun Sharma
+echo 'make %{?_smp_mflags} INSTALL_FW_PATH=$RPM_BUILD_ROOT/lib/firmware KBUILD_SRC=
firmware_install'
I don't think we need firmware_install, just package the firmware installed by modules_install.
Michal
Re: [PATCH 6/6] kbuild: cleanup the rpm buildroot
In reply to Arun SharmaQuoted 2 lines · Arun Sharma
echo "%build"
+echo 'rm -rf $RPM_BUILD_ROOT'
Don't do it, this allows another user to create their or $RPM_BUILD_ROOT and let you package it.
Michal
Re: [PATCH 6/6] kbuild: cleanup the rpm buildroot
Quoted 6 lines · Michal Marek
Quoted 2 lines · Arun Sharma
echo "%build"
+echo 'rm -rf $RPM_BUILD_ROOT'Don't do it, this allows another user to create their or $RPM_BUILD_ROOT and let you package it.
Here's the motivation for the change:
mkspec has a BuildRoot that is deterministic (i.e. the next time I rebuild I get the same buildroot)
Quoted 1 line
echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
So if I were to restart a broken build, the build root could have old files that break the build even after the breakage is fixed.
-Arun
Quoted 2 lines · Michal Marek
Or use
/sbin/installkerneland let distros handle it.
Updated distro specific patch (not expecting you to apply it). The earlier version was mixed up with kernel-devel patch.
-Arun
commit cb73fb35a588922344763c075b2fce159df41fc7
Author: Arun Sharma <[email protected]> Date: Sun Mar 6 08:08:53 2011 -0800
kbuild: Integrate with new-kernel-pkg
Handles mkinitrd, updating the bootloader among other things.
scripts/package/mkspec +10 -0
@@ -40,6 +40,8 @@ echo "Source: kernel-$__KERNELRELEASE.tar.gz" fi echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root" +echo "Requires(post): /sbin/new-kernel-pkg" +echo "Requires(preun): /sbin/new-kernel-pkg" echo "Provides: $PROVIDES" echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" echo "%define debug_package %{nil}"
@@ -95,6 +97,14 @@ echo 'mv vmlinux.orig vmlinux' echo "%endif" echo "" +echo "%preun" +echo '/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove '"$KERNELRELEASE"' || exit $?' + +echo "" +echo "%post" +echo '/sbin/new-kernel-pkg --mkinitrd --depmod --install --make-default '"$KERNELRELEASE"' || exit $?' + +echo "" echo "%clean" echo 'rm -rf $RPM_BUILD_ROOT' echo ""
Re: [PATCH 2/6] kbuild: Add a kernel-devel package
In reply to Arun Sharma[ Updated version of this patch. ]
kbuild: Add a kernel-devel package
Useful for building modules without having kernel sources
scripts/package/mkspec +17 -0
@@ -49,6 +49,14 @@ echo "" echo "%description" echo "The Linux Kernel, the operating system core itself" echo "" +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 "" if ! $PREBUILT; then echo "%prep"
@@ -96,6 +104,11 @@ echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" echo 'mv vmlinux.orig vmlinux' echo "%endif" +echo 'rm -rf $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/{build,source}" +echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" +echo "rsync -avz --exclude '.git/' --exclude '*vmlinux*' --exclude '.*' --exclude '*.o' --exclude '*.so' --exclude '*.ko' . "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE/" +echo 'pushd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"' && ln -s build source && ln -s '"/usr/src/kernels/$KERNELRELEASE"' build && popd' + echo "" echo "%preun" echo '/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove '"$KERNELRELEASE"' || exit $?'
@@ -115,3 +128,7 @@ echo "/lib/modules/$KERNELRELEASE" echo "/lib/firmware" echo "/boot/*" echo "" +echo "%files devel" +echo '%defattr (-, root, root)' +echo "/usr/src/kernels/$KERNELRELEASE" +echo ""
Re: [PATCH 5/6] kbuild: Append RPM release to $KERNELRELEASE
In reply to Michal MarekQuoted 8 lines · Michal Marek
Please stop decorating the kernel release string for the sake of make rpm, thanks. If you really want the kernel release string match rpm's %{version}-%{release}, how about this: Let the user set
CONFIG_LOCALVERSION=-<number> and check in make rpm if $KERNELRELEASE ends with -<number>. If so, use <number> in the Release: field and the rest in Version:, otherwise use the same scheme as before. That way, you won't force a new kernel release numbering scheme on anyone.
This patch has been working better than the previous one for us and it has a similar property that it is a nop for developers who don't use rpm for packaging.
commit 29cbbfa5d840ac1ecd80a2045f05f6440d2c4c04
Author: Arun Sharma <[email protected]> Date: Fri May 20 14:48:01 2011 -0700
kbuild: Use KERNELRELEASE from packaging scripts
This adds two changes to the kernel Makefile:
* Honor KERNELRELEASE if it's already set
* Allow external scripts to append $LOCAL_VERSION to $EXTRA_VERSION
Makefile +5 -1
@@ -368,7 +368,11 @@ KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds # Read KERNELRELEASE from include/config/kernel.release (if it exists) -KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +# and if it's not already defined +KERNELRELEASE ?= $(shell cat include/config/kernel.release 2> /dev/null) +ifdef LOCAL_VERSION +EXTRAVERSION := $(EXTRAVERSION)_$(LOCAL_VERSION) +endif KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
scripts/package/mkspec +8 -1
@@ -23,13 +23,16 @@ fi PROVIDES="$PROVIDES kernel-$KERNELRELEASE" __KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"` +LOCAL_VERSION=`. $srctree/scripts/mkversion``$srctree/scripts/setlocalversion | sed 's/-/_/g'` +KERNELRELEASE=${__KERNELRELEASE}-${LOCAL_VERSION} + echo "Name: kernel" echo "Summary: The Linux Kernel" echo "Version: $__KERNELRELEASE" # we need to determine the NEXT version number so that uname and # rpm -q will agree -echo "Release: `. $srctree/scripts/mkversion`" +echo "Release: $LOCAL_VERSION" echo "License: GPL" echo "Group: System Environment/Kernel" echo "Vendor: The Linux Community"
@@ -84,6 +87,8 @@ fi echo "%build" echo 'rm -rf $RPM_BUILD_ROOT' +echo "export KERNELRELEASE=%{version}-%{release}" +echo "export LOCAL_VERSION=%{release}" if ! $PREBUILT; then echo "make clean && make %{?_smp_mflags}"
@@ -91,6 +96,8 @@ echo "" fi echo "%install" +echo "export KERNELRELEASE=%{version}-%{release}" +echo "export LOCAL_VERSION=%{release}" echo "%ifarch ia64" echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware'