summaryrefslogtreecommitdiff
path: root/libre/grub/PKGBUILD
blob: 5865ab712b07d1991263565d18049f949964bb58 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
# Maintainer (Arch): Tobias Powalowski <tpowa@archlinux.org>
# Maintainer (Arch): Ronald van Haren <ronald.archlinux.org>
# Contributor (Arch): Keshav Amburay <(the ddoott ridikulus ddoott rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
# Maintainer: André Silva <emulatorman@parabola.nu>
# Maintainer: Márcio Silva <coadde@parabola.nu>


### ARM_UBOOT - loadaddr ###
# 0x00007fc0   - versatile[versatile_ab/versatile_pb]
# 0x00100000   - snowball/u8500_href
# 0x00800000   - dns325/highbank/wireless_space
# 0x02000000   - zynq[zynq_microzed/zynq_picozed/zynq_zc702/zynq_zc706/zynq_zc70x/zynq_zc770[zynq_zc770_xm010/zynq_zc770_xm012/zynq_zc770_xm013]/zynq_zed/zynq_zybo]
# 0x08000000   - grub
# 0x10800000   - cm_fx6
# 0x12000000   - aristainetos[aristainetos/aristainetos2]/mx6[mx6slevk/mx6sxsabresd]
# 0x40007000   - origen
# 0x43e00000   - origen
# 0x60008000   - vexpress_ca9x4
# 0x70800000   - ima3-mx53/mx53evk/mx53smd
# 0x72000000   - mx53ard/mx53loco
# 0x80000000   - am335x_bur[kwb/tseries]/am3517[am3517_crane/am3517_evm]/mcx
# 0x80007fc0   - am335x_ti[pcm051]
# 0x80008000   - vexpress_ca9x4/vexpress[vexpress_ca15_tc2/vexpress_ca5x2](extended-mem)
# 0x80100000   - am335x_bur[kwb]/ls2085a[ls2085a_emu/ls2085a_simu/ls2085aqds/ls2085ardb]
# 0x80200000   - am335x_bur[tseries]/am335x_ti[am335x_evm/omap3_beagle/pengwyn]/ti814x_evm
# 0x80800000   - * flea3/mx31ads/mx35pdk/qong/woodburn/woodburn_sd
# 0x81000000   - ti814x_evm * mx25pdk/omap3_logic/ti816x_evm/tx25
# 0x82000000   - am335x_ti[am335x_evm/omap3_beagle/pcm051/pengwyn]/am3517[am3517_crane/am3517_evm]/mcx
#               /mx6[gw_ventana[gwventana]/mx6cuboxi/mx6qarm2[mx6dlarm2]/mx6qsabreauto[mx6dlsabreauto]/mx6sabresd[mx6dlsabresd/mx6qsabresd]]
#               /omap3_ti[devkit8000]
# *              bav335x/cm_t335/cm_t3517/dig297/omap3_evm/omap3_igep00x0/omap3_mvblx/omap3_sdp3430/omap3_zoom1/tao3530
# 0x84000000   - am335x_baltos
# 0x90000000   - vexpress64_base[vexpress_aemv8a_semi]/vexpress64_juno[vexpress_aemv8a_juno]
# 0x90000000UL - ls2085a[ls2085a_emu/ls2085a_simu/ls2085aqds/ls2085ardb]
# 0x90800000   - vision2
# 0x92000000   - mx51evk
# 0xa0008000   - vexpress[vexpress_ca15_tc2/vexpress_ca5x2](extended-mem)
# 0xa0800000   - imx27lite
# 0xc0000014   - davinci[ea20]
# 0xc0700000   - davinci[ea20]
# 0x12000000   - udoo_dl udoo_quad

