pmaports/device/linux-teclast-x80pro/APKBUILD
Oliver Smith ec14336927
teclast-x80pro: enable CONFIG_UEVENT_HELPER (!472)
[ci:skip-build]: will not finish in time. I've built linux-asus-me176c
                 and it builds fine. I'm assuming that
                 linux-teclast-x80pro will also build, since it is
                 pretty much the vanilla kernel.
2019-06-30 18:46:37 +02:00

184 lines
5.3 KiB
Text

# Note that this is equivalent to postmarketos-stable with the kernel config from Arch Linux.
# TODO: Merge the two packages so that the teclast-x80pro is on actual mainline/stable kernel.
# The default QEMU kernel config is missing too many options to allow it to boot on a real x86_64 platform.
_flavor=teclast-x80pro
_hash="7b6fbfd899b4133e4f789843e5967beb139ec4d2"
_config="config-${_flavor}.${CARCH}"
pkgname=linux-${_flavor}
pkgver=4.14.73
case $pkgver in
*.*.*) _kernver=${pkgver%.*};;
*.*) _kernver=$pkgver;;
esac
pkgrel=4
arch="x86_64"
pkgdesc="Linux for pmOS supported chipsets (stable)"
url="https://kernel.org/"
depends=""
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev openssl-dev"
options="!strip !check !tracedeps"
install=
source="
https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz
config-${_flavor}.x86_64
"
if [ "${pkgver%.0}" = "$pkgver" ]; then
source="$source
https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz"
fi
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
# Compiler: latest GCC from Alpine
HOSTCC="${CC:-gcc}"
HOSTCC="${HOSTCC#${CROSS_COMPILE}}"
ksrcdir="$srcdir/linux-$_kernver"
prepare() {
local _patch_failed=
cd "$ksrcdir"
if [ "$_kernver" != "$pkgver" ]; then
msg "Applying patch-$pkgver.xz"
unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N
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
# Remove -Werror from all makefiles
local i
local makefiles="$(find . -type f -name Makefile)
$(find . -type f -name Kbuild)"
for i in $makefiles; do
sed -i 's/-Werror-/-W/g' "$i"
sed -i 's/-Werror//g' "$i"
done
mkdir -p "$srcdir"/build
cp -v "$srcdir"/$_config "$srcdir"/build/.config
make -C "$ksrcdir" 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 ))-postmarketOS" \
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,
# 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 "$srcdir"/linux-$_kernver 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 "$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' \) \
-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="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8 linux-4.14.tar.xz
ae6d0f701c86629e6bd77ab4361a9cf5947b1ecd1c990b13f9b8bf6ea7de3c3c7009e417b9281acf64fce56015e885acf0b0318ee5ff44795d0da1ada575b771 config-teclast-x80pro.x86_64
d509365295b6bb5ad55d8859a6cc7cae00ef7b7b34aef21167fcfc992accbf9ac1f4191446c911b55844b09ff0c7f83fd422aea71c2877521331b7b0e05a9205 patch-4.14.73.xz"