# Maintainer: Natanael Copa _flavor=vanilla pkgname=linux-${_flavor} pkgver=4.4.7 case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac pkgrel=0 pkgdesc="Linux vanilla kernel" url="http://kernel.org" depends="mkinitfs linux-firmware" makedepends="perl sed installkernel bash gmp-dev bc linux-headers" options="!strip" _config=${config:-config-vanilla.${CARCH}} install= source="http://ftp.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz config-vanilla.armhf config-vanilla.x86 config-vanilla.x86_64 " if [ "${pkgver%.0}" = "$pkgver" ]; then source="$source http://ftp.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz" fi subpackages="$pkgname-dev" arch="all" license="GPL2" _abi_release=${pkgver} prepare() { local _patch_failed= cd "$srcdir"/linux-$_kernver if [ "$_kernver" != "$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 mkdir -p "$srcdir"/build cp "$srcdir"/$_config "$srcdir"/build/.config || return 1 make -C "$srcdir"/linux-$_kernver O="$srcdir"/build HOSTCC="${CC:-gcc}" \ silentoldconfig } # this is so we can do: 'abuild menuconfig' to reconfigure kernel menuconfig() { cd "$srcdir"/build || return 1 make menuconfig cp .config "$startdir"/$_config } build() { cd "$srcdir"/build export GCC_SPECS=hardenednopie.specs make CC="${CC:-gcc}" \ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \ || return 1 } package() { cd "$srcdir"/build mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules local _install case "$CARCH" in arm*) local _dtbdir="$pkgdir"/usr/lib/linux-${_abi_release} mkdir -p "$_dtbdir" for i in arch/arm/boot/dts/*.dtb ; do install -m644 "$i" "$_dtbdir" done _install=zinstall ;; *) _install=install ;; esac make -j1 modules_install firmware_install $_install \ INSTALL_MOD_PATH="$pkgdir" \ INSTALL_PATH="$pkgdir"/boot \ || return 1 rm -f "$pkgdir"/lib/modules/${_abi_release}/build \ "$pkgdir"/lib/modules/${_abi_release}/source rm -rf "$pkgdir"/lib/firmware install -D include/config/kernel.release \ "$pkgdir"/usr/share/kernel/$_flavor/kernel.release } dev() { # 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" 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 "$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/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="9a78fa2eb6c68ca5a40ed5af08142599 linux-4.4.tar.xz 331267c63d973a1a99105a3d4c9d464f config-vanilla.armhf 7b39fd82ac03ff3a5ac6403b10af0006 config-vanilla.x86 eae91875faa28c1f3ab2672137c22499 config-vanilla.x86_64 2286314f215706401dd51bf07b179ae4 patch-4.4.7.xz" sha256sums="401d7c8fef594999a460d10c72c5a94e9c2e1022f16795ec51746b0d165418b2 linux-4.4.tar.xz 0fee35a85d9883620b0c9d49c428f371e401a2cb38cfa7eda39b52814570c183 config-vanilla.armhf daf10b005d5c9b7ebdb76f26090cde613ed4ce0ebaaf590f4356a28f33c579e1 config-vanilla.x86 fb69e1cfd5ba1a798f63312229370b402bea407819bfd8da0302f21364e10d80 config-vanilla.x86_64 34a0e0bc123fe2224a83e13a4da25f7f816438fd77c58dce19588441f5166f0e patch-4.4.7.xz" sha512sums="13c8459933a8b80608e226a1398e3d1848352ace84bcfb7e6a4a33cb230bbe1ab719d4b58e067283df91ce5311be6d2d595fc8c19e2ae6ecc652499415614b3e linux-4.4.tar.xz fe2abe917c35f5ebb3e2e07b1cc7c86879eb8a500b8552e9cce9d82b485a5f7458ce32fbb826ae64a3b1e4e33d70b5ac4cf859efc18d2dc40d73a7859b55d678 config-vanilla.armhf 00c3ba594f3c21151bcf156a3bab5bda9118f35782884914ab7f4361dabc2fe9eea8dbd59feebc8a39fc4eca8e5682996bd06f91380da8a670fa45618e2f2aae config-vanilla.x86 038420ba58fe1aba49cbb046f7ae4558c232dcd33388aaeea8d33c614ba956780032a633eb43512d776260f5b9c8fb57996c72e92823313437dacc69a04f7f0c config-vanilla.x86_64 b88e8fdfcba306b49bb1d6d3e6cf5a97ee47481b0b801c199db9bade4f1298930ae3d1fe36d003a7927867bd5a092eeecdcbd151c9b2e85470c69f99b0d4bcc5 patch-4.4.7.xz"