# openmamba kernel specfile for embedded kernels # Copyright (C) 2011-2016 by Silvan Calarco # # To build a specific target: # # rpmbuild -ba --define="KERNEL_TARGET " kernel.spec # # To cross-compile: # rpmbuild -ba kernel-rpi2.spec --target arm --define="cross_target_cpu arm" # # To cross-compile using an alternative compiler: # rpmbuild -ba kernel-rpi2.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_ver 4.4.26 %define kernel_majver %(echo %version | cut -d. -f1-2) %define gitdirver %(echo %version | cut -d. -f3-4) #% define KERNEL_TARGET rpi-v7 # 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: 4.4.1.20161020 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 URL: https://github.com/raspberrypi/linux Source0: git://github.com/raspberrypi/linux.git/raspberrypi-kernel_%{gitdirver}-1/linux-%{version}.tar.bz2 #Source0: git://github.com/raspberrypi/linux.git/rpi-%{gitdirver}.y/linux-%{version}.tar.bz2 Source20: kernel-rpi-logo.png Source100: %{name}-v7-%{kernel_majver}-arm-config Source101: %{name}-%{kernel_majver}-arm-config License: GPL ## AUTOBUILDREQ-BEGIN BuildRequires: glibc-devel BuildRequires: libperl BuildRequires: perl-devel ## AUTOBUILDREQ-END BuildRequires: /bin/bash /bin/sh /usr/bin/perl BuildRequires: kmod BuildRequires: mkbootimg Provides: kernel Requires(post): dracut Requires: linux_firmware 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 -n kernel-%{KERNEL_TARGET} Group: Development/Kernel Summary: The Linux Kernel, the operating system core itself for the RaspberryPI (%{KERNEL_TARGET}) %if "%{KERNEL_TARGET}" == "rpi-v7" Provides: kernel-rpi2 Obsoletes: kernel-rpi2 %endif %description -n kernel-%{KERNEL_TARGET} 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 -n kernel-%{KERNEL_TARGET}-source Group: Development/Kernel Summary: The source code for the Linux kernel Requires: kernel-%{KERNEL_TARGET}-headers == %{version}-%{release} Provides: kernelsource %if "%{KERNEL_TARGET}" == "rpi-v7" Provides: kernel-rpi2-source Obsoletes: kernel-rpi2-source %endif %description -n kernel-%{KERNEL_TARGET}-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 -n kernel-%{KERNEL_TARGET}-headers Group: Development/Kernel Summary: Headers, scripts, configuration and Makefile for the linux kernel Provides: kernelheaders %if "%{KERNEL_TARGET}" == "rpi-v7" Provides: kernel-rpi2-headers Obsoletes: kernel-rpi2-headers %endif %description -n kernel-%{KERNEL_TARGET}-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 -n kernel-%{KERNEL_TARGET}-headers-sanitised Group: Development/Kernel Summary: Sanitised kernel headers used for glibc build Provides: kernelsanitisedheaders %if "%{KERNEL_TARGET}" == "rpi-v7" Provides: kernel-rpi2-headers-sanitised Obsoletes: kernel-rpi2-headers-sanitised %endif %description -n kernel-%{KERNEL_TARGET}-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 -n kernel-%{KERNEL_TARGET}-modules Group: System/Kernel and Hardware Summary: The kernel base modules normally used by the device Requires: kernel-%{KERNEL_TARGET} == %{version}-%{release} Provides: kernelmodules %if "%{KERNEL_TARGET}" == "rpi-v7" Provides: kernel-rpi2-modules Obsoletes: kernel-rpi2-modules %endif %description -n kernel-%{KERNEL_TARGET}-modules The kernel-modules package contains the base modules normally used by the device %package -n kernel-%{KERNEL_TARGET}-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 %if "%{KERNEL_TARGET}" == "rpi-v7" Provides: kernel-rpi2-modules-extra Obsoletes: kernel-rpi2-modules-extra %endif %description -n kernel-%{KERNEL_TARGET}-modules-extra The kernel-modules-extra package contains extra modules not normally used by the device. %package -n kernel-%{KERNEL_TARGET}-firmware Group: System/Kernel and Hardware Summary: Firmware files used by %{name} Requires: kernel-%{KERNEL_TARGET} == %{version}-%{release} Provides: kernelfirmware = %{version} Provides: linux_firmware %if "%{KERNEL_TARGET}" == "rpi-v7" Provides: kernel-rpi2-firmware Obsoletes: kernel-rpi2-firmware %endif %description -n kernel-%{KERNEL_TARGET}-firmware Firmware files used by the Linux Kernel. %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 # #% patch0 -p1 #% patch1 -p1 make mrproper # create build dirs for each kernel # and copy proper configuration %if %{_target_cpu} == arm case %{?KERNEL_TARGET} in rpi) kernel_cfg=%{SOURCE101} ;; rpi-v7) 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} ARCH=%{target_cpu} make CROSS_COMPILE=%{_target_platform}- %{?_smp_mflags} dtbs %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} # install dtbs cp arch/arm/boot/dts/*.dtb %{buildroot}/boot/ install -d -m0755 %{buildroot}/boot/overlays/ cp arch/arm/boot/dts/overlays/*.dtb* %{buildroot}/boot/overlays/ #cp arch/arm/boot/dts/overlays/README %{buildroot}/boot/overlays/ # 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=%{SOURCE101} ;; rpi-v7) 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=%{_build}-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="block 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 -name *.h -exec \ echo "%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/"{} >> \ %{_builddir}/linux-%{version}/kernel-headers.files \; %if "%{with_full_source}" == "1" find $splitdirs -not -type d -a -not -name *.h -exec \ echo "%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/"{} >> \ %{_builddir}/linux-%{version}/kernel-source.files \; %else touch %{_builddir}/linux-%{version}/kernel-source.files find $splitdirs -not -type d -a -not -name *.h -exec rm -f {} \; rm -rf firmware samples virt %endif archs=" `ls %{buildroot}%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/arch` " for i in $archs; do [ "$i" == "$headers_arch" ] || \ %if "%{with_full_source}" == "1" echo "%{_prefix}/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/arch/$i" >> \ %{_builddir}/linux-%{version}/kernel-source.files %else rm -rf arch/$i %endif 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=%{_build}-gcc \ CROSS_COMPILE=%{_target_platform}- \ INSTALL_HDR_PATH=%{buildroot}%{_prefix}/src/linux-%{kernel_ver}-%{KERNEL_TARGET}/usr # Do not package cross-platform host tools if [ "%{_build}" != "%{_target_platform}" ]; then for f in asn1_compiler conmakehash extract-cert kallsyms sortextable; do rm -f %{buildroot}/usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/scripts/$f done fi %clean [ "%{buildroot}" != / ] && rm -rf "%{buildroot}" %post -n kernel-%{KERNEL_TARGET} # 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 -n kernel-%{KERNEL_TARGET} # 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 -n kernel-%{KERNEL_TARGET}-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 -n kernel-%{KERNEL_TARGET}-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 -n kernel-%{KERNEL_TARGET}-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 -n kernel-%{KERNEL_TARGET} %defattr (-, root, root) /boot/System.map-%{kernel_ver}-%{?KERNEL_TARGET} /boot/%{KIMAGE_DEST}-%{kernel_ver}-%{?KERNEL_TARGET} /boot/*.dtb* /boot/overlays/*.dtb* %files -n kernel-%{KERNEL_TARGET}-source -f kernel-source.files %defattr(-,root,root) /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/arch/.gitignore /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/Documentation /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/certs /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/init /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/REPORTING-BUGS /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}/.missing-syscalls.d /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/.mailmap /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/Kconfig %if "%{with_full_source}" == "1" /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/block /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/firmware /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/samples /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/virt %endif %files -n kernel-%{KERNEL_TARGET}-headers-sanitised %defattr(-,root,root) /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/usr/include %files -n kernel-%{KERNEL_TARGET}-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 /usr/src/linux-%{kernel_ver}-%{?KERNEL_TARGET}/.get_maintainer.ignore /lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/build /lib/modules/%{kernel_ver}-%{?KERNEL_TARGET}/source %files -n kernel-%{KERNEL_TARGET}-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/* %files -n kernel-%{KERNEL_TARGET}-firmware %defattr (-, root, root) %dir /lib/firmware /lib/firmware/* %changelog * Thu Nov 10 2016 Silvan Calarco 4.4.1.20161020-1mamba - update to 4.4.1.20161020 * Tue Jul 12 2016 Silvan Calarco 4.4.1.20160620-1mamba - update to 4.4.1.20160620 * Fri Feb 27 2015 Silvan Calarco 3.18.7.20150227git-1mamba - update to 3.18.7.20150227git * Sun Dec 07 2014 Silvan Calarco 3.12.34.20141207git-1mamba - update to 3.12.34.20141207git * Sat Dec 06 2014 Silvan Calarco 3.14.6.20140831git-3mamba - rebuilt with newer gcc to see if it works * Sat Sep 06 2014 Silvan Calarco 3.14.6.20140831git-2mamba - update configuration, sync with arch/arm/configs/bcmrpi_defconfig * Sun Aug 31 2014 Automatic Build System 3.14.6.20140831git-1mamba - update to 3.14.6.20140831git * Mon Sep 09 2013 Silvan Calarco 3.6.11.20130909git-1mamba - package created from kernel-hannspad template