-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-script
executable file
·1709 lines (1495 loc) · 62.2 KB
/
install-script
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
#!/bin/bash
GET_ARCH="$(lscpu | grep -w '^Architecture' | sed 's/\s\s*/ /g' | cut -d ' ' -f 1 --complement | cut -d ' ' -f 1 -z)"
if [ $(nproc) -eq 16 ] || [ $(nproc) -gt 16 ]; then
_PARALLEL_THREADS="\$((\$(nproc)+1))"
elif [ $(nproc) -gt 4 ]; then
_PARALLEL_THREADS="\$((\$(nproc)-4))"
elif [ $(nproc) -eq 4 ]; then
_PARALLEL_THREADS="\$((\$(nproc)-2))"
elif [ $(nproc) -eq 2 ]; then
_PARALLEL_THREADS="\$((\$(nproc)-1))"
fi
case "${GET_ARCH}" in
x86_64)
;;
aarch64)
echo "Support for ${GET_ARCH} is planned."
;;
*)
echo "Support for ${GET_ARCH} is unavailable for this script at this time."
;;
esac
if test -x "$(command -v pacman > /dev/null 2>&1)"; then
if ! test -x "$(command -v genfstab > /dev/null 2>&1)"; then
echo "Package 'arch-install-scripts' needs to be installed; please install it first."
return 1
fi
DISTRO="Arch-based"
elif test -x "$(command -v emerge > /dev/null 2>&1)"; then
DISTRO="Gentoo-based"
else
echo "Either an Arch-based or Gentoo-based distro is required to use this script."
return 1
fi
LRED='\033[01;31m'
GREEN='\033[0;32m'
LCYAN='\033[1;36m'
LBLUE='\033[1;34m'
LPURPLE='\033[0;35m'
DGRAY='\033[1;30m'
NC='\033[0m' # No Color
MOUNT_LOCATION=/mnt/gentoo
TIMEZONE=America/Chicago # Change this to your relevant timezone located in "/usr/share/zoneinfo"
AUTODETECT_CPU_ARCH=true
AUTODETECT_CPU_FLAGS=true
# "march" and "mtune" needs to be configured based on what this command responds with:
# gcc -march=native -Q --help=target | grep -- '-march=' | cut -f3 | cut -d ' ' -f 1 -z
if [ ${AUTODETECT_CPU_ARCH} != false ]; then
echo "Setting CPU architecture"
CPU_ARCH="$(gcc -march=native -Q --help=target | grep -- '-march=' | cut -f3 | cut -d ' ' -f 1 -z)"
fi
CFLAGS="-march=${CPU_ARCH} -mtune-${CPU_ARCH} -O3 -pipe -fno-plt -pthread -fsanitize=bounds,alignment,object-size -fsanitize-undefined-trap-on-error \
-fvisibility=hidden -fexceptions -Wformat -Werror=format-security \
-Wvla -Wimplicit-fallthrough -Wno-unused-result -Wno-unneeded-internal-declaration -Warray-bounds"
# We want the CPU_FLAGS given by "cpuid2cpuflags" - this implementation only supports x86/x86_64 right now
if [ ${AUTODETECT_CPU_FLAGS} != false ]; then
echo "Installing cpuid2cpuflags"
case "${DISTRO}" in
"Arch-based")
if test -x "$( ! command -v cpuid2cpuflags > /dev/null 2>&1)"; then
echo "The 'cpuid2cpuflags' package is required to run this script."
echo "Please install it from the AUR before proceeding."
return 1
fi
;;
"Gentoo-based")
emerge --oneshot --noreplace cpuid2cpuflags
;;
*)
if test -x "$( ! command -v cpuid2cpuflags > /dev/null 2>&1)"; then
echo "Non-supported distro in-use; exiting."
return 1
fi
;;
esac
echo "Setting CPU_FLAGS"
CPU_FLAGS=$(cpuid2cpuflags | cut -c 1-15 --complement)
fi
## Not entirely sure how enabling "32", "x32", "abi_x86_32" works; my lack of understanding about that may either cause Wine build errors or needlessly installed 32-bit libraries
USE_FLAGS="a52 aac acpi branding cairo cdr dbus dri dts dvd dvdr encode exif flac gif gpm gui icu jpeg lcms libnotify mad mng mp3 mp4 mpeg ogg pdf png ppds spell startup-notification svg tiff truetype vorbis udev udisks unicode upower usb wxwidgets x264 xml xv xvid X xcb wayland acl bindist mmx sse sse2 initramfs redistributable elogind -suid -selinux xattr clang desktop-portal accessibility crypt bluetooth browser-integration sna pulseaudio pipewire pipewire-alsa policykit sysv-utils netifrc ncurses audit pam -systemd -test -examples layers vulkan opencl discord-presence mgba autotype browser keeshare network introspection zip steamruntime en-US d3d9 gles1 gles2 llvm lm-sensors opencl osmesa valgrind xa xvmc zink 64 32 x32 unwind vaapi zstd dist-kernel symlink fonts seccomp"
MAKE_OPTIONS="-j${_PARALLEL_THREADS}"
IS_SSD=true # Change to false if the target device is not an SSD drive
IS_NVME=true # Change to false if the target device is not an NVME drive
### These are the main values that need reviewed for installation; though, you can add post-install packages to 'LATE_PACKAGES' further below
USE_KERNEL_CONFIG=$(read -n 1 -r -p "Use your own kernel .config file? - (y/n): ")
if [ "${USE_KERNEL_CONFIG}" != n ]; then
USE_KERNEL_CONFIG=true
else
USE_KERNEL_CONFIG=false
fi
# Use if your Intel CPU has an iGPU (most Intel CPUs have this; you'll probably already know if it doesn't, but if you don't look up your CPU name)
INSTALL_INTEL_DRIVER=$(read -n 1 -r -p "Do you use an Intel CPU? - (y/n): ")
if [ "${INSTALL_INTEL_DRIVER}" != n ]; then
INSTALL_INTEL_DRIVER=true
else
INSTALL_INTEL_DRIVER=false
fi
USE_NVIDIA=$(read -n 1 -r -p "Do you use an Nvidia GPU? - (y/n): ")
if [ "${USE_NVIDIA}" != "n" ]; then
# Use this if you want to use the Nvidia proprietary driver - the "open modules" option below doesn't require this to be enabled
INSTALL_NVIDIA_DRIVER=$(read -n 1 -r -p "Do you use an Nvidia GPU and wish to use the official driver? - (y/n): ")
if [ "${INSTALL_NVIDIA_DRIVER}" != "n" ]; then
INSTALL_NVIDIA_DRIVER=true
# Use this if you have an RTX or newer card and aren't afraid to report bugs to improve driver support: https://github.com/NVIDIA/open-gpu-kernel-modules
INSTALL_NVIDIA_OPEN_GPU_MODULES=$(read -n 1 -r -p "Use the open-source kernel modules (not the nouveau driver)? Requires RTX or newer. - (y/n): ")
if [ "${INSTALL_NVIDIA_OPEN_GPU_MODULES}" != "n" ]; then
INSTALL_NVIDIA_OPEN_GPU_MODULES=true
else
INSTALL_NVIDIA_OPEN_GPU_MODULES=false
fi
else
INSTALL_NVIDIA_DRIVER=false
# Use this if you either have a really old Nvidia card that the official drivers don't support or intend to contribute to the Nouveau project
INSTALL_NOUVEAU_DRIVER=$(read -n 1 -r -p "Do you use an Nvidia GPU and wish to use the FOSS driver? Support for this driver is limited. - (y/n): ")
if [ "${INSTALL_NOUVEAU_DRIVER}" != "n" ]; then
INSTALL_NOUVEAU_DRIVER=true
else
INSTALL_NOUVEAU_DRIVER=false
fi
fi
fi
# Use this if you either have an AMD GPU or AMD APU (AMD CPU with an iGPU)
USE_RADEON=$(read -n 1 -r -p "Do you use an AMD GPU or APU/iGPU? - (y/n): ")
if [ "${USE_RADEON}" != "n" ]; then
USE_RADEON=true
else
USE_RADEON=false
fi
USED_VIDEO_CARDS="" ## Don't touch this!! This value is for the installer.
## DO NOT add desktop environments to this list (if you know bash), only personal applications. (I set an example here: keep, add, or remove as desired.)
# Desktop Environments and similar related applications (like file managers, associated terminals, and associated utilities) can be added manually in this script further down.
# This is to encourage adding new desktop environment profiles to the script, as I only use KDE Plasma, and I know this isn't the case for everyone
LATE_PACKAGES="app-shells/fish dev-util/rustup net-misc/croc app-misc/neofetch net-misc/axel dev-lang/mono virtual/dotnet-sdk games-util/lutris dev-vcs/git-lfs net-ftp/filezilla net-im/discord-bin media-gfx/blender media-video/obs-studio app-office/libreoffice games-fps/xonotic games-action/supertuxkart dev-util/shellcheck app-admin/hardinfo net-print/cups"
### -------------------------------------------------------------
### Make sure to make your own partitions; formatting is handled by the script
## This script currently checks for NVME SSDs first, if available; reference "lsblk" for available devices if you want to change which SSD you want Gentoo installed to by either
## changing all of the "nvme0n1" references to a different NVME drive or by setting "IS_NVME", above, to false if you don't want to install to an available NVME drive.
## Similarly, this can be done for the middle "else" check to do the same for SATA SSDs
if lsblk | grep -w '^nvme0n1' | cut -f3 | cut -d ' ' -f 1 > /dev/null 2>&1 && ${IS_SSD} != false && ${IS_NVME} != false || lsblk | grep -w '^nvme0n1' | cut -f3 | cut -d ' ' -f 1 > /dev/null 2>&1 && ${IS_SSD} != true && ${IS_NVME} != false; then ## Written this way as error handling
BOOT_PARTITION=/dev/nvme0n1p1
SWAP_PARTITION=/dev/nvme0n1p2
ROOT_PARTITION=/dev/nvme0n1p3
elif ${IS_SSD} != false; then
BOOT_PARTITION=/dev/sda1
SWAP_PARTITION=/dev/sda2
ROOT_PARTITION=/dev/sda3
else
BOOT_PARTITION=/dev/sda1
SWAP_PARTITION=/dev/sda2
ROOT_PARTITION=/dev/sda3
fi
## This script only supports BTRFS right now; feel free to make a PR for other options in addition to BTRFS if you know bash
ROOT_FS_TYPE=btrfs
STAGE3="stage3/stage3$*"
KERNEL_CONFIG_FILE=$(pwd)/kernel-configs/.config-gentoo # kernel config file is optimized for my particular system; you will have to modify it for your system
HOSTNAME="GENTOO"
PACKAGES="sys-fs/btrfs-progs sys-fs/btrfsmaintenance sys-fs/e2fsprogs sys-fs/dosfstools sys-fs/ntfs3g net-wireless/iwd net-wireless/wireless-tools net-misc/dhcpcd app-text/tree sys-apps/pciutils sys-fs/genfstab x11-misc/xdg-user-dirs"
TOOLS="app-admin/sysklogd sys-process/cronie sys-apps/mlocate sys-apps/man-pages sys-apps/man-db app-editors/nano app-shells/bash"
## Video card check
# Note: A bash case check would look prettier here; might need help with doing this here though
if [ ${INSTALL_INTEL_DRIVER} != false ]; then
USE+=" intel"
USED_VIDEO_CARDS="intel"
elif [ ${INSTALL_NVIDIA_DRIVER} != false ] && [ ${INSTALL_INTEL_DRIVER} != false ]; then
USE+=" intel nvidia bbswitch persistenced driver"
USED_VIDEO_CARDS="intel nvidia"
elif [ ${INSTALL_NVIDIA_DRIVER} != false ] && [ ${INSTALL_NVIDIA_OPEN_GPU_MODULES} != true ] ; then
USE+=" nvidia persistenced driver"
USED_VIDEO_CARDS="nvidia"
elif [ ${INSTALL_NVIDIA_OPEN_GPU_MODULES} != false ] && [ ${INSTALL_INTEL_DRIVER} != false ]; then
USE+=" intel nvidia bbswitch kernel-open persistenced"
USED_VIDEO_CARDS="nvidia"
elif [ ${INSTALL_NVIDIA_OPEN_GPU_MODULES} != false ]; then
USE+=" nvidia kernel-open persistenced"
USED_VIDEO_CARDS="nvidia"
elif [ ${INSTALL_NOUVEAU_DRIVER} != false ] && [ ${INSTALL_INTEL_DRIVER} != false ]; then
USE+=" intel nouveau bbswitch"
USED_VIDEO_CARDS="intel nouveau"
elif [ ${INSTALL_NOUVEAU_DRIVER} != false ]; then
USE+=" nouveau"
USED_VIDEO_CARDS="nouveau"
elif [ ${USE_RADEON} != false ] && [ ${INSTALL_INTEL_DRIVER} != false ]; then
USE+=" intel radeon"
USED_VIDEO_CARDS="intel radeon"
elif [ ${USE_RADEON} != false ]; then
USE+=" radeon"
USED_VIDEO_CARDS="radeon"
fi
message ()
{
echo
echo -e " $LBLUE>>> $LRED $* $NC"
}
command ()
{
echo -e "$LCYAN$*$NC"
"$@"
if [ $? -ne 0 ]; then
echo -e "$LREDFailed$NC"
return 1
fi
}
GENTOO_DESKTOP=$(command read -n 1 -r -p "Is the desired installation intended to be a desktop? (y/n)")
case "${GENTOO_DESKTOP}" in
"y")
message "Using a desktop configuration"
INSTALL_KDE_PLASMA=$(command read -n 1 -r -p "Install KDE Plasma? (y/n): ")
if [ "${INSTALL_KDE_PLASMA}" != "n" ]; then
USE_FLAGS+=" colord crash-handler display-manager firewall gtk kde legacy-systray networkmanager qt5 sddm semantic-desktop smart telemetry -discover -gnome -kwallet -qt4 -wallpapers"
fi
if [ "${GET_ARCH}" == x86_64 ]; then
INSTALL_WINE=$(read -n 1 -r -p "Install Wine? (https://wiki.gentoo.org/wiki/Wine) - (y/n): ")
if [ "${INSTALL_WINE}" != "n" ]; then
message "Adding Wine packages to LATE_PACKAGES"
LATE_PACKAGES+=" app-emulation/wine-vanilla app-emulation/wine-gecko app-emulation/wine-mono app-emulation/winetricks app-emulation/wine-desktop-common"
fi
INSTALL_STEAM=$(read -n 1 -r -p "Install Steam? (https://wiki.gentoo.org/wiki/Steam) - (y/n): ")
if [ "${INSTALL_STEAM}" != "n" ] && [ "${GET_ARCH}" == x86_64 ]; then
message "Enabling Steam for installation later"
fi
fi
INSTALL_GAME_EMULATORS=$(read -n 1 -r -p "Install game emulators?- (y/n): ") ## Use this if you like to play retro games :)
if [ "${INSTALL_GAME_EMULATORS}" != "n" ]; then
message "Adding game emulators to be installed later."
fi
INSTALL_FLATPAK=$(read -n 1 -r -p "Install flatpak? (https://wiki.gentoo.org/wiki/Flatpak) - (y/n): ")
if [ "${INSTALL_FLATPAK}" != "n" ]; then
message "Adding flatpak packages to LATE_PACKAGES"
LATE_PACKAGES+=" sys-apps/flatpak"
fi
;;
"n")
message "Using a non-desktop configuration"
;;
*)
## I want to use case switches instead of these if-checks but I need proper error handling implementation first to avoid breaking the script in the event a user mistake is made
message "A system type must be selected."
return 1
;;
esac
message "The value below attempts to build the entire system via the Clang LLVM compiler;"
message "this would only be applicable much later, but does lengthen installation time."
MAKE_CLANG_DEFAULT_COMPILER=$(read -n 1 -r -p "Make Clang the default compiler? - (y/n): ")
if [ "${MAKE_CLANG_DEFAULT_COMPILER}" != "n" ]; then
MAKE_CLANG_DEFAULT_COMPILER=true
message "Set Clang as the default compiler."
else
MAKE_CLANG_DEFAULT_COMPILER=false
message "Set GCC as the default compiler."
fi
INSTALL_DOAS=$(read -n 1 -r -p "Install doas? (It's a smaller sudo replacement semi-ported from BSD-land) - (y/n): ")
if [ "${INSTALL_DOAS}" != "n" ]; then
message "Adding 'doas' to TOOLS"
TOOLS+=" app-admin/doas"
fi
message "For more information about uutils as of 2022, see: https://youtu.be/ZIgve4YpipE"
INSTALL_UUTILS=$(read -n 1 -r -p "Install the Rust port of GNU coreutils instead (uutils)? (https://github.com/uutils/coreutils) - (y/n): ")
if [ "${INSTALL_UUTILS}" != "n" ]; then
message "Adding 'sys-apps/uutils' to PACKAGES"
PACKAGES+=" sys-apps/uutils"
fi
EMERGE_UNATTENDED=$(read -n 1 -r -p "Run the install script (mostly) unattended? - (y/n): ")
if [ "${EMERGE_UNATTENDED}" != "n" ]; then
message "Selected unattended"
EMERGE="emerge"
else
message "Selected interactive"
EMERGE="emerge --ask"
fi
install_gentoo_prep ()
{
#Disk Setup
message "Beginning Installation Process"
message "Formating Boot Partition"
command mkfs.fat -F 32 ${BOOT_PARTITION}
message "Formating Swap Partition"
command mkswap -f ${SWAP_PARTITION}
command swapon ${SWAP_PARTITION}
message "Formating Root Partition"
command mkfs.${ROOT_FS_TYPE} -f ${ROOT_PARTITION}
message "Adding partition labels"
command e2label ${BOOT_PARTITION} "boot"
command swaplabel ${SWAP_PARTITION} -L "swap"
command btrfs filesystem label ${ROOT_PARTITION} "root-partition"
#Mount Disks
message "Mounting Root and Boot partitions"
command mount -v ${ROOT_PARTITION} "${MOUNT_LOCATION}"
command mkdir -pv "${MOUNT_LOCATION}/boot"
command mount -v ${BOOT_PARTITION} "${MOUNT_LOCATION}/boot"
message "Make sure that date and time is set correctly, if it isn't then it can cause problems in the future"
command date
message "Is the following date correct (y/n)?"
read -r DATE_CORRECT
if [ "${DATE_CORRECT}" = "n" ]; then
message "Enter the date and time in MMDDhhmmYYYY format"
read -r CORRECTED_DATE
command date "${CORRECTED_DATE}"
fi
#Stage3 Tarball
# message "Copying stage3 tarball to system"
# command cp -rv "${STAGE3}" "${MOUNT_LOCATION}"
# command cd "${MOUNT_LOCATION}"
message "Extracting stage3 tarball"
command tar --numeric-owner --xattrs xvjpf "${STAGE3}" -C "${MOUNT_LOCATION}"
command rm "${STAGE3}"
command cd "${MOUNT_LOCATION}" || return
message "Copying configuration files"
command mkdir -pv "${MOUNT_LOCATION}/etc"
command mkdir -pv "${MOUNT_LOCATION}/etc/portage"
if [ ${USE_KERNEL_CONFIG} != false ]; then
message "Copying kernel configuration files"
command cp -rv "${KERNEL_CONFIG_FILE}" "${MOUNT_LOCATION}/kernel-config"
fi
## Chroot
message "Copying DNS info"
command cp -L /etc/resolv.conf "${MOUNT_LOCATION}"/etc/
case "${DISTRO}" in
"Arch-based")
if test -x "$(command pacman -Qi arch-install-scripts > /dev/null 2>&1)"; then
if [ ${IS_SSD} != true ] || [ ${IS_SSD} != true ] && [ ${IS_NVME} != true ]; then
message "Generating fstab file"
command genfstab -L / >> "${MOUNT_LOCATION}/etc/fstab"
fi
else
echo "Dependency 'arch-install-scripts' was not found."
return 1
fi
;;
"Gentoo-based")
if [ ${IS_SSD} != true ] || [ ${IS_SSD} != true ] && [ ${IS_NVME} != true ]; then
message "Installing genfstab"
command emerge --oneshot --noreplace sys-fs/genfstab
message "Generating fstab file"
command genfstab -L / >> "${MOUNT_LOCATION}/etc/fstab"
fi
;;
*)
if test -x "$(command genfstab > /dev/null 2>&1)"; then
if [ ${IS_SSD} != true ] || [ ${IS_SSD} != true ] && [ ${IS_NVME} != true ]; then
message "Generating fstab file"
command genfstab -L / >> "${MOUNT_LOCATION}/etc/fstab"
fi
else
echo "Non-supported distro type is being used; returning."
return 1
fi
;;
esac
message "Mounting Necessary Filesystems"
command mount -t proc proc /mnt/gentoo/proc
command mount --rbind /sys /mnt/gentoo/sys
command mount --make-rslave /mnt/gentoo/sys
command mount --rbind /dev /mnt/gentoo/dev
command mount --make-rslave /mnt/gentoo/dev
message "Chrooting into System"
command chroot "${MOUNT_LOCATION}" /bin/env -i TERM="${TERM}" /bin/bash -c "install_gentoo_chroot"
}
install_gentoo_chroot()
{
message "Inside chroot env"
command env-update
command source /etc/profile
command export PS1="(chroot) $PS1"
#Portage
message "Installing portage snapshot"
command emerge-webrsync
message "Updating portage tree"
command emerge --sync
message "Configuring /etc/portage/env/compiler-gcc"
cat << EOF > /etc/portage/env/compiler-gcc
CC="gcc"
CXX="g++"
AR="ar"
NM="nm"
RANLIB="ranlib"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS}"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-gcc
message "Configuring /etc/portage/make.conf"
if [ -f /etc/portage/make.conf ]; then
cp -v /etc/portage/make.conf /etc/portage/make.conf.default.bak
fi
cp -v /etc/portage/env/compiler-gcc /etc/portage/make.conf
message "Configuring /etc/portage/env/compiler-gcc-static"
cat << EOF > /etc/portage/env/compiler-gcc-static
CC="gcc"
CXX="g++"
AR="ar"
NM="nm"
RANLIB="ranlib"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -static -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS}"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-gcc-static
message "Configuring /etc/portage/env/compiler-gcc-nvidia"
cat << EOF > /etc/portage/env/compiler-gcc-nvidia
CC="gcc"
CXX="g++"
AR="ar"
NM="nm"
RANLIB="ranlib"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -static -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS} static-libs tools"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="nvidia"
EOF
chmod 755 /etc/portage/env/compiler-gcc-nvidia
message "Configuring /etc/portage/env/compiler-gcc-wine"
cat << EOF > /etc/portage/env/compiler-gcc-wine
### Wine doesn't play nice with LTO; it usually doesn't compile
CC="gcc"
CXX="g++"
AR="ar"
NM="nm"
RANLIB="ranlib"
_CLFAGS="${CFLAGS/-fno-plt/}" ## Wine Doesn't play nice with -fno-plt
_CLFAGS="\${_CFLAGS/-O3/}" ## Wine is faster with -O2
CFLAGS="\${_CFLAGS} -O2"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -Wl,-O3,--sort-common,--as-needed" ## mingw can't use relro
CROSSCFLAGS="\${CFLAGS}"
CROSSCXXFLAGS="\${CXXFLAGS}"
CROSSLDFLAGS="\${LDFLAGS}"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS} capi cups fontconfig gecko gstreamer mono mp3 netapi nls odbc openal opengl osmesa oss pcap perl realtime run-exes samba scanner sdl ssl threads unwind xcomposite xinerama abi_x86_64 abi_x86_32 -custom-cflags -mingw -crossdev-mingw"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-gcc-wine
message "Configuring /etc/portage/env/compiler-gcc-lto"
cat << EOF > /etc/portage/env/compiler-gcc-lto
CC="gcc"
CXX="g++"
AR="gcc-ar"
NM="gcc-nm"
RANLIB="gcc-ranlib"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-flto -fuse-linker-plugin -lpthread -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS}"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-gcc-lto
message "Configuring /etc/portage/env/compiler-gcc-static-lto"
cat << EOF > /etc/portage/env/compiler-gcc-static-lto
CC="gcc"
CXX="g++"
AR="gcc-ar"
NM="gcc-nm"
RANLIB="gcc-ranlib"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-flto -fuse-linker-plugin -lpthread -static -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS}"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-gcc-static-lto
message "Configuring /etc/portage/env/compiler-clang"
cat << EOF > /etc/portage/env/compiler-clang
### See:
## https://wiki.gentoo.org/wiki/Clang
## https://bugs.gentoo.org/408963
## and
## https://github.com/BilyakA/gentoo-clang
### for building an exclusively clang system
CC="clang"
CXX="clang++"
OBJC=clang
LD="/usr/bin/ld.lld"
AS="llvm-as"
### Ignore these three for non-LTO builds:
AR=""
NM=""
RANLIB=""
###
STRIP="llvm-strip"
OBJCOPY="llvm-objcopy"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS} libcxxabi libunwind"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-clang
message "Configuring /etc/portage/env/compiler-clang-static"
cat << EOF > /etc/portage/env/compiler-clang-static
### See:
## https://wiki.gentoo.org/wiki/Clang
## https://bugs.gentoo.org/408963
## and
## https://github.com/BilyakA/gentoo-clang
### for building an exclusively clang system
CC="clang"
CXX="clang++"
OBJC=clang
LD="/usr/bin/ld.lld"
AS="llvm-as"
### Ignore these three for non-LTO builds:
AR=""
NM=""
RANLIB=""
###
STRIP="llvm-strip"
OBJCOPY="llvm-objcopy"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -static -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS} libcxxabi libunwind"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-clang-static
message "Configuring /etc/portage/env/compiler-clang-nvidia"
cat << EOF > /etc/portage/env/compiler-clang-nvidia
### See:
## https://wiki.gentoo.org/wiki/Clang
## https://bugs.gentoo.org/408963
## and
## https://github.com/BilyakA/gentoo-clang
### for building an exclusively clang system
CC="clang"
CXX="clang++"
OBJC=clang
LD="/usr/bin/ld.lld"
AS="llvm-as"
### Ignore these three for non-LTO builds:
AR=""
NM=""
RANLIB=""
###
STRIP="llvm-strip"
OBJCOPY="llvm-objcopy"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -static -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS} static-libs tools libcxxabi libunwind"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="nvidia"
EOF
chmod 755 /etc/portage/env/compiler-clang-nvidia
message "Configuring /etc/portage/env/compiler-clang-wine"
cat << EOF > /etc/portage/env/compiler-clang-wine
## Not the Wine default because Wine doesn't always play nice with Clang at runtime
### See:
## https://wiki.gentoo.org/wiki/Clang
## https://bugs.gentoo.org/408963
## and
## https://github.com/BilyakA/gentoo-clang
### for building an exclusively clang system
CC="clang"
CXX="clang++"
OBJC=clang
LD="/usr/bin/ld.lld"
AS="llvm-as"
### Ignore these three for non-LTO builds:
AR=""
NM=""
RANLIB=""
### Wine doesn't play nice with LTO; it usually doesn't compile
STRIP="llvm-strip"
OBJCOPY="llvm-objcopy"
_CLFAGS="${CFLAGS/-fno-plt/}" ## Wine Doesn't play nice with -fno-plt
_CLFAGS="\${_CFLAGS/-O3/}" ## Wine is faster with -O2
CFLAGS="\${_CFLAGS} -O2 -std=gnu89"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -static -Wl,-O2,--sort-common,--as-needed" ## mingw can't use relro
CROSSCFLAGS="\${CFLAGS}"
CROSSCXXFLAGS="\${CXXFLAGS}"
CROSSLDFLAGS="\${LDFLAGS}"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS} capi cups fontconfig gecko gstreamer mono mp3 netapi nls odbc openal opengl osmesa oss pcap perl realtime run-exes samba scanner sdl ssl threads unwind xcomposite xinerama abi_x86_64 abi_x86_32 -custom-cflags -mingw -crossdev-mingw libcxxabi libunwind"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-clang-wine
message "Configuring /etc/portage/env/compiler-clang-lto"
cat << EOF > /etc/portage/env/compiler-clang-lto
### See:
## https://wiki.gentoo.org/wiki/Clang
## https://bugs.gentoo.org/408963
## and
## https://github.com/BilyakA/gentoo-clang
### for building an exclusively clang system
CC="clang"
CXX="clang++"
OBJC=clang
LD="/usr/bin/ld.lld"
AR="llvm-ar"
NM="llvm-nm"
AS="llvm-as"
RANLIB="llvm-ranlib"
STRIP="llvm-strip"
OBJCOPY="llvm-objcopy"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} -flto=thin \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS} libcxxabi libunwind"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-clang-lto
message "Configuring /etc/portage/env/compiler-clang-static-lto"
cat << EOF > /etc/portage/env/compiler-clang-static-lto
### See:
## https://wiki.gentoo.org/wiki/Clang
## https://bugs.gentoo.org/408963
## and
## https://github.com/BilyakA/gentoo-clang
### for building an exclusively clang system
## This file exists to prevent system-critical packages from breaking due to dependency issues
CC="clang"
CXX="clang++"
OBJC=clang
LD="/usr/bin/ld.lld"
AR="llvm-ar"
NM="llvm-nm"
AS="llvm-as"
RANLIB="llvm-ranlib"
STRIP="llvm-strip"
OBJCOPY="llvm-objcopy"
_HARDENING_FLAGS="-fstack-clash-protection -fstack-protector-strong -fcf-protection -Wp,-D_FORTIFY_SOURCE=2"
CFLAGS="${CFLAGS} -flto=thin \${_HARDENING_FLAGS}"
CXXFLAGS="\${CFLAGS}"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
LDFLAGS="-lpthread -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -static -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
CPU_FLAGS="${CPU_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
USE="${USE_FLAGS} libcxxabi libunwind"
MAKEOPTS="-j${_PARALLEL_THREADS}"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
ACCEPT_LICENSE="*"
VIDEO_CARDS="${USED_VIDEO_CARDS}"
EOF
chmod 755 /etc/portage/env/compiler-clang-static-lto
#Installation
# message "Setting Profile to default/linux/amd64/13.0/desktop"
# command eselect profile set default/linux/amd64/13.0/desktop
## Recursive error handling would be desired here but is difficult for me to properly figure out at the moment
## Not sure which of these two is the better method of implementing interactive eselect
# command read -r -p "Enter the desired profile value via 'eselect profile set ': "
# command read -n 1 -r -p "Enter the desired profile value: " | eselect profile set
case ${GENTOO_DESKTOP} in
"y")
if [ "${INSTALL_KDE_PLASMA}" != "n" ]; then
plasma_profile_selection () {
message "Select a KDE Plasma Desktop profile:"
message "NOTE: DO NOT select 'no-multilib' if installing Wine or Steam (Steam is enabled by default in this script)"
message "NOTE: DO NOT select 'systemd' without modifying this script to support it"
command eselect profile list | grep plasma
PROFILE_SELECTION=$(command read -n 1 -r -p "Enter the desired profile value: ")
if [ "${PROFILE_SELECTION}" -lt 1 ] || [ "${PROFILE_SELECTION}" -gt 9 ]; then
plasma_profile_selection
fi
}
plasma_profile_selection
fi
;;
"n")
;;
esac
message "Updating @world set"
command ${EMERGE} --update --deep --newuse @world
message "Installing filesystem packages"
command ${EMERGE} "${PACKAGES}"
message "Configuring timezone"
command echo "$TIMEZONE" > /etc/timezone
command emerge --quiet --config sys-libs/timezone-data
message "Writing /etc/locale.gen file"
cat << EOF > /etc/locale.gen
# All blank lines and lines starting with # are ignored.
#en_US ISO-8859-1
en_US.UTF-8 UTF-8
#ja_JP.EUC-JP EUC-JP
ja_JP.UTF-8 UTF-8
#ja_JP EUC-JP
#en_HK ISO-8859-1
#en_PH ISO-8859-1
#de_DE ISO-8859-1
#de_DE@euro ISO-8859-15
#es_MX ISO-8859-1
#fa_IR UTF-8
#fr_FR ISO-8859-1
#fr_FR@euro ISO-8859-15
#it_IT ISO-8859-1
EOF
command locale-gen
command eselect locale set en_US.utf8
message "Selecting keymap"
command sed -i "/keymap=/c\\keymap=\"us\"" /etc/conf.d/keymaps
message "Reloading Environment"
command env-update && source /etc/profile && export PS1="(chroot) $PS1"
if [ ${USE_KERNEL_CONFIG} != false ]; then
message "Downloading Kernel Sources and mcelog"
command ${EMERGE} sys-kernel/gentoo-sources app-admin/mcelog
else
message "Downloading Gentoo Kernel Source and mcelog"
command ${EMERGE} sys-kernel/installkernel-gentoo
command ${EMERGE} sys-kernel/gentoo-kernel-bin app-admin/mcelog
fi
message "Cleaning Kernel source folder"
command cd /usr/src/linux/ || return
command make clean
command make mrproper
if [ ${USE_KERNEL_CONFIG} != false ]; then
message "Loading kernel configuration file"
command mv -v /kernel-config /usr/src/linux/.config-gentoo-final
command cp -rv /usr/src/linux/.config-gentoo-final /usr/src/linux/.config
fi
message "Beginning Kernel Compilation Process"
command make ${MAKE_OPTIONS}
command make modules_install
command make install
message "Removing old kernel files"
command rm -rf /boot/*old
message "Creating bootx64.efi, (Meant for UEFI systems)"
command mkdir -pv /boot/efi/boot
command cp /boot/vmlinuz-* /boot/efi/boot/bootx64.efi
message "Installing genkernel"
command ${EMERGE} sys-kernel/genkernel
message "Installing linux-firmware"
command ${EMERGE} sys-kernel/linux-firmware
## Would be good to have CPU detection for this when applicable; AMD microcode is bundled with sys-kernel/linux-firmware
if [ ${INSTALL_INTEL_DRIVER} != false ]; then
message "Installing Intel microcode"
command ${EMERGE} sys-kernel/intel-microcode
fi
message "Generating initramfs"
if [ ${USE_KERNEL_CONFIG} != false ]; then
command genkernel --${ROOT_FS_TYPE} --kerneldir=/usr/src/linux --kernel-config="/usr/src/linux/.config-gentoo-final" --install --no-ramdisk-modules initramfs
else
command genkernel --${ROOT_FS_TYPE} --kerneldir=/usr/src/linux --install --no-ramdisk-modules initramfs
fi