Commit 27e9507d authored by Dennis Krupenik's avatar Dennis Krupenik

linux-custom

parent 6f05b3fe
# Maintainer: Dennis Krupenik <dennis@krupenik.com>
pkgname=linux-custom
# NOTE: this kernel is intended for testing
# please resist urge to upgrade it blindly
pkgver=5.11.6
case $pkgver in
*.*.*) _kernver=${pkgver%.*};;
*.*) _kernver=$pkgver;;
esac
pkgrel=0
pkgdesc="Linux latest stable kernel"
url="https://www.kernel.org"
depends=""
depends_dev="perl gmp-dev elfutils-dev bash flex bison"
makedepends="$depends_dev sed installkernel bc linux-headers linux-firmware-any openssl-dev diffutils findutils"
options="!strip"
subpackages="$pkgname-dev"
source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz config"
case $pkgver in
*.*.0) source="$source";;
*.*.*) source="$source https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz" ;;
esac
arch="x86_64"
license="GPL-2.0"
prepare() {
local _patch_failed=
cd "$srcdir"/linux-$_kernver
case $pkgver in
*.*.0);;
*)
msg "Applying patch-$pkgver.xz"
unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N ;;
esac
# 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() {
mkdir -p "$builddir"
cp "$srcdir"/config "$builddir"/.config
make -C "$srcdir"/linux-$_kernver O="$builddir" listnewconfig oldconfig
}
build() {
unset LDFLAGS
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
cd "$builddir"
nice make CC="${CC:-gcc}" -j"$(nproc)"
}
package() {
depends="$depends linux-firmware-any"
local _abi_release=${pkgver}-${pkgrel}-custom
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
cd "$builddir"
mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules
make -j1 modules_install install INSTALL_MOD_PATH="$pkgdir" INSTALL_PATH="$pkgdir"/boot
rm -f "$pkgdir"/lib/modules/${_abi_release}/build "$pkgdir"/lib/modules/${_abi_release}/source
rm -rf "$pkgdir"/lib/firmware
install -D include/config/kernel.release "$pkgdir"/usr/share/kernel/custom/kernel.release
}
dev() {
local _abi_release=${pkgver}-${pkgrel}-custom
# 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 custom 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 "$dir"/.config
make -j1 -C "$srcdir"/linux-$_kernver O="$dir" 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' -o -name 'Platform' \) \
-print | cpio -pdm "$dir"
cp -a scripts include "$dir"
find $(find arch -name include -type d -print) -type f | cpio -pdm "$dir"
install -Dm644 "$builddir"/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="a567ec133018bb5ec00c60281479b466c26e02137a93a9c690e83997947df02b6fd94e76e8df748f6d70ceb58a19bacc3b1467de10b7a1fad2763db32b3f1330 linux-5.11.tar.xz
59ae960f0ce1362b5a7955338d7b2f8a56195e13f1f2660d7669f28ba3e613c47dfd2e5288215a009786488903f93b8b7c5fc7b7b7014ac30cce011bd882c03d config
240a4aea2982963e96dd9a4714c7385dfaafb2adf8bcc8354038230e43cbf79fa244337aa4d40106cc8ecdf19cc069b4517ab5538a962b9a5126338de4813b7b patch-5.11.6.xz"
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment