# Maintainer: Natanael Copa _flavor=vanilla pkgname=linux-${_flavor} pkgver=4.1.10 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 0001-inet-fix-potential-deadlock-in-reqsk_queue_unlink.patch 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="fe9dc0f6729f36400ea81aa41d614c37 linux-4.1.tar.xz ffa7fdc282af20f2b48b95b2687b7452 0001-inet-fix-potential-deadlock-in-reqsk_queue_unlink.patch 422932534e96a80d5d9a1d9c0252c11e config-vanilla.armhf 376bae192604828303b9643811a62f33 config-vanilla.x86 e6f826b0d12b106a5be8b3386fe025e7 config-vanilla.x86_64 599cb082ef44d8fb76ad8fd49d1b50fc patch-4.1.10.xz" sha256sums="caf51f085aac1e1cea4d00dbbf3093ead07b551fc07b31b2a989c05f8ea72d9f linux-4.1.tar.xz c56583010561ca7d7b5e5aa3eed67c939f67deb2d22af7155e475c10baa4d7a5 0001-inet-fix-potential-deadlock-in-reqsk_queue_unlink.patch d8c728efad3fc796462190541747e35205e3e9936d2a52002deffe3e00129766 config-vanilla.armhf f8b3d63753088345d9424d561c4ae17eeca58325e85a0db9471d9de92a7bfb50 config-vanilla.x86 85521da5ca80783b91a7cb1bae5c359665e8de75b52aa57c11b8b09e52c3f82b config-vanilla.x86_64 929e210fe6dbd5dd26812c146630be14e979aae6c960a2feb39544babb8e73cb patch-4.1.10.xz" sha512sums="168ef84a4e67619f9f53f3574e438542a5747f9b43443363cb83597fcdac9f40d201625c66e375a23226745eaada9176eb006ca023613cec089349e91751f3c0 linux-4.1.tar.xz 32ae58cf74d5e02cb09445be35772dad0a517949bd1836f8dbc90b871de67901b61dba5eccdc2a795a9f7e5c06831335504a738205eb49768f7424cf30ddd8ae 0001-inet-fix-potential-deadlock-in-reqsk_queue_unlink.patch d3bfdd3e27f43cbbc46593e512895f2c1396fb41cc310efacfa71dcb7391cd77a79e77dc3d7aae0e8d30cd635a1f2f62c319a6f32bed25a9bb6d40269e163793 config-vanilla.armhf d68ccbe54b79ccce9cff920af642a7435f8682f00130249481a157e7b1a104466cdf8429fe0e0313ae55805b7bc6277d9bfe8bac2b255b179c3413bf2b431e55 config-vanilla.x86 5e9ea0d2beab662bd28865501da963040fbbdec95244025924508a045ce5bfb3c628baff598cc35a9a410016782914bd102e8f16ef52a76b2f1f27e3310fa521 config-vanilla.x86_64 3b5cb5c8f494958c39a06a1b416e3e5a075a3c76c44f8bf1ae5a14deec9861407100c2ef59b0720e8fc0729b5c8422b4d819ff59f1f7ec4eed20c5ba8a95d6d5 patch-4.1.10.xz"