Untitled Diff

Created Diff never expires
56 removals
198 lines
215 additions
351 lines
# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Piotr Gorski <lucjan.lucjanov@gmail.com>
# Maintainer: Joakim Hernberg <jbh@alchemy.lu>
# Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Thomas Baechler <thomas@archlinux.org>

### BUILD OPTIONS
# Set these variables to ANYTHING that is not null to enable them

### Tweak kernel options prior to a build via nconfig
_makenconfig=

### Tweak kernel options prior to a build via menuconfig
_makemenuconfig=

### Tweak kernel options prior to a build via xconfig
_makexconfig=

### Tweak kernel options prior to a build via gconfig
_makegconfig=

### Running with a 1000 HZ tick rate
_1k_HZ_ticks=y

# NUMA is optimized for multi-socket motherboards.
# A single multi-core CPU actually runs slower with NUMA enabled.
# See, https://bugs.archlinux.org/task/31187
_NUMAdisable=y

# Compile ONLY used modules to VASTLYreduce the number of modules built
# and the build time.
#
# To keep track of which modules are needed for your specific system/hardware,
# give module_db script a try: https://aur.archlinux.org/packages/modprobed-db
# This PKGBUILD read the database kept if it exists
#
# More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed-db
_localmodcfg=

# Use the current kernel's .config file
# Enabling this option will use the .config of the RUNNING kernel rather than
# the ARCH defaults. Useful when the package gets updated and you already went
# through the trouble of customizing your config options. NOT recommended when
# a new kernel is released, but again, convenient for package bumps.
_use_current=


pkgbase=linux-rt
### Do not edit below this line unless you know what you're doing
pkgver=5.11.4.11.arch1

pkgrel=1
pkgbase=linux-rt-bfq-dev
pkgdesc='Linux RT'
# pkgname=('linux-rt-bfq-dev' 'linux-rt-bfq-dev-headers' 'linux-rt-bfq-dev-docs')
_major=5.11
_minor=4
_rtver=11
_rtpatchver=rt${_rtver}
pkgver=${_major}.${_minor}.${_rtpatchver}
_pkgver=${_major}.${_minor}
_srcname=linux-${_pkgver}
pkgrel=13
pkgdesc='Linux RT-BFQ-dev'
arch=('x86_64')
arch=('x86_64')
url="https://wiki.linuxfoundation.org/realtime/start"
url="https://github.com/sirlucjan/bfq-mq-lucjan"
license=('GPL2')
license=('GPL2')
makedepends=('bc' 'git' 'graphviz' 'imagemagick' 'kmod' 'libelf' 'pahole'
'python-sphinx' 'python-sphinx_rtd_theme' 'xmlto')
options=('!strip')
options=('!strip')
source=(
makedepends=('kmod' 'bc' 'libelf' 'python-sphinx' 'python-sphinx_rtd_theme'
"git+https://gitlab.archlinux.org/dvzrv/linux-rt#tag=v${pkgver}?signed"
'graphviz' 'imagemagick' 'pahole' 'cpio' 'perl' 'tar' 'xz')
config
#_lucjanpath="https://raw.githubusercontent.com/sirlucjan/kernel-patches/master/${_major}"
)
_lucjanpath="https://gitlab.com/sirlucjan/kernel-patches/raw/master/${_major}"
sha512sums=('SKIP'
# Some patches for BFQ conflict with patches for BFQ-dev.
'977ac2ff9c344619758aa30aeb1c9fd6ad2777c99774a5a2b6956cd85c38640a00a4f292a53195fca15e645e2cba3bb725a4d0ca043b3a03261d456504512824')
# To use linux-bfq-dev smoothly apply bfq-reverts before bfq-dev patch.
b2sums=('SKIP'
# Otherwise the kernel will not compile.
'56cd37f1ac075db2cd4b30a9bb2bedcb0a9c4648cc23e408a121a529d090b894c7e919b9ea996e30ca23f559fde6172594935af3083e69ce5e1c62719e3658fa')
#_bfq_rev_path="bfq-reverts-all"
validpgpkeys=(
#_bfq_rev_patch="0001-bfq-reverts.patch"
'647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman <gregkh@kernel.org>
#_bfq_path="bfq-dev-lucjan"
'64254695FFF0AA4466CC19E67B96E8162A8CF5D1' # Sebastian Andrzej Siewior
#_bfq_ver="v14"
'C7E7849466FE2358343588377258734B41C31549' # David Runge <dvzrv@archlinux.org>
#_bfq_rel="r2K210223"
)
#_bfq_patch="${_major}-${_bfq_path}-${_bfq_ver}-${_bfq_rel}.patch"
_bfq_path="bfq-lucjan"
_bfq_rel="r2K210325"
_bfq_patch="${_major}-${_bfq_path}-${_bfq_rel}.patch"
_gcc_path="cpu-patches-v4-sep"
_gcc_patch="0001-cpu-${_major}-merge-graysky-s-patchset.patch"

source=("https://www.kernel.org/pub/linux/kernel/v5.x/${_srcname}.tar.xz"
"https://www.kernel.org/pub/linux/kernel/v5.x/${_srcname}.tar.sign"
"http://www.kernel.org/pub/linux/kernel/projects/rt/${_major}/patch-${_pkgver}-${_rtpatchver}.patch.xz"
"http://www.kernel.org/pub/linux/kernel/projects/rt/${_major}/patch-${_pkgver}-${_rtpatchver}.patch.sign"
#"${_lucjanpath}/${_bfq_rev_path}/${_bfq_rev_patch}"
"${_lucjanpath}/${_bfq_path}/${_bfq_patch}"
"${_lucjanpath}/${_gcc_path}/${_gcc_patch}"
"${_lucjanpath}/arch-patches-v9/0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch"
# the main kernel config files
'config')


export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase
export KBUILD_BUILD_USER=$pkgbase
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"


prepare() {
prepare() {
cd "${pkgbase}"
cd $_srcname

### Add rt patch
echo "Add rt patch"
patch -Np1 -i ../patch-${_pkgver}-${_rtpatchver}.patch

### Setting version
echo "Setting version..."
scripts/setlocalversion --save-scmversion
echo "-$pkgrel" > localversion.10-pkgrel
echo "${pkgbase#linux}" > localversion.20-pkgname

### Patching sources
local src
for src in "${source[@]}"; do
src="${src%%::*}"
src="${src##*/}"
[[ $src = *.patch ]] || continue
echo "Applying patch $src..."
patch -Np1 < "../$src"
done

### Setting config
echo "Setting config..."
cp ../config .config
make olddefconfig


echo "Setting version..."
### Prepared version
scripts/setlocalversion --save-scmversion
make -s kernelrelease > version
echo "-$pkgrel" > localversion.10-pkgrel
echo "Prepared $pkgbase version $(<version)"
echo "${pkgbase#linux}" > localversion.20-pkgname


local src
### Optionally use running kernel's config
for src in "${source[@]}"; do
# code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
src="${src%%::*}"
if [ -n "$_use_current" ]; then
src="${src##*/}"
if [[ -s /proc/config.gz ]]; then
# picking up the RT patch
echo "Extracting config from /proc/config.gz..."
src="${src//patch.xz/patch}"
# modprobe configs
[[ $src = *.patch ]] || continue
zcat /proc/config.gz > ./.config
echo "Applying patch $src..."
else
patch -Np1 < "../$src"
warning "Your kernel was not compiled with IKCONFIG_PROC!"
done
warning "You cannot read the current config!"
warning "Aborting!"
exit
fi
fi


echo "Setting config..."
### Optionally set tickrate to 1000
cp ../config .config
if [ -n "$_1k_HZ_ticks" ]; then
make olddefconfig
echo "Setting tick rate to 1k..."
# make nconfig
scripts/config --disable CONFIG_HZ_300
scripts/config --enable CONFIG_HZ_1000
scripts/config --set-val CONFIG_HZ 1000
fi

### Optionally disable NUMA for 64-bit kernels only
# (x86 kernels do not support NUMA)
if [ -n "$_NUMAdisable" ]; then
echo "Disabling NUMA from kernel config..."
scripts/config --disable CONFIG_NUMA
fi

### Optionally load needed modules for the make localmodconfig
# See https://aur.archlinux.org/packages/modprobed-db
if [ -n "$_localmodcfg" ]; then
if [ -f $HOME/.config/modprobed.db ]; then
echo "Running Steven Rostedt's make localmodconfig now"
make LSMOD=$HOME/.config/modprobed.db localmodconfig
else
echo "No modprobed.db data found"
exit
fi
fi


make -s kernelrelease > version
### Running make nconfig
echo "Prepared $pkgbase version $(<version)"
[[ -z "$_makenconfig" ]] || make nconfig

### Running make menuconfig
[[ -z "$_makemenuconfig" ]] || make menuconfig

### Running make xconfig
[[ -z "$_makexconfig" ]] || make xconfig

### Running make gconfig
[[ -z "$_makegconfig" ]] || make gconfig

### Save configuration for later reuse
cat .config > "${startdir}/config.last"
}
}


build() {
build() {
cd "${pkgbase}"
cd $_srcname

make all
make all
make htmldocs
make htmldocs
}
}


_package() {
_package() {
pkgdesc="The $pkgdesc kernel and modules"
pkgdesc="The $pkgdesc kernel and modules"
depends=(coreutils initramfs kmod)
depends=('coreutils' 'kmod' 'initramfs')
optdepends=('crda: to set the correct wireless channels of your country'
optdepends=('crda: to set the correct wireless channels of your country'
'linux-firmware: firmware images needed for some devices')
'linux-firmware: firmware images needed for some devices'
provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
'modprobed-db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig')
provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE linux-rt-bfq)
replaces=('linux-rt-bfq')
conflicts=('linux-rt-bfq')


cd "${pkgbase}"
cd $_srcname
local kernver="$(<version)"
local kernver="$(<version)"
local modulesdir="$pkgdir/usr/lib/modules/$kernver"
local modulesdir="$pkgdir/usr/lib/modules/$kernver"


echo "Installing boot image..."
echo "Installing boot image..."
# systemd expects to find the kernel here to allow hibernation
# systemd expects to find the kernel here to allow hibernation
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"


# Used by mkinitcpio to name the kernel
# Used by mkinitcpio to name the kernel
echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"


echo "Installing modules..."
echo "Installing modules..."
make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install


# remove build and source links
# remove build and source links
rm "$modulesdir"/{source,build}
rm "$modulesdir"/{source,build}
}
}


_package-headers() {
_package-headers() {
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
depends=(pahole)
depends=('linux-rt-bfq-dev' 'pahole')
replaces=('linux-rt-bfq-headers')
conflicts=('linux-rt-bfq-headers')
provides=('linux-rt-bfq-headers')


cd "${pkgbase}"
cd $_srcname
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"


echo "Installing build files..."
echo "Installing build files..."
install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
localversion.* version vmlinux
localversion.* version vmlinux
install -Dt "$builddir/kernel" -m644 kernel/Makefile
install -Dt "$builddir/kernel" -m644 kernel/Makefile
install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
cp -t "$builddir" -a scripts
cp -t "$builddir" -a scripts


# add objtool for external module building and enabled VALIDATION_STACK option
# add objtool for external module building and enabled VALIDATION_STACK option
install -Dt "$builddir/tools/objtool" tools/objtool/objtool
install -Dt "$builddir/tools/objtool" tools/objtool/objtool


# add xfs and shmem for aufs building
# add xfs and shmem for aufs building
mkdir -p "$builddir"/{fs/xfs,mm}
mkdir -p "$builddir"/{fs/xfs,mm}


echo "Installing headers..."
echo "Installing headers..."
cp -t "$builddir" -a include
cp -t "$builddir" -a include
cp -t "$builddir/arch/x86" -a arch/x86/include
cp -t "$builddir/arch/x86" -a arch/x86/include
install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s


install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h


# http://bugs.archlinux.org/task/13146
# http://bugs.archlinux.org/task/13146
install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h


# http://bugs.archlinux.org/task/20402
# http://bugs.archlinux.org/task/20402
install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h


echo "Installing KConfig files..."
echo "Installing KConfig files..."
find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;


echo "Removing unneeded architectures..."
echo "Removing unneeded architectures..."
local arch
local arch
for arch in "$builddir"/arch/*/; do
for arch in "$builddir"/arch/*/; do
[[ $arch = */x86/ ]] && continue
[[ $arch = */x86/ ]] && continue
echo "Removing $(basename "$arch")"
echo "Removing $(basename "$arch")"
rm -r "$arch"
rm -r "$arch"
done
done


echo "Removing documentation..."
echo "Removing documentation..."
rm -r "$builddir/Documentation"
rm -r "$builddir/Documentation"


echo "Removing broken symlinks..."
echo "Removing broken symlinks..."
find -L "$builddir" -type l -printf 'Removing %P\n' -delete
find -L "$builddir" -type l -printf 'Removing %P\n' -delete


echo "Removing loose objects..."
echo "Removing loose objects..."
find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete


echo "Stripping build tools..."
echo "Stripping build tools..."
local file
local file
while read -rd '' file; do
while read -rd '' file; do
case "$(file -bi "$file")" in
case "$(file -bi "$file")" in
application/x-sharedlib\;*) # Libraries (.so)
application/x-sharedlib\;*) # Libraries (.so)
strip -v $STRIP_SHARED "$file" ;;
strip -v $STRIP_SHARED "$file" ;;
application/x-archive\;*) # Libraries (.a)
application/x-archive\;*) # Libraries (.a)
strip -v $STRIP_STATIC "$file" ;;
strip -v $STRIP_STATIC "$file" ;;
application/x-executable\;*) # Binaries
application/x-executable\;*) # Binaries
strip -v $STRIP_BINARIES "$file" ;;
strip -v $STRIP_BINARIES "$file" ;;
application/x-pie-executable\;*) # Relocatable binaries
application/x-pie-executable\;*) # Relocatable binaries
strip -v $STRIP_SHARED "$file" ;;
strip -v $STRIP_SHARED "$file" ;;
esac
esac
done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)


echo "Stripping vmlinux..."
echo "Stripping vmlinux..."
strip -v $STRIP_STATIC "$builddir/vmlinux"
strip -v $STRIP_STATIC "$builddir/vmlinux"


echo "Adding symlink..."
echo "Adding symlink..."
mkdir -p "$pkgdir/usr/src"
mkdir -p "$pkgdir/usr/src"
ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
}
}


_package-docs() {
_package-docs() {
pkgdesc="Documentation for the $pkgdesc kernel"
pkgdesc="Documentation for the $pkgdesc kernel"
depends=('linux-rt-bfq-dev')
replaces=('linux-rt-bfq-docs')
conflicts=('linux-rt-bfq-docs')
provides=('linux-rt-bfq-docs')


cd "${pkgbase}"
cd $_srcname
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"


echo "Installing documentation..."
echo "Installing documentation..."
local src dst
local src dst
while read -rd '' src; do
while read -rd '' src; do
dst="${src#Documentation/}"
dst="${src#Documentation/}"
dst="$builddir/Documentation/${dst#output/}"
dst="$builddir/Documentation/${dst#output/}"
install -Dm644 "$src" "$dst"
install -Dm644 "$src" "$dst"
done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
done < <(find Documentation -name '.*' -prune -o ! -type d -print0)


echo "Adding symlink..."
echo "Adding symlink..."
mkdir -p "$pkgdir/usr/share/doc"
mkdir -p "$pkgdir/usr/share/doc"
ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
}
}


pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
for _p in "${pkgname[@]}"; do
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
$(declare -f "_package${_p#$pkgbase}")
_package${_p#$pkgbase}
_package${_p#$pkgbase}
}"
}"
done
done


# vim:set ts=8 sts=2 sw=2 et:
sha512sums=('69bf72b99b0ef55cb9cd8c37bc9670e0dc7d97ab1f5b9f7edd2c161e8489d3aac43eeb23fd52f32fb78a627dc74fbaeaeb7df63bf93420f5ae588fe9f457e98e'
'SKIP'
'e37ebf7e6c0f669f35bbc96bbbb096ae37541aeb65c540caa1201fcc11ebd7b7cca1a6a5f42b92e1da4040c92f882fb7830d054051d5b37a7b178a2de5ca3e24'
'SKIP'
'64a5b940cac72be8fc50c3feb93550e1da140df4708fe70da15a39c304021707d5638be6b75c7077a2ca56637025dfed50f00919972eafd270be59ba6c079312'
'08ba50a763f71267215ebf00f136edf68c63aa8afa362c30d6b06fbf38d5cd03c4300165eebb9db9571e7c47150eaa6efbbb7a7f53053b05570cb11f3b4a8303'
'14b28af9ba68e82aaba77a7a857f8ba5d71f862f6d008fcd416e455f0dcca61c51d3ad0ec4867c06e0bb273a6a28b50f07f20552acc1ed46aead8a1dc09bba22'
'105c632754bf9a8cffd3c90680d5d1eac4e597746df442df65033d1598d57ec250ce95637908e1e7af9fe6a46d5c0515494893678808a8247b9320f3f9a4fe77')

validpgpkeys=(
'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
'647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
'64254695FFF0AA4466CC19E67B96E8162A8CF5D1' # Sebastian Andrzej Siewior
'5ED9A48FC54C0A22D1D0804CEBC26CDB5A56DE73' # Steven Rostedt
'E644E2F1D45FA0B2EAA02F33109F098506FF0B14' # Thomas Gleixner
)