diff options
Diffstat (limited to 'main/linux-lts/APKBUILD')
-rw-r--r-- | main/linux-lts/APKBUILD | 241 |
1 files changed, 241 insertions, 0 deletions
diff --git a/main/linux-lts/APKBUILD b/main/linux-lts/APKBUILD new file mode 100644 index 0000000000..1a4994da19 --- /dev/null +++ b/main/linux-lts/APKBUILD @@ -0,0 +1,241 @@ +# Maintainer: Natanael Copa <ncopa@alpinelinux.org> + +_flavor=lts +pkgname=linux-${_flavor} +pkgver=5.4.2 +case $pkgver in + *.*.*) _kernver=${pkgver%.*};; + *.*) _kernver=$pkgver;; +esac +pkgrel=0 +pkgdesc="Linux lts kernel" +url="http://kernel.org" +depends="mkinitfs" +_depends_dev="perl gmp-dev elfutils-dev bash flex bison" +makedepends="$_depends_dev sed installkernel bc linux-headers linux-firmware-any openssl-dev + diffutils" +options="!strip" +_config=${config:-config-lts.${CARCH}} +install= +source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz + config-lts.aarch64 + config-lts.armv7 + config-lts.x86 + config-lts.x86_64 + config-lts.ppc64le + config-lts.s390x + + config-virt.aarch64 + config-virt.x86 + config-virt.x86_64 + " +subpackages="$pkgname-dev:_dev:$CBUILD_ARCH" +_flavors= +for _i in $source; do + case $_i in + config-*.$CARCH) + _f=${_i%.$CARCH} + _f=${_f#config-} + _flavors="$_flavors ${_f}" + if [ "linux-$_f" != "$pkgname" ]; then + subpackages="$subpackages linux-${_f}::$CBUILD_ARCH linux-${_f}-dev:_dev:$CBUILD_ARCH" + fi + ;; + esac +done + +if [ "${pkgver%.0}" = "$pkgver" ]; then + source="$source + https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz" +fi +arch="all !armhf" +license="GPL-2.0" + +_carch=${CARCH} +case "$_carch" in +aarch64*) _carch="arm64" ;; +arm*) _carch="arm" ;; +mips*) _carch="mips" ;; +ppc*) _carch="powerpc" ;; +s390*) _carch="s390" ;; +esac + +HOSTCC="${CC:-gcc}" +HOSTCC="${HOSTCC#${CROSS_COMPILE}}" + +prepare() { + local _patch_failed= + cd "$srcdir"/linux-$_kernver + 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 localversion from patch if any + rm -f localversion* + oldconfig +} + +oldconfig() { + for i in $_flavors; do + local _config=config-$i.${CARCH} + local _builddir="$srcdir"/build-$i.$CARCH + mkdir -p "$_builddir" + echo "-$pkgrel-$i" > "$_builddir"/localversion-alpine \ + || return 1 + + cp "$srcdir"/$_config "$_builddir"/.config + make -C "$srcdir"/linux-$_kernver \ + O="$_builddir" \ + ARCH="$_carch" HOSTCC="$HOSTCC" \ + listnewconfig oldconfig + done +} + +build() { + unset LDFLAGS + export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" + for i in $_flavors; do + cd "$srcdir"/build-$i.$CARCH + make ARCH="$_carch" CC="${CC:-gcc}" \ + KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" + done +} + +_package() { + local _buildflavor="$1" _outdir="$2" + local _abi_release=${pkgver}-${pkgrel}-${_buildflavor} + export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" + + cd "$srcdir"/build-$_buildflavor.$CARCH + # modules_install seems to regenerate a defect Modules.symvers on s390x. Work + # around it by backing it up and restore it after modules_install + cp Module.symvers Module.symvers.backup + + mkdir -p "$_outdir"/boot "$_outdir"/lib/modules + + local _install + case "$CARCH" in + arm*) + local _dtbdir="$_outdir"/boot/dtbs + mkdir -p "$_dtbdir" + for i in arch/arm/boot/dts/*.dtb ; do + install -m644 "$i" "$_dtbdir" + done + + _install=zinstall + ;; + *) + _install=install + ;; + esac + + make -j1 modules_install $_install \ + ARCH="$_carch" \ + INSTALL_MOD_PATH="$_outdir" \ + INSTALL_PATH="$_outdir"/boot + + cp Module.symvers.backup Module.symvers + + rm -f "$_outdir"/lib/modules/${_abi_release}/build \ + "$_outdir"/lib/modules/${_abi_release}/source + rm -rf "$_outdir"/lib/firmware + + install -D include/config/kernel.release \ + "$_outdir"/usr/share/kernel/$_buildflavor/kernel.release +} + +# main flavor installs in $pkgdir +package() { + depends="$depends linux-firmware-any" + + _package lts "$pkgdir" +} + +# subflavors install in $subpkgdir +virt() { + _package virt "$subpkgdir" +} + +_dev() { + local _flavor=$(echo $subpkgname | sed -E 's/(^linux-|-dev$)//g') + local _abi_release=${pkgver}-${pkgrel}-$_flavor + # 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 $_flavor kernel" + depends="$_depends_dev" + local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release} + export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" + + # first we import config, run prepare to set up for building + # external modules, and create the scripts + mkdir -p "$dir" + cp "$srcdir"/config-$_flavor.${CARCH} "$dir"/.config + echo "-$pkgrel-$_flavor" > "$dir"/localversion-alpine + + make -j1 -C "$srcdir"/linux-$_kernver O="$dir" ARCH="$_carch" HOSTCC="$HOSTCC" \ + syncconfig prepare modules_prepare scripts + + # 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-$_flavor.$CARCH/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="9f60f77e8ab972b9438ac648bed17551c8491d6585a5e85f694b2eaa4c623fbc61eb18419b2656b6795eac5deec0edaa04547fc6723fbda52256bd7f3486898f linux-5.4.tar.xz +9c7299179f5bd4cb445c39d2c16c4a8aa555e7c802a5b009cb4ed25aa6af9ce308f4d615e623612c97e6011010ebcbae22620d079504a28611bfda25d6ab370a config-lts.aarch64 +f3e890fcfa8378c07996b28c4bbc04c15bb310c444c7299e542308195f1494689e129047e9b3a72a1f21d22ee07719573f57541238568ab9dfae0193e5f6bbf4 config-lts.armv7 +9b5ebd87496bb121bcea14331e553dbb1d197f3091f958b3e961a07ba68ece7255bb12226bf86c5b82ec7a568c2e71d383af13a2264695cbe6c88d1664dd643c config-lts.x86 +bd815deb587c19be72c5221a4c3573f11e0c4950b8d97aa507c798b680ba1733ccb3f82e6934b85876f7cf94bc1cd3580091e6c2575f750c90eafc9357597519 config-lts.x86_64 +a158573b244f80d0660690efced7e0a5a56c28352700f3ae171b23b0952272369837c5046512159ba3474ef46cc33da953f127fa50014b66db9cb6e63cc44d68 config-lts.ppc64le +f46c885f5325b698c86057f1c1286d76ec2b41ac9d20b36dcdbb88c55722b848c9ab52d0b9605f5f6e0588df34f4f223f0da420c3ee90127052c176e2ff2fc93 config-lts.s390x +ad13aef539f8abfdb861d4d2c75ee517270d500013f77e69a104c82c0a4e8d712fabe7ef41ae96a4d7996ab2a8159e4d35f36be20bc7579f3249b13bd8a12525 config-virt.aarch64 +b4daedb6b96e77e40cf87d83a49acdf27aa8ae37f57e40dedf929336cbb28a173bea444a3b43b54bdcbe9822ef84e3fa92019993c419510911b2477c680dddab config-virt.x86 +c7f558fefa928a9ae87b3be9cfa8742f54533a9c7c7e721acd72131fcb8513d1763597ccd9fbc3a0af50d3ec880e0ecb733f4d18c9b550cda415d9c7fa657e2f config-virt.x86_64 +aba07d75524ad33cd014700a1317c450fe4ea02817dc225848187fa2a353a215011d3ab485d1900796e0797b8c145bbbf10d706ab45784cc9413dbbc96889041 patch-5.4.2.xz" |