# alt
# am335x_igep0033
# am43xx_evm
# apalis_t30
# apf27
# apx4devkit
# armadillo-800eva
# arndale
# aspenite
# at91rm9200ek
# at91sam9260ek at91sam9g20ek/at91sam9xeek
# at91sam9261ek at91sam9g10ek
# at91sam9263ek
# at91sam9m10g45ek
# at91sam9n12ek
# at91sam9rlek
# at91sam9x5ek
# balloon3
# bav335x birdland_bav335a/birdland_bav335b
# bcm28155_ap bcm11130/bcm28155_w1d
# bcmcygnus bcm911360/bcm911360k/bcm958300k/bcm958305k
# bcmnsp bcm958622hr
# beagle_x15
# beaver
# bg0900
# calimain
# cam_enc_4xx
# cardhu
# cgtqmx6eval cgtqmx6qeval
# cm_t335
# cm_t3517
# cm_t35
# cm_t54
# colibri_pxa270
# colibri_t20
# colibri_t30
# colibri_vf
# corvus
# cpu9260 cpu9G20
# cpuat91
# da830evm
# da850evm da850_am18xxevm
# dalmore
# davinci_dm355evm
# davinci_dm355leopard
# davinci_dm365evm
# davinci_dm6467evm davinci_dm6467Tevm
# davinci_dvevm
# davinci_schmoogie
# davinci_sffsdr
# davinci_sonata
# db-88f6820-gp
# db-mv784mp-gp
# devkit3250
# devkit8000
# dig297
# dockstar
# dra7xx_evm
# draco
# dreamplug
# duovero
# eb_cpux9k2
# eco5pk
# edb93xx edb9315a
# edminiv2
# embestmx6boards marsboard/riotboard
# enbw_cmc
# ethernut5
# flea3
# goflexhome
# gose
# gplugd
# guruplug
# h2200
# harmony
# ib62x0
# iconnect
# imx27lite
# imx31_litekit
# imx31_phycore
# integrator_ap integratorap_cm720t/integratorap_cm920t/integratorap_cm926ej_s/integratorap_cm946es
# integrator_cp integratorcp_cm1136/integratorcp_cm920t/integratorcp_cm926ej_s/integratorcp_cm946es
# ipam390
# jetson-tk1
# jornada
# k2e_evm
# k2hk_evm
# k2l_evm
# km_kirkwood kmcoge5un/kmnusa/kmsugp1/kmsuv31/mgcoge3un/portl2
# koelsch
# kosagi_novena novena
# kzm9g
# lager
# lp8x4x
# ls1021aqds
# ls1021atwr
# lsxl lschlv2/lsxhl
# magnesium
# maxbcm
# mcx
# medcom-wide
# meesc
# m28evk
# m53evk
# mt_ventoux
# mv88f6281gtw_ge
# mx23_olinuxino
# mx23evk
# mx25pdk
# mx28evk
# mx31ads
# mx31pdk
# mx35pdk
# mx51_efikamx mx51_efikasb
# mx51evk
# nas220
# net2big_v2 d2net_v2
# netspace_v2 inetspace_v2/netspace_lite_v2/netspace_max_v2/netspace_mini_v2
# nitrogen6x mx6qsabrelite/nitrogen6dl2g/nitrogen6dl/nitrogen6q2g/nitrogen6q/nitrogen6s1g/nitrogen6s
# nokia_rx51
# nomadik_nhk8815
# nyan-big
# odroid
# odroid-xu3
# omap3_cairo cairo
# omap3_evm
# omap3_evm_quick
# omap3_igep00x0 igep0020/igep0030/igep0032
# omap3_logic
# omap3_mvblx
# omap3_overo
# omap3_pandora
# omap3_sdp3430
# omap3_zoom1
# omap4_panda
# omap4_sdp4430
# omap5_uevm
# omapl138_lcdk
# openrd
# origen
# ot1200
# otc570
# palmld
# palmtreo680
# paz00
# peach-pi
# peach-pit
# pengwyn
# pepper
# platinum_picon
# platinum_titanium
# plutux
# pm9261
# pm9263
# pm9g45
# pogo_e02
# porter
# pxa255_idp
# pxm2
# qong
# rastaban
# rd6281a
# rpi_2
# rpi
# rut
# s5p_goni
# s5pc210_universal
# sama5d3_xplained
# sama5d3xek
# sama5d4_xplained
# sama5d4ek
# sansa_fuze_plus
# sc_sps_1
# scb9328
# seaboard
# secomx6 secomx6quq7
# sheevaplug
# silk
# smdk2410
# smdk5250
# smdk5420
# smdkc100
# smdkv310
# snapper9260 snapper9g20
# snow
# socfpga_arria5
# socfpga_cyclone5 socfpga_socrates
# spear300
# spear310
# spear320
# spear600
# stamp9g20 portuxg20
# stm32f429-discovery
# stv0991
# sun4i-a10-a1000(mele)
# sun4i-a10-ba10-tvbox
# sun4i-a10-chuwi-v7-cw0825
# sun4i-a10-cubieboard
# sun4i-a10-gemei-g9
# sun4i-a10-hyundai-a7hd
# sun4i-a10-inet-3f
# sun4i-a10-inet-3w
# sun4i-a10-jesurun-q5
# sun4i-a10-marsboard
# sun4i-a10-mini-xplus
# sun4i-a10-mk802
# sun4i-a10-mk802ii
# sun4i-a10-olinuxino-lime
# sun4i-a10-pcduino
# sun5i-a10s-auxtek-t004
# sun5i-a10s-mk802
# sun5i-a10s-olinuxino-micro
# sun5i-a10s-r7-tv-dongle
# sun5i-a13-ampe-a76
# sun5i-a13-forfun-q88db
# sun5i-a13-inet-86vs
# sun5i-a13-olinuxino
# sun5i-a13-olinuxino-micro
# sun5i-a13-tzx-q8-713b7
# sun5i-a13-utoo-p66
# sun6i-a31-colombus
# sun6i-a31-hummingbird
# sun6i-a31-i7(mele)
# sun6i-a31-m9(mele)
# sun6i-a31-mele-a1000g-quad
# sun6i-a31-mixtile-loftq
# sun6i-a31s-cs908
# sun6i-a31s-primo81(msi)
# sun7i-a20-ainol-aw1
# sun7i-a20-bananapi
# sun7i-a20-bananapro
# sun7i-a20-cubieboard2
# sun7i-a20-cubietruck
# sun7i-a20-i12-tvbox
# sun7i-a20-m3(mele)
# sun7i-a20-m5(mele)
# sun7i-a20-mk808c
# sun7i-a20-olinuxino-lime
# sun7i-a20-olinuxino-lime2
# sun7i-a20-olinuxino-micro
# sun7i-a20-orangepi
# sun7i-a20-orangepi-mini
# sun7i-a20-pcduino3
# sun7i-a20-pcduino3-nano
# sun7i-a20-primo73(msi)
# sun7i-a20-wexler-tab7200
# sun7i-a20-wits-pro-a20-dkt
# sun7i-a20-yones-toptech-bd1078
# sun8i-a23-ippo-q8h-v1.2
# sun8i-a23-ippo-q8h-v5
# sun8i-a33-et-q8-v1.6
# sun8i-a33-ga10h-v1.1
# sun8i-a33-ippo-q8h-v1.2
# sun8i-a33-sinlinx-sina33
# sun9i-a80-optimus(merri)
# tao3530 omap3_ha
# taurus axm
# tbs2910
# tec
# tec-ng
# thuban
# ti814x_evm
# ti816x_evm
# titanium
# tk71
# tqma6 tqma6q_mba6/tqma6s_mba6
# trats
# trats2
# tricorder
# trimslice
# trizepsiv polaris
# tseries
# tt01
# twister
# tx25
# uniphier-ph1-ld4-ref
# uniphier-ph1-pro4-ref
# uniphier-ph1-sld8-ref
# usb_a9263
# usbarmory
# VCMA9
# venice2
# ventana
# vf610twr
# vl_ma2sc
# vpac270
# wandboard
# warp
# whistler
# woodburn
# woodburn_sd
# work_92105
# x600
# xaeniax
# xfi3
# xilinx_zynqmp
# zipitz2
# zmx25


## '1' to enable IA32-EFI build in Arch x86_64, '0' to disable
_IA32_EFI_IN_ARCH_X64='1'

## '1' to enable IA32-XEN build in Arch x86_64, "0" to disable
_IA32_XEN_IN_ARCH_X64='1'

## '1' to enable EMU build (x86_64 and i686 only), "0" to disable
_GRUB_EMU_BUILD='0'

_pkgver='2.02'
_GRUB_GIT_TAG='grub-2.02-beta2'
_GRUB_EXTRAS_COMMIT=4a56e2c2cc3d78f12f1788c27669a651071dee49

