Skip to content

Commit b18ec31

Browse files
authored
Misc PKGBUILD clenaups (#284)
1 parent 3f4e336 commit b18ec31

File tree

11 files changed

+414
-436
lines changed

11 files changed

+414
-436
lines changed

linux-cachyos-bore/PKGBUILD

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ _build_nvidia_open=${_build_nvidia_open-}
145145
_build_debug=${_build_debug-}
146146

147147
if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
148-
pkgsuffix=cachyos-${_cpusched}-lto
149-
pkgbase=linux-$pkgsuffix
148+
_pkgsuffix="cachyos-${_cpusched}-lto"
149+
pkgbase="linux-$_pkgsuffix"
150150

151151
elif [ -n "$_use_llvm_lto" ] || [[ "$_use_lto_suffix" = "n" ]]; then
152-
pkgsuffix=cachyos-${_cpusched}
153-
pkgbase=linux-$pkgsuffix
152+
_pkgsuffix="cachyos-${_cpusched}"
153+
pkgbase="linux-$_pkgsuffix"
154154
fi
155155
_major=6.10
156156
_minor=6
@@ -164,8 +164,8 @@ _srcname=linux-${_stable}
164164
#_srcname=linux-${_major}
165165
pkgdesc='Linux BORE + Cachy Sauce scheduler Kernel by CachyOS with other patches and improvements'
166166
pkgrel=2
167-
_kernver=$pkgver-$pkgrel
168-
_kernuname="${pkgver}-${pkgsuffix}"
167+
_kernver="$pkgver-$pkgrel"
168+
_kernuname="${pkgver}-${_pkgsuffix}"
169169
arch=('x86_64')
170170
url="https://github.com/CachyOS/linux-cachyos"
171171
license=('GPL-2.0-only')
@@ -255,14 +255,13 @@ case "$_cpusched" in
255255
esac
256256

257257
export KBUILD_BUILD_HOST=cachyos
258-
export KBUILD_BUILD_USER=$pkgbase
258+
export KBUILD_BUILD_USER="$pkgbase"
259259
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
260260

261261
_die() { error "$@" ; exit; }
262262

263263
prepare() {
264-
265-
cd ${srcdir}/$_srcname
264+
cd "$_srcname"
266265

267266
echo "Setting version..."
268267
echo "-$pkgrel" > localversion.10-pkgrel
@@ -296,7 +295,7 @@ prepare() {
296295
fi
297296

298297
scripts/config -k -d CONFIG_GENERIC_CPU
299-
scripts/config -k -e CONFIG_${MARCH2}
298+
scripts/config -k -e "CONFIG_${MARCH2}"
300299
fi
301300

302301
### Use autooptimization
@@ -346,7 +345,7 @@ prepare() {
346345
echo "Selecting '$_use_llvm_lto' LLVM level..."
347346

348347
### Select tick rate
349-
[ -z $_HZ_ticks ] && _die "The value is empty. Choose the correct one again."
348+
[ -z "$_HZ_ticks" ] && _die "The value is empty. Choose the correct one again."
350349

351350
case "$_HZ_ticks" in
352351
100|250|500|600|625|750|1000)
@@ -492,40 +491,39 @@ prepare() {
492491
### Optionally load needed modules for the make localmodconfig
493492
# See https://aur.archlinux.org/packages/modprobed-db
494493
if [ -n "$_localmodcfg" ]; then
495-
if [ -e $HOME/.config/modprobed.db ]; then
494+
if [ -e "$HOME/.config/modprobed.db" ]; then
496495
echo "Running Steven Rostedt's make localmodconfig now"
497-
make ${BUILD_FLAGS[*]} LSMOD=$HOME/.config/modprobed.db localmodconfig
496+
make "${BUILD_FLAGS[@]}" LSMOD="$HOME/.config/modprobed.db" localmodconfig
498497
else
499-
echo "No modprobed.db data found"
500-
exit
498+
_die "No modprobed.db data found"
501499
fi
502500
fi
503501

504502
### Rewrite configuration
505503
echo "Rewrite configuration..."
506-
make ${BUILD_FLAGS[*]} prepare
507-
yes "" | make ${BUILD_FLAGS[*]} config >/dev/null
504+
make "${BUILD_FLAGS[@]}" prepare
505+
yes "" | make "${BUILD_FLAGS[@]}" config >/dev/null
508506
diff -u ../config .config || :
509507

510508
### Prepared version
511509
make -s kernelrelease > version
512510
echo "Prepared $pkgbase version $(<version)"
513511

514512
### Running make nconfig
515-
[[ -z "$_makenconfig" ]] || make ${BUILD_FLAGS[*]} nconfig
513+
[[ -z "$_makenconfig" ]] || make "${BUILD_FLAGS[@]}" nconfig
516514

517515
### Running make menuconfig
518-
[[ -z "$_makemenuconfig" ]] || make ${BUILD_FLAGS[*]} menuconfig
516+
[[ -z "$_makemenuconfig" ]] || make "${BUILD_FLAGS[@]}" menuconfig
519517

520518
### Running make xconfig
521-
[[ -z "$_makexconfig" ]] || make ${BUILD_FLAGS[*]} xconfig
519+
[[ -z "$_makexconfig" ]] || make "${BUILD_FLAGS[@]}" xconfig
522520

523521
### Running make gconfig
524-
[[ -z "$_makegconfig" ]] || make ${BUILD_FLAGS[*]} gconfig
522+
[[ -z "$_makegconfig" ]] || make "${BUILD_FLAGS[@]}" gconfig
525523

526524
### Save configuration for later reuse
527525
echo "Save configuration for later reuse..."
528-
cat .config > "${startdir}/config-${pkgver}-${pkgrel}${pkgbase#linux}"
526+
cat .config > "${srcdir}/../config-${pkgver}-${pkgrel}${pkgbase#linux}"
529527

530528
if [ -n "$_build_nvidia" ]; then
531529
cd "${srcdir}"
@@ -545,8 +543,8 @@ prepare() {
545543
}
546544

547545
build() {
548-
cd ${srcdir}/${_srcname}
549-
make ${BUILD_FLAGS[*]} -j$(nproc) all
546+
cd "$_srcname"
547+
make "${BUILD_FLAGS[@]}" -j"$(nproc)" all
550548
make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
551549

552550
if [ -n "$_build_nvidia" ]; then
@@ -559,7 +557,7 @@ build() {
559557
)
560558

561559
cd "${srcdir}/${_nv_pkg}/kernel"
562-
make ${BUILD_FLAGS[*]} ${MODULE_FLAGS[*]} -j$(nproc) modules
560+
make "${BUILD_FLAGS[@]}" "${MODULE_FLAGS[@]}" -j"$(nproc)" modules
563561

564562
fi
565563

@@ -572,7 +570,7 @@ build() {
572570
SYSSRC="${srcdir}/${_srcname}"
573571
SYSOUT="${srcdir}/${_srcname}"
574572
)
575-
CFLAGS= CXXFLAGS= LDFLAGS= make ${BUILD_FLAGS[*]} ${MODULE_FLAGS[*]} -j$(nproc) modules
573+
CFLAGS= CXXFLAGS= LDFLAGS= make "${BUILD_FLAGS[@]}" "${MODULE_FLAGS[@]}" -j"$(nproc)" modules
576574
fi
577575

578576
if [ -n "$_build_zfs" ]; then
@@ -583,11 +581,11 @@ build() {
583581

584582
./autogen.sh
585583
sed -i "s|\$(uname -r)|${_kernuname}|g" configure
586-
./configure ${CONFIGURE_FLAGS[*]} --prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin \
584+
./configure "${CONFIGURE_FLAGS[@]}" --prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin \
587585
--libdir=/usr/lib --datadir=/usr/share --includedir=/usr/include \
588586
--with-udevdir=/lib/udev --libexecdir=/usr/lib/zfs --with-config=kernel \
589-
--with-linux=${srcdir}/$_srcname
590-
make ${BUILD_FLAGS[*]}
587+
--with-linux="${srcdir}/$_srcname"
588+
make "${BUILD_FLAGS[@]}"
591589
fi
592590

593591
}
@@ -601,7 +599,7 @@ _package() {
601599
'uksmd: Userspace KSM helper daemon')
602600
provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE UKSMD-BUILTIN)
603601

604-
cd ${srcdir}/$_srcname
602+
cd "$_srcname"
605603

606604
local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
607605

@@ -623,9 +621,9 @@ _package() {
623621

624622
_package-headers() {
625623
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
626-
depends=('pahole' ${pkgbase} )
624+
depends=('pahole' "${pkgbase}")
627625

628-
cd ${srcdir}/${_srcname}
626+
cd "${_srcname}"
629627
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
630628

631629
echo "Installing build files..."
@@ -707,23 +705,23 @@ _package-headers() {
707705

708706
_package-dbg(){
709707
pkgdesc="Non-stripped vmlinux file for the $pkgdesc kernel"
710-
depends=(${pkgbase}-headers)
708+
depends=("${pkgbase}-headers")
711709

712-
cd "${srcdir}/${_srcname}"
710+
cd "${_srcname}"
713711
mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"
714712
install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux
715713
}
716714

717715
_package-zfs(){
718716
pkgdesc="zfs module for the $pkgdesc kernel"
719-
depends=('pahole' $pkgbase=$_kernver)
717+
depends=('pahole' "${pkgbase}=${_kernver}")
720718
provides=('ZFS-MODULE')
721719
license=('CDDL')
722720

723-
cd ${srcdir}/$_srcname
721+
cd "$_srcname"
724722
local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
725723

726-
cd ${srcdir}/"zfs"
724+
cd "${srcdir}/zfs"
727725
install -dm755 "${modulesdir}"
728726
install -m644 module/*.ko "${modulesdir}"
729727
find "$pkgdir" -name '*.ko' -exec zstd --rm -19 {} +
@@ -737,10 +735,10 @@ _package-nvidia(){
737735
conflicts=("$pkgbase-nvidia-open")
738736
license=('custom')
739737

740-
cd ${srcdir}/$_srcname
738+
cd "$_srcname"
741739
local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
742740

743-
cd "${srcdir}/${_nv_pkg}/"
741+
cd "${srcdir}/${_nv_pkg}"
744742
install -dm755 "${modulesdir}"
745743
install -m644 kernel/*.ko "${modulesdir}"
746744
install -Dt "$pkgdir/usr/share/licenses/${pkgname}" -m644 LICENSE
@@ -754,7 +752,7 @@ _package-nvidia-open(){
754752
conflicts=("$pkgbase-nvidia")
755753
license=('MIT AND GPL-2.0-only')
756754

757-
cd ${srcdir}/$_srcname
755+
cd "$_srcname"
758756
local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
759757

760758
cd "${srcdir}/${_nv_open_pkg}"

0 commit comments

Comments
 (0)