Skip to content

Commit 31da92e

Browse files
ventureooptr1337
authored andcommitted
Unify values for options that accept a boolean value
Signed-off-by: Vasiliy Stelmachenok <[email protected]>
1 parent 094182f commit 31da92e

File tree

13 files changed

+525
-660
lines changed

13 files changed

+525
-660
lines changed

linux-cachyos-bmq/PKGBUILD

+48-61
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Set these variables to ANYTHING that is not null or choose proper variable to enable them
1010

1111
### Selecting CachyOS config
12-
: "${_cachy_config:=y}"
12+
: "${_cachy_config:=yes}"
1313

1414
### Selecting the CPU scheduler
1515
# ATTENTION - only one of the following values can be selected:
@@ -23,22 +23,22 @@
2323
: "${_cpusched:=bmq}"
2424

2525
### Tweak kernel options prior to a build via nconfig
26-
: "${_makenconfig:=}"
26+
: "${_makenconfig:=no}"
2727

2828
### Tweak kernel options prior to a build via menuconfig
29-
: "${_makemenuconfig:=}"
29+
: "${_makemenuconfig:=no}"
3030

3131
### Tweak kernel options prior to a build via xconfig
32-
: "${_makexconfig:=}"
32+
: "${_makexconfig:=no}"
3333

3434
### Tweak kernel options prior to a build via gconfig
35-
: "${_makegconfig:=}"
35+
: "${_makegconfig:=no}"
3636

3737
# NUMA is optimized for multi-socket motherboards.
3838
# A single multi-core CPU actually runs slower with NUMA enabled.
3939
# See, https://bugs.archlinux.org/task/31187
4040
# It seems that in 2023 this is not really a huge regression anymore
41-
: "${_NUMAdisable:=}"
41+
: "${_NUMAdisable:=no}"
4242

4343
# Compile ONLY used modules to VASTLYreduce the number of modules built
4444
# and the build time.
@@ -48,7 +48,7 @@
4848
# This PKGBUILD read the database kept if it exists
4949
#
5050
# More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed-db
51-
: "${_localmodcfg:=}"
51+
: "${_localmodcfg:=no}"
5252

5353
# Path to the list of used modules
5454
: "${_localmodcfg_path:="$HOME/.config/modprobed.db"}"
@@ -58,16 +58,16 @@
5858
# the ARCH defaults. Useful when the package gets updated and you already went
5959
# through the trouble of customizing your config options. NOT recommended when
6060
# a new kernel is released, but again, convenient for package bumps.
61-
: "${_use_current:=}"
61+
: "${_use_current:=no}"
6262

6363
### Enable KBUILD_CFLAGS -O3
64-
: "${_cc_harder:=y}"
64+
: "${_cc_harder:=yes}"
6565

6666
### Set performance governor as default
67-
: "${_per_gov:=}"
67+
: "${_per_gov:=no}"
6868

6969
### Enable TCP_CONG_BBR3
70-
: "${_tcp_bbr3:=}"
70+
: "${_tcp_bbr3:=no}"
7171

7272
### Running with a 1000HZ, 750Hz, 625Hz, 600 Hz, 500Hz, 300Hz, 250Hz and 100Hz tick rate
7373
: "${_HZ_ticks:=1000}"
@@ -98,7 +98,7 @@
9898
: "${_processor_opt:=}"
9999

100100
# This does automatically detect your supported CPU and optimizes for it
101-
: "${_use_auto_optimization:=y}"
101+
: "${_use_auto_optimization:=yes}"
102102

103103
# Clang LTO mode, only available with the "llvm" compiler - options are "none", "full" or "thin".
104104
# ATTENTION - one of three predefined values should be selected!
@@ -109,48 +109,48 @@
109109

110110
# Use suffix -lto only when requested by the user
111111
# Enabled by default.
112-
# y - enable -lto suffix
113-
# n - disable -lto suffix
112+
# yes - enable -lto suffix
113+
# no - disable -lto suffix
114114
# https://github.com/CachyOS/linux-cachyos/issues/36
115-
: "${_use_lto_suffix:=y}"
115+
: "${_use_lto_suffix:=yes}"
116116