_UNIFONT_VER='6.3.20131217'

[[ "${CARCH}" = 'armv7h' ]] && _EFI_ARCH='arm'
[[ "${CARCH}" = 'x86_64' ]] && _EFI_ARCH='x86_64'
[[ "${CARCH}" = 'i686' ]] && _EFI_ARCH='i386'

[[ "${CARCH}" = 'x86_64' ]] && _XEN_ARCH='x86_64'
[[ "${CARCH}" = 'i686' ]] && _XEN_ARCH='i386'

[[ "${CARCH}" = 'armv7h' ]] && _EMU_ARCH='arm'
[[ "${CARCH}" = 'x86_64' ]] && _EMU_ARCH='x86_64'
[[ "${CARCH}" = 'i686' ]] && _EMU_ARCH='i386'

pkgbase='grub'
pkgname=('grub')
[[ $CARCH = armv7h ]] && pkgname+=('grub-am335x_bone' 'grub-udoo' 'grub-omap3_beagle'
                                   'grub-omap3_beagle_xm' 'grub-omap3_beagle_xm_ab')
pkgdesc='GNU GRand Unified Bootloader (2), (Parabola rebranded)'
pkgver='2.02.beta2'
pkgrel='6.parabola1'
epoch='1'
url='https://www.gnu.org/software/grub/'
arch=('x86_64' 'i686' 'armv7h')
license=('GPL3')
backup=('etc/default/grub' 'etc/grub.d/40_custom')
install="${pkgname}.install"
options=('!makeflags')
depends=('sh' 'xz' 'gettext' 'device-mapper')
makedepends=('git' 'rsync' 'xz' 'freetype2' 'ttf-dejavu' 'python' 'autogen'
             'texinfo' 'help2man' 'gettext' 'device-mapper' 'fuse')

if [[ "${CARCH}" = 'x86_64' ]] || [[ "${CARCH}" = 'i686' ]]; then
	makedepends+=('xen')
fi

if [[ "${_GRUB_EMU_BUILD}" = '1' ]]; then
	makedepends+=('libusbx' 'sdl')
fi

optdepends=('freetype2: For grub-mkfont usage'
            'fuse: For grub-mount usage'
            'dosfstools: For grub-mkrescue FAT FS and EFI support' 
            'efibootmgr: For grub-install EFI support'
            'libisoburn: Provides xorriso for generating grub rescue iso using grub-mkrescue'
            'os-prober: To detect other OSes when generating grub.cfg in BIOS systems'
            'mtools: For grub-mkrescue FAT FS support')

if [[ "${CARCH}" = 'x86_64' ]] || [[ "${CARCH}" = 'i686' ]]; then
	provides=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}")
	conflicts=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}" 'grub-legacy' 'grub-parabola')
	replaces=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}" 'grub-parabola')
elif [[ "$CARCH" = 'armv7h' ]]; then
	provides=('grub-common' 'grub-emu' "grub-efi-${_EFI_ARCH}")
	conflicts=('grub-common' 'grub-emu' "grub-efi-${_EFI_ARCH}")
	replaces=('grub-common' 'grub-emu' "grub-efi-${_EFI_ARCH}")
fi

source=("grub-${_pkgver}::git+git://git.sv.gnu.org/grub.git#tag=${_GRUB_GIT_TAG}"
        "grub-extras::git+git://git.sv.gnu.org/grub-extras.git#commit=${_GRUB_EXTRAS_COMMIT}"
        "http://ftp.gnu.org/gnu/unifont/unifont-${_UNIFONT_VER}/unifont-${_UNIFONT_VER}.bdf.gz"
        "http://ftp.gnu.org/gnu/unifont/unifont-${_UNIFONT_VER}/unifont-${_UNIFONT_VER}.bdf.gz.sig"
        '0001-Fix-security-issue-when-reading-username-and-passwor.patch'
        'grub-10_linux-20_linux_xen-detect-parabola-initramfs.patch'
        'grub-add-GRUB_COLOR_variables.patch'
        '60_memtest86+'
        'grub.default'
        'grub-10_linux-20_linux_xen-detect-am335x_bone+am335x_boneblack-devicetree-file.patch'
        'grub-10_linux-20_linux_xen-detect-omap3_beagle-devicetree-file.patch'
        'grub-10_linux-20_linux_xen-detect-omap3_beagle_xm-devicetree-file.patch'
        'grub-10_linux-20_linux_xen-detect-omap3_beagle_xm_ab-devicetree-file.patch'
        'grub-10_linux-20_linux_xen-detect-udoo-devicetree-file.patch'
        'grub-10_linux-20_linux_xen-rebrand-free-distros.patch')

md5sums=('SKIP'
         'SKIP'
         '728b7439ac733a7c0d56049adec364c7'
         'SKIP'
         '9589ec46a04f9bb4d5da987340a4a324'
         '3a9bb9bafe0062388e11f72f0e80ba7e'
         'e506ae4a9f9f7d1b765febfa84e10d48'
         'be55eabc102f2c60b38ed35c203686d6'
         '8d1dd54ae4a1b550c097e056892ce953'
         'a46695e19b588a53b8bac9e3b3c56096'
         '803f5b5f56ba6d74ca84aea67659116e'
         'b2c20ce3aa7944636b3ea499b40f2160'
         '7e3245bdd30e291f44ab8a00b8a38f3e'
         '95b721dfe74f42df52b7ae94e0e7c067'
         'e0133ad89ab3014210d4599f396a556e')

validpgpkeys=('95D2E9AB8740D8046387FD151A09227B1F435A33') #Paul Hardy

_pkgver() {
	cd "${srcdir}/grub-${_pkgver}/"
	echo "$(git describe --tags)" | sed -e 's|grub.||g' -e 's|-|\.|g'
}

