# Maintainer: Natanael Copa _mainflavor=rpi pkgname=linux-$_mainflavor pkgver=4.1.15 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=${pkgver};; esac pkgrel=1 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-20160105.patch rpi-cirrus-4.1.y-20151218.patch gpio-mcp23s08-pullups.patch rotary-encoder-fix.patch issue-4973.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 5ec05841161a172f8ae1a7f38bb382b0 patch-4.1.15.xz c5bf5a6389520729d0e17bf02ab44504 linux-4.1.y-rpi-20160105.patch d4b70738cf06dbd70534d5e873442951 rpi-cirrus-4.1.y-20151218.patch b66e8aa4991ca5c2ccd61559ed7e6491 gpio-mcp23s08-pullups.patch 53112c9e4422d407463ad6c45faa789c rotary-encoder-fix.patch 29281b74d2cef6965fa4ab6d826a2aa4 issue-4973.patch 3b645eef5408cbbcf9c6b13581ef775a config-rpi.armhf 1c21e249ea27b70dd5e0a7b69820fdee config-rpi2.armhf e587cae1dca2f5992555d9bcf53deecf markdt" sha256sums="caf51f085aac1e1cea4d00dbbf3093ead07b551fc07b31b2a989c05f8ea72d9f linux-4.1.tar.xz 0ffca8557f1aa191da2f2260ad279c9cc858e6308a8af8a76f7ca3d3c0540344 patch-4.1.15.xz d093ece97f5ae05b255cfd3923a9f2683c41e77d5d83aa8c1ac92f163c1657c5 linux-4.1.y-rpi-20160105.patch 5aa17a1554598c3b364b7e8aea84bacfc13e8aca9b9101e58d89c211674a3d5a rpi-cirrus-4.1.y-20151218.patch b389a556bbd98053881b43deef1adf20640f980557c5f37cfd7ece2daeecbda9 gpio-mcp23s08-pullups.patch 8f810099810660436a49f029429aadb573aec756b07fcefbcc2ca2ffd21d6ecb rotary-encoder-fix.patch 3a16e927ce53a8c56e7f1dd86fe8ad08b1c06466f5206c521a7e2de1e4796d6c issue-4973.patch 7eb3025189c64f4023db864169dcc9d64d029fc871d0ffbc59621292a338772a config-rpi.armhf 10318f14c68a7fafe3b1a8f3208c8586dabce5c01598a4bf7a2da76166b273b4 config-rpi2.armhf 0f6681fc5c3590e1dbe13a2bde796403bd1529cf0fe19720899eaa0db79bcb49 markdt" sha512sums="168ef84a4e67619f9f53f3574e438542a5747f9b43443363cb83597fcdac9f40d201625c66e375a23226745eaada9176eb006ca023613cec089349e91751f3c0 linux-4.1.tar.xz 646daf16c01fb8c3013c7c9919c18c3635eb6bd37560623cb56cc7a6d0b22fb13290cee8865dfbcc435cd8544cc3ecb6f3aae538d10c9e0b1098806f233155a3 patch-4.1.15.xz bdd4caf18762e1705536227d573321164f62d7c194dec06848764ad1a2a91e2eaa5a4e032a4bfb94d2264a6d9a77ab28e5659c34e011b9465557be03d6e343dc linux-4.1.y-rpi-20160105.patch 843afc1f2a72fa9618935dd67d4ac33a22ee78f20114af349f8d93e54864375b3ef192c8d8fde814d6685d5fe675c2a850743834ef89640eedce9f4db5ffdb67 rpi-cirrus-4.1.y-20151218.patch 36724ba56cb8fdf3a3d347cffb67ae1cc3d7b1052d526b6b5134ebf6baae9f9724b586c97833453dc7697ab24699426f0749af78b6a80be36967a80033a0cf40 gpio-mcp23s08-pullups.patch e948ce9c44bc7f20a632519f9ca49f0b9c8c256cdf75d5632a184d41d6a9995c122232d7812d5224def7d119192d4d18f6f9acb9cf6adc8f1df52bea4970731b rotary-encoder-fix.patch 501c91bf2538a18102da59bbccc3097f9c3c90079acc0e946ff075074160c09b8a66934e5ce5470e170f0e4f93d114709a95230367426d0bb7ea02c4bdf4cc9b issue-4973.patch 51f7fcacb9fb05aa14e7ee7890f7726ce4b0001496cfe9ca2152693c2acf5fefbfa654d2d4f26058aa3b617141f29cff7e0427c30e291209829ab1e44c6412ba config-rpi.armhf 1e249312b12e5d247ca7e250653afbacb5bc9d23983eaa4d552ff5b28c2dc0b0302a1c6af499fa59fa166a31e067fddae191bd977b0bd13773a66c81ca398f93 config-rpi2.armhf a4ecd1f48db64f9d6a189250d1937d7f2cd3a049a3d24cc527d04d05db06137722f1ba44bcd6033794781c3f2cfe2fbe065410a16de4bfdf4b1cd95d89322a77 markdt"