-
Notifications
You must be signed in to change notification settings - Fork 73
/
PKGBUILD
2310 lines (2070 loc) · 96.3 KB
/
PKGBUILD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Created by: Tk-Glitch <ti3nou at gmail dot com>
# Originally based on https://aur.archlinux.org/packages/nvidia-beta-all/
# Includes DKMS support, libglvnd compat, 32-bit libs and building for all kernels currently installed
plain ' .---.` `.---.'
plain ' `/syhhhyso- -osyhhhys/`'
plain ' .syNMdhNNhss/``.---.``/sshNNhdMNys.'
plain ' +sdMh.`+MNsssssssssssssssNM+`.hMds+'
plain ' :syNNdhNNhssssssssssssssshNNhdNNys:'
plain ' /ssyhhhysssssssssssssssssyhhhyss/'
plain ' .ossssssssssssssssssssssssssssso.'
plain ' :sssssssssssssssssssssssssssssssss:'
plain ' /sssssssssssssssssssssssssssssssssss/'
plain ' :sssssssssssssoosssssssoosssssssssssss:'
plain ' osssssssssssssoosssssssoossssssssssssso'
plain ' osssssssssssyyyyhhhhhhhyyyyssssssssssso'
plain ' /yyyyyyhhdmmmmNNNNNNNNNNNmmmmdhhyyyyyy/'
plain ' smmmNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmmms'
plain ' /dNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNd/'
plain ' `:sdNNNNNNNNNNNNNNNNNNNNNNNNNds:`'
plain ' `-+shdNNNNNNNNNNNNNNNdhs+-`'
plain ' `.-:///////:-.`'
plain ''
where="$PWD" # track basedir as different Arch based distros are moving srcdir around
source "$where"/customization.cfg
# Load external configuration file if present. Available variable values will overwrite customization.cfg ones.
if [ -e "$_EXT_CONFIG_PATH" ]; then
source "$_EXT_CONFIG_PATH" && msg2 "External configuration file '$_EXT_CONFIG_PATH' will be used to override customization.cfg values." && plain ""
fi
# Auto-add kernel userpatches to source
_autoaddpatch="false"
# Package type selector
if [ -z "$_driver_version" ] || [ "$_driver_version" = "latest" ] || [ -z "$_driver_branch" ] && [ ! -e options ]; then
# Unset this just in case another prompt using CONDITION is ever added before this code.
unset CONDITION
if [ "$_driver_version" = "latest" ]; then
if [ "$_driver_branch" = "regular" ]; then
CONDITION="2"
elif [ "$_driver_branch" = "vulkandev" ]; then
CONDITION="1"
else
error "\"latest\" driver specified, but without branch. Make sure _driver_branch is set."
fi
fi
warning "Please make sure you have the corresponding kernel headers package installed for each kernel on your system !\n"
if [[ -z $CONDITION ]]; then
read -p " Which driver version do you want?`echo $'\n > 1.Vulkan dev: 550.40.82\n 2.565 series: 565.77\n 3.560 series: 560.35.03\n 4.550 series: 550.135\n 5.470 series: 470.256.02 (LTS kernel recommended)\n 6.Older series\n 7.Custom version (396.xx series or higher)\n choice[1-7?]: '`" CONDITION;
fi
# This will be treated as the latest regular driver.
if [ "$CONDITION" = "2" ]; then
echo '_driver_version=565.77' > options
echo '_md5sum=48d9a5b5999d0f30ec8326c94b34945e' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "3" ]; then
echo '_driver_version=560.35.03' > options
echo '_md5sum=d4f54004bb80da17b3e2fb21ac17c018' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "4" ]; then
echo '_driver_version=550.135' > options
echo '_md5sum=a8c3ae0076f11e864745fac74bfdb01f' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "5" ]; then
echo '_driver_version=470.256.02' > options
echo '_md5sum=57f54d5f6ddef5417215645aabbf9b9c' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "6" ]; then
read -p " Which legacy driver version do you want?`echo $'\n > 1.555 series: 555.58.02\n 2.545 series: 545.29.06\n 3.535 series: 535.183.01\n 4.530 series: 530.41.03\n 5.525 series: 525.147.05\n 6.520 series: 520.56.06\n 7.515 series: 515.86.01\n 8.510 series: 510.85.02\n 9.495 series: 495.46\n 10.465 series: 465.31\n 11.460 series: 460.91.03\n 12.455 series: 455.45.01\n 13.450 series: 450.119.03\n 14.440 series: 440.100 (kernel 5.8 or lower)\n 15.435 series: 435.21 (kernel 5.6 or lower)\n 16.430 series: 430.64 (kernel 5.5 or lower)\n 17.418 series: 418.113 (kernel 5.5 or lower)\n 18.415 series: 415.27 (kernel 5.4 or lower)\n 19.410 series: 410.104 (kernel 5.5 or lower)\n 20.396 series: 396.54 (kernel 5.3 or lower, 5.1 or lower recommended)\n choice[1-20?]: '`" CONDITION;
if [ "$CONDITION" = "2" ]; then
echo '_driver_version=545.29.06' > options
echo '_md5sum=406f748abf16db5d599b652c508b99fd' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "3" ]; then
echo '_driver_version=535.183.01' > options
echo '_md5sum=e9ea27c842436f3af6ccab7ec4727c0b' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "4" ]; then
echo '_driver_version=530.41.03' > options
echo '_md5sum=9049dbe01410eac1e05b249de10f6b91' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "5" ]; then
echo '_driver_version=525.147.05' > options
echo '_md5sum=bf00562896e64ebf3f28e528947049ce' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "6" ]; then
echo '_driver_version=520.56.06' > options
echo '_md5sum=18136ef051cbfc3850e88aa5184b31b8' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "7" ]; then
echo '_driver_version=515.86.01' > options
echo '_md5sum=5eaf6786f0c92cfcecb1ab950ff70df5' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "8" ]; then
echo '_driver_version=510.85.02' > options
echo '_md5sum=0367f772fc61bccecee8559c4fe9bb3d' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "9" ]; then
echo '_driver_version=495.46' > options
echo '_md5sum=db1d6b0f9e590249bbf940a99825f000' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "10" ]; then
echo '_driver_version=465.31' > options
echo '_md5sum=4996eefa54392b0c9541d22e88abab66' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "11" ]; then
echo '_driver_version=460.91.03' > options
echo '_md5sum=15c5ada08bdb25d757d90e0f21b6f270' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "12" ]; then
echo '_driver_version=455.45.01' > options
echo '_md5sum=f0161877350aa9155eada811ff2844a8' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "13" ]; then
echo '_driver_version=450.119.03' > options
echo '_md5sum=b2725b8c15a364582be90c5fa1d6690f' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "14" ]; then
echo '_driver_version=440.100' > options
echo '_md5sum=7b99bcd2807ecd37af60d29de7bc30c2' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "15" ]; then
echo '_driver_version=435.21' > options
echo '_md5sum=050acb0aecc93ba15d1fc609ee82bebe' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "16" ]; then
echo '_driver_version=430.64' > options
echo '_md5sum=a4ea35bf913616c71f104f15092df714' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "17" ]; then
echo '_driver_version=418.113' > options
echo '_md5sum=0b21dbabaa25beed46c20a177e59642e' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "18" ]; then
echo '_driver_version=415.27' > options
echo '_md5sum=f4777691c4673c808d82e37695367f6d' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "19" ]; then
echo '_driver_version=410.104' > options
echo '_md5sum=4f3219b5fad99465dea399fc3f4bb866' >> options
echo '_driver_branch=regular' >> options
elif [ "$CONDITION" = "20" ]; then
echo '_driver_version=396.54' > options
echo '_md5sum=195afa93d400bdbb9361ede6cef95143' >> options
echo '_driver_branch=regular' >> options
else
echo '_driver_version=555.58.02' > options
echo '_md5sum=f6efa3d40fccc97fbac9b55fc81e30d7' >> options
echo '_driver_branch=regular' >> options
fi
elif [ "$CONDITION" = "7" ]; then
echo '_driver_version=custom' > options
read -p "Which branch do you want?`echo $'\n> 1.Stable or regular beta\n 2.Vulkan dev\nchoice[1-2?]: '`" CONDITION;
if [ "$CONDITION" = "2" ]; then
echo '_driver_branch=vulkandev' >> options
read -p "Type the desired version number (format: xxx.xx.xx): " _driver_version;
else
echo '_driver_branch=regular' >> options
read -p "Type the desired version number (format: xxx.xx.xx or xxx.xxx or xxx.xx): " _driver_version;
fi
echo "_md5sum='SKIP'" >> options
echo "_driver_version=$_driver_version" >> options
# This (condition 1) will be treated as the latest Vulkan developer driver.
else
echo '_driver_version=550.40.82' > options
echo '_md5sum=7e1d4ae4c6f39a87c16deb1826c62d2a' >> options
echo '_driver_branch=vulkandev' >> options
fi
# Package type selector
if [ -z "$_dkms" ]; then
read -p "Build the dkms package or the regular one?`echo $'\n> 1.dkms (recommended)\n 2.regular\nchoice[1-2?]: '`" CONDITION;
if [ "$CONDITION" = "2" ]; then
echo '_dkms="false"' >> options
else
echo '_dkms="true"' >> options
fi
fi
else
_md5sum='SKIP'
fi
if [ -e options ]; then
source options
if [ "$_open_source_modules" != "false" ]; then
# Open source kernel module availability check
msg2 "Checking open driver availability..."
if [[ "$( curl -Is "https://download.nvidia.com/XFree86/NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-$_driver_version.tar.xz" | head -n 1 )" = *200* ]] || [[ "$( curl -Is "https://codeload.github.com/NVIDIA/open-gpu-kernel-modules/tar.gz/refs/tags/$_driver_version" | head -n 1 )" = *200* ]]; then
if [ -z "$_open_source_modules" ]; then
msg2 " - Open source kernel modules available - "
warning "IT ONLY OFFERS SUPPORT FOR TURING AND NEWER, AND DOESN'T OFFER ALL THE FEATURES OF THE PROPRIETARY ONE."
warning "SLI, G-Sync on notebooks and virtual GPU support are notably missing."
plain "Do you want to use it instead of the proprietary one?"
read -rp "`echo $' > N/y : '`" _open_source;
if [[ "$_open_source" =~ [yY] ]]; then
echo '_open_source_modules="true"' >> options
else
echo '_open_source_modules="false"' >> options
fi
fi
if [[ "$( curl -Is "https://download.nvidia.com/XFree86/NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-$_driver_version.tar.xz" | head -n 1 )" = *200* ]]; then
echo '_srcbase="NVIDIA-kernel-module-source"' >> options
elif [[ "$( curl -Is "https://codeload.github.com/NVIDIA/open-gpu-kernel-modules/tar.gz/refs/tags/$_driver_version" | head -n 1 )" = *200* ]]; then
echo '_srcbase="open-gpu-kernel-modules"' >> options
fi
else
msg2 "No open source kernel module available"
echo '_open_source_modules="false"' >> options
fi
source options
fi
fi
# Check if the version we are going for is newer or not if enabled
if [[ "$_only_update_if_newer" == "true" ]]; then
# Check current version, if possible
if pacman -Qs "nvidia-utils" >/dev/null; then
# We have enough packages installed to get the version
# returns a string, like "460.39" or "455.45.01"
# HACK Checks the first nvidia-utils match, does not catch potential missmatches and other stuff
_current_version=$(pacman -Q "nvidia-utils" | grep -oP '\d+(\.\d+)+' | head -n 1)
_current_package_example=$(pacman -Q "nvidia-utils" | grep -oP '[a-z]+(\-[a-z]+)+' | head -n 1)
msg2 "Found version $_current_version installed (from package '$_current_package_example')"
## HACK Stupid string compare
## TODO Ensure that nvidia versions do not differ from this format
if [[ $_driver_version > $_current_version ]]; then
# We have a newer version to install, do nothing
msg2 "Selected version ($_driver_version, $_driver_branch) is newer than installed version, continuing."
else
# Older version, or at least not newer version
msg2 "Selected version ($_driver_version, $_driver_branch) is not newer than installed version, exiting."
plain ""
if [ -e "$_EXT_CONFIG_PATH" ]; then
plain "If this is not intended, have a look at '$_EXT_CONFIG_PATH'"
else
plain "If this is not intended, have a look at '"$where"/customization.cfg'"
fi
# We have to clean up "options"
rm -f "${where}"/options
# TODO Do we need to clean up something more?
# TODO Should the exit_cleanup be called? (requires reorganization of script)
exit 0
fi
else
warning "'\$_only_update_if_newer' is enabled, but no installed driver found."
warning "Continuing on as if '\$_only_update_if_newer' was not enabled."
plain ""
fi
fi
msg2 "Building driver version $_driver_version on branch $_driver_branch."
_pkgname_array=()
# optional series in pkgname
if [ "$_series_in_pkgname" = "true" ]; then
_series="-${_driver_version%%.*}xx"
fi
if [ "$_driver_branch" = "vulkandev" ]; then
_branchname="nvidia$_series-dev"
else
_branchname="nvidia$_series"
fi
# packages
if [ "$_open_source_modules" = "true" ]; then
__branchname="$_branchname-open"
else
__branchname="$_branchname"
fi
if [ "$_dkms" = "full" ]; then
_pkgname_array+=("$__branchname-dkms-tkg")
_pkgname_array+=("$__branchname-tkg")
elif [ "$_dkms" = "true" ]; then
_pkgname_array+=("$__branchname-dkms-tkg")
else
_pkgname_array+=("$__branchname-tkg")
fi
_pkgname_array+=("$_branchname-utils-tkg")
if [ "$_lib32" = "true" ]; then
_pkgname_array+=("lib32-$_branchname-utils-tkg")
fi
if [ "$_opencl" = "true" ]; then
_pkgname_array+=("opencl-$_branchname-tkg")
if [ "$_lib32" = "true" ]; then
_pkgname_array+=("lib32-opencl-$_branchname-tkg")
fi
fi
if [ "$_nvsettings" = "true" ]; then
_pkgname_array+=("$_branchname-settings-tkg")
fi
if [ "$_eglwayland" = "true" ]; then
_pkgname_array+=("$_branchname-egl-wayland-tkg")
fi
pkgname=("${_pkgname_array[@]}")
pkgver=$_driver_version
pkgrel=263
arch=('x86_64')
url="http://www.nvidia.com/"
license=('custom:NVIDIA')
optdepends=('linux-headers' 'linux-lts-headers: Build the module for LTS Arch kernel')
options=(!strip !lto !buildflags)
cp "$where"/patches/* "$where" && cp -r "$where"/system/* "$where"
# Installer name
_pkg="NVIDIA-Linux-x86_64-$pkgver"
# Source
if [ "$_driver_branch" = "vulkandev" ]; then
if (( ${pkgver%%.*} >= 525 )); then
_source_name="NVIDIA-Linux-x86_64-$pkgver.run::https://developer.nvidia.com/downloads/vulkan-beta-${pkgver//.}-linux"
elif [[ $pkgver = 396* ]]; then
_source_name="NVIDIA-Linux-x86_64-$pkgver.run::https://developer.nvidia.com/linux-${pkgver//.}"
else
_source_name="NVIDIA-Linux-x86_64-$pkgver.run::https://developer.nvidia.com/vulkan-beta-${pkgver//.}-linux"
fi
else
_source_name="https://us.download.nvidia.com/XFree86/Linux-x86_64/$pkgver/NVIDIA-Linux-x86_64-$pkgver.run"
fi
source=($_source_name
'10-nvidia-drm-outputclass.conf'
'nvidia-utils-tkg.sysusers'
'60-nvidia.rules'
'nvidia-tkg.hook'
'nvidia-open-gcc-ibt-sls.diff'
'gcc-14-470.diff'
'gcc-14.diff'
'linux-version.diff' # include linux version
'01-ipmi-vm.diff' # ipmi & vm patch for older than 415.22 releases (2018.12.7) (396.xx)
'02-ipmi-vm.diff' # ipmi & vm patch for older than 415.22 releases (2018.12.7) (addon for 410+)
'list_is_first.diff' # fix for "redefinition of ‘list_is_first’" on <418.56 drivers when used on 5.1+
'kernel-4.16.patch' # 4.16 workaround
'kernel-4.19.patch' # 4.19 workaround
'kernel-5.0.patch' # 5.0 workaround
'kernel-5.1.patch' # 5.1 workaround
'kernel-5.2.patch' # 5.2 workaround
'kernel-5.3.patch' # 5.3 workaround
'kernel-5.4.patch' # 5.4 workaround
'kernel-5.4-symver.diff' # 5.4 symver fix only
'kernel-5.4-prime.diff' # 5.4+ PRIME fixing attempt
'kernel-5.5.patch' # 5.5 workaround
'kernel-5.6.patch' # 5.6 workaround
'5.6-legacy-includes.diff' # 5.6 includes needed for <440.59(stable) and <440.58.01(vk dev)
'5.6-ioremap.diff' # 5.6 additional ioremap workaround (<440.64)
'kernel-5.7.patch' # 5.7 workaround
'kernel-5.8.patch' # 5.8 workaround
'5.8-legacy.diff' # 5.8 additional vmalloc workaround (<450.57)
'kernel-5.9.patch' # 5.9 workaround
'5.9-gpl.diff' # 5.9 cuda/nvenc workaround
'kernel-5.10.patch' # 5.10 workaround
'kernel-5.11.patch' # 5.11 workaround
'5.11-legacy.diff' # 5.11 additional workaround (<460.32.03)
'455-crashfix.diff' # 455 drivers fix - https://forums.developer.nvidia.com/t/455-23-04-page-allocation-failure-in-kernel-module-at-random-points/155250/79
'kernel-5.12.patch' # 5.12 workaround
'kernel-5.14.patch' # 5.14 workaround
'kernel-5.16.patch' # 5.16 workaround
'kernel-5.16-std.diff' # 5.16 workaround for 470.6x
'kernel-5.17.patch' # 5.17 workaround
'kernel-6.0.patch'
'kernel-6.0-470.patch' # acpi backports from 515.x for 470.x
'kernel-6.2.patch'
'kernel-6.3.patch'
'legacy-kernel-6.4.diff'
'kernel-6.4.patch'
'legacy-kernel-6.5.diff'
'kernel-6.5.patch'
'legacy-kernel-6.6.diff'
'6.1-6-7-8-gpl.diff'
'kernel-6.8.patch'
'make-modeset-fbdev-default.diff'
'make-modeset-fbdev-default-565.diff'
'6.11-fbdev.diff'
'nvidia-sleep.conf'
'kernel-6.12.patch'
'silence-event-assert-until-570.diff'
'fix-hdmi-names.diff'
)
msg2 "Selected driver integrity check behavior (md5sum or SKIP): $_md5sum" # If the driver is "known", return md5sum. If it isn't, return SKIP
md5sums=("$_md5sum"
'cb27b0f4a78af78aa96c5aacae23256c'
'3d2894e71d81570bd00bce416d3e547d'
'552087b81ab385edf016adac0b33db7a'
'596f7cbf2db48d4f5b1c38967bb93cea'
'9b1543768ea75320fd0d2315de66d1c8'
'afb98b1dab0c61df526d4c0ee4d18abf'
'e5d1574892eb68de9af1b79a6bfb5e7b'
'7a825f41ada7e106c8c0b713a49b3bfa'
'd961d1dce403c15743eecfe3201e4b6a'
'14460615a9d4e247c8d9bcae8776ed48'
'401859ea7bb4a9864af24ecd67abf34c'
'adb83cede754daf5adb001f077b1ff67'
'58d058367934813d29d38328bc3b4dcd'
'6cff80c311debfdb6b543e575a81820a'
'a3ce8ebab6506f556f4b222e2372ce87'
'98b67a671ece0a796f9767793c209c93'
'6f9a62ef76ac86f299b0174f44488987'
'8bf41d705afdf9aad7d934be06a7b12b'
'0d9aa49647cc73a4522246cc22ae15e1'
'e6270c2d19afd982efc92bdecd9f48f0'
'1c1966d6ee6f3cd381ebcc92f1488c68'
'c44e43638e1ab708fbdd6d7aa76afcf2'
'84dc2d2eff2846b2f961388b153e2a89'
'1f11f5c765e42c471b202e630e3cd407'
'd911a0531c6f270926cacabd1dd80f02'
'589dfc0c801605018b7ccd690f06141a'
'd67bf0a9aa5c19f07edbaf6bd157d661'
'888d12b9aea711e6a025835b8ad063e2'
'0758046ed7c50463fd0ec378e9e34f95'
'bcdd512edad1bad8331a8872259d2581'
'fd0d6e14e675a61f32279558678cfc36'
'8764cc714e61363cc8f818315957ad17'
'08bec554de265ce5fdcfdbd55fb608fc'
'3980770412a1d4d7bd3a16c9042200df'
'f5fd091893f513d2371654e83049f099'
'd684ca11fdc9894c14ead69cb35a5946'
'0f987607c98eb6faeb7d691213de6a70'
'a70bc9cbbc7e8563b48985864a11de71'
'31128900574dec9ebdb753db50ef4f16'
'0b9b855d9be313153a5903e46e774a30'
'5d573b1aa0712b9bd2000c9fefdf84c2'
'a6acbba08173769399658914eb86a212'
'f0173a8bce0124b2d62a54f2e22d1552'
'4f855bb0e0b84e8e5d072c687256767a'
'50d3eac54d14d44d70df92770a3a9abf'
'b81cac7573842ebd7af30fdf851c63f9'
'd11cb3bd76ab61a0f086aea9a0c53087'
'f7f95287eb18be63bfad0427f13b6d43'
'7481cb7f52b76c426d579b115e4c84b6'
'c06a9359969ba331bc9fac91fe0eeff2'
'c691df97015eee42d51b34b147dd5236'
'adfcf56ea4a4a420d9ef07b9d4b451dc'
'2b5b62c1265b3b6b18022a0a716e5fcd'
'676d7039ff5b5e2bdd03db08fd1cba4e'
'0e54e7d932e520c403181e3348d4d42b'
'6904323d3a4ad04a708c927e930efc34')
if [ "$_open_source_modules" = "true" ]; then
if [[ "$_srcbase" == "NVIDIA-kernel-module-source" ]]; then
source+=("NVIDIA-kernel-module-source-$pkgver.tar.xz::https://download.nvidia.com/XFree86/NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-${pkgver}.tar.xz")
elif [[ "$_srcbase" == "open-gpu-kernel-modules" ]]; then
source+=("$pkgname-$pkgver.tar.gz::https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/${pkgver}.tar.gz")
fi
md5sums+=("SKIP")
fi
if [ "$_autoaddpatch" = "true" ]; then
# Auto-add *.patch files from $startdir to source=()
for _patch in $(find "$startdir" -maxdepth 1 -name '*.patch' -printf "%f\n"); do
# Don't duplicate already listed ones
if [[ ! " ${source[@]} " =~ " $_patch " ]]; then # https://stackoverflow.com/a/15394738/1821548
source+=("$_patch")
md5sums+=('SKIP')
fi
done
fi
_create_links() {
# create missing soname links
find "$pkgdir" -type f -name '*.so*' ! -path '*xorg/*' -print0 | while read -d $'\0' _lib; do
if [[ $_lib != *libnvidia-vulkan-producer.* ]]; then # Workaround no SONAME entry for libnvidia-vulkan-producer.so
_dirname="$(dirname "${_lib}")"
_original="$(basename "${_lib}")"
_soname="$(readelf -d "${_lib}" | grep -Po 'SONAME.*: \[\K[^]]*' || true)" # Get soname/base name
_base="$(echo ${_soname} | sed -r 's/(.*)\.so.*/\1.so/')"
cd "${_dirname}"
# Create missing links
if ! [[ -z "${_soname}" ]]; then # if not empty
if ! [[ -e "./${_soname}" ]]; then
ln -s $(basename "${_lib}") "./${_soname}"
fi
fi
if ! [[ -z "${_base}" ]]; then # if not empty (if _soname is empty, _base should be too)
if ! [[ -e "./${_base}" ]]; then
ln -s "./${_soname}" "./${_base}"
fi
fi
fi
done
cd "${where}"
}
prepare() {
# Remove previous builds
[ -d "$_pkg" ] && rm -rf "$_pkg"
# Use custom compiler paths if defined
if [ -n "${CUSTOM_GCC_PATH}" ]; then
PATH=${CUSTOM_GCC_PATH}/bin:${CUSTOM_GCC_PATH}/lib:${CUSTOM_GCC_PATH}/include:${PATH}
fi
if [ "$_gcc14_fix" = "true" ] && [[ "$(gcc -dumpversion)" = 14* ]]; then
_gcc14="true"
msg2 "GCC 14 detected"
fi
# Extract
msg2 "Self-Extracting $_pkg.run..."
sh "$_pkg".run -x
if [ "$_open_source_modules" = "true" ]; then
cd ${_srcbase}-${pkgver}
# Fix for https://bugs.archlinux.org/task/74886
if (( ${pkgver%%.*} < 525 )); then
patch -Np1 --no-backup-if-mismatch -i "$srcdir"/nvidia-open-gcc-ibt-sls.diff
fi
# Enable modeset and fbdev as default
# This avoids various issue, when Simplefb is used
# https://gitlab.archlinux.org/archlinux/packaging/packages/nvidia-utils/-/issues/14
# https://github.com/rpmfusion/nvidia-kmod/blob/master/make_modeset_default.patch
if (( ${pkgver%%.*} < 565 )); then
msg2 "Applying make-modeset-fbdev-default.diff for kernel-open..."
( cd "$srcdir"/"$_pkg"/kernel-open && patch -Np2 -i "$srcdir"/make-modeset-fbdev-default.diff )
fi
if (( ${pkgver%%.*} == 565 )); then
# Enable modeset and fbdev as default
# This avoids various issue, when Simplefb is used
# https://gitlab.archlinux.org/archlinux/packaging/packages/nvidia-utils/-/issues/14
# https://github.com/rpmfusion/nvidia-kmod/blob/master/make_modeset_default.patch
msg2 "Applying make-modeset-fbdev-default-565.diff for kernel-open..."
( cd "$srcdir"/"$_pkg"/kernel-open && patch -Np2 -i "$srcdir"/make-modeset-fbdev-default-565.diff )
# Patch by Nvidia to silence error messages until a real fix drops in 570.xx
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/716#issuecomment-2391898884
msg2 "Applying silence-event-assert-until-570.diff for kernel-open..."
patch -Np1 -i "$srcdir"/silence-event-assert-until-570.diff
# Patch by Nvidia to fix HDMI names which are otherwise broken in the /proc/asound/NVidia/* ELD files
# Should hopefully ship with 570.xx
# https://github.com/NVIDIA/open-gpu-kernel-modules/pull/715
msg2 "Applying fix-hdmi-names.diff for kernel-open..."
patch -Np1 -i "$srcdir"/fix-hdmi-names.diff
fi
# Attempt to make this reproducible
sed -i "s/^HOSTNAME.*/HOSTNAME = echo archlinux"/ utils.mk
sed -i "s/^WHOAMI.*/WHOAMI = echo archlinux-builder"/ utils.mk
sed -i "s/^DATE.*/DATE = date -r version.mk"/ utils.mk
sed -i "s/__VERSION_STRING/${pkgver}/" kernel-open/dkms.conf
sed -i 's/__JOBS/`nproc`/' kernel-open/dkms.conf
sed -i 's/__EXCLUDE_MODULES//' kernel-open/dkms.conf
sed -i 's/__DKMS_MODULES//' kernel-open/dkms.conf
sed -i '$i\
BUILT_MODULE_NAME[0]="nvidia"\
BUILT_MODULE_LOCATION[0]="kernel-open"\
DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\
BUILT_MODULE_NAME[1]="nvidia-uvm"\
BUILT_MODULE_LOCATION[1]="kernel-open"\
DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\
BUILT_MODULE_NAME[2]="nvidia-modeset"\
BUILT_MODULE_LOCATION[2]="kernel-open"\
DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\
BUILT_MODULE_NAME[3]="nvidia-drm"\
BUILT_MODULE_LOCATION[3]="kernel-open"\
DEST_MODULE_LOCATION[3]="/kernel/drivers/video"\
BUILT_MODULE_NAME[4]="nvidia-peermem"\
BUILT_MODULE_LOCATION[4]="kernel-open"\
DEST_MODULE_LOCATION[4]="/kernel/drivers/video"' kernel-open/dkms.conf
# Clean version for later copying for DKMS
cp -r ../${_srcbase}-${pkgver} "$srcdir"/open-gpu-kernel-modules-dkms
cd "$srcdir/$_pkg"
bsdtar -xf nvidia-persistenced-init.tar.bz2
else
cd "$_pkg"
# linux-rt fix for newer drivers. This just passes the same value regardless of kernel type as a bypass. This was stolen from https://gitlab.manjaro.org/packages/community/realtime-kernels/linux416-rt-extramodules/blob/master/nvidia/PKGBUILD - Thanks Muhownage <3
sed -i -e 's|PREEMPT_RT_PRESENT=1|PREEMPT_RT_PRESENT=0|g' kernel/conftest.sh
# non-english locale workaround for 440.26
if [[ $pkgver = 440.26 ]]; then
sed -i -e 's|$CC $CFLAGS -c conftest_headers$$.c|LC_ALL=C $CC $CFLAGS -c conftest_headers$$.c|g' kernel/conftest.sh
fi
# 440.58.01 Unfrogging
if [[ $pkgver = 440.58.01 ]]; then
sed -i -e '/bug/d' nvidia-application-profiles-440.58.01-rc
fi
cp -a kernel kernel-dkms
cd kernel-dkms
sed -i "s/__VERSION_STRING/${pkgver}/" dkms.conf
sed -i 's/__JOBS/`nproc`/' dkms.conf
sed -i 's/__DKMS_MODULES//' dkms.conf
if (( ${pkgver%%.*} >= 470 )); then
sed -i '$iBUILT_MODULE_NAME[0]="nvidia"\
DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\
BUILT_MODULE_NAME[1]="nvidia-uvm"\
DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\
BUILT_MODULE_NAME[2]="nvidia-modeset"\
DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\
BUILT_MODULE_NAME[3]="nvidia-drm"\
DEST_MODULE_LOCATION[3]="/kernel/drivers/video"\
BUILT_MODULE_NAME[4]="nvidia-peermem"\
DEST_MODULE_LOCATION[4]="/kernel/drivers/video"' dkms.conf
elif (( ${pkgver%%.*} = 465 )); then
sed -i '$iBUILT_MODULE_NAME[0]="nvidia"\
DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\
BUILT_MODULE_NAME[1]="nvidia-uvm"\
DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\
BUILT_MODULE_NAME[2]="nvidia-modeset"\
DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\
BUILT_MODULE_NAME[3]="nvidia-drm"\
DEST_MODULE_LOCATION[3]="/kernel/drivers/video"\
BUILT_MODULE_NAME[4]="nvidia-peermem"\
DEST_MODULE_LOCATION[4]="/kernel/drivers/video"\
BUILT_MODULE_NAME[5]="nvidia-ib-peermem-stub"\
DEST_MODULE_LOCATION[5]="/kernel/drivers/video"' dkms.conf
else
sed -i '$iBUILT_MODULE_NAME[0]="nvidia"\
DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\
BUILT_MODULE_NAME[1]="nvidia-uvm"\
DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\
BUILT_MODULE_NAME[2]="nvidia-modeset"\
DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\
BUILT_MODULE_NAME[3]="nvidia-drm"\
DEST_MODULE_LOCATION[3]="/kernel/drivers/video"' dkms.conf
fi
# Gift for linux-rt guys
sed -i 's/NV_EXCLUDE_BUILD_MODULES/IGNORE_PREEMPT_RT_PRESENCE=1 NV_EXCLUDE_BUILD_MODULES/' dkms.conf
cd ../
bsdtar -xf nvidia-persistenced-init.tar.bz2
if [[ $pkgver = 396* ]] || [[ $pkgver = 410* ]] || [[ $pkgver = 415* ]] || [[ $pkgver = 418* ]] || [[ $pkgver = 430* ]]; then
sed -i 's/__NV_VK_ICD__/libGLX_nvidia.so.0/' nvidia_icd.json.template
fi
# Loop kernels (4.15.0-1-ARCH, 4.14.5-1-ck, ...)
local -a _kernels
if [ -n "$_kerneloverride" ]; then
_kernels="$_kerneloverride"
else
mapfile -t _kernels < <(find /usr/lib/modules/*/build/version -exec cat {} + || find /usr/lib/modules/*/extramodules/version -exec cat {} +)
fi
for _kernel in "${_kernels[@]}"; do
# Use separate source directories
cp -r kernel kernel-"$_kernel"
cd "$srcdir"/"$_pkg"/kernel-"$_kernel"
if (( ${pkgver%%.*} <= 455 )); then
msg2 "Applying linux-version.diff for $_kernel..."
patch -p2 -i "$srcdir"/linux-version.diff
fi
# https://forums.developer.nvidia.com/t/455-23-04-page-allocation-failure-in-kernel-module-at-random-points/155250/77
# Not sure if it actually affects 455.50.02 - let's skip the patch on that version for now
if [[ $pkgver = 455.2* ]] || [[ $pkgver = 455.3* ]] || [[ $pkgver = 455.4* ]]; then
msg2 "Applying 455 crashfix for $_kernel..."
patch -p2 -i "$srcdir"/455-crashfix.diff
fi
cd ..
## kernel version variables, quirks & driver patch whitelists
# https://bugs.archlinux.org/task/62142
if [ "$_62142_fix" = "true" ]; then
sed -i 's/return (ops->map_resource != NULL);/return (ops \&\& ops->map_resource);/' "$srcdir/$_pkg/kernel-$_kernel/nvidia/nv-dma.c" && msg2 "Applied fix for https://bugs.archlinux.org/task/62142"
fi
# 4.16
if (( $(vercmp "$_kernel" "4.16") >= 0 )); then
_kernel416="1"
_whitelist416=( 396* 410* 415* 418.3* 418.4* 418.52.0* 418.52.10 418.52.14 )
fi
# 4.19
if (( $(vercmp "$_kernel" "4.19") >= 0 )); then
_kernel419="1"
_whitelist419=( 396* )
fi
# 4.20
if (( $(vercmp "$_kernel" "4.20") >= 0 )); then
# Fix for "unknown type name 'ipmi_user_t'" (required for older than 2018.12.7 drivers when used on 4.20+)
if [[ $pkgver = 396* ]] || [[ $pkgver = 410.5* ]] || [[ $pkgver = 410.6* ]] || [[ $pkgver = 410.7* ]] || [[ $pkgver = 415.1* ]]; then
_oldstuff="1"
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying 01-ipmi-vm.diff for $_kernel..."
patch -p2 -i "$srcdir"/01-ipmi-vm.diff
if [[ $pkgver != 396* ]]; then
_youngeryetoldstuff="1"
msg2 "Applying 02-ipmi-vm.diff for $_kernel..."
patch -p2 -i "$srcdir"/02-ipmi-vm.diff
fi
cd ..
else
msg2 "Skipping ipmi-vm fixes (not needed for this driver/kernel combination)"
fi
fi
# 5.0
if (( $(vercmp "$_kernel" "5.0") >= 0 )); then
_kernel50="1"
_whitelist50=( 396* 410.5* 410.6* 410.7* 410.9* 415* )
fi
# 5.1
if (( $(vercmp "$_kernel" "5.1") >= 0 )); then
_kernel51="1"
_whitelist51=( 396* 410* 415* 418.3* 418.4* 418.52.0* 418.52.10 )
if [[ $pkgver != 430* ]]; then
sed -i "s/static int nv_drm_vma_fault(struct vm_fault \*vmf)/#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)\nstatic int nv_drm_vma_fault(struct vm_fault \*vmf)\n#else\nstatic vm_fault_t nv_drm_vma_fault(struct vm_fault \*vmf)\n#endif/g" "$srcdir/$_pkg/kernel-$_kernel/nvidia-drm/nvidia-drm-gem-nvkms-memory.c"
if [[ $pkgver = 396* ]] || [[ $pkgver = 410* ]] || [[ $pkgver = 415* ]] || [[ $pkgver = 418.3* ]] || [[ $pkgver = 418.4* ]]; then
_low418="1"
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying list_is_first.diff for $_kernel..."
# Use sed for the moving parts of the patch - Fix for "redefinition of ‘list_is_first’" (required for older than 418.56 drivers when used on 5.1+)
sed -i "s/static inline int list_is_first(const struct list_head \*list,/#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)\nstatic inline int list_is_first(const struct list_head \*list,/g" "$srcdir/$_pkg/kernel-$_kernel/common/inc/nv-list-helpers.h"
sed -i "s/ const struct list_head \*head)/ const struct list_head \*head)\n#else\nstatic inline int nv_list_is_first(const struct list_head \*list,\n const struct list_head \*head)\n#endif/g" "$srcdir/$_pkg/kernel-$_kernel/common/inc/nv-list-helpers.h"
patch -Np2 -i "$srcdir"/list_is_first.diff
cd ..
else
msg2 "Skipping list_is_first fixes (not needed for this driver/kernel combination)"
fi
fi
fi
# 5.2
if (( $(vercmp "$_kernel" "5.2") >= 0 )); then
_kernel52="1"
_whitelist52=( 396* 410* 415* 418.3* 418.4* 418.56 418.7* 418.52.0* 418.52.10 418.52.14 )
fi
# 5.3
if (( $(vercmp "$_kernel" "5.3") >= 0 )); then
_kernel53="1"
_whitelist53=( 396* 410* 415* 418.3* 418.4* 418.5* 418.7* 418.8* )
fi
# 5.4
if (( $(vercmp "$_kernel" "5.4") >= 0 )); then
_kernel54="1"
_whitelist54=( 410* 415* 418.3* 418.4* 418.5* 418.7* 418.8* 430.0* 430.1* 430.2* 430.3* 430.4* 430.5* 435.1* 435.21* 435.24* 435.27.01 )
if [[ $pkgver = 435.27.02 ]] || [[ $pkgver = 435.27.03 ]] || [[ $pkgver = 435.27.06 ]] || [[ $pkgver = 435.27.07 ]] || [[ $pkgver = 435.27.08 ]] || [[ $pkgver = 440.26 ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying kernel-5.4-symver.diff for $_kernel..."
patch -Np2 -i "$srcdir"/kernel-5.4-symver.diff
cd ..
fi
if [[ $pkgver = 410* ]] || [[ $pkgver = 415* ]] || [[ $pkgver = 418.* ]] || [[ $pkgver = 430.0* ]] || [[ $pkgver = 435.* ]] || [[ $pkgver = 440.2* ]] || [[ $pkgver = 440.3* ]] || [[ $pkgver = 440.43.* ]] || [[ $pkgver = 440.44 ]] && [ "$_54_prime_fixing_attempt" = "true" ]; then
_54_prime="true"
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying kernel-5.4-prime.diff for $_kernel..."
patch -Np2 -i "$srcdir"/kernel-5.4-prime.diff
cd ..
fi
fi
# 5.5
if (( $(vercmp "$_kernel" "5.5") >= 0 )); then
_kernel55="1"
_whitelist55=( 410* 418* 430* 435* 440.2* 440.3* 440.43.01 440.44 )
fi
# 5.6
if (( $(vercmp "$_kernel" "5.6") >= 0 )); then
_kernel56="1"
_whitelist56=( 435* 440.2* 440.3* 440.4* 440.5* 440.6* )
if [[ $pkgver = 418.* ]] || [[ $pkgver = 435.* ]] || [[ $pkgver = 440.2* ]] || [[ $pkgver = 440.3* ]] || [[ $pkgver = 440.4* ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying 5.6-legacy-includes.diff for $_kernel..."
patch -Np2 -i "$srcdir"/5.6-legacy-includes.diff
msg2 "Applying 5.6-ioremap.diff for $_kernel..."
patch -Np2 -i "$srcdir"/5.6-ioremap.diff
cd ..
elif [[ $pkgver = 440.5* ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying 5.6-ioremap.diff for $_kernel..."
patch -Np2 -i "$srcdir"/5.6-ioremap.diff
cd ..
fi
fi
# 5.7
if (( $(vercmp "$_kernel" "5.7") >= 0 )); then
_kernel57="1"
_whitelist57=( 440* )
fi
# 5.8
if (( $(vercmp "$_kernel" "5.8") >= 0 )); then
_kernel58="1"
_whitelist58=( 440* 450.3* 450.51 450.56.01 )
if [[ $pkgver = 44* ]] || [[ $pkgver = 450.3* ]] || [[ $pkgver = 450.51 ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying 5.8-legacy.diff for $_kernel..."
patch -Np2 -i "$srcdir"/5.8-legacy.diff
cd ..
fi
fi
# 5.9
if (( $(vercmp "$_kernel" "5.9") >= 0 )); then
_kernel59="1"
_whitelist59=( 450.5* 450.6* )
fi
# 5.9 - 5.10 quirk
if (( $(vercmp "$_kernel" "5.9") >= 0 )) || (( $(vercmp "$_kernel" "5.10") >= 0 )); then
if [[ $pkgver = 450* ]] || [[ $pkgver = 455.2* ]] || [[ $pkgver = 455.3* ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying 5.9-gpl.diff for $_kernel..."
patch -Np2 -i "$srcdir"/5.9-gpl.diff
cd ..
fi
fi
# 5.10
if (( $(vercmp "$_kernel" "5.10") >= 0 )); then
_kernel510="1"
_whitelist510=( 450.5* 450.6* 450.8* 455.2* 455.3* )
fi
# 5.11
if (( $(vercmp "$_kernel" "5.11") >= 0 )); then
_kernel511="1"
_whitelist511=( 455.45* 455.50.0* 455.50.10 455.50.12 455.50.14 460.27* 460.32* )
if [[ $pkgver = 455.45* ]] || [[ $pkgver = 455.50* ]] || [[ $pkgver = 460.27* ]] && [[ $pkgver != 455.50.19 ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying 5.11-legacy.diff for $_kernel..."
patch -Np2 -i "$srcdir"/5.11-legacy.diff
cd ..
fi
fi
# 5.12
if (( $(vercmp "$_kernel" "5.12") >= 0 )); then
_kernel512="1"
_whitelist512=( 455.4* 455.5* )
fi
# 5.14
if (( $(vercmp "$_kernel" "5.14") >= 0 )); then
_kernel514="1"
_whitelist514=( 465* 470.4* 470.5* )
fi
# 5.16
if (( $(vercmp "$_kernel" "5.16") >= 0 )); then
_kernel516="1"
_whitelist516=( 470.8* 470.9* 495*)
if [[ $pkgver = 470.62.* ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying kernel-5.16-std.diff for $_kernel..."
patch -Np2 -i "$srcdir"/kernel-5.16-std.diff
cd ..
fi
fi
# 5.17
if (( $(vercmp "$_kernel" "5.17") >= 0 )); then
_kernel517="1"
_whitelist517=( 470.62.* 495*)
fi
# 6.0
if (( $(vercmp "$_kernel" "6.0") >= 0 )); then
_kernel60="1"
_whitelist60=( 515.6* 470.4* 470.5* 470.6* 470.7* 470.8* 470.9* 470.10* 470.12* 470.14* )
fi
# 6.2
if (( $(vercmp "$_kernel" "6.2") >= 0 )); then
_kernel62="1"
_whitelist62=( 525.5* 525.6* 525.7* )
fi
# 6.3
if (( $(vercmp "$_kernel" "6.3") >= 0 )); then
_kernel63="1"
_whitelist63=( 470.4* 470.5* 470.6* 470.7* 470.8* 470.9* 470.10* 470.12* 470.14* 470.16* 470.18* )
fi
# 6.4
if (( $(vercmp "$_kernel" "6.4") >= 0 )); then
_kernel64="1"
_whitelist64=( 470.4* 470.5* 470.6* 470.7* 470.8* 470.9* 470.10* 470.12* 470.14* 470.16* 470.18* 530* )
if [[ $pkgver = 470.199* ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying legacy-kernel-6.4.patch for $_kernel..."
patch -Np2 -i "$srcdir"/legacy-kernel-6.4.diff
cd ..
fi
fi
# 6.5
if (( $(vercmp "$_kernel" "6.5") >= 0 )); then
_kernel65="1"
_whitelist65=(525.5* 525.6* 525.7* 525.8* 525.10* 525.11* 525.12* 530* 535.5* 535.43.02)
if [[ $pkgver = 470.199* ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying legacy-kernel-6.5.patch for $_kernel..."
patch -Np2 -i "$srcdir"/legacy-kernel-6.5.diff
cd ..
fi
fi
# 6.6
if (( $(vercmp "$_kernel" "6.6") >= 0 )); then
_kernel66="1"
_whitelist66=()
if [[ $pkgver = 470.199* ]]; then
cd ..
fi
fi
# 6.1-6-7-8 GPL
if (( $(vercmp "$_kernel" "6.1") >= 0 )) || (( $(vercmp "$_kernel" "6.6") >= 0 )) || (( $(vercmp "$_kernel" "6.7") >= 0 )) || (( $(vercmp "$_kernel" "6.8") >= 0 )); then
if [[ $pkgver = 470.4* ]] || [[ $pkgver = 470.5* ]] || [[ $pkgver = 470.6* ]] || [[ $pkgver = 470.7* ]] || [[ $pkgver = 470.8* ]] || [[ $pkgver = 470.9* ]] || [[ $pkgver = 470.1* ]] || [[ $pkgver = 470.22* ]] || [[ $pkgver = 535.4* ]] || [[ $pkgver = 535.5* ]] || [[ $pkgver = 535.8* ]] || [[ $pkgver = 535.9* ]] || [[ $pkgver = 535.10* ]] || [[ $pkgver = 535.11* ]] || [[ $pkgver = 535.12* ]] || [[ $pkgver = 535.14* ]] || [[ $pkgver = 535.15* ]] || [[ $pkgver = 545.* ]] || [[ $pkgver = 550.40.07 ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying 6.1-6-7-8-gpl.diff for $_kernel..."
patch -Np2 -i "$srcdir"/6.1-6-7-8-gpl.diff
cd ..
fi
fi
# 6.6
if (( $(vercmp "$_kernel" "6.8") >= 0 )); then
_kernel68="1"
_whitelist68=(525*)
fi
# 6.11
if (( $(vercmp "$_kernel" "6.11") >= 0 )); then
if [[ $pkgver = 560.* ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
# Enable modeset and fbdev as default
# This avoids various issue, when Simplefb is used
# https://gitlab.archlinux.org/archlinux/packaging/packages/nvidia-utils/-/issues/14
# https://github.com/rpmfusion/nvidia-kmod/blob/master/make_modeset_default.patch
msg2 "Applying make-modeset-fbdev-default.diff for $_kernel..."
patch -Np2 -i "$srcdir"/make-modeset-fbdev-default.diff
# Add fix for fbdev "phantom" monitor with 6.11
# https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/issues/80
msg2 "Applying 6.11-fbdev.diff for $_kernel..."
patch -Np2 -i "$srcdir"/6.11-fbdev.diff
cd ..
elif [[ $pkgver = 565.* ]]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
# Enable modeset and fbdev as default
# This avoids various issue, when Simplefb is used
# https://gitlab.archlinux.org/archlinux/packaging/packages/nvidia-utils/-/issues/14
# https://github.com/rpmfusion/nvidia-kmod/blob/master/make_modeset_default.patch
msg2 "Applying make-modeset-fbdev-default-565.diff for $_kernel..."
patch -Np2 -i "$srcdir"/make-modeset-fbdev-default-565.diff
cd ..
fi
fi
# 6.12
if (( $(vercmp "$_kernel" "6.12") >= 0 )); then
_kernel612="1"
_whitelist612=( 565.57* )
fi
if [ "$_gcc14" = "true" ]; then
cd "$srcdir"/"$_pkg"/kernel-$_kernel
msg2 "Applying gcc-14 patch..."
if [[ $pkgver = 470* ]]; then
patch -Np2 -i "$srcdir"/gcc-14-470.diff
else
patch -Np2 -i "$srcdir"/gcc-14.diff
fi
cd ..
fi
# Loop patches (linux-4.15.patch, lol.patch, ...)
for _p in $(printf -- '%s\n' ${source[@]} | grep .patch); do # https://stackoverflow.com/a/21058239/1821548
# Patch version (4.15, "", ...)
_patch=$(echo $_p | grep -Po "\d+\.\d+")
# Cd in place
cd "$srcdir"/"$_pkg"/kernel-$_kernel