117117
# Use suffix -gcc when requested by the user
118118
# This was added to facilitate https://github.com/CachyOS/linux-cachyos/issues/286
119-
: "${_use_gcc_suffix:=}"
119+
: "${_use_gcc_suffix:=no}"
120120

121121
# KCFI is a proposed forward-edge control-flow integrity scheme for
122122
# Clang, which is more suitable for kernel use than the existing CFI
123123
# scheme used by CONFIG_CFI_CLANG. kCFI doesn't require LTO, doesn't
124124
# alter function references to point to a jump table, and won't break
125125
# function address equality.
126-
: "${_use_kcfi:=}"
126+
: "${_use_kcfi:=no}"
127127

128128
# Build the zfs module in to the kernel
129129
# WARNING: The ZFS module doesn't build with selected RT sched due to licensing issues.
130130
# If you use ZFS, refrain from building the RT kernel
131-
: "${_build_zfs:=}"
131+
: "${_build_zfs:=no}"
132132

133133
# Builds the nvidia module and package it into a own base
134134
# This does replace the requirement of nvidia-dkms
135-
: "${_build_nvidia:=}"
135+
: "${_build_nvidia:=no}"
136136

137137
# Builds the open nvidia module and package it into a own base
138138
# This does replace the requirement of nvidia-open-dkms
139139
# Use this only if you have Turing+ GPU
140-
: "${_build_nvidia_open:=}"
140+
: "${_build_nvidia_open:=no}"
141141

142142
# Build a debug package with non-stripped vmlinux
143-
: "${_build_debug:=}"
143+
: "${_build_debug:=no}"
144144

145145
# ATTENTION: Do not modify after this line
146146
_is_lto_kernel() {
147147
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]]
148148
return $?
149149
}
150150

151-
if _is_lto_kernel && [ "$_use_lto_suffix" = "y" ]; then
151+
if _is_lto_kernel && [ "$_use_lto_suffix" = "yes" ]; then
152152
_pkgsuffix="cachyos-${_cpusched}-lto"
153-
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "y" ]; then
153+
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "yes" ]; then
154154
_pkgsuffix="cachyos-${_cpusched}-gcc"
155155
else
156156
_pkgsuffix="cachyos-${_cpusched}"
@@ -216,18 +216,18 @@ if [[ "$_cpusched" = "rt" || "$_cpusched" = "rt-bore" ]]; then
216216
fi
217217

218218
# ZFS support
219-
if [ -n "$_build_zfs" ]; then
219+
if [ "$_build_zfs" = "yes" ]; then
220220
makedepends+=(git)
221221
source+=("git+https://github.com/cachyos/zfs.git#commit=e65f69e41f4a276d7d0d1800a2878308a0ba84a6")
222222
fi
223223

224224
# NVIDIA pre-build module support
225-
if [ -n "$_build_nvidia" ]; then
225+
if [ "$_build_nvidia" = "yes" ]; then
226226
source+=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${_nv_ver}/${_nv_pkg}.run"
227227
"${_patchsource}/misc/nvidia/0001-Make-modeset-and-fbdev-default-enabled.patch")
228228
fi
229229

230-
if [ -n "$_build_nvidia_open" ]; then
230+
if [ "$_build_nvidia_open" = "yes" ]; then
231231
source+=("nvidia-open-${_nv_ver}.tar.gz::https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/${_nv_ver}.tar.gz"
232232
"${_patchsource}/misc/nvidia/0001-Make-modeset-and-fbdev-default-enabled.patch"
233233
"${_patchsource}/misc/nvidia/0002-Do-not-error-on-unkown-CPU-Type-and-add-Zen5-support.patch"
@@ -294,19 +294,17 @@ prepare() {
294294
fi
295295

296296
### Use autooptimization
297-
if [ -n "$_use_auto_optimization" ]; then
297+
if [ "$_use_auto_optimization" = "yes" ]; then
298298
"${srcdir}"/auto-cpu-optimization.sh
299299
fi
300300

301301
### Selecting CachyOS config
302-
if [ -n "$_cachy_config" ]; then
302+
if [ "$_cachy_config" = "yes" ]; then
303303
echo "Enabling CachyOS config..."
304304
scripts/config -e CACHY
305305
fi
306306

307307
### Selecting the CPU scheduler
308-
[ -z "$_cpusched" ] && _die "The value is empty. Choose the correct one again."
309-
310308
case "$_cpusched" in
311309
cachyos|bore|hardened) scripts/config -e SCHED_BORE;;
312310
bmq) scripts/config -e SCHED_ALT -e SCHED_BMQ;;
@@ -319,14 +317,12 @@ prepare() {
319317
echo "Selecting ${_cpusched^^} CPU scheduler..."
320318

321319
### Enable KCFI
322-
if [ -n "$_use_kcfi" ]; then
320+
if [ "$_use_kcfi" = "yes" ]; then
323321
echo "Enabling kCFI"
324322
scripts/config -e ARCH_SUPPORTS_CFI_CLANG -e CFI_CLANG -e CFI_AUTO_DEFAULT
325323
fi
326324

327325
### Select LLVM level
328-
[ -z "$_use_llvm_lto" ] && _die "The value is empty. Choose the correct one again."
329-
330326
case "$_use_llvm_lto" in
331327
thin) scripts/config -e LTO -e LTO_CLANG -e ARCH_SUPPORTS_LTO_CLANG -e ARCH_SUPPORTS_LTO_CLANG_THIN -d LTO_NONE -e HAS_LTO_CLANG -d LTO_CLANG_FULL -e LTO_CLANG_THIN -e HAVE_GCC_PLUGINS;;
332328
full) scripts/config -e LTO -e LTO_CLANG -e ARCH_SUPPORTS_LTO_CLANG -e ARCH_SUPPORTS_LTO_CLANG_THIN -d LTO_NONE -e HAS_LTO_CLANG -e LTO_CLANG_FULL -d LTO_CLANG_THIN -e HAVE_GCC_PLUGINS;;
@@ -337,8 +333,6 @@ prepare() {
337333
echo "Selecting '$_use_llvm_lto' LLVM level..."
338334

339335
### Select tick rate
340-
[ -z "$_HZ_ticks" ] && _die "The value is empty. Choose the correct one again."
341-
342336
case "$_HZ_ticks" in
343337
100|250|500|600|625|750|1000)
344338
scripts/config -d HZ_300 -e "HZ_${_HZ_ticks}" --set-val HZ "${_HZ_ticks}";;
@@ -351,7 +345,7 @@ prepare() {
351345
echo "Setting tick rate to ${_HZ_ticks}Hz..."
352346

353347
### Disable NUMA
354-
if [ -n "$_NUMAdisable" ]; then
348+
if [ "$_NUMAdisable" = "yes" ]; then
355349
echo "Disabling NUMA from kernel config..."
356350
scripts/config -d NUMA \
357351
-d AMD_NUMA \
@@ -369,15 +363,13 @@ prepare() {
369363
fi
370364

371365
### Select performance governor
372-
if [ -n "$_per_gov" ]; then
366+
if [ "$_per_gov" = "yes" ]; then
373367
echo "Setting performance governor..."
374368
scripts/config -d CPU_FREQ_DEFAULT_GOV_SCHEDUTIL \
375369
-e CPU_FREQ_DEFAULT_GOV_PERFORMANCE
376370
fi
377371

378372
### Select tick type
379-
[ -z "$_tickrate" ] && _die "The value is empty. Choose the correct one again."
380-
381373
case "$_tickrate" in
382374
perodic) scripts/config -d NO_HZ_IDLE -d NO_HZ_FULL -d NO_HZ -d NO_HZ_COMMON -e HZ_PERIODIC;;
383375
idle) scripts/config -d HZ_PERIODIC -d NO_HZ_FULL -e NO_HZ_IDLE -e NO_HZ -e NO_HZ_COMMON;;
@@ -391,8 +383,6 @@ prepare() {
391383

392384
# We should not set up the PREEMPT for RT kernels
393385
if [[ "$_cpusched" != "rt" || "$_cpusched" != "rt-bore" ]]; then
394-
[ -z "$_preempt" ] && _die "The value is empty. Choose the correct one again."
395-
396386
case "$_preempt" in
397387
full) scripts/config -e PREEMPT_BUILD -d PREEMPT_NONE -d PREEMPT_VOLUNTARY -e PREEMPT -e PREEMPT_COUNT -e PREEMPTION -e PREEMPT_DYNAMIC;;
398388
voluntary) scripts/config -e PREEMPT_BUILD -d PREEMPT_NONE -e PREEMPT_VOLUNTARY -d PREEMPT -e PREEMPT_COUNT -e PREEMPTION -d PREEMPT_DYNAMIC;;
@@ -404,7 +394,7 @@ prepare() {
404394
fi
405395

406396
### Enable O3
407-
if [ -n "$_cc_harder" ] && [ -z "$_cc_size" ]; then
397+
if [ "$_cc_harder" = "yes" ]; then
408398
echo "Enabling KBUILD_CFLAGS -O3..."
409399
scripts/config -d CC_OPTIMIZE_FOR_PERFORMANCE \
410400
-e CC_OPTIMIZE_FOR_PERFORMANCE_O3
@@ -427,7 +417,7 @@ prepare() {
427417
fi
428418

429419
### Enable bbr3
430-
if [ -n "$_tcp_bbr3" ]; then
420+
if [ "$_tcp_bbr3" = "yes" ]; then
431421
echo "Disabling TCP_CONG_CUBIC..."
432422
scripts/config -m TCP_CONG_CUBIC \
433423
-d DEFAULT_CUBIC \
@@ -441,8 +431,6 @@ prepare() {
441431
fi
442432

443433
### Select THP
444-
[ -z "$_hugepage" ] && _die "The value is empty. Choose the correct one again."
445-
446434
case "$_hugepage" in
447435
always) scripts/config -d TRANSPARENT_HUGEPAGE_MADVISE -e TRANSPARENT_HUGEPAGE_ALWAYS;;
448436
madvise) scripts/config -d TRANSPARENT_HUGEPAGE_ALWAYS -e TRANSPARENT_HUGEPAGE_MADVISE;;
@@ -456,7 +444,7 @@ prepare() {
456444

457445
### Optionally use running kernel's config
458446
# code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
459-
if [ -n "$_use_current" ]; then
447+
if [ "$_use_current" = "yes" ]; then
460448
if [[ -s /proc/config.gz ]]; then
461449
echo "Extracting config from /proc/config.gz..."
462450
# modprobe configs
@@ -469,10 +457,9 @@ prepare() {
469457
fi
470458
fi
471459

472-
473460
### Optionally load needed modules for the make localmodconfig
474461
# See https://aur.archlinux.org/packages/modprobed-db
475-
if [ -n "$_localmodcfg" ]; then
462+
if [ "$_localmodcfg" = "yes" ]; then
476463
if [ -e "$_localmodcfg_path" ]; then
477464
echo "Running Steven Rostedt's make localmodconfig now"
478465
make "${BUILD_FLAGS[@]}" LSMOD="${_localmodcfg_path}" localmodconfig
@@ -492,31 +479,31 @@ prepare() {
492479
echo "Prepared $pkgbase version $(<version)"
493480

494481
### Running make nconfig
495-
[[ -z "$_makenconfig" ]] || make "${BUILD_FLAGS[@]}" nconfig
482+
[ "$_makenconfig" = "yes" ] && make "${BUILD_FLAGS[@]}" nconfig
496483

497484
### Running make menuconfig
498-
[[ -z "$_makemenuconfig" ]] || make "${BUILD_FLAGS[@]}" menuconfig
485+
[ "$_makemenuconfig" = "yes" ] && make "${BUILD_FLAGS[@]}" menuconfig
499486

500487
### Running make xconfig
501-
[[ -z "$_makexconfig" ]] || make "${BUILD_FLAGS[@]}" xconfig
488+
[ "$_makexconfig" = "yes" ] && make "${BUILD_FLAGS[@]}" xconfig
502489

503490
### Running make gconfig
504-
[[ -z "$_makegconfig" ]] || make "${BUILD_FLAGS[@]}" gconfig
491+
[ "$_makegconfig" = "yes" ] && make "${BUILD_FLAGS[@]}" gconfig
505492

506493
### Save configuration for later reuse
507494
echo "Save configuration for later reuse..."
508495
local basedir="$(dirname "$(readlink "${srcdir}/config")")"
509496
cat .config > "${basedir}/config-${pkgver}-${pkgrel}${pkgbase#linux}"
510497

511-
if [ -n "$_build_nvidia" ]; then
498+
if [ "$_build_nvidia" = "yes" ]; then
512499
cd "${srcdir}"
513500
sh "${_nv_pkg}.run" --extract-only
514501

515502
# Use fbdev and modeset as default
516503
patch -Np1 -i "${srcdir}/0001-Make-modeset-and-fbdev-default-enabled.patch" -d "${srcdir}/${_nv_pkg}/kernel"
517504
fi
518505

519-
if [ -n "$_build_nvidia_open" ]; then
506+
if [ "$_build_nvidia_open" = "yes" ]; then
520507
patch -Np1 -i "${srcdir}/0001-Make-modeset-and-fbdev-default-enabled.patch" -d "${srcdir}/${_nv_open_pkg}/kernel-open"
521508
# Fix for Zen5 error print in dmesg
522509
patch -Np1 --no-backup-if-mismatch -i "${srcdir}/0002-Do-not-error-on-unkown-CPU-Type-and-add-Zen5-support.patch" -d "${srcdir}/${_nv_open_pkg}"
@@ -540,20 +527,20 @@ build() {
540527
SYSSRC="${srcdir}/${_srcname}"
541528
SYSOUT="${srcdir}/${_srcname}"
542529
)
543-
if [ -n "$_build_nvidia" ]; then
530+
if [ "$_build_nvidia" = "yes" ]; then
544531
MODULE_FLAGS+=(NV_EXCLUDE_BUILD_MODULES='__EXCLUDE_MODULES')
545532
cd "${srcdir}/${_nv_pkg}/kernel"
546533
make "${BUILD_FLAGS[@]}" "${MODULE_FLAGS[@]}" -j"$(nproc)" modules
547534

548535
fi
549536

550-
if [ -n "$_build_nvidia_open" ]; then
537+
if [ "$_build_nvidia_open" = "yes" ]; then
551538
cd "${srcdir}/${_nv_open_pkg}"
552539
MODULE_FLAGS+=(IGNORE_CC_MISMATCH=yes)
553540
CFLAGS= CXXFLAGS= LDFLAGS= make "${BUILD_FLAGS[@]}" "${MODULE_FLAGS[@]}" -j"$(nproc)" modules
554541
fi
555542

556-
if [ -n "$_build_zfs" ]; then
543+
if [ "$_build_zfs" = "yes" ]; then
557544
cd ${srcdir}/"zfs"
558545

559546
local CONFIGURE_FLAGS=()
@@ -745,11 +732,11 @@ _package-nvidia-open(){
745732
}
746733

747734
pkgname=("$pkgbase")
748-
[ -n "$_build_debug" ] && pkgname+=("$pkgbase-dbg")
735+
[ "$_build_debug" = "yes" ] && pkgname+=("$pkgbase-dbg")
749736
pkgname+=("$pkgbase-headers")
750-
[ -n "$_build_zfs" ] && pkgname+=("$pkgbase-zfs")
751-
[ -n "$_build_nvidia" ] && pkgname+=("$pkgbase-nvidia")
752-
[ -n "$_build_nvidia_open" ] && pkgname+=("$pkgbase-nvidia-open")
737+
[ "$_build_zfs" = "yes" ] && pkgname+=("$pkgbase-zfs")
738+
[ "$_build_nvidia" = "yes" ] && pkgname+=("$pkgbase-nvidia")
739+
[ "$_build_nvidia_open" = "yes" ] && pkgname+=("$pkgbase-nvidia-open")
753740
for _p in "${pkgname[@]}"; do
754741
eval "package_$_p() {
755742
$(declare -f "_package${_p#$pkgbase}")

0 commit comments

Comments
 (0)