kernel-rpi/kernel-rpi.spec

377 lines
13 KiB
RPMSpec
Raw Permalink Normal View History

# openmamba kernel specfile for embedded kernels
# Copyright (C) 2011-2013 by Silvan Calarco
#
# To build a specific target:
#
# rpmbuild -ba --define="KERNEL_TARGET <target>" kernel.spec
#
# To cross-compile:
# rpmbuild -ba kernel-rpi.spec --target arm --define="cross_target_cpu arm"
#
# To cross-compile using an alternative compiler:
# rpmbuild -ba kernel-rpi.spec --target arm --define="cross_target_cpu arm" \
# --define="_target_platform arm-openmamba-linux-gnueabi"
#
%define kernel_ver %(echo %version | cut -d. -f1-3)
%define KERNEL_TARGET rpi
# define short kernel target name for Lilo
%define KERNEL_TARGET_SHORT %{KERNEL_TARGET}
%if "%{_target_cpu}" == "i586"
%define KIMAGE arch/i386/boot/bzImage
%define KIMAGE_DEST vmlinuz
%define DEPMOD /sbin/depmod
%endif
%if "%{_target_cpu}" == "arm"
%define KIMAGE arch/arm/boot/zImage
%define KIMAGE_DEST zImage
%define DEPMOD /sbin/depmod
%endif
%if "%{_target_cpu}" == "x86_64"
%if "%{KERNEL_TARGET}" == "mamba-xen"
%define KIMAGE arch/x86_64/boot/vmlinuz
%define KIMAGE_DEST vmlinuz
%define DEPMOD /sbin/depmod
%else
%define KIMAGE arch/x86_64/boot/bzImage
%define KIMAGE_DEST vmlinuz
%define DEPMOD /sbin/depmod
%endif
%endif
%if "%{_target_cpu}" == "ppc"
%define KIMAGE vmlinux
%define KIMAGE_DEST vmlinux
%define DEPMOD /bin/true
%endif
%if "%{_target_cpu}" == "i586"
%define target_cpu i386
%else
%define target_cpu %{_target_cpu}
%endif
# disable internal dependency generator for scriptlets
%define _use_internal_dependency_generator 1
Name: kernel-rpi
Version: 3.6.11.20130909git
Release: 1mamba
Summary: The Linux Kernel, the operating system core itself for the RaspberryPI
Group: System/Kernel and Hardware
Vendor: openmamba
Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: https://github.com/raspberrypi/linux
Source0: git://github.com/raspberrypi/linux.git/rpi-3.6.y/linux-%{version}.tar.bz2
Source20: %{name}-logo.png
Source100: %{name}-%{version}-arm-config
License: GPL
BuildRequires: /bin/bash /bin/sh /usr/bin/perl
BuildRequires: kmod
BuildRequires: mkbootimg
Provides: kernel
Requires(post): dracut
BuildRoot: %{_tmppath}/%{name}-build
%description
The Linux Kernel, the operating system core itself for the Raspberry PI.
The kernel package contains the Linux kernel (%{KIMAGE_DEST}), the operating system core itself.
The kernel handles the basic functions of the operating system: memory allocation, process allocation, device input and output, etc.
This is the source package used to build kernel for different architectures and targets.
This kernel was build for %{_target_cpu} architecture and the following target: %{?KERNEL_TARGET}.
%package source
Group: Development/Kernel
Summary: The source code for the Linux kernel
Requires: kernel-%{KERNEL_TARGET}-headers == %{version}-%{release}
Provides: kernelsource
%description source
The kernel-source package contains the source code files for the Linux kernel.
The source files can be used to build a custom kernel that is better tuned to your particular hardware, if you are so inclined (and you know what you're doing).
This kernel sources are configured for %{TARGET_CPU} architecture and the following target: %{?KERNEL_TARGET}.
%package headers
Group: Development/Kernel
Summary: Headers, scripts, configuration and Makefile for the linux kernel
Provides: kernelheaders
%description headers
The kernel-headers package contains the headers, scripts, configuration and Makefile to develop with the linux kernel
The kernel-headers can be used to build modules for the kernel.
This kernel headers are configured for %{TARGET_CPU} architecture and the following target: %{?KERNEL_TARGET}.
%package headers-sanitised
Group: Development/Kernel
Summary: Sanitised kernel headers used for glibc build
Provides: kernelsanitisedheaders
%description headers-sanitised
Sanitised kernel headers used for glibc build.
This kernel sanitised headers are configured for %{TARGET_CPU} architecture and the following target: %{?KERNEL_TARGET}.
%package modules
Group: System/Kernel and Hardware
Summary: The kernel base modules normally used by the device
Requires: kernel-%{KERNEL_TARGET} == %{version}-%{release}
Provides: kernelmodules
%description modules
The kernel-modules package contains the base modules normally used by the device
%package modules-extra
Group: System/Kernel and Hardware
Summary: The kernel extra modules not normally used by the device
Requires: kernel-%{KERNEL_TARGET} == %{version}-%{release}
Provides: kernelmodulesextra
%description modules-extra
The kernel-modules-extra package contains extra modules not normally used by the device.
%prep
%setup -q -n linux-%{version}
#-D -T
#:<< ___EOF
%if "%{?KERNEL_TARGET}" == ""
echo "No target specified, aborting."
exit 1
%else
echo "I'm going to build a %{KERNEL_TARGET} kernel..."
%endif
#
# patch and configure STANDARD kernel
#
make mrproper
# create build dirs for each kernel
# and copy proper configuration
%if %{_target_cpu} == arm
case %{?KERNEL_TARGET} in
rpi) kernel_cfg=%{SOURCE100}
;;
esac
%endif
cp $kernel_cfg ./.config
cp Makefile Makefile.orig
sed -i "s/\(EXTRAVERSION =.*\)/\1-%{?KERNEL_TARGET}/" Makefile
# add custom logo
pngtopnm %{SOURCE20} | ppmquant -plain 224 > drivers/video/logo/logo_linux_clut224.ppm
%build
#:<< ___EOF
#
# build kernel for given target
#
ARCH=%{target_cpu} make oldconfig
ARCH=%{target_cpu} make CROSS_COMPILE=%{_target_platform}- %{?_smp_mflags}
%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
# create system dirs in install environment
install -d %{buildroot}{/usr/src/,/boot,%{_initrddir},/lib/modules,/lib/firmware}
ARCH=%{target_cpu} make \
modules_install INSTALL_MOD_PATH=%{buildroot} DEPMOD=%{DEPMOD}
install -m0644 modules.builtin %{buildroot}/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/
install -m0644 modules.order %{buildroot}/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/
(cd %{buildroot}/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}
rm -f build && ln -sf /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET} build )
cp %{KIMAGE} %{buildroot}/boot/%{KIMAGE_DEST}-%{kernel_ver}-%{?KERNEL_TARGET}
cp System.map %{buildroot}/boot/System.map-%{kernel_ver}-%{?KERNEL_TARGET}
# recreate kernel sources
[ -e kernel-headers.files ] && rm -f kernel-headers.files
[ -e kernel-source.files ] && rm -f kernel-source.files
cp -R %{_builddir}/linux-%{version} %{buildroot}/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}
cd %{buildroot}/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}
ARCH=%{target_cpu} make mrproper
%if %{_target_cpu} == arm
case %{?KERNEL_TARGET} in
rpi) kernel_cfg=%{SOURCE100} ;;
esac
%endif
cp $kernel_cfg %{buildroot}/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/.config
cp %{_builddir}/linux-%{version}/Module.symvers %{buildroot}/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}
ARCH=%{target_cpu} make oldconfig
#cp Makefile Makefile.orig
#sed -i "s/\(EXTRAVERSION =.*\)/\1-%{?KERNEL_TARGET}/" Makefile
#%if "%{_target_platform}" == "%{_build}"
ARCH=%{target_cpu} make \
HOSTCC=%{_target_platform}-gcc \
CROSS_COMPILE=%{_target_platform}- \
prepare scripts oldconfig
#%endif
rm .config.old
# clean modules files created by depmod
rm -f %{buildroot}/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/modules.{alias,alias.bin,ccwmap,dep,dep.bin,devname,ieee1394map}
rm -f %{buildroot}/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/modules.{inputmap,isapnpmap,ofmap,pcimap,seriomap,softdep}
rm -f %{buildroot}/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/modules.{symbols,symbols.bin,usbmap}
# remove .tmp files if any
rm -f %{buildroot}%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/.tmp* || true
# fix symlink pointing to sources
rm -f %{buildroot}/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/source
ln -s %{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET} %{buildroot}/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/source
#
# create kernel-source.files and kernel-headers.files
#
cd %{buildroot}%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}
splitdirs="crypto drivers fs ipc kernel lib mm net security sound"
case %{_target_cpu} in
i586|x86_64) headers_arch="x86" ;;
arm) headers_arch="arm" ;;
ppc) headers_arch="ppc" ;;
esac
find $splitdirs -type f -name *.h -exec \
echo "%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/"{} >> \
%{_builddir}/linux-%{version}/kernel-headers.files \;
find $splitdirs -type f -not -name *.h -exec \
echo "%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/"{} >> \
%{_builddir}/linux-%{version}/kernel-source.files \;
archs=" `ls %{buildroot}%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/arch` "
for i in $archs; do
[ "$i" == "$headers_arch" ] || \
echo "%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/arch/$i" >> \
%{_builddir}/linux-%{version}/kernel-source.files
done
echo "%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/arch/$headers_arch" >> \
%{_builddir}/linux-%{version}/kernel-headers.files
# install sanitised headers used by glibc
ARCH=%{target_cpu} make headers_install \
HOSTCC=%{_target_platform}-gcc \
CROSS_COMPILE=%{_target_platform}- \
INSTALL_HDR_PATH=%{buildroot}%{_prefix}/src/linux-%{kernel_ver}-%{KERNEL_TARGET}/usr
%clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%post
# new install or upgrade
if [ $1 -ge 1 ]; then
/sbin/depmod -A -F /boot/System.map-%{kernel_ver}-%{?KERNEL_TARGET} \
%{kernel_ver}-%{?KERNEL_TARGET} &>/dev/null
mkinitrd -f /boot/initramfs-%{kernel_ver}-%{?KERNEL_TARGET}.img %{kernel_ver}-%{?KERNEL_TARGET}
fi
#[ -e /dev/mtd3 ] && {
# flash_eraseall /dev/mtd3
# cat /boot/%{KIMAGE_DEST}-%{kernel_ver}-%{?KERNEL_TARGET} > /dev/mtd3
#}
exit 0
%postun
# erase this package
if [ $1 -eq 0 ]; then
[ -f /boot/%{KIMAGE_DEST}-%{kernel_ver}-%{?KERNEL_TARGET} ] ||
rm -f /boot/initramfs-%{kernel_ver}-%{?KERNEL_TARGET}.img
fi
exit 0
%post headers
# touch file so it results up-to-date on make
touch %{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/include/config/MARKER
exit 0
%post modules
# new install or upgrade
if [ $1 -ge 1 ]; then
/sbin/depmod -A -F /boot/System.map-%{kernel_ver}-%{?KERNEL_TARGET} \
%{kernel_ver}-%{?KERNEL_TARGET} &>/dev/null
fi
exit 0
%post modules-extra
# new install or upgrade
if [ $1 -ge 1 ]; then
/sbin/depmod -A -F /boot/System.map-%{kernel_ver}-%{?KERNEL_TARGET} \
%{kernel_ver}-%{?KERNEL_TARGET} &>/dev/null
fi
exit 0
%files
%defattr (-, root, root)
/boot/System.map-%{kernel_ver}-%{?KERNEL_TARGET}
/boot/%{KIMAGE_DEST}-%{kernel_ver}-%{?KERNEL_TARGET}
%files source -f kernel-source.files
%defattr(-,root,root)
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/arch/.gitignore
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/block
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/Documentation
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/firmware
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/init
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/REPORTING-BUGS
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/samples
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/usr/gen_init_cpio.c
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/usr/initramfs_data*.S
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/usr/Kconfig
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/usr/Makefile
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/usr/.gitignore
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/tools
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/virt
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/.missing-syscalls.d
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/.missing-syscalls.d
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/.mailmap
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/Kconfig
%files headers-sanitised
%defattr(-,root,root)
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/usr/include
%files headers -f kernel-headers.files
%defattr(-,root,root)
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/COPYING
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/CREDITS
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/Kbuild
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/include
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/Makefile
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/Makefile.orig
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/Module.symvers
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/MAINTAINERS
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/README
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/scripts
/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/.config
/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/build
/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/source
%files modules
%defattr (-, root, root)
%dir /lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}
/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/modules.builtin
/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/modules.builtin.bin
/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/modules.order
%dir /lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/kernel
/lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/kernel/*
%dir /lib/firmware
/lib/firmware
%changelog
* Mon Sep 09 2013 Silvan Calarco <silvan.calarco@mambasoft.it> 3.6.11.20130909git-1mamba
- package created from kernel-hannspad template