# Maintainer: Natanael Copa _flavor=vanilla pkgname=linux-${_flavor} pkgver=4.4.15 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.aarch64 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} _carch=${CARCH} case "$_carch" in aarch64*) _carch="arm64" ;; arm*) _carch="arm" ;; esac HOSTCC="${CC:-gcc}" HOSTCC="${HOSTCC#${CROSS_COMPILE}}" 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 ARCH="$_carch" HOSTCC="$HOSTCC" \ silentoldconfig } # this is so we can do: 'abuild menuconfig' to reconfigure kernel menuconfig() { cd "$srcdir"/build || return 1 make ARCH="$_carch" menuconfig cp .config "$startdir"/$_config } build() { cd "$srcdir"/build make ARCH="$_carch" CC="${CC:-gcc}" \ KCFLAGS="-fno-pie" \ 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* | aarch64*) 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 \ ARCH="$_carch" \ KCFLAGS="-fno-pie" \ 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" ARCH="$_carch" HOSTCC="$HOSTCC" \ 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 3201b979fa698c679e4a6b5bec757df9 config-vanilla.aarch64 1b986f138b3bd1e920515ced30578268 config-vanilla.armhf 60c2b6b5d9c671470fff8266555ad3d8 config-vanilla.x86 1b7e060937dd969d42480e48b516b721 config-vanilla.x86_64 12786f8aef0ad2f87cbf95a68f34cb56 patch-4.4.15.xz" sha256sums="401d7c8fef594999a460d10c72c5a94e9c2e1022f16795ec51746b0d165418b2 linux-4.4.tar.xz e3a52fedc26ce9c4119cb7dc1dbecce7b395b7b41512f74181db5ecdb6f5f887 config-vanilla.aarch64 044c2eac9428c94ef784fc70a232ce0b88c10e70b4612d4d6061bee223884b2e config-vanilla.armhf e7df86b65f7064eca60b8ac5a21260161a4eae8a48b6dfe7f057751f119c492a config-vanilla.x86 70d4f132f8fd55df918b7f6a1348b9901644117c48acb4cff6731e461ef538a9 config-vanilla.x86_64 69fcb928e4958f87fb134d0f6acf98072655b5572dd3497c3a0844882f261bf8 patch-4.4.15.xz" sha512sums="13c8459933a8b80608e226a1398e3d1848352ace84bcfb7e6a4a33cb230bbe1ab719d4b58e067283df91ce5311be6d2d595fc8c19e2ae6ecc652499415614b3e linux-4.4.tar.xz 2bab7e9a8a39778ddc31d2d2dbefe3f732e860d6ec6f4969f0869a173c6630d4161bea505d99bb56d282d466a317b9af31435b8699b248fd8cd89a0a65eee020 config-vanilla.aarch64 cb748b5129e1f60ff9734223c1f88b213d15ba405cbea4d2dc737acdc76efbdf9f102ea08f68c6343db19522ef22df52fe61b9c353f41339790c751897393e70 config-vanilla.armhf 84f1779ab4ee7bbdcddca2c713947af0768d2b29e53f607c728b7c2f7de64bf5d9b5e1556e0d2a8479ff7a15a8532e38fd949098fd478bcbf571707d0aef5c3c config-vanilla.x86 cacc61470c25934fff51dcdf2f6188aeb833eb881399d6b7f97548e399095c3279704655dc090ce3a56c089e8b0fb101e1469500f79b4fd28b4335658435b901 config-vanilla.x86_64 1522839ac4f1330db34618a20712e42ae85d4961b2d2a699723c2675f065f52b07127bb96b33944ee519448027dcd402a31503d748debb12f05fb0f2896b3d73 patch-4.4.15.xz"