pmaports/device/linux-google-crosshatch-mainline/APKBUILD

170 lines
4.8 KiB
Text
Raw Normal View History

# Kernel config based on: arch/arm64/configs/defconfig
# APKBUILD based on linux-postmarketos-mainline
# See: https://gitlab.com/postmarketOS/pmaports/issues/153
_flavor=google-crosshatch-mainline
_config="config-${_flavor}.${CARCH}"
pkgname=linux-${_flavor}
pkgver=5.1_rc7
_pkgver=${pkgver/_/-}
_kernver=${pkgver%_rc*}
_mainver=${_kernver%.*}
_patchlevel=${_kernver/$_mainver./}
_basever=${_mainver}.$((_patchlevel-1))
pkgrel=0
arch="aarch64"
pkgdesc="Google Pixel 3 XL mainline kernel; only USB networking works, nothing else"
url="https://kernel.org/"
depends=""
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev openssl-dev file bison flex"
options="!strip !check !tracedeps"
install=
_repository="linux"
_commit="35ce53723a6f7eb8506f4f67062f15f573e5ce46"
source="
$pkgname-$_commit.tar.gz::https://github.com/Pixel3Dev/${_repository}/archive/${_commit}.tar.gz
config-${_flavor}.aarch64
"
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=
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
}
package() {
cd "$srcdir/build/arch/${_carch}/boot"
if [ "$CARCH" == "aarch64" ]; then
install -Dm644 "$srcdir/build/arch/${_carch}/boot/Image.gz" \
"$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,
# 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="0775a75fcaa97cd3cbfc387657a547ffdab2e358f7fb4d4ed77f182acd71863298e92d16adcca1663a19f9c2c986256cd0f0069fde82a974ac64b6320be001d5 linux-google-crosshatch-mainline-35ce53723a6f7eb8506f4f67062f15f573e5ce46.tar.gz
81e5af85a0b75caed13cd1fb5f5866c13df86ae22601d2eb0bba4195f72aab4ed78ef8a88bec2cd2554d3543c0fd58e87cfbf6fa6cac2d955a4b031fa387c0b8 config-google-crosshatch-mainline.aarch64"