# Maintainer: Natanael Copa _mainflavor=rpi pkgname=linux-$_mainflavor pkgver=4.1.13 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=${pkgver};; esac pkgrel=0 pkgdesc="Linux kernel with Raspberry Pi patches" url=https://github.com/raspberrypi/linux depends="mkinitfs linux-firmware" makedepends="perl installkernel bash gmp-dev bc" options="!strip" install= source="http://ftp.kernel.org/pub/linux/kernel/v4.x/linux-$_kernver.tar.xz http://ftp.kernel.org/pub/linux/kernel/v4.x/patch-$pkgver.xz http://dev.alpinelinux.org/~tteras/linux-4.1.y-rpi-20151119.patch rpi-dma-i2s-fix.patch rpi-cirrus-4.1.x-20151025.patch config-rpi.armhf config-rpi2.armhf markdt " subpackages="$pkgname-dev" _flavors= for _i in $source; do case $_i in config-*.$CARCH) _f=${_i%.$CARCH} _f=${_f#config-} _flavors="$_flavors ${_f}" if [ "linux-$_f" != "$pkgname" ]; then subpackages="$subpackages linux-${_f}" fi ;; esac done arch="armhf" license="GPL2" prepare() { local _patch_failed= cd "$srcdir"/linux-$_kernver if [ "${pkgver%.0}" = "$pkgver" ]; then msg "Applying patch-$pkgver.xz" unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N || return 1 fi # first apply patches in specified order for i in $source; do case $i in *.patch) msg "Applying $i..." if ! patch -s -p1 -N -i "$srcdir"/${i##*/}; then echo $i >>failed _patch_failed=1 fi ;; esac done if ! [ -z "$_patch_failed" ]; then error "The following patches failed:" cat failed return 1 fi # remove localversion from patch if any rm -f localversion* for i in $_flavors; do local _config=config-$i.${CARCH} local _builddir="$srcdir"/build-$i mkdir -p "$_builddir" echo "-$pkgrel-$i" > "$srcdir"/build-$i/localversion-alpine \ || return 1 cp "$srcdir"/$_config "$_builddir"/.config || return 1 make -C "$srcdir"/linux-$_kernver \ O="$_builddir" \ HOSTCC="${CC:-gcc}" \ silentoldconfig || return 1 done } build() { export GCC_SPECS=hardenednopie.specs for i in $_flavors; do cd "$srcdir"/build-$i make CC="${CC:-gcc}" \ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \ || return 1 done } _package() { local _buildflavor="$1" _outdir="$2" local _abi_release=${pkgver}-${pkgrel}-${_buildflavor} cd "$srcdir"/build-$_buildflavor || return 1 mkdir -p "$_outdir"/boot "$_outdir"/lib/modules local _install case "$CARCH" in arm*) local _dtbdir="$_outdir"/usr/lib/linux-${_abi_release} cd "$srcdir"/build-$_buildflavor/arch/arm/boot/dts || return 1 mkdir -p "$_dtbdir" find . -name "*.dtb" -type f | cpio -pdm "$_dtbdir" _install=zinstall ;; *) _install=install ;; esac cd "$srcdir"/build-$_buildflavor || return 1 make -j1 modules_install firmware_install $_install \ INSTALL_MOD_PATH="$_outdir" \ INSTALL_PATH="$_outdir"/boot \ || return 1 # tell rpi bootloader we are device tree capable "$srcdir"/markdt "$_outdir"/boot/vmlinuz-$_buildflavor \ || return 1 rm -f "$_outdir"/lib/modules/${_abi_release}/build \ "$_outdir"/lib/modules/${_abi_release}/source rm -rf "$_outdir"/lib/firmware install -D include/config/kernel.release \ "$_outdir"/usr/share/kernel/$_buildflavor/kernel.release } # main flavor installs in $pkgdir package() { _package rpi "$pkgdir" } # subflavors install in $subpkgdir rpi2() { _package rpi2 "$subpkgdir" } # we only provide -dev for main flavor for now dev() { local _abi_release=${pkgver}-${pkgrel}-$_mainflavor # copy the only the parts that we really need for build 3rd party # kernel modules and install those as /usr/src/linux-headers, # simlar to what ubuntu does # # this way you dont need to install the 300-400 kernel sources to # build a tiny kernel module # pkgdesc="Headers and script for third party modules for grsec kernel" depends="gmp-dev bash" local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release} # first we import config, run prepare to set up for building # external modules, and create the scripts mkdir -p "$dir" cp "$srcdir"/config-$_mainflavor.${CARCH} "$dir"/.config make -j1 -C "$srcdir"/linux-$_kernver O="$dir" HOSTCC="${CC:-gcc}" \ silentoldconfig prepare modules_prepare scripts # remove the stuff that poits to real sources. we want 3rd party # modules to believe this is the soruces rm "$dir"/Makefile "$dir"/source # copy the needed stuff from real sources # # this is taken from ubuntu kernel build script # http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-jaunty.git;a=blob;f=debian/rules.d/3-binary-indep.mk;hb=HEAD cd "$srcdir"/linux-$_kernver find . -path './include/*' -prune -o -path './scripts/*' -prune \ -o -type f \( -name 'Makefile*' -o -name 'Kconfig*' \ -o -name 'Kbuild*' -o -name '*.sh' -o -name '*.pl' \ -o -name '*.lds' \) | cpio -pdm "$dir" cp -a drivers/media/dvb/dvb-core/*.h "$dir"/drivers/media/dvb/dvb-core cp -a drivers/media/video/*.h "$dir"/drivers/media/video cp -a drivers/media/dvb/frontends/*.h "$dir"/drivers/media/dvb/frontends cp -a scripts include "$dir" find $(find arch -name include -type d -print) -type f \ | cpio -pdm "$dir" install -Dm644 "$srcdir"/build-$_mainflavor/Module.symvers \ "$dir"/Module.symvers mkdir -p "$subpkgdir"/lib/modules/${_abi_release} ln -sf /usr/src/linux-headers-${_abi_release} \ "$subpkgdir"/lib/modules/${_abi_release}/build } md5sums="fe9dc0f6729f36400ea81aa41d614c37 linux-4.1.tar.xz e1005015404c53692e8aa6dd14efff74 patch-4.1.13.xz 351cb861020321c0fd23fdc5a201463a linux-4.1.y-rpi-20151119.patch 52787712305201c60ab9bc128c9e373b rpi-dma-i2s-fix.patch e3429d7772cb3bf73ff4c51aabb2a5cf rpi-cirrus-4.1.x-20151025.patch cb71e2a517e7d019596eab9cbc91a080 config-rpi.armhf 59f634c4646dab6bc1fe059efaf773e9 config-rpi2.armhf e587cae1dca2f5992555d9bcf53deecf markdt" sha256sums="caf51f085aac1e1cea4d00dbbf3093ead07b551fc07b31b2a989c05f8ea72d9f linux-4.1.tar.xz 1c3ba78cbaa1a260798d6d0d2aa319ff41ae676b443e5bf06ab441436dcdd171 patch-4.1.13.xz cdb26705b8841bbadcf4e862dc3f582049fe8169a4951e4c4a34de1f3dac4293 linux-4.1.y-rpi-20151119.patch f1349b95149f4a21949ebc3dae1c2b144278d170322afeb7975d2cea7f64f10c rpi-dma-i2s-fix.patch b1b5b8bf16e2eacec19931279984f2bc96851da6e9786d4c9422caa1ac7af2fe rpi-cirrus-4.1.x-20151025.patch c38d092ae49c4d3f642c4a99432d139092c331f2b33e81c5855b38381ad79411 config-rpi.armhf 5f450314b5af2d6079d32c3a67eb7df49dd73c4732cff392a953b19838fa6e6a config-rpi2.armhf 0f6681fc5c3590e1dbe13a2bde796403bd1529cf0fe19720899eaa0db79bcb49 markdt" sha512sums="168ef84a4e67619f9f53f3574e438542a5747f9b43443363cb83597fcdac9f40d201625c66e375a23226745eaada9176eb006ca023613cec089349e91751f3c0 linux-4.1.tar.xz 0fa60b9fceb6103c11ed1df8d4f264d1c4efcd75da258709f1d0a6813f8117977fa2279b36da22bd69cc2bc808b092207a438c2e80a65a988f4c72363a605832 patch-4.1.13.xz cae26e2303fccf5246d1b3f8c78425860410ad7667ab7a9805497493d4926978b99ebe95486f00324e3af9cd86fb9e1965f719531ccff9c56efab8ea29b180d0 linux-4.1.y-rpi-20151119.patch 080ba354e40f86338278339b8b3fc2cfd5b77c38c34067b0b7e2b31d07834baf99b3bf04153844e86433bda6fc0de5d86679e1d99521109b1a9a5dbeee6df2b6 rpi-dma-i2s-fix.patch 3e4717c21def19d7c9714b1d9d07f8dbf8fd27e986cbd978eda50c586cc21d1399b50db4255589d09abb6fe5b532c3959481098f229c4ea4526a044fc1da17b0 rpi-cirrus-4.1.x-20151025.patch 69b5beae27dc58e7e7cf1aa351923a980ae453b39f9092fe97220f0b508f46e7e45197da22a2088723bafd6f9293c31475741c63a9ed8e587a1d45392addb9af config-rpi.armhf 7d2f238f0a460fa4cbf6b26188fdbe8241a07846eaf3f6c6f4be33bdb836e9e26c58312109d51092e6faeb304c9281541c62da46539faa1614ef4c1bdacc08eb config-rpi2.armhf a4ecd1f48db64f9d6a189250d1937d7f2cd3a049a3d24cc527d04d05db06137722f1ba44bcd6033794781c3f2cfe2fbe065410a16de4bfdf4b1cd95d89322a77 markdt"