prepare() {
	cd "${srcdir}/grub-${_pkgver}/"

	msg 'CVE-2015-8370'
	patch -Np1 -i "${srcdir}/0001-Fix-security-issue-when-reading-username-and-passwor.patch"

	msg 'Patch to detect of Parabola GNU/Linux-libre initramfs images by grub-mkconfig'
	patch -Np1 -i "${srcdir}/grub-10_linux-20_linux_xen-detect-parabola-initramfs.patch"

	msg 'Patch to enable GRUB_COLOR_* variables in grub-mkconfig'
	## Based on http://lists.gnu.org/archive/html/grub-devel/2012-02/msg00021.html
	patch -Np1 -i "${srcdir}/grub-add-GRUB_COLOR_variables.patch"

	msg 'Fix DejaVuSans.ttf location so that grub-mkfont can create *.pf2 files for starfield theme'
	sed 's|/usr/share/fonts/dejavu|/usr/share/fonts/dejavu /usr/share/fonts/TTF|g' -i "${srcdir}/grub-${_pkgver}/configure.ac"

	msg 'Rebranding for some free distros'
	patch -Np1 -i "${srcdir}/grub-10_linux-20_linux_xen-rebrand-free-distros.patch"

	msg "Fix mkinitcpio 'rw' FS#36275"
	sed 's| ro | rw |g' -i "${srcdir}/grub-${_pkgver}/util/grub.d/10_linux.in"

	# msg 'autogen.sh requires python (2/3). since bzr is in makedepends, use python2 and no need to pull python3'
	# sed 's|python |python2 |g' -i "${srcdir}/grub-${_pkgver}/autogen.sh"

	msg 'Pull in latest language files'
	./linguas.sh

	msg 'Remove not working langs which need LC_ALL=C.UTF-8'
	sed -e 's#en@cyrillic en@greek##g' -i "${srcdir}/grub-${_pkgver}/po/LINGUAS"

	msg 'Avoid problem with unifont during compile of grub, http://savannah.gnu.org/bugs/?40330 and https://bugs.archlinux.org/task/37847'
	cp "${srcdir}/unifont-${_UNIFONT_VER}.bdf" "${srcdir}/grub-${_pkgver}/unifont.bdf"

	# DISABLED TEMPORARY, due fail to build.
	# msg "Add the grub-extra sources for BIOS build"
	# install -d "${srcdir}/grub-${_pkgver}/grub-extras"
	# cp -r "${srcdir}/grub-extras/915resolution" "${srcdir}/grub-${_pkgver}/grub-extras/915resolution" # failed in compilation
	# export GRUB_CONTRIB="${srcdir}/grub-${_pkgver}/grub-extras/"
}

_build_grub-efi() {
	msg "Copy the source for building the ${_EFI_ARCH} EFI part"
	cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-efi-${_EFI_ARCH}"
	cd "${srcdir}/grub-${_pkgver}-efi-${_EFI_ARCH}/"

	msg "Unset all compiler FLAGS for ${_EFI_ARCH} EFI build"
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-efi-${_EFI_ARCH}/"

	msg 'Run autogen.sh for ${_EFI_ARCH} EFI build'
	./autogen.sh

	msg "Run ./configure for ${_EFI_ARCH} EFI build"
	./configure \
		--with-platform="efi" \
		--target="${_EFI_ARCH}" \
		--disable-efiemu \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-boot-time \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--prefix="/usr" \
		--bindir="/usr/bin" \
		--sbindir="/usr/bin" \
		--mandir="/usr/share/man" \
		--infodir="/usr/share/info" \
		--datarootdir="/usr/share" \
		--sysconfdir="/etc" \
		--program-prefix="" \
		--with-bootdir="/boot" \
		--with-grubdir="grub" \
		--disable-silent-rules \
		--disable-werror

	msg "Run make for ${_EFI_ARCH} EFI build"
	make
}

_build_grub-xen() {
	msg "Copy the source for building the ${_XEN_ARCH} XEN part"
	cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-xen-${_XEN_ARCH}"
	cd "${srcdir}/grub-${_pkgver}-xen-${_XEN_ARCH}/"

	msg "Unset all compiler FLAGS for ${_XEN_ARCH} XEN build"
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-xen-${_XEN_ARCH}/"

	msg "Run autogen.sh for ${_XEN_ARCH} XEN build"
	./autogen.sh

	msg "Run ./configure for ${_XEN_ARCH} XEN build"
	./configure \
		--with-platform='xen' \
		--target="${_XEN_ARCH}" \
		--disable-efiemu \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-boot-time \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--prefix='/usr' \
		--bindir='/usr/bin' \
		--sbindir='/usr/bin' \
		--mandir='/usr/share/man' \
		--infodir='/usr/share/info' \
		--datarootdir='/usr/share' \
		--sysconfdir='/etc' \
		--program-prefix='' \
		--with-bootdir='/boot' \
		--with-grubdir='grub' \
		--disable-silent-rules \
		--disable-werror

	msg "Run make for ${_XEN_ARCH} XEN build"
	make
}

_build_grub-bios() {
	msg 'Set ARCH dependent variables for BIOS build'
	if [[ "${CARCH}" = 'x86_64' ]]; then
		_EFIEMU='--enable-efiemu'
	else
		_EFIEMU='--disable-efiemu'
	fi

	msg 'Copy the source for building the BIOS part'
	cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-bios"
	cd "${srcdir}/grub-${_pkgver}-bios/"

	msg 'Unset all compiler FLAGS for BIOS build'
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-bios/"
	
	msg 'Run autogen.sh for BIOS build'
	./autogen.sh

	msg 'Run ./configure for BIOS build'
	./configure \
		--with-platform='pc' \
		--target='i386' \
		"${_EFIEMU}" \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-boot-time \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--prefix='/usr' \
		--bindir='/usr/bin' \
		--sbindir='/usr/bin' \
		--mandir='/usr/share/man' \
		--infodir='/usr/share/info' \
		--datarootdir='/usr/share' \
		--sysconfdir='/etc' \
		--program-prefix='' \
		--with-bootdir='/boot' \
		--with-grubdir='grub' \
		--disable-silent-rules \
		--disable-werror

	msg 'Run make for BIOS build'
	make
}

_build_grub-qemu() {
	msg 'Copy the source for building the QEMU part'
	cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-qemu"
	cd "${srcdir}/grub-${_pkgver}-qemu/"

	msg 'Unset all compiler FLAGS for QEMU build'
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-qemu/"

	msg 'Run autogen.sh for QEMU build'
	./autogen.sh

	msg 'Run ./configure for QEMU build'
	./configure \
		--with-platform='qemu' \
		--target='i386' \
		--disable-efiemu \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-boot-time \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--prefix='/usr' \
		--bindir='/usr/bin' \
		--sbindir='/usr/bin' \
		--mandir='/usr/share/man' \
		--infodir='/usr/share/info' \
		--datarootdir='/usr/share' \
		--sysconfdir='/etc' \
		--program-prefix='' \
		--with-bootdir='/boot' \
		--with-grubdir='grub' \
		--disable-silent-rules \
		--disable-werror

	msg 'Run make for QEMU build'
	make
}

_build_grub-ieee1275() {
	msg 'Copy the source for building the IEEE1275 (OpenFirmware) part'
	cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-ieee1275"
	cd "${srcdir}/grub-${_pkgver}-ieee1275/"

	msg 'Unset all compiler FLAGS for IEEE1275 (OpenFirmware) build'
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-ieee1275/"

	msg 'Run autogen.sh for IEEE1275 (OpenFirmware) build'
	./autogen.sh

	msg 'Run ./configure for IEEE1275 (OpenFirmware) build'
	./configure \
		--with-platform='ieee1275' \
		--target='i386' \
		--disable-efiemu \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-boot-time \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--prefix='/usr' \
		--bindir='/usr/bin' \
		--sbindir='/usr/bin' \
		--mandir='/usr/share/man' \
		--infodir='/usr/share/info' \
		--datarootdir='/usr/share' \
		--sysconfdir='/etc' \
		--program-prefix='' \
		--with-bootdir='/boot' \
		--with-grubdir='grub' \
		--disable-silent-rules \
		--disable-werror

	msg 'Run make for IEEE1275 (OpenFirmware) build'
	make
}

_build_grub-libreboot() {
	msg 'Copy the source for building the Libreboot part'
	cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-libreboot"
	cd "${srcdir}/grub-${_pkgver}-libreboot/"

	msg 'Unset all compiler FLAGS for Libreboot build'
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-libreboot/"

	msg 'Run autogen.sh for Libreboot build'
	./autogen.sh

	msg 'Run ./configure for Libreboot build'
	./configure \
		--with-platform='coreboot' \
		--target='i386' \
		--disable-efiemu \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-boot-time \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--prefix='/usr' \
		--bindir='/usr/bin' \
		--sbindir='/usr/bin' \
		--mandir='/usr/share/man' \
		--infodir='/usr/share/info' \
		--datarootdir='/usr/share' \
		--sysconfdir='/etc' \
		--program-prefix='' \
		--with-bootdir='/boot' \
		--with-grubdir='grub' \
		--disable-silent-rules \
		--disable-werror

	msg 'Run make for Libreboot build'
	make
}

_build_grub-multiboot() {
	msg 'Copy the source for building the Multiboot part'
	cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-multiboot"
	cd "${srcdir}/grub-${_pkgver}-multiboot/"

	msg 'Unset all compiler FLAGS for Multiboot build'
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-multiboot/"

	msg 'Run autogen.sh for Multiboot build'
	./autogen.sh

	msg 'Run ./configure for Multiboot build'
	./configure \
		--with-platform='multiboot' \
		--target='i386' \
		--disable-efiemu \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-boot-time \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--prefix='/usr' \
		--bindir='/usr/bin' \
		--sbindir='/usr/bin' \
		--mandir='/usr/share/man' \
		--infodir='/usr/share/info' \
		--datarootdir='/usr/share' \
		--sysconfdir='/etc' \
		--program-prefix='' \
		--with-bootdir='/boot' \
		--with-grubdir='grub' \
		--disable-silent-rules \
		--disable-werror

	msg 'Run make for Multiboot build'
	make
}

_build_grub-emu() {
	msg 'Copy the source for building the emu part'
	cp -r "${srcdir}/grub-${_pkgver}/" "${srcdir}/grub-${_pkgver}-emu/"

	msg 'Unset all compiler FLAGS for emu build'
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-emu/"

	msg 'Run autogen.sh for emu build'
	./autogen.sh

	msg 'Run ./configure for emu build'
	./configure \
		--with-platform='emu' \
		--target="${_EMU_ARCH}" \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--enable-grub-emu-usb=no \
		--enable-grub-emu-sdl=no \
		--disable-grub-emu-pci \
		--prefix='/usr' \
		--bindir='/usr/bin' \
		--sbindir='/usr/bin' \
		--mandir='/usr/share/man' \
		--infodir='/usr/share/info' \
		--datarootdir='/usr/share' \
		--sysconfdir='/etc' \
		--program-prefix='' \
		--with-bootdir='/boot' \
		--with-grubdir='grub' \
		--disable-silent-rules \
		--disable-werror

	msg 'Run make for emu build'
	make
}

_build_grub-uboot_am335x-bone() {
	msg "Copy the source for building the U-Boot (am335x-bone) part"
	cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-uboot_am335x-bone"
	cd "${srcdir}/grub-${_pkgver}-uboot_am335x-bone/"

	msg 'Patch to detect am335x-bone device tree blob file (dtb)'
	patch -Np1 -i "${srcdir}/grub-10_linux-20_linux_xen-detect-am335x_bone+am335x_boneblack-devicetree-file.patch"

	msg 'change memory adapted for am335x-bone support'
	sed -i '\|arm_uboot_ldflags| s|0x08000000|0x82000000|
                \|GRUB_KERNEL_ARM_UBOOT_LINK_ADDR| s|0x08000000|0x82000000|
	       ' grub-core/Makefile.core.def \
	         include/grub/offsets.h

	msg 'Unset all compiler FLAGS for U-Boot (am335x-bone) build'
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-uboot_am335x-bone/"

	msg 'Run autogen.sh for U-Boot (am335x-bone) build'
	./autogen.sh

	msg 'Run ./configure for U-Boot (am335x-bone) build'
	./configure \
		--with-platform='uboot' \
		--target='arm' \
		--disable-efiemu \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-boot-time \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--prefix='/usr' \
		--bindir='/usr/bin' \
		--sbindir='/usr/bin' \
		--mandir='/usr/share/man' \
		--infodir='/usr/share/info' \
		--datarootdir='/usr/share' \
		--sysconfdir='/etc' \
		--program-prefix='' \
		--with-bootdir='/boot' \
		--with-grubdir='grub' \
		--disable-silent-rules \
		--disable-werror

	msg 'Run make for U-Boot (am335x-bone) build'
	make
}

