183 lines
5 KiB
Text
183 lines
5 KiB
Text
|
# APKBUILD loosely based on linux-vanilla aport. Changes:
|
||
|
#
|
||
|
# - Use new kernel config for the postmarketos device support
|
||
|
# - Package the device tree files
|
||
|
#
|
||
|
# Kernel config based on: arch/arm/configs/lineageos_mako_defconfig
|
||
|
# Changes:
|
||
|
# - enable devtmpfs (needed for udev -> touch support in weston)
|
||
|
|
||
|
_flavor=postmarketos
|
||
|
_hash="7b6fbfd899b4133e4f789843e5967beb139ec4d2"
|
||
|
_config="config-${_flavor}.${CARCH}"
|
||
|
|
||
|
pkgname=linux-${_flavor}
|
||
|
|
||
|
pkgver=4.12.3
|
||
|
case $pkgver in
|
||
|
*.*.*) _kernver=${pkgver%.*};;
|
||
|
*.*) _kernver=$pkgver;;
|
||
|
esac
|
||
|
pkgrel=1
|
||
|
|
||
|
arch="all"
|
||
|
pkgdesc="Mainline Linux for pmOS supported chipsets (OMAP)"
|
||
|
url="https://kernel.org/"
|
||
|
depends="postmarketos-mkinitfs"
|
||
|
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev"
|
||
|
options="!strip !check !tracedeps"
|
||
|
install=
|
||
|
source="
|
||
|
https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz
|
||
|
config-${_flavor}.armhf
|
||
|
config-${_flavor}.x86_64
|
||
|
"
|
||
|
subpackages="$pkgname-dev::$CBUILD_ARCH"
|
||
|
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}}"
|
||
|
|
||
|
ksrcdir="$srcdir/linux-$_kernver"
|
||
|
|
||
|
prepare() {
|
||
|
local _patch_failed=
|
||
|
cd "$ksrcdir"
|
||
|
|
||
|
# 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 -v "$srcdir"/$_config "$srcdir"/build/.config || return 1
|
||
|
make -C "$ksrcdir" 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
|
||
|
unset LDFLAGS
|
||
|
make ARCH="$_carch" CC="${CC:-gcc}" \
|
||
|
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \
|
||
|
CFLAGS_MODULE=-fno-pic \
|
||
|
|| return 1
|
||
|
}
|
||
|
|
||
|
package() {
|
||
|
cd "$srcdir/build/arch/${_carch}/boot"
|
||
|
|
||
|
install -Dm644 "$srcdir/build/arch/${_carch}/boot/"*zImage \
|
||
|
"$pkgdir/boot/vmlinuz-$_flavor"
|
||
|
|
||
|
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" \
|
||
|
|| return 1
|
||
|
|
||
|
if [ -d "$pkgdir/arch/${_carch}/boot/dts" ]; then
|
||
|
mv "$pkgdir/arch/${_carch}/boot/dts" "$pkgdir/usr/share"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
|
||
|
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 "$srcdir"/linux-$_kernver O="$dir" ARCH="$_carch" HOSTCC="$HOSTCC" \
|
||
|
silentoldconfig 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 "$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" || return 1
|
||
|
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="8e81b41b253e63233e92948941f44c6482acb52aa3a3fd172f03a38a86f2c35b2ad4fd407acd1bc3964673eba344fe104d3a03e3ff4bf9cd1f22bd44263bd728 linux-4.12.tar.xz
|
||
|
3f4435ce0cf227e4ba64aa7153c913370c53069e34a376e453786d601b5a73706a3f44b002fab1b10a72dc94e896c1d8fb462c2b78e62ed69c468d98aa7220da config-postmarketos.armhf
|
||
|
a657c7fe0ebd5deba7c335ef8536d15edfdfb112dd4078d41710cad8db17cb86b88879b144d3ca34dddceb1ec841f65a4842a0ef0ae9dc48980eeeffc8545efa config-postmarketos.x86_64"
|