bbf3e19294
[ci:skip-build]: Takes more than an hour to build on CI. Signed-off-by: Danct12 <danct12@disroot.org>
175 lines
5.2 KiB
Text
175 lines
5.2 KiB
Text
_flavor=postmarketos-stable
|
|
_hash="7b6fbfd899b4133e4f789843e5967beb139ec4d2"
|
|
_config="config-${_flavor}.${CARCH}"
|
|
|
|
pkgname=linux-${_flavor}
|
|
|
|
pkgver=5.1.5
|
|
case $pkgver in
|
|
*.*.*) _kernver=${pkgver%.*};;
|
|
*.*) _kernver=$pkgver;;
|
|
esac
|
|
pkgrel=0
|
|
|
|
arch="x86_64 armv7 aarch64"
|
|
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 file bison flex"
|
|
options="!strip !check !tracedeps"
|
|
install=
|
|
source="
|
|
https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz
|
|
config-${_flavor}.armv7
|
|
config-${_flavor}.aarch64
|
|
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
|
|
|
|
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
|
|
|
|
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,
|
|
# 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" \
|
|
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 "$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="ae96f347badc95f1f3acf506c52b6cc23c0bd09ce8f4ce6705d4b4058b62593059bba1bc603c8d8b00a2f19131e7e56c31ac62b45883a346fa61d655e178f236 linux-5.1.tar.xz
|
|
a428ce2a9c65bae3e7f88a43b0112e2524298ba068cf85732b25f18c5f92d101089ab3589582050c0dc9fca3571ea7fb89f9398d0c9dede03f1754b3f5fe455c config-postmarketos-stable.armv7
|
|
b24240f2c8e011ffa1ff141cf8d623dcbe4cbde389322e59e264edf1b01985b3527576a06c1f0d8e5ef67519f95cc9a9ff9f2636178d00e4272cd472e268f1ec config-postmarketos-stable.aarch64
|
|
77ae0b80272d871475043cc17ae54e20d5456da8c729ea832906c2881389c53e4d800aaeab38090f3f878f15045b2c70dc4912b62742753c40f80ad69ed51599 config-postmarketos-stable.x86_64
|
|
793d61bbefe3587f95cf2b6eb56f3c60ef36512448ddcb1ab7c4fb614e14336e8d703f7cf188dfab46cb40d60511291b5163d2dae8c0bc950caeebd1e4e6c9c2 patch-5.1.5.xz"
|