_build_grub-uboot_omap3_beagle() {
        msg "Copy the source for building the U-Boot (omap3_beagle) part"
        cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle"
        cd "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle/"

        msg 'Patch to detect omap3_beagle device tree blob file (dtb)'
        patch -Np1 -i "${srcdir}/grub-10_linux-20_linux_xen-detect-omap3_beagle-devicetree-file.patch"

        msg 'change memory adapted for omap3_beagle support'
        sed -i '\|arm_uboot_ldflags| s|0x08000000|0x82000000|
                \|GRUB_KERNEL_ARM_UBOOT_LINK_ADDR| s|0x08000000|0x82000000|
               ' grub-core/Makefile.core.def \
                 include/grub/offsets.h

        msg 'Unset all compiler FLAGS for U-Boot (omap3_beagle) build'
        unset CFLAGS
        unset CPPFLAGS
        unset CXXFLAGS
        unset LDFLAGS
        unset MAKEFLAGS

        cd "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle/"

        msg 'Run autogen.sh for U-Boot (omap3_beagle) build'
        ./autogen.sh

        msg 'Run ./configure for U-Boot (omap3_beagle) build'
        ./configure \
                --with-platform='uboot' \
                --target='arm' \
                --disable-efiemu \
                --enable-mm-debug \
                --enable-nls \
                --enable-device-mapper \
                --enable-cache-stats \
                --enable-boot-time \
                --enable-grub-mkfont \
                --enable-grub-mount \
                --prefix='/usr' \
                --bindir='/usr/bin' \
                --sbindir='/usr/bin' \
                --mandir='/usr/share/man' \
                --infodir='/usr/share/info' \
                --datarootdir='/usr/share' \
                --sysconfdir='/etc' \
                --program-prefix='' \
                --with-bootdir='/boot' \
                --with-grubdir='grub' \
                --disable-silent-rules \
                --disable-werror

        msg 'Run make for U-Boot (omap3_beagle) build'
        make
}

_build_grub-uboot_omap3_beagle_xm() {
        msg "Copy the source for building the U-Boot (omap3_beagle_xm) part"
        cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle_xm"
        cd "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle_xm/"

        msg 'Patch to detect omap3_beagle_xm device tree blob file (dtb)'
        patch -Np1 -i "${srcdir}/grub-10_linux-20_linux_xen-detect-omap3_beagle_xm-devicetree-file.patch"

        msg 'change memory adapted for omap3_beagle_xm support'
        sed -i '\|arm_uboot_ldflags| s|0x08000000|0x82000000|
                \|GRUB_KERNEL_ARM_UBOOT_LINK_ADDR| s|0x08000000|0x82000000|
               ' grub-core/Makefile.core.def \
                 include/grub/offsets.h

        msg 'Unset all compiler FLAGS for U-Boot (omap3_beagle_xm) build'
        unset CFLAGS
        unset CPPFLAGS
        unset CXXFLAGS
        unset LDFLAGS
        unset MAKEFLAGS

        cd "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle_xm/"

        msg 'Run autogen.sh for U-Boot (omap3_beagle_xm) build'
        ./autogen.sh

        msg 'Run ./configure for U-Boot (omap3_beagle_xm) build'
        ./configure \
                --with-platform='uboot' \
                --target='arm' \
                --disable-efiemu \
                --enable-mm-debug \
                --enable-nls \
                --enable-device-mapper \
                --enable-cache-stats \
                --enable-boot-time \
                --enable-grub-mkfont \
                --enable-grub-mount \
                --prefix='/usr' \
                --bindir='/usr/bin' \
                --sbindir='/usr/bin' \
                --mandir='/usr/share/man' \
                --infodir='/usr/share/info' \
                --datarootdir='/usr/share' \
                --sysconfdir='/etc' \
                --program-prefix='' \
                --with-bootdir='/boot' \
                --with-grubdir='grub' \
                --disable-silent-rules \
                --disable-werror

        msg 'Run make for U-Boot (omap3_beagle_xm) build'
        make
}

_build_grub-uboot_omap3_beagle_xm_ab() {
        msg "Copy the source for building the U-Boot (omap3_beagle_xm_ab) part"
        cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle_xm_ab"
        cd "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle_xm_ab/"

        msg 'Patch to detect omap3_beagle_xm_ab device tree blob file (dtb)'
        patch -Np1 -i "${srcdir}/grub-10_linux-20_linux_xen-detect-omap3_beagle_xm_ab-devicetree-file.patch"

        msg 'change memory adapted for omap3_beagle_xm_ab support'
        sed -i '\|arm_uboot_ldflags| s|0x08000000|0x82000000|
                \|GRUB_KERNEL_ARM_UBOOT_LINK_ADDR| s|0x08000000|0x82000000|
               ' grub-core/Makefile.core.def \
                 include/grub/offsets.h

        msg 'Unset all compiler FLAGS for U-Boot (omap3_beagle_xm_ab) build'
        unset CFLAGS
        unset CPPFLAGS
        unset CXXFLAGS
        unset LDFLAGS
        unset MAKEFLAGS

        cd "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle_xm_ab/"

        msg 'Run autogen.sh for U-Boot (omap3_beagle_xm_ab) build'
        ./autogen.sh

        msg 'Run ./configure for U-Boot (omap3_beagle_xm_ab) build'
        ./configure \
                --with-platform='uboot' \
                --target='arm' \
                --disable-efiemu \
                --enable-mm-debug \
                --enable-nls \
                --enable-device-mapper \
                --enable-cache-stats \
                --enable-boot-time \
                --enable-grub-mkfont \
                --enable-grub-mount \
                --prefix='/usr' \
                --bindir='/usr/bin' \
                --sbindir='/usr/bin' \
                --mandir='/usr/share/man' \
                --infodir='/usr/share/info' \
                --datarootdir='/usr/share' \
                --sysconfdir='/etc' \
                --program-prefix='' \
                --with-bootdir='/boot' \
                --with-grubdir='grub' \
                --disable-silent-rules \
                --disable-werror

        msg 'Run make for U-Boot (omap3_beagle_xm_ab) build'
        make
}

