Commit 5289c322 authored by Masahiro Yamada's avatar Masahiro Yamada

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: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent 81771ce2
...@@ -10,19 +10,21 @@ ...@@ -10,19 +10,21 @@
# #
# how we were called determines which rpms we build and how we build them # how we were called determines which rpms we build and how we build them
if [ "$1" = "prebuilt" ]; then if [ "$1" = prebuilt ]; then
PREBUILT=true PREBUILT=true
else else
PREBUILT=false PREBUILT=false
fi fi
# starting to output the spec if grep -q CONFIG_DRM=y .config; then
if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then
PROVIDES=kernel-drm PROVIDES=kernel-drm
fi fi
PROVIDES="$PROVIDES kernel-$KERNELRELEASE" 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 "Name: kernel"
echo "Summary: The Linux Kernel" echo "Summary: The Linux Kernel"
...@@ -37,7 +39,6 @@ if ! $PREBUILT; then ...@@ -37,7 +39,6 @@ if ! $PREBUILT; then
echo "Source: kernel-$__KERNELRELEASE.tar.gz" echo "Source: kernel-$__KERNELRELEASE.tar.gz"
fi fi
echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
echo "Provides: $PROVIDES" echo "Provides: $PROVIDES"
echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
echo "%define debug_package %{nil}" echo "%define debug_package %{nil}"
...@@ -57,6 +58,8 @@ echo "header files define structures and constants that are needed for" ...@@ -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 "building most standard programs and are also needed for rebuilding the"
echo "glibc package." echo "glibc package."
echo "" echo ""
if ! $PREBUILT; then
echo "%package devel" echo "%package devel"
echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel" echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
echo "Group: System Environment/Kernel" echo "Group: System Environment/Kernel"
...@@ -65,39 +68,26 @@ echo "%description -n kernel-devel" ...@@ -65,39 +68,26 @@ echo "%description -n kernel-devel"
echo "This package provides kernel headers and makefiles sufficient to build modules" echo "This package provides kernel headers and makefiles sufficient to build modules"
echo "against the $__KERNELRELEASE kernel package." echo "against the $__KERNELRELEASE kernel package."
echo "" echo ""
if ! $PREBUILT; then
echo "%prep" echo "%prep"
echo "%setup -q" echo "%setup -q"
echo "" echo ""
fi
echo "%build" echo "%build"
echo "make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}"
if ! $PREBUILT; then
echo "make clean && make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}"
echo "" echo ""
fi fi
echo "%install" echo "%install"
echo 'KBUILD_IMAGE=$(make image_name)' echo 'mkdir -p $RPM_BUILD_ROOT/boot'
echo "%ifarch ia64" echo "%ifarch ia64"
echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi'
echo "%else" echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
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 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
echo "%else" 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 "%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 '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 System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
echo 'bzip2 -9 --keep vmlinux' echo 'bzip2 -9 --keep vmlinux'
echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
...@@ -106,8 +96,7 @@ if ! $PREBUILT; then ...@@ -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/build"
echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source" echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source"
echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" 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 cf - . $EXCLUDES | tar xf - -C "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"
echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE" echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"
echo "ln -sf /usr/src/kernels/$KERNELRELEASE build" echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
echo "ln -sf /usr/src/kernels/$KERNELRELEASE source" echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
...@@ -146,12 +135,11 @@ echo "" ...@@ -146,12 +135,11 @@ echo ""
echo "%files headers" echo "%files headers"
echo '%defattr (-, root, root)' echo '%defattr (-, root, root)'
echo "/usr/include" echo "/usr/include"
echo ""
if ! $PREBUILT; then if ! $PREBUILT; then
echo ""
echo "%files devel" echo "%files devel"
echo '%defattr (-, root, root)' echo '%defattr (-, root, root)'
echo "/usr/src/kernels/$KERNELRELEASE" echo "/usr/src/kernels/$KERNELRELEASE"
echo "/lib/modules/$KERNELRELEASE/build" echo "/lib/modules/$KERNELRELEASE/build"
echo "/lib/modules/$KERNELRELEASE/source" echo "/lib/modules/$KERNELRELEASE/source"
echo ""
fi fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment