pmaports/main/linux-postmarketos-qcom/APKBUILD
Brian Masney 0e8cb764e1
main/linux-postmarketos-qcom: update to kernel v5.2 (!514)
Update to the 5.2 kernel plus my patches for the Nexus 5 display that
will also work for other msm8974-based systems:
https://github.com/masneyb/linux/commits/v5.2-nexus5-display. There's
currently 25 extra patches on top of 5.2:

- The first 9 patches after the 5.2 commit are currently in 5.3rc1 and
  were back ported to 5.2. All of these patches have 'Commit XXX
  upstream.' messages in the commit message.
- The next 9 patches are for ocmem support and some msm display fixes. I
  expect that these will be merged upstream for 5.4rc1.
- The remaining 7 patches are still not suitable to send upstream.

[ci:skip-build]: already built successfully in CI
2019-07-24 00:22:12 +02:00

162 lines
4.5 KiB
Text

_flavor=postmarketos-qcom
_config="config-${_flavor}.${CARCH}"
pkgname=linux-${_flavor}
pkgver=5.2.0
pkgrel=0
arch="armv7"
pkgdesc="Kernel close to mainline with extra patches for Qualcomm devices"
url="https://kernel.org/"
makedepends="dtbtool perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev openssl-dev file bison flex"
options="!strip !check !tracedeps"
_commit="33fee68163e501634338b40aac2ebe279bf7787b"
source="
linux-${_commit}.tar.gz::https://github.com/masneyb/linux/archive/${_commit}.tar.gz
config-${_flavor}.armv7
"
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-${_commit}"
prepare() {
local _patch_failed=
ls "$srcdir"
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
}
build() {
cd "$srcdir"/build
unset LDFLAGS
make ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-${_flavor}" \
CFLAGS_MODULE=-fno-pic
dtbTool -s 2048 -p scripts/dtc/ -o arch/arm/boot/dt.img arch/arm/boot/dts --version=2
}
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"
install -Dm644 "$srcdir/build/arch/arm/boot/dt.img" \
"$pkgdir/boot/dt.img"
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,
# similar to what ubuntu does
#
# this way you don't 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 sources
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
}
sha512sums="b2d0e92ace0904308ceb9914f8ff3e54d9421c6cba4dcaf073046a7444e7f2cc80543115b869544f75d83c0321c81ca73d4046bdb53c8160e94c613d0bc3ea26 linux-33fee68163e501634338b40aac2ebe279bf7787b.tar.gz
924308f9b7ab68b0d04faf882cf00a9597463583cd35e6453c5e1bae404c6b75526d3f43c44214ade80e3723da857c57cacc06333dcfaee601662ddccc901e1e config-postmarketos-qcom.armv7"