_build_grub-uboot_udoo() {
	msg "Copy the source for building the U-Boot (udoo) part"
	cp -r "${srcdir}/grub-${_pkgver}" "${srcdir}/grub-${_pkgver}-uboot_udoo"
	cd "${srcdir}/grub-${_pkgver}-uboot_udoo/"

	msg 'Patch to detect udoo device tree blob file (dtb)'
	patch -Np1 -i "${srcdir}/grub-10_linux-20_linux_xen-detect-udoo-devicetree-file.patch"

	msg 'change memory adapted for udoo support'
	sed -i '\|arm_uboot_ldflags| s|0x08000000|0x12000000|
                \|GRUB_KERNEL_ARM_UBOOT_LINK_ADDR| s|0x08000000|0x12000000|
	       ' grub-core/Makefile.core.def \
	         include/grub/offsets.h

	msg 'Unset all compiler FLAGS for U-Boot (udoo) build'
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS

	cd "${srcdir}/grub-${_pkgver}-uboot_udoo/"

	msg 'Run autogen.sh for U-Boot (udoo) build'
	./autogen.sh

	msg 'Run ./configure for U-Boot (udoo) build'
	./configure \
		--with-platform='uboot' \
		--target='arm' \
		--disable-efiemu \
		--enable-mm-debug \
		--enable-nls \
		--enable-device-mapper \
		--enable-cache-stats \
		--enable-boot-time \
		--enable-grub-mkfont \
		--enable-grub-mount \
		--prefix='/usr' \
		--bindir='/usr/bin' \
		--sbindir='/usr/bin' \
		--mandir='/usr/share/man' \
		--infodir='/usr/share/info' \
		--datarootdir='/usr/share' \
		--sysconfdir='/etc' \
		--program-prefix='' \
		--with-bootdir='/boot' \
		--with-grubdir='grub' \
		--disable-silent-rules \
		--disable-werror

	msg 'Run make for U-Boot (udoo) build'
	make
}

