linux-cachyos/PKGBUILD

730 lines
27 KiB
Bash
Raw Normal View History

2021-10-12 20:31:02 +02:00
# Maintainer: Peter Jung ptr1337 <admin@ptr1337.dev>
2021-12-29 20:23:50 +01:00
# Contributor: Piotr Gorski <lucjan.lucjanov@gmail.com>
2021-11-08 20:16:56 +01:00
# Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Thomas Baechler <thomas@archlinux.org>
2021-10-12 20:31:02 +02:00
2021-12-29 20:23:50 +01:00
### Selecting the CPU scheduler
# ATTENTION - one of seven predefined values should be selected!
# 'bmq' - select 'BitMap Queue CPU scheduler'
# 'pds' - select 'Priority and Deadline based Skip list multiple queue CPU scheduler'
# 'cacule' - select 'CacULE scheduler'
# 'cacule-rdb' - select 'CacULE-RDB scheduler'
# 'bore' - select 'Burst-Oriented Response Enhancer'
# 'cfs' - select 'Completely Fair Scheduler'
2022-05-14 08:55:19 +02:00
_cpusched='bore'
2021-12-29 20:23:50 +01:00
2021-10-12 20:31:02 +02:00
### BUILD OPTIONS
2021-11-08 20:16:56 +01:00
# Set these variables to ANYTHING that is not null to enable them
### Tweak kernel options prior to a build via nconfig
2022-03-26 11:31:14 +01:00
_makenconfig=
2021-11-08 20:16:56 +01:00
2021-10-12 20:31:02 +02:00
# 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
2022-04-20 22:38:53 +02:00
_NUMAdisable=y
2021-10-12 20:31:02 +02:00
2021-11-08 20:16:56 +01:00
# 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=
2022-01-29 13:49:17 +01:00
### Enable KBUILD_CFLAGS -O3
_cc_harder=y
### Set performance governor as default
_per_gov=y
### Enable TCP_CONG_BBR2
_tcp_bbr2=y
2022-04-20 22:38:53 +02:00
### Running with a 1000HZ, 750Hz, 600 Hz or 500Hz tick rate
2022-05-09 10:28:34 +02:00
_HZ_ticks=750
2021-10-12 20:31:02 +02:00
2022-05-09 10:28:34 +02:00
## Choose between perodic, tickless idle or full tickless
### Full tickless can give higher performances in various cases but, depending on hardware, lower consistency.
2022-04-20 22:38:53 +02:00
_tickrate=full
2022-05-09 10:28:34 +02:00
## Choose between full(low-latency), voluntary or server
_preempt=voluntary
2021-10-12 20:31:02 +02:00
### Disable MQ-Deadline I/O scheduler
_mq_deadline_disable=y
### Disable Kyber I/O scheduler
_kyber_disable=y
### Enable multigenerational LRU
2021-12-10 22:55:20 +01:00
_lru_enable=y
2021-10-12 20:31:02 +02:00
2022-05-09 10:28:34 +02:00
## Enable DAMON
2022-05-23 00:56:40 +02:00
_damon=y
2021-11-18 20:08:11 +01:00
2022-05-09 10:28:34 +02:00
## enable SPECULATIVE_PAGE_FAULT
2022-03-28 17:07:54 +02:00
_spf_enable=y
2022-04-20 22:38:53 +02:00
2022-05-09 10:28:34 +02:00
## Enable Linux Random Number Generator
2021-10-12 20:31:02 +02:00
_lrng_enable=y
## Apply Kernel automatic Optimization
2022-05-23 00:56:40 +02:00
_use_auto_optimization=
2021-10-12 20:31:02 +02:00
## Apply Kernel Optimization selecting
2022-05-23 00:56:40 +02:00
_use_optimization_select=y
2021-10-12 20:31:02 +02:00
2022-05-26 13:59:24 +02:00
# disable debug to lower the size of the kernel
_disable_debug=y
2022-05-11 15:25:37 +02:00
## Enable zram/zswap ZSTD compression
2022-01-29 13:49:17 +01:00
_zstd_compression=y
2022-02-03 22:32:32 +01:00
_nf_cone=y
2021-10-12 20:31:02 +02:00
2022-04-20 22:38:53 +02:00
# Clang LTO mode, only available with the "llvm" compiler - options are "no", "full" or "thin".
# "full: uses 1 thread for Linking, slow and uses more memory, theoretically with the highest performance gains."
# "thin: uses multiple threads, faster and uses less memory, may have a lower runtime performance than Full."
2021-10-12 20:31:02 +02:00
_use_llvm_lto=
2022-04-27 16:26:04 +02:00
## Change the thin lto cachedir for fixing building several dkms modules including zfs
_thin_lto_cachedir=
2022-05-23 00:56:40 +02:00
# KCFI is a proposed forward-edge control-flow integrity scheme for
# Clang, which is more suitable for kernel use than the existing CFI
# scheme used by CONFIG_CFI_CLANG. KCFI doesn't require LTO, doesn't
# alter function references to point to a jump table, and won't break
# function address equality.
# ATTENTION!: you do need a patched llvm for the usage of kcfi,
# you can find a patched llvm-git in the cachyos-repo's.
# The packagename is called "llvm-kcfi"
_use_kcfi=
2021-10-12 20:31:02 +02:00
if [ -n "$_use_llvm_lto" ]; then
2022-05-11 15:27:46 +02:00
pkgbase=linux-cachyos-lto
2021-10-12 20:31:02 +02:00
else
2022-05-11 15:27:46 +02:00
pkgbase=linux-cachyos
2021-10-12 20:31:02 +02:00
fi
2022-05-23 00:56:40 +02:00
_major=5.18
2022-05-31 19:16:31 +02:00
_minor=1
2022-01-12 01:13:57 +01:00
#_minorc=$((_minor+1))
#_rcver=rc8
2021-11-08 20:16:56 +01:00
pkgver=${_major}.${_minor}
2022-05-31 19:16:31 +02:00
_stable=${_major}.${_minor}
#_stable=${_major}
2022-01-22 14:09:00 +01:00
#_stablerc=${_major}-${_rcver}
2022-03-28 17:07:54 +02:00
_srcname=linux-${_stable}
#_srcname=linux-${_major}
2021-10-12 20:31:02 +02:00
arch=(x86_64 x86_64_v3)
2022-05-14 08:55:19 +02:00
pkgdesc='Linux BORE scheduler Kernel by CachyOS with other patches and improvements'
2022-06-02 02:11:42 +02:00
pkgrel=4
2021-10-12 20:31:02 +02:00
arch=('x86_64' 'x86_64_v3')
url="https://github.com/CachyOS/linux-cachyos"
license=('GPL2')
options=('!strip')
2022-04-09 15:16:00 +02:00
makedepends=('bc' 'texlive-latexextra' 'libelf' 'pahole' 'cpio' 'perl' 'tar' 'xz' 'zstd' 'xmlto' 'git' 'gcc' 'gcc-libs' 'glibc' 'binutils' 'make' 'patch')
2021-12-29 20:23:50 +01:00
if [ -n "$_use_llvm_lto" ]; then
2022-05-11 15:25:37 +02:00
makedepends+=(clang llvm lld python)
2022-05-23 00:56:40 +02:00
BUILD_FLAGS=(
CC=clang
LD=ld.lld
LLVM=1
LLVM_IAS=1
)
2021-12-29 20:23:50 +01:00
fi
2022-04-19 19:40:20 +02:00
_patchsource="https://raw.githubusercontent.com/ptr1337/kernel-patches/master/${_major}"
2021-12-29 20:23:50 +01:00
source=(
2022-05-26 13:59:24 +02:00
"https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/${_srcname}.tar.xz"
"config")
2022-04-20 22:38:53 +02:00
if [ "$_cpusched" = "bmq" ]; then
2022-05-09 10:28:34 +02:00
source+=("${_patchsource}/sched/0001-prjc.patch")
2022-04-20 22:38:53 +02:00
fi
if [ "$_cpusched" = "pds" ]; then
2022-05-09 10:28:34 +02:00
source+=("${_patchsource}/sched/0001-prjc.patch")
2022-04-20 22:38:53 +02:00
fi
if [ "$_cpusched" = "cacule" ]; then
2022-05-23 00:56:40 +02:00
source+=("${_patchsource}/sched/0001-cacULE-5.18.patch")
2022-04-20 22:38:53 +02:00
fi
if [ "$_cpusched" = "cacule-rdb" ]; then
2022-05-23 00:56:40 +02:00
source+=("${_patchsource}/sched/0001-cacULE-5.18.patch")
2022-04-20 22:38:53 +02:00
fi
if [ "$_cpusched" = "bore" ]; then
2022-06-02 02:11:42 +02:00
source+=("${_patchsource}/sched/0001-bore-sched.patch"
"${_patchsource}/0001-migrate.patch")
fi
if [ "$_cpusched" = "cfs" ]; then
source+=("${_patchsource}/0001-migrate.patch")
2022-04-20 22:38:53 +02:00
fi
source+=(
2022-05-23 00:56:40 +02:00
"${_patchsource}/0001-amd-perf.patch"
2022-05-09 10:28:34 +02:00
"${_patchsource}/0001-arch.patch"
2022-05-23 00:56:40 +02:00
"${_patchsource}/0001-bbr2.patch"
"${_patchsource}/0001-cachy.patch"
"${_patchsource}/0001-clearlinux.patch"
"${_patchsource}/0001-cpu.patch"
"${_patchsource}/0001-Extend-DAMOS-for-Proactive-LRU-lists-Sorting.patch"
"${_patchsource}/0001-fixes.patch"
"${_patchsource}/0001-futex-winesync.patch"
"${_patchsource}/0001-hwmon.patch"
"${_patchsource}/0001-kbuild.patch"
"${_patchsource}/0001-lrng.patch"
"${_patchsource}/0001-lru-le9-spf.patch"
"${_patchsource}/0001-ksm.patch"
"${_patchsource}/0001-zram-entropy-calculation.patch"
2022-05-09 10:28:34 +02:00
"auto-cpu-optimization.sh"
2021-10-17 12:08:56 +02:00
)
2022-05-11 15:25:37 +02:00
2022-05-23 00:56:40 +02:00
if [ -n "$_use_kcfi" ]; then
source+=("${_patchsource}/0001-kcfi.patch")
depends+=(clang llvm lld python)
BUILD_FLAGS=(
CC=clang
LD=ld.lld
LLVM=1
)
2022-04-27 16:26:04 +02:00
fi
2021-10-12 20:31:02 +02:00
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
prepare() {
2021-11-08 20:16:56 +01:00
2022-05-09 10:28:34 +02:00
cd $_srcname
echo "Setting version..."
scripts/setlocalversion --save-scmversion
echo "-$pkgrel" > localversion.10-pkgrel
echo "${pkgbase#linux}" > localversion.20-pkgname
local src
for src in "${source[@]}"; do
src="${src%%::*}"
src="${src##*/}"
[[ $src = *.patch ]] || continue
echo "Applying patch $src..."
patch -Np1 < "../$src"
done
echo "Setting config..."
cp ../config .config
if [ -n "$_use_auto_optimization" ]; then
"${srcdir}"/auto-cpu-optimization.sh
2021-12-29 20:23:50 +01:00
fi
2022-01-29 13:49:17 +01:00
2022-05-09 10:28:34 +02:00
if [ -n "$_use_optimization_select" ]; then
source "${startdir}"/configure
cpu_arch
fi
### Selecting the CPU scheduler
if [ "$_cpusched" = "bmq" ]; then
echo "Selecting BMQ CPU scheduler..."
2022-05-11 15:25:37 +02:00
scripts/config --enable SCHED_ALT \
--enable SCHED_BMQ \
--disable SCHED_PDS
2022-05-09 10:28:34 +02:00
elif [ "$_cpusched" = "pds" ]; then
echo "Selecting PDS CPU scheduler..."
2022-05-11 15:25:37 +02:00
scripts/config --enable SCHED_ALT \
--disable SCHED_BMQ \
--enable SCHED_PDS
2022-05-09 10:28:34 +02:00
elif [ "$_cpusched" = "cacule" ]; then
echo "Selecting CacULE scheduler..."
2022-05-11 15:25:37 +02:00
scripts/config --enable CACULE_SCHED \
--disable CACULE_RDB
2022-05-09 10:28:34 +02:00
elif [ "$_cpusched" = "cacule-rdb" ]; then
echo "Selecting CacULE-RDB scheduler..."
2022-05-11 15:25:37 +02:00
scripts/config --enable CACULE_SCHED \
--enable CACULE_RDB \
--set-val RDB_INTERVAL 19
2022-05-09 10:28:34 +02:00
elif [ "$_cpusched" = "bore" ]; then
echo "Selecting BORE Scheduler..."
2022-05-11 15:25:37 +02:00
scripts/config --enable SCHED_BORE
2022-05-26 13:59:24 +02:00
elif [ "$_cpusched" = "tt" ]; then
echo "Selecting TT Scheduler..."
scripts/config --enable TT_SCHED
scripts/config --enable TT_ACCOUNTING_STATS
2022-05-09 10:28:34 +02:00
elif [ "$_cpusched" = "cfs" ]; then
echo "Selecting Completely Fair Scheduler..."
2021-10-17 12:08:56 +02:00
else
2022-05-09 10:28:34 +02:00
if [ -n "$_cpusched" ]; then
error "The value $_cpusched is invalid. Choose the correct one again."
else
error "The value is empty. Choose the correct one again."
fi
error "Selecting the CPU scheduler failed!"
exit
2021-10-17 12:08:56 +02:00
fi
2021-10-12 20:31:02 +02:00
2022-05-23 00:56:40 +02:00
if [ -n "$_use_kcfi" ]; then
echo "Enabling kCFI"
scripts/config --enable ARCH_SUPPORTS_CFI_CLANG \
--enable CFI_CLANG
fi
2022-01-22 14:09:00 +01:00
2022-05-09 10:28:34 +02:00
if [ "$_use_llvm_lto" = "thin" ]; then
echo "Enabling LLVM THIN LTO..."
scripts/config --disable LTO_NONE \
2022-05-11 15:25:37 +02:00
--enable LTO \
--enable LTO_CLANG \
--enable ARCH_SUPPORTS_LTO_CLANG \
--enable ARCH_SUPPORTS_LTO_CLANG_THIN \
--enable HAS_LTO_CLANG \
--enable LTO_CLANG_THIN \
--enable HAVE_GCC_PLUGINS
elif [ "$_use_llvm_lto" = "full" ]; then
2022-05-09 10:28:34 +02:00
echo "Enabling LLVM FULL LTO..."
scripts/config --disable LTO_NONE \
2022-05-11 15:25:37 +02:00
--enable LTO \
--enable LTO_CLANG \
--enable ARCH_SUPPORTS_LTO_CLANG \
--enable ARCH_SUPPORTS_LTO_CLANG_THIN \
--enable HAS_LTO_CLANG \
--enable LTO_CLANG \
--enable LTO_CLANG_FULL \
--enable HAVE_GCC_PLUGINS
2022-01-29 13:49:17 +01:00
else
2022-05-11 15:25:37 +02:00
scripts/config --enable LTO_NONE
2022-05-09 10:28:34 +02:00
fi
if [ "$_HZ_ticks" = "1000" ]; then
echo "Setting tick rate to 1k Hz..."
2022-05-11 15:25:37 +02:00
scripts/config --disable HZ_300 \
--enable HZ_1000 \
--set-val HZ 1000
2022-05-09 10:28:34 +02:00
elif [ "$_HZ_ticks" = "750" ]; then
echo "Setting tick rate to 750Hz..."
2022-05-11 15:25:37 +02:00
scripts/config --disable HZ_300 \
--enable HZ_750 \
--set-val HZ 750
2022-05-09 10:28:34 +02:00
elif [ "$_HZ_ticks" = "600" ]; then
echo "Setting tick rate to 600Hz..."
2022-05-11 15:25:37 +02:00
scripts/config --disable HZ_300 \
--enable HZ_600 \
--set-val HZ 600
2022-05-09 10:28:34 +02:00
elif [ "$_HZ_ticks" = "500" ]; then
echo "Setting tick rate to 500Hz..."
2022-05-11 15:25:37 +02:00
scripts/config --disable HZ_300 \
--enable HZ_500 \
--set-val HZ 500
2022-05-09 10:28:34 +02:00
elif [ "$_HZ_ticks" = "300" ]; then
echo "Setting tick rate to 300Hz..."
fi
if [ -n "$_NUMAdisable" ]; then
echo "Disabling NUMA from kernel config..."
2022-05-11 15:25:37 +02:00
scripts/config --disable NUMA \
--disable AMD_NUMA \
--disable X86_64_ACPI_NUMA \
--disable NODES_SPAN_OTHER_NODES \
--disable NUMA_EMU \
--disable NEED_MULTIPLE_NODES \
--disable USE_PERCPU_NUMA_NODE_ID \
--disable ACPI_NUMA \
--disable ARCH_SUPPORTS_NUMA_BALANCING \
--disable NODES_SHIFT \
--undefine NODES_SHIFT \
--disable NEED_MULTIPLE_NODES
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_mq_deadline_disable" ]; then
echo "Disabling MQ-Deadline I/O scheduler..."
2022-05-11 15:25:37 +02:00
scripts/config --disable MQ_IOSCHED_DEADLINE
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_kyber_disable" ]; then
echo "Disabling Kyber I/O scheduler..."
2022-05-11 15:25:37 +02:00
scripts/config --disable MQ_IOSCHED_KYBER
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_per_gov" ]; then
echo "Setting performance governor..."
2022-05-11 15:25:37 +02:00
scripts/config --disable CPU_FREQ_DEFAULT_GOV_SCHEDUTIL \
--enable CPU_FREQ_DEFAULT_GOV_PERFORMANCE \
--enable PCIEASPM \
--enable PCIEASPM_PERFORMANCE \
--enable PCIE_BUS_PERFORMANCE
fi
2022-05-09 10:28:34 +02:00
if [ "$_tickrate" = "perodic" ]; then
echo "Enabling periodic ticks..."
2022-05-11 15:25:37 +02:00
scripts/config --disable NO_HZ_IDLE \
--disable NO_HZ_FULL \
--disable NO_HZ \
--disable NO_HZ_COMMON \
--enable HZ_PERIODIC
2022-05-09 10:28:34 +02:00
elif [ "$_tickrate" = "idle" ]; then
echo "Enabling tickless idle..."
2022-05-11 15:25:37 +02:00
scripts/config --disable HZ_PERIODIC \
--disable NO_HZ_FULL \
--enable NO_HZ_IDLE \
--enable NO_HZ \
--enable NO_HZ_COMMON
2022-05-09 10:28:34 +02:00
elif [ "$_tickrate" = "full" ]; then
echo "Enabling tickless idle..."
2022-05-11 15:25:37 +02:00
scripts/config --disable HZ_PERIODIC \
--disable NO_HZ_IDLE \
--disable CONTEXT_TRACKING_FORCE \
--enable NO_HZ_FULL_NODEF \
--enable NO_HZ_FULL \
--enable NO_HZ \
--enable NO_HZ_COMMON \
--enable CONTEXT_TRACKING
2022-05-09 10:28:34 +02:00
fi
if [ "$_preempt" = "full" ]; then
echo "Enabling low latency preempt..."
2022-05-11 15:25:37 +02:00
scripts/config --enable PREEMPT_BUILD \
--disable PREEMPT_NONE \
--disable PREEMPT_VOLUNTARY \
--enable PREEMPT \
--enable PREEMPT_COUNT \
--enable PREEMPTION \
--enable PREEMPT_DYNAMIC
2022-05-09 10:28:34 +02:00
elif [ "$_preempt" = "voluntary" ]; then
echo "Enabling tickless idle..."
2022-05-11 15:25:37 +02:00
scripts/config --enable PREEMPT_BUILD \
--disable PREEMPT_NONE \
--enable PREEMPT_VOLUNTARY \
--disable PREEMPT \
--enable PREEMPT_COUNT \
--enable PREEMPTION \
--enable PREEMPT_DYNAMIC
2022-05-09 10:28:34 +02:00
elif [ "$_tickrate" = "server" ]; then
echo "Enabling tickless idle..."
2022-05-11 15:25:37 +02:00
scripts/config --enable PREEMPT_NONE_BUILD \
--enable PREEMPT_NONE \
--disable PREEMPT_VOLUNTARY \
--disable PREEMPT \
--disable PREEMPT_COUNT \
--disable PREEMPTION \
--disable PREEMPT_DYNAMIC
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_cc_harder" ]; then
echo "Enabling KBUILD_CFLAGS -O3..."
2022-05-11 15:25:37 +02:00
scripts/config --disable CC_OPTIMIZE_FOR_PERFORMANCE \
--enable CC_OPTIMIZE_FOR_PERFORMANCE_O3
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_tcp_bbr2" ]; then
echo "Disabling TCP_CONG_CUBIC..."
2022-05-11 15:25:37 +02:00
scripts/config --module TCP_CONG_CUBIC \
--disable DEFAULT_CUBIC \
--enable TCP_CONG_BBR2 \
--enable DEFAULT_BBR2 \
--set-str DEFAULT_TCP_CONG bbr2
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_nf_cone" ]; then
echo "Enabling FULLCONENAT..."
2022-05-11 15:25:37 +02:00
scripts/config --module IP_NF_TARGET_FULLCONENAT \
--module NETFILTER_XT_TARGET_FULLCONENAT
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_spf_enable" ]; then
echo "Enabling SPECULATIVE_PAGE_FAULT LRU..."
2022-05-11 15:25:37 +02:00
scripts/config --enable SPECULATIVE_PAGE_FAULT
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_lru_enable" ]; then
echo "Enabling multigenerational LRU..."
2022-05-11 15:25:37 +02:00
scripts/config --enable ARCH_HAS_NONLEAF_PMD_YOUNG \
--enable LRU_GEN \
--enable LRU_GEN_ENABLED \
--disable LRU_GEN_STATS
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_damon" ]; then
echo "Enabling DAMON..."
2022-05-11 15:25:37 +02:00
scripts/config --enable DAMON \
2022-05-23 00:56:40 +02:00
--enable DAMON_VADDR \
--enable DAMON_DBGFS \
--enable DAMON_SYSFS \
2022-05-11 15:25:37 +02:00
--enable DAMON_PADDR \
--enable DAMON_RECLAIM
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_lrng_enable" ]; then
echo "Enabling Linux Random Number Generator ..."
2022-05-11 15:25:37 +02:00
scripts/config --disable RANDOM_DEFAULT_IMPL \
--enable LRNG \
--enable LRNG_OVERSAMPLE_ENTROPY_SOURCES \
--set-val LRNG_OVERSAMPLE_ES_BITS 64 \
--set-val LRNG_SEED_BUFFER_INIT_ADD_BITS 128 \
--enable LRNG_IRQ \
--enable LRNG_CONTINUOUS_COMPRESSION_ENABLED \
--disable LRNG_CONTINUOUS_COMPRESSION_DISABLED \
--enable LRNG_ENABLE_CONTINUOUS_COMPRESSION \
--enable LRNG_SWITCHABLE_CONTINUOUS_COMPRESSION \
--disable LRNG_COLLECTION_SIZE_512 \
--enable LRNG_COLLECTION_SIZE_1024 \
--disable LRNG_COLLECTION_SIZE_2048 \
--disable LRNG_COLLECTION_SIZE_4096 \
--disable LRNG_COLLECTION_SIZE_8192 \
--set-val LRNG_COLLECTION_SIZE 1024 \
--enable LRNG_HEALTH_TESTS \
--set-val LRNG_RCT_CUTOFF 31 \
--set-val LRNG_APT_CUTOFF 325 \
--set-val LRNG_IRQ_ENTROPY_RATE 256 \
--enable LRNG_JENT \
--set-val LRNG_JENT_ENTROPY_RATE 16 \
--enable LRNG_CPU \
--set-val LRNG_CPU_ENTROPY_RATE 8 \
--enable LRNG_DRNG_SWITCH \
--enable LRNG_KCAPI_HASH \
--module LRNG_DRBG \
--module LRNG_KCAPI \
--enable LRNG_TESTING_MENU \
--disable LRNG_RAW_HIRES_ENTROPY \
--disable LRNG_RAW_JIFFIES_ENTROPY \
--disable LRNG_RAW_IRQ_ENTROPY \
--disable LRNG_RAW_IRQFLAGS_ENTROPY \
--disable LRNG_RAW_RETIP_ENTROPY \
--disable LRNG_RAW_REGS_ENTROPY \
--disable LRNG_RAW_ARRAY \
--disable LRNG_IRQ_PERF \
--disable LRNG_ACVT_HASH \
--enable LRNG_RUNTIME_ES_CONFIG \
--disable LRNG_RUNTIME_MAX_WO_RESEED_CONFIG \
--disable LRNG_TEST_CPU_ES_COMPRESSION \
--enable LRNG_SELFTEST \
--disable LRNG_SELFTEST_PANIC
2022-05-09 10:28:34 +02:00
fi
if [ -n "$_zstd_swap_compression" ]; then
echo "Enabling zram ZSTD compression..."
2022-05-11 15:25:37 +02:00
scripts/config --disable ZRAM_DEF_COMP_LZORLE \
--enable ZRAM_DEF_COMP_ZSTD \
--set-str ZRAM_DEF_COMP zstd \
--disable ZSWAP_COMPRESSOR_DEFAULT_LZ4 \
--enable ZSWAP_COMPRESSOR_DEFAULT_ZSTD \
--set-str ZSWAP_COMPRESSOR_DEFAULT zstd
2022-05-09 10:28:34 +02:00
fi
2022-05-26 13:59:24 +02:00
if [ -n "$_disable_debug" ]; then
scripts/config --disable DEBUG_INFO \
--disable DEBUG_INFO_BTF \
--disable DEBUG_INFO_DWARF4 \
2022-05-31 19:16:31 +02:00
--disable DEBUG_INFO_DWARF5 \
2022-05-26 13:59:24 +02:00
--disable PAHOLE_HAS_SPLIT_BTF \
--disable DEBUG_INFO_BTF_MODULES \
--disable SLUB_DEBUG \
--disable PM_DEBUG \
--disable PM_ADVANCED_DEBUG \
--disable PM_SLEEP_DEBUG \
--disable ACPI_DEBUG \
--disable SCHED_DEBUG \
--disable LATENCYTOP \
--disable DEBUG_PREEMPT
fi
2022-05-23 00:56:40 +02:00
echo "Enable ZRAM_ENTROPY"
scripts/config --enable ZRAM_ENTROPY
2022-05-11 15:25:37 +02:00
echo "Enable USER_NS_UNPRIVILEGED"
scripts/config --enable USER_NS
2022-05-09 10:28:34 +02:00
echo "Enable WINE FASTSYNC"
2022-05-11 15:25:37 +02:00
scripts/config --enable WINESYNC
2022-05-09 10:28:34 +02:00
### Optionally use running kernel's config
# code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
if [ -n "$_use_current" ]; then
if [[ -s /proc/config.gz ]]; then
echo "Extracting config from /proc/config.gz..."
# modprobe configs
zcat /proc/config.gz > ./.config
else
2022-05-11 15:25:37 +02:00
warning "Your kernel was not compiled with IKPROC!"
2022-05-09 10:28:34 +02:00
warning "You cannot read the current config!"
warning "Aborting!"
exit
fi
fi
### Optionally load needed modules for the make localmodconfig
# See https://aur.archlinux.org/packages/modprobed-db
if [ -n "$_localmodcfg" ]; then
if [ -e $HOME/.config/modprobed.db ]; then
echo "Running Steven Rostedt's make localmodconfig now"
make ${BUILD_FLAGS[*]} LSMOD=$HOME/.config/modprobed.db localmodconfig
else
echo "No modprobed.db data found"
exit
fi
2022-01-29 13:49:17 +01:00
fi
2022-01-22 14:09:00 +01:00
2022-01-29 13:49:17 +01:00
2022-05-09 10:28:34 +02:00
echo "Applying default config..."
make ${BUILD_FLAGS[*]} olddefconfig
make ${BUILD_FLAGS[*]} -s kernelrelease > version
echo "Prepared $pkgbase version $(<version)"
2021-10-12 20:31:02 +02:00
2022-05-09 10:28:34 +02:00
### Running make nconfig
[[ -z "$_makenconfig" ]] || make ${BUILD_FLAGS[*]} nconfig
2021-11-08 20:16:56 +01:00
2022-05-09 10:28:34 +02:00
### Save configuration for later reuse
cp -Tf ./.config "${startdir}/config-${pkgver}-${pkgrel}${pkgbase#linux}"
2021-11-08 20:16:56 +01:00
2021-10-12 20:31:02 +02:00
}
build() {
2022-05-09 10:28:34 +02:00
cd ${_srcname}
make ${BUILD_FLAGS[*]} -j$(nproc) all
2021-10-12 20:31:02 +02:00
}
_package() {
2022-05-09 10:28:34 +02:00
pkgdesc="The $pkgdesc kernel and modules"
depends=('coreutils' 'kmod' 'initramfs')
optdepends=('crda: to set the correct wireless channels of your country'
'linux-firmware: firmware images needed for some devices'
'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 KSMBD-MODULE)
cd $_srcname
2022-05-11 15:25:37 +02:00
2022-05-09 10:28:34 +02:00
local kernver="$(<version)"
local modulesdir="$pkgdir/usr/lib/modules/$kernver"
echo "Installing boot image..."
# systemd expects to find the kernel here to allow hibernation
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
2022-05-11 15:25:37 +02:00
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
2022-05-09 10:28:34 +02:00
# Used by mkinitcpio to name the kernel
echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
echo "Installing modules..."
2022-05-11 15:25:37 +02:00
make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
2022-05-09 10:28:34 +02:00
DEPMOD=/doesnt/exist modules_install # Suppress depmod
# remove build and source links
rm "$modulesdir"/{source,build}
2021-10-12 20:31:02 +02:00
}
_package-headers() {
2022-05-09 10:28:34 +02:00
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
depends=(pahole)
2022-05-11 15:25:37 +02:00
cd ${_srcname}
2022-05-09 10:28:34 +02:00
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
echo "Installing build files..."
install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
localversion.* version vmlinux
install -Dt "$builddir/kernel" -m644 kernel/Makefile
install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
cp -t "$builddir" -a scripts
# required when STACK_VALIDATION is enabled
install -Dt "$builddir/tools/objtool" tools/objtool/objtool
2022-05-23 00:56:40 +02:00
# required when DEBUG_INFO_BTF_MODULES is enabled
if [ -f tools/bpf/resolve_btfids/resolve_btfids ]; then
install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
fi
2022-05-09 10:28:34 +02:00
echo "Installing headers..."
cp -t "$builddir" -a 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/drivers/md" -m644 drivers/md/*.h
install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
# https://bugs.archlinux.org/task/13146
install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
# https://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/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
# https://bugs.archlinux.org/task/71392
install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
echo "Installing KConfig files..."
find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
echo "Removing unneeded architectures..."
local arch
for arch in "$builddir"/arch/*/; do
[[ $arch = */x86/ ]] && continue
echo "Removing $(basename "$arch")"
rm -r "$arch"
done
echo "Removing documentation..."
rm -r "$builddir/Documentation"
echo "Removing broken symlinks..."
find -L "$builddir" -type l -printf 'Removing %P\n' -delete
echo "Removing loose objects..."
find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
echo "Stripping build tools..."
local file
while read -rd '' file; do
case "$(file -bi "$file")" in
application/x-sharedlib\;*) # Libraries (.so)
strip -v $STRIP_SHARED "$file" ;;
application/x-archive\;*) # Libraries (.a)
strip -v $STRIP_STATIC "$file" ;;
application/x-executable\;*) # Binaries
strip -v $STRIP_BINARIES "$file" ;;
application/x-pie-executable\;*) # Relocatable binaries
strip -v $STRIP_SHARED "$file" ;;
esac
done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
2022-05-11 15:25:37 +02:00
echo "Stripping vmlinux..."
strip -v $STRIP_STATIC "$builddir/vmlinux"
2022-05-09 10:28:34 +02:00
echo "Adding symlink..."
mkdir -p "$pkgdir/usr/src"
ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
2021-10-12 20:31:02 +02:00
}
2021-11-08 20:16:56 +01:00
pkgname=("$pkgbase" "$pkgbase-headers")
2021-10-17 12:08:56 +02:00
for _p in "${pkgname[@]}"; do
2022-05-09 10:28:34 +02:00
eval "package_$_p() {
2022-01-21 12:27:08 +01:00
$(declare -f "_package${_p#$pkgbase}")
_package${_p#$pkgbase}
2022-05-09 10:28:34 +02:00
}"
2021-10-17 12:08:56 +02:00
done
2021-12-08 19:25:50 +01:00
2022-05-31 19:16:31 +02:00
sha256sums=('83d14126c660186a7a1774a4a5c29d38e170fa5e52cfd2d08fd344dcf1f57d22'
2022-06-02 02:11:42 +02:00
'4c29c60f2a466df0be5b75a267611a2bf8f2f83b8cd69b0c262321d32e50147a'
'4ad6f3aedcf2b39d7e44b7f03639e0afee8267ea256192a0555dd973f09400a9'
'e8179f661dc9ba2ad89455f0c7e952e9dd9b4d6445476384cbac2730cdd46b65'
'85eeddbd0b1fdb44333c450e6d93e370dcd7e230cecccce47667aaa746bea3ae'
2022-05-23 00:56:40 +02:00
'2bfe45a67732a97cea01bf760a8f9fb297057c2488eb9e61720a0bb26c9b11e2'
'56f58801a73e6d930d7680806dc734b50b69617a0eef96244627d7a946b62efd'
2022-06-02 02:11:42 +02:00
'3754c1ad6bc2fb4e73e9d77137e9f245b3be1a73a05685f0ca03f4c086e5d04d'
'e2266d499cebdd5d195a044048ae4a13755f1d3edb3ece2c3f8837228b4cd521'
2022-05-23 00:56:40 +02:00
'c2bf57d37db1f93c5f3eeff2e2957f01618f4786613c13755f9ae6989d2b745c'
'30fd4ca078cb1eee0bc4005700da4d15515a577ccdb96ea7922040aa9086d6b7'
2022-06-02 02:11:42 +02:00
'75aabb11608394725b8f38a7d813a12e6fb1a521a48eb3c078df80419c2675c7'
'1d9c83de97d541f5a7ae4612a96c05aea8ce38de5471cc21fd2197dbd6644d00'
2022-05-23 00:56:40 +02:00
'c1aae07261bafc711c2d66e26c2c30e444e11509cacc7aec148dc021761294cd'
2022-06-02 02:11:42 +02:00
'781cd26d7b0794d11f103ada94140061117c628471a4c49f0228f22f0a6cf425'
'99b18e00ca3e038481a23f4c83bc285a1ad0e209d049a8476c8f997627aaea79'
2022-05-23 00:56:40 +02:00
'd2c542b3d44ef11364248c550d20ec7b52261cd98ee5191c24d59c9e0a69392e'
'8edf9b9b1a9c26cc4d6dfaf5f14c06b197a04c5bbb8459dd292c033aa2534d19'
'efe8558b63feb0e76b61d69952c5300ad54c951d9044101be7c01932a54fb4fb'
'be21f15aeb22b2ca1e35e4975590d30736af0483ea7464e3464a60d993e37e22')