_flavor=postmarketos-mainline _config="config-${_flavor}.${CARCH}" pkgname=linux-${_flavor} pkgver=4.15_rc6 _pkgver=${pkgver/_/-} _kernver=${pkgver%_rc*} _mainver=${_kernver%.*} _patchlevel=${_kernver/$_mainver./} _basever=${_mainver}.$((_patchlevel-1)) pkgrel=4 arch="x86_64 armhf aarch64" pkgdesc="Linux for pmOS supported chipsets (mainline, more bleeding-edge than stable)" url="https://kernel.org/" depends="" makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev libressl-dev file" options="!strip !check !tracedeps" install= source=" https://cdn.kernel.org/pub/linux/kernel/v$_mainver.x/linux-$_basever.tar.xz linux-v$_basever-v$_pkgver.patch::https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/rawdiff/?id=v$_pkgver&id2=v$_basever config-${_flavor}.armhf config-${_flavor}.aarch64 config-${_flavor}.x86_64 0001-sony-amami-dts.patch 0002-tools-objtool-Makefile-don-t-assume-sync-check.sh-is.patch " subpackages="$pkgname-dev" license="GPL2" _abi_release=$_pkgver _carch=${CARCH} case "$_carch" in aarch64*) _carch="arm64" ;; arm*) _carch="arm" ;; ppc*) _carch="powerpc" ;; s390*) _carch="s390" ;; esac HOSTCC="${CC:-gcc}" HOSTCC="${HOSTCC#${CROSS_COMPILE}}" builddir="$srcdir/linux-$_basever" prepare() { local _patch_failed= cd "$builddir" # first apply patches in specified order for i in $source; do case $i in *.patch|*.patch::*) _patch=${i%::*} msg "Applying $_patch..." if ! patch -s -p1 -N -i "$srcdir"/$_patch; then echo $_patch >>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 -v "$srcdir"/$_config "$srcdir"/build/.config make -C "$builddir" O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \ olddefconfig } # this is so we can do: 'abuild menuconfig' to reconfigure kernel menuconfig() { cd "$srcdir"/build make ARCH="$_carch" menuconfig cp .config "$startdir"/$_config } build() { cd "$srcdir"/build unset LDFLAGS make ARCH="$_carch" CC="${CC:-gcc}" \ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-${_flavor}" \ CFLAGS_MODULE=-fno-pic } package() { cd "$srcdir/build/arch/${_carch}/boot" if [ "$CARCH" == "aarch64" ]; then install -Dm644 "$srcdir/build/arch/${_carch}/boot/Image" \ "$pkgdir/boot/vmlinuz-$_flavor" else install -Dm644 "$srcdir/build/arch/${_carch}/boot/"*zImage \ "$pkgdir/boot/vmlinuz-$_flavor" fi install -D "$srcdir/build/include/config/kernel.release" \ "$pkgdir/usr/share/kernel/$_flavor/kernel.release" cd "$srcdir"/build local _install case "$CARCH" in aarch64*|arm*) _install="modules_install dtbs_install" ;; *) _install="modules_install" ;; esac make -j1 $_install \ ARCH="$_carch" \ INSTALL_MOD_PATH="$pkgdir" \ INSTALL_DTBS_PATH="$pkgdir/usr/share/dtb" } 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 postmarketos kernel" depends="gmp-dev bash perl" 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 "$builddir" O="$dir" ARCH="$_carch" HOSTCC="$HOSTCC" \ olddefconfig prepare modules_prepare scripts # needed for 3rd party modules # https://bugzilla.kernel.org/show_bug.cgi?id=11143 case "$CARCH" in ppc*) (cd "$dir" && make arch/powerpc/lib/crtsavres.o);; esac # remove the stuff that points 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/ubuntu/ubuntu-zesty.git/tree/debian/rules.d/3-binary-indep.mk cd "$builddir" 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' \) \ -print | cpio -pdm "$dir" 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 # cross-compiling: delete binaries with host arch and replace them with # symlinks to binaries with the target arch (packaged in kernel-scripts) if [ -n "$CROSS_COMPILE" ]; then msg "Symlinking binary scripts..." depends="$depends kernel-scripts" cd "$dir/scripts" local i for i in $(find . -type f); do local type="$(file -b --mime-type "$i")" [ "$type" != "application/x-sharedlib" ] && continue local native="/usr/bin/kernel-scripts/$(echo "$i" | cut -d '/' -f 2-)" ln -svf "$native" "$i" done fi } sha512sums="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8 linux-4.14.tar.xz 5d05754adc696f180405acda79e2678075f99d12252fc1f7e6af46f5ab39076de926db6de900c28b2e05dd3753df60d3515bb805b71d3bff991a5ed040b91167 linux-v4.14-v4.15-rc6.patch a75225750193cf31c8b6c15e7748699f842ecadc9ed573f0b10f42bb5343b4e092bcb65b359d170a42a102a4ddfe09d63c1d67550f4b99c29295fa22e1d7b995 config-postmarketos-mainline.armhf 6310035a0a4c028cc98cab92919cca54be9b79ee9fe63211e7a05876d7befdbd8506a2f80548e228e014e99b0f91f63946352789d8d2f2134c66914163f66ab3 config-postmarketos-mainline.aarch64 3d42c60061d12a436d19ffdf00623ea71ca31f16f690ae82ebf872d35177c283b4038cd5e270f4e610d6cf6861cef73ac63c995f1f4cfe9d6f2a4a8648ba28fb config-postmarketos-mainline.x86_64 e0fb34032fe70d9a4713ed521b8a5e29cf7f76cb7c56ceb24ed7206a8445ba743226e4873fa2069077952e21f99fb36eabf7c4daa779f565961f0dded4591887 0001-sony-amami-dts.patch 04863696e5ed64a8fe41b3ac49c4f7e3028a945c3abf74467e0b0b39d57748f1f89269776f4e0301e2f996738f29a1e1932b3c121d6530a889eb3c1fd91a7af4 0002-tools-objtool-Makefile-don-t-assume-sync-check.sh-is.patch"