build() {
	cd "${srcdir}/grub-${_pkgver}/"

	if [[ "${CARCH}" = 'x86_64' ]] || [[ "${CARCH}" = 'i686' ]] || [[ "${CARCH}" = 'armv7h' ]]; then
		msg "Build grub ${_EFI_ARCH} EFI stuff"
		_build_grub-efi

		if [[ "${CARCH}" = 'x86_64' ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" = '1' ]]; then
			msg 'Build grub i386 EFI stuff'
			_EFI_ARCH='i386' _build_grub-efi
		fi
	fi

	if [[ "${CARCH}" = 'x86_64' ]] || [[ "${CARCH}" = 'i686' ]]; then
		msg "Build grub ${_XEN_ARCH} XEN stuff"
		_build_grub-xen

		if [[ "${CARCH}" = 'x86_64' ]] && [[ "${_IA32_XEN_IN_ARCH_X64}" = '1' ]]; then
			msg 'Build grub i386 XEN stuff'
			_XEN_ARCH='i386' _build_grub-xen
		fi

		msg 'Build grub BIOS stuff'
		_build_grub-bios

		msg 'Build grub QEMU stuff'
		_build_grub-qemu

		msg 'Build grub IEEE1275 (OpenFirmware) stuff'
		_build_grub-ieee1275

		msg 'Build grub Libreboot stuff'
		_build_grub-libreboot

		msg 'Build grub Multiboot stuff'
		_build_grub-multiboot

		msg "Build grub ${_XEN_ARCH} XEN stuff"
		_build_grub-xen
	elif [[ "${CARCH}" = 'armv7h' ]]; then
		msg 'Build grub U-Boot for BeagleBone and BeagleBone Black (am335x-bone) stuff'
		_build_grub-uboot_am335x-bone

		msg 'Build grub U-Boot for BeagleBoard (omap3_beagle) stuff'
		_build_grub-uboot_omap3_beagle

		msg 'Build grub U-Boot for BeagleBoard-xM (omap3_beagle_xm) stuff'
		_build_grub-uboot_omap3_beagle_xm

		msg 'Build grub U-Boot for BeagleBoard-xM rev A/B (omap3_beagle_xm_ab) stuff'
		_build_grub-uboot_omap3_beagle_xm_ab

		msg 'Build grub U-Boot for UDOO (udoo) stuff'
		_build_grub-uboot_udoo
	fi

	if [[ "${_GRUB_EMU_BUILD}" = '1' ]]; then
		msg 'Build grub emu stuff'
		_build_grub-emu
	fi
}

_package_grub-efi() {
	cd "${srcdir}/grub-${_pkgver}-efi-${_EFI_ARCH}/"

	msg "Run make install for ${_EFI_ARCH} EFI build"
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg "Remove gdb debugging related files for ${_EFI_ARCH} EFI build"
	rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/{kernel.exec,gdb_grub,gmodule.pl} || true
}

_package_grub-xen() {
	cd "${srcdir}/grub-${_pkgver}-xen-${_XEN_ARCH}/"

	msg "Run make install for ${_XEN_ARCH} XEN build"
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg "Remove gdb debugging related files for ${_XEN_ARCH} XEN build"
	rm -f "${pkgdir}/usr/lib/grub/${_XEN_ARCH}-xen"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/${_XEN_ARCH}-xen"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/${_XEN_ARCH}-xen"/{kernel.exec,gdb_grub,gmodule.pl} || true
}

_package_grub-bios() {
	cd "${srcdir}/grub-${_pkgver}-bios/"

	msg 'Run make install for BIOS build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for BIOS build'
	rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/i386-pc"/{kernel.exec,gdb_grub,gmodule.pl} || true
}

_package_grub-qemu() {
	cd "${srcdir}/grub-${_pkgver}-qemu/"

	msg 'Run make install for QEMU build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for QEMU build'
	rm -f "${pkgdir}/usr/lib/grub/i386-qemu"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/i386-qemu"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/i386-qemu"/{kernel.exec,gdb_grub,gmodule.pl} || true
}

_package_grub-ieee1275() {
	cd "${srcdir}/grub-${_pkgver}-ieee1275/"

	msg 'Run make install for IEEE1275 (OpenFirmware) build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for IEEE1275 (OpenFirmware) build'
	rm -f "${pkgdir}/usr/lib/grub/i386-ieee1275"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/i386-ieee1275"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/i386-ieee1275"/{kernel.exec,gdb_grub,gmodule.pl} || true
}

_package_grub-libreboot() {
	cd "${srcdir}/grub-${_pkgver}-libreboot/"

	msg 'Run make install for Libreboot build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for Libreboot build'
	rm -f "${pkgdir}/usr/lib/grub/i386-coreboot"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/i386-coreboot"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/i386-coreboot"/{kernel.exec,gdb_grub,gmodule.pl} || true
}

_package_grub-multiboot() {
	cd "${srcdir}/grub-${_pkgver}-multiboot/"

	msg 'Run make install for Multiboot build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for Multiboot build'
	rm -f "${pkgdir}/usr/lib/grub/i386-multiboot"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/i386-multiboot"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/i386-multiboot"/{kernel.exec,gdb_grub,gmodule.pl} || true
}

_package_grub-emu() {
	cd "${srcdir}/grub-${_pkgver}-emu/"

	msg 'Run make install for emu build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for emu build'
	rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/{kernel.exec,gdb_grub,gmodule.pl} || true
}

package_grub() {
	if [[ "${CARCH}" = 'i686' ]]; then
		optdepends+=('linux-libre-xen: For boot support into XEN server')
	fi

	if [[ "${_GRUB_EMU_BUILD}" = '1' ]]; then
		optdepends+=('libusbx: For grub-emu USB support'
		             'sdl: For grub-emu SDL support')
	fi

	cd "${srcdir}/grub-${_pkgver}/"

	if [[ "${CARCH}" = 'x86_64' ]] || [[ "${CARCH}" = 'i686' ]] || [[ "${CARCH}" = 'armv7h' ]]; then	
		msg "Package grub ${_EFI_ARCH} EFI stuff"
		_package_grub-efi

		if [[ "${CARCH}" = 'x86_64' ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" = '1' ]]; then
			msg 'Package grub i386 EFI stuff'
			_EFI_ARCH='i386' _package_grub-efi
		fi
	fi

	if [[ "${CARCH}" = 'x86_64' ]] || [[ "${CARCH}" = 'i686' ]]; then
		msg "Package grub ${_XEN_ARCH} XEN stuff"
		_package_grub-xen

		if [[ "${CARCH}" = 'x86_64' ]] && [[ "${_IA32_XEN_IN_ARCH_X64}" = '1' ]]; then
			msg 'Package grub i386 XEN stuff'
			_XEN_ARCH='i386' _package_grub-xen
		fi

		msg 'Package grub BIOS stuff'
		_package_grub-bios

		msg 'Package grub QEMU stuff'
		_package_grub-qemu

		msg 'Package grub IEEE1275 (OpenFirmware) stuff'
		_package_grub-ieee1275

		msg 'Package grub Libreboot stuff'
		_package_grub-libreboot

		msg 'Package grub Multiboot stuff'
		_package_grub-multiboot

		msg 'Install extra /etc/grub.d/ files'
		install -D -m0755 "${srcdir}/60_memtest86+" "${pkgdir}/etc/grub.d/60_memtest86+"
	fi

	if [[ "${_GRUB_EMU_BUILD}" = '1' ]]; then
		msg 'Package grub emu stuff'
		_package_grub-emu
	fi

	msg 'Install /etc/default/grub (used by grub-mkconfig)'
	install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
}

package_grub-am335x_bone() {
	pkgdesc='GNU GRand Unified Bootloader (2) for BeagleBone and BeagleBone Black (am335x-bone), (Parabola rebranded)'

	cd "${srcdir}/grub-${_pkgver}-uboot_am335x-bone/"

	msg 'Package grub U-Boot stuff'

	msg 'Run make install for U-Boot build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for U-Boot build'
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/{kernel.exec,gdb_grub,gmodule.pl} || true

	msg 'Install /etc/default/grub (used by grub-mkconfig)'
	install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
}

package_grub-omap3_beagle() {
	pkgdesc='GNU GRand Unified Bootloader (2) for BeagleBoard (omap3_beagle), (Parabola rebranded)'
	provides+=('grub-beagleboard')

	cd "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle/"

	msg 'Package grub U-Boot stuff'

	msg 'Run make install for U-Boot build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for U-Boot build'
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/{kernel.exec,gdb_grub,gmodule.pl} || true

	msg 'Install /etc/default/grub (used by grub-mkconfig)'
	install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
}

package_grub-omap3_beagle_xm() {
	pkgdesc='GNU GRand Unified Bootloader (2) for BeagleBoard-xM (omap3_beagle_xm), (Parabola rebranded)'
	provides+=('grub-beagleboard')

	cd "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle_xm/"

	msg 'Package grub U-Boot stuff'

	msg 'Run make install for U-Boot build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for U-Boot build'
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/{kernel.exec,gdb_grub,gmodule.pl} || true

	msg 'Install /etc/default/grub (used by grub-mkconfig)'
	install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
}

package_grub-omap3_beagle_xm_ab() {
	pkgdesc='GNU GRand Unified Bootloader (2) for BeagleBoard-xM rev A/B (omap3_beagle_xm_ab), (Parabola rebranded)'
	provides+=('grub-beagleboard')

	cd "${srcdir}/grub-${_pkgver}-uboot_omap3_beagle_xm_ab/"

	msg 'Package grub U-Boot stuff'

	msg 'Run make install for U-Boot build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for U-Boot build'
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/{kernel.exec,gdb_grub,gmodule.pl} || true

	msg 'Install /etc/default/grub (used by grub-mkconfig)'
	install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
}

package_grub-udoo() {
	pkgdesc='GNU GRand Unified Bootloader (2) for UDOO (udoo), (Parabola rebranded)'

	cd "${srcdir}/grub-${_pkgver}-uboot_udoo/"

	msg 'Package grub U-Boot stuff'

	msg 'Run make install for U-Boot build'
	make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install

	msg 'Remove gdb debugging related files for U-Boot build'
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.module || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/*.image || true
	rm -f "${pkgdir}/usr/lib/grub/arm-uboot"/{kernel.exec,gdb_grub,gmodule.pl} || true

	msg 'Install /etc/default/grub (used by grub-mkconfig)'
	install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
}