# Maintainer: Natanael Copa pkgname=linux-rpi pkgver=4.4.11 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=${pkgver};; esac pkgrel=3 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/rpi/linux-4.4.y-rpi-20160514.patch rpi-cirrus-4.4.y-20160514.patch gpio-mcp23s08-pullups.patch rotary-encoder-fix.patch issue-4973.patch config-rpi.armhf config-rpi2.armhf markdt " subpackages="" _flavors= for _i in $source; do case $_i in config-*.$CARCH) _f=${_i%.$CARCH} _f=${_f#config-} _flavors="$_flavors ${_f}" [ "linux-$_f" != "$pkgname" ] && subpackages="$subpackages linux-${_f}" subpackages="$subpackages linux-${_f}-dev:_${_f}_dev" ;; 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" } _dev() { local _abi_release=${pkgver}-${pkgrel}-$1 # 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 $1 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-$1.${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-$1/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 } for _f in $_flavors; do [ "linux-$_f" != "$pkgname" ] && eval "${_f}() { _package "$_f" "$subpkgdir"; }" eval "_${_f}_dev() { _dev $_f; }" done md5sums="9a78fa2eb6c68ca5a40ed5af08142599 linux-4.4.tar.xz 5c1d328f03aaafb9cf7fdc442468c348 patch-4.4.11.xz 1d08efb60aaa1a161aaa128807fcd8ce linux-4.4.y-rpi-20160514.patch 1ac525e064919fd4ffec5d40b910cae1 rpi-cirrus-4.4.y-20160514.patch b66e8aa4991ca5c2ccd61559ed7e6491 gpio-mcp23s08-pullups.patch 5508d2b3e5967bd57f92f551d90b3e54 rotary-encoder-fix.patch 29281b74d2cef6965fa4ab6d826a2aa4 issue-4973.patch 79e6d3f6054a99062c33e15c8f925e64 config-rpi.armhf 26fbc79db35af5f371caf258336d5ab9 config-rpi2.armhf e587cae1dca2f5992555d9bcf53deecf markdt" sha256sums="401d7c8fef594999a460d10c72c5a94e9c2e1022f16795ec51746b0d165418b2 linux-4.4.tar.xz 394c3970865c092f21cd02b8f433024adbf8539114567d6bde197fed6612f553 patch-4.4.11.xz 68b19c4c589afa869d6278d775a34bb30bc83b3e09c703d9df3163f144a9d36e linux-4.4.y-rpi-20160514.patch 651845267ee7ee815cc5e78cad9dad87d3de388ce07f911f68b20880ca1e3292 rpi-cirrus-4.4.y-20160514.patch b389a556bbd98053881b43deef1adf20640f980557c5f37cfd7ece2daeecbda9 gpio-mcp23s08-pullups.patch ab6740577fe8c1d71d2c716720ebbbf9a750985963d6938093b4ca9194b6e871 rotary-encoder-fix.patch 3a16e927ce53a8c56e7f1dd86fe8ad08b1c06466f5206c521a7e2de1e4796d6c issue-4973.patch 2f0c9c69c92c4831025194ff55cd21dbdc85ce0ffeadce7398ab9dfda57b5185 config-rpi.armhf b46b7f6fece372840d8818c35fc74f09de7f2fba71eb2b86b184e37b5ed07484 config-rpi2.armhf 0f6681fc5c3590e1dbe13a2bde796403bd1529cf0fe19720899eaa0db79bcb49 markdt" sha512sums="13c8459933a8b80608e226a1398e3d1848352ace84bcfb7e6a4a33cb230bbe1ab719d4b58e067283df91ce5311be6d2d595fc8c19e2ae6ecc652499415614b3e linux-4.4.tar.xz 697e6dd2b85da13ae65ac70b9654c9c3fa00c3120d425fdb53104fc234457cda40b9f0ebe29e7ae5c1a191730666c0bbd291721b16623ee8e402287771f20def patch-4.4.11.xz 77818e23a9ae1854589da425377f8ea96581166597a18f5fd70f1cfca2a7049d42aea239c25836e91702436b079369f0aa427c4eee58e43d1e4d5dcf7d62488d linux-4.4.y-rpi-20160514.patch abe4d482a98450335eb935cf49be468accc8955a464553c45280f15d4114a87e96b158800536c2f6c09be07474386bef952d1f96e58eaac5a4f6d6bd47e845c1 rpi-cirrus-4.4.y-20160514.patch 36724ba56cb8fdf3a3d347cffb67ae1cc3d7b1052d526b6b5134ebf6baae9f9724b586c97833453dc7697ab24699426f0749af78b6a80be36967a80033a0cf40 gpio-mcp23s08-pullups.patch 3a711e2cdb6c0ecaceb3755437d38626dec8403e8aa167a6e16f64d8a8b7cc5bdc7e04aa7c05938719ebc90e319ec4124ee2151a7855e7838ee143b62d140ad0 rotary-encoder-fix.patch 501c91bf2538a18102da59bbccc3097f9c3c90079acc0e946ff075074160c09b8a66934e5ce5470e170f0e4f93d114709a95230367426d0bb7ea02c4bdf4cc9b issue-4973.patch 88f358e38b5401f6d8446ab1e9c964b4d239b45d5361b460bad86be6a47b3ad26bd8376cbe69661c555501cf7977f2736d389caf70bd82182dcdc395d3127a10 config-rpi.armhf 44b0774ce1aa8c2ad7a4c09001fe7c227524d07093997671dc470254dba9901174e6a2a6be67d5940ab95473f44a7a59fcf4c6e6a024e2cb0756142c7f8d0f95 config-rpi2.armhf a4ecd1f48db64f9d6a189250d1937d7f2cd3a049a3d24cc527d04d05db06137722f1ba44bcd6033794781c3f2cfe2fbe065410a16de4bfdf4b1cd95d89322a77 markdt"