@@ -442,6 +442,10 @@ _make_bootmodes() {
442
442
for bootmode in " ${bootmodes[@]} " ; do
443
443
_run_once " _make_bootmode_${bootmode} "
444
444
done
445
+
446
+ if [[ " ${bootmodes[*]} " != * grub* ]]; then
447
+ _run_once _make_common_grubenv_and_loopbackcfg
448
+ fi
445
449
}
446
450
447
451
# Copy kernel and initramfs to ISO 9660
@@ -500,7 +504,7 @@ _make_bootmode_bios.syslinux.mbr() {
500
504
install -d -m 0755 -- " ${isofs_dir} /boot/memtest86+/"
501
505
# rename for PXE: https://wiki.archlinux.org/title/Syslinux#Using_memtest
502
506
install -m 0644 -- " ${pacstrap_dir} /boot/memtest86+/memtest.bin" " ${isofs_dir} /boot/memtest86+/memtest"
503
- install -m 0644 -- " ${pacstrap_dir} /usr/share/licenses/spdx/GPL-2.0-only.txt" " ${isofs_dir} /boot/memtest86+/"
507
+ install -m 0644 -- " ${pacstrap_dir} /usr/share/licenses/spdx/GPL-2.0-only.txt" " ${isofs_dir} /boot/memtest86+/LICENSE "
504
508
fi
505
509
_msg_info " Done! SYSLINUX set up for BIOS booting from a disk successfully."
506
510
}
660
664
> " ${work_dir} /grub/grubenv"
661
665
}
662
666
667
+ # Create GRUB specific configuration files when GRUB is not used as a boot loader
668
+ _make_common_grubenv_and_loopbackcfg () {
669
+ local search_filename
670
+
671
+ install -d -m 0755 -- " ${isofs_dir} /boot/grub"
672
+ # Create a /boot/grub/YYYY-mm-dd-HH-MM-SS-00.uuid file on ISO 9660. GRUB will search for it to find the ISO
673
+ # volume. This is similar to what grub-mkrescue does, except it places the file in /.disk/, but we opt to use a
674
+ # directory that does not start with a dot to avoid it being accidentally missed when copying the ISO's contents.
675
+ search_filename=" /boot/grub/${iso_uuid} .uuid"
676
+ : > " ${isofs_dir} /${search_filename} "
677
+
678
+ # Write grubenv
679
+ printf ' %.1024s' \
680
+ " $( printf ' # GRUB Environment Block\nNAME=%s\nVERSION=%s\nARCHISO_LABEL=%s\nINSTALL_DIR=%s\nARCH=%s\nARCHISO_SEARCH_FILENAME=%s\n%s' \
681
+ " ${iso_name} " \
682
+ " ${iso_version} " \
683
+ " ${iso_label} " \
684
+ " ${install_dir} " \
685
+ " ${arch} " \
686
+ " ${search_filename} " \
687
+ " $( printf ' %0.1s' " #" {1..1024}) " ) " \
688
+ > " ${isofs_dir} /boot/grub/grubenv"
689
+
690
+ # Copy loopback.cfg to /boot/grub/ on ISO 9660
691
+ if [[ -e " ${profile} /grub/loopback.cfg" ]]; then
692
+ sed " s|%ARCHISO_LABEL%|${iso_label} |g;
693
+ s|%ARCHISO_UUID%|${iso_uuid} |g;
694
+ s|%INSTALL_DIR%|${install_dir} |g;
695
+ s|%ARCH%|${arch} |g;
696
+ s|%ARCHISO_SEARCH_FILENAME%|${search_filename} |g" \
697
+ " ${profile} /grub/loopback.cfg" > " ${isofs_dir} /boot/grub/loopback.cfg"
698
+ fi
699
+ }
700
+
663
701
_make_bootmode_uefi-ia32.grub.esp () {
664
702
local grubmodules=()
665
703
@@ -780,7 +818,7 @@ _make_bootmode_uefi-x64.grub.esp() {
780
818
if [[ -e " ${pacstrap_dir} /boot/memtest86+/memtest.efi" ]]; then
781
819
install -d -m 0755 -- " ${isofs_dir} /boot/memtest86+/"
782
820
install -m 0644 -- " ${pacstrap_dir} /boot/memtest86+/memtest.efi" " ${isofs_dir} /boot/memtest86+/memtest.efi"
783
- install -m 0644 -- " ${pacstrap_dir} /usr/share/licenses/spdx/GPL-2.0-only.txt" " ${isofs_dir} /boot/memtest86+/"
821
+ install -m 0644 -- " ${pacstrap_dir} /usr/share/licenses/spdx/GPL-2.0-only.txt" " ${isofs_dir} /boot/memtest86+/LICENSE "
784
822
fi
785
823
786
824
_msg_info " Done! GRUB set up for UEFI booting successfully."
@@ -815,43 +853,76 @@ _make_bootmode_uefi-x64.grub.eltorito() {
815
853
_msg_info " Done!"
816
854
}
817
855
818
- # Prepare systemd-boot for booting when written to a disk (isohybrid)
819
- _make_bootmode_uefi-x64.systemd-boot.esp () {
856
+ _make_common_bootmode_systemd-boot () {
820
857
local _file efiboot_imgsize
821
858
local _available_ucodes=()
822
- _msg_info " Setting up systemd-boot for UEFI booting..."
823
859
824
860
for _file in " ${ucodes[@]} " ; do
825
861
if [[ -e " ${pacstrap_dir} /boot/${_file} " ]]; then
826
862
_available_ucodes+=(" ${pacstrap_dir} /boot/${_file} " )
827
863
fi
828
864
done
829
865
# Calculate the required FAT image size in bytes
830
- efiboot_files+=(" ${pacstrap_dir} /usr/lib/systemd/boot/efi/systemd-bootx64.efi"
831
- " ${pacstrap_dir} /usr/share/edk2-shell/x64/Shell_Full.efi"
832
- " ${profile} /efiboot/"
866
+ # shellcheck disable=SC2076
867
+ if [[ " ${bootmodes[*]} " =~ ' uefi-x64.systemd-boot.esp ' || " ${bootmodes[*]} " =~ ' uefi-x64.systemd-boot.eltorito ' ]]; then
868
+ efiboot_files+=(" ${pacstrap_dir} /usr/lib/systemd/boot/efi/systemd-bootx64.efi"
869
+ " ${pacstrap_dir} /usr/share/edk2-shell/x64/Shell_Full.efi" )
870
+ fi
871
+ # shellcheck disable=SC2076
872
+ if [[ " ${bootmodes[*]} " =~ ' uefi-ia32.systemd-boot.esp ' || " ${bootmodes[*]} " =~ ' uefi-ia32.systemd-boot.eltorito ' ]]; then
873
+ efiboot_files+=(" ${pacstrap_dir} /usr/lib/systemd/boot/efi/systemd-bootia32.efi"
874
+ " ${pacstrap_dir} /usr/share/edk2-shell/ia32/Shell_Full.efi" )
875
+ fi
876
+ efiboot_files+=(" ${work_dir} /loader/"
833
877
" ${pacstrap_dir} /boot/vmlinuz-" *
834
878
" ${pacstrap_dir} /boot/initramfs-" * " .img"
835
879
" ${_available_ucodes[@]} " )
836
- efiboot_imgsize=" $( du -bcs -- " ${efiboot_files[@]} " \
837
- 2> /dev/null | awk ' END { print $1 }' ) "
880
+ efiboot_imgsize=" $( du -bcs -- " ${efiboot_files[@]} " 2> /dev/null | awk ' END { print $1 }' ) "
838
881
# Create a FAT image for the EFI system partition
839
882
_make_efibootimg " $efiboot_imgsize "
883
+ }
840
884
841
- # Copy systemd-boot EFI binary to the default/fallback boot path
842
- mcopy -i " ${efibootimg} " \
843
- " ${pacstrap_dir} /usr/lib/systemd/boot/efi/systemd-bootx64.efi" ::/EFI/BOOT/BOOTx64.EFI
885
+ _make_common_bootmode_systemd-boot_conf () {
886
+ local _conf
844
887
845
- # Copy systemd-boot configuration files
846
- mmd -i " ${efibootimg} " ::/loader ::/loader/entries
847
- mcopy -i " ${efibootimg} " " ${profile} /efiboot/loader/loader.conf" :: /loader/
888
+ install -d -m 0755 -- " ${work_dir} /loader " " ${work_dir} /loader/entries "
889
+
890
+ install -m 0644 -- " ${profile} /efiboot/loader/loader.conf" " ${work_dir} /loader"
848
891
for _conf in " ${profile} /efiboot/loader/entries/" * " .conf" ; do
849
892
sed " s|%ARCHISO_LABEL%|${iso_label} |g;
850
893
s|%ARCHISO_UUID%|${iso_uuid} |g;
851
894
s|%INSTALL_DIR%|${install_dir} |g;
852
895
s|%ARCH%|${arch} |g" \
853
- " ${_conf} " | mcopy -i " ${efibootimg} " - " :: /loader/entries/${_conf##*/ } "
896
+ " ${_conf} " > " ${work_dir} /loader/entries/${_conf##*/ } "
854
897
done
898
+ }
899
+
900
+ # Copy systemd-boot configuration files to ISO 9660
901
+ _make_common_bootmode_systemd-boot_conf.isofs () {
902
+ cp -r --remove-destination -- " ${work_dir} /loader" " ${isofs_dir} /"
903
+ }
904
+
905
+ # Copy systemd-boot configuration files to FAT image
906
+ _make_common_bootmode_systemd-boot_conf.esp () {
907
+ mcopy -i " ${efibootimg} " -s " ${work_dir} /loader" ::/
908
+ }
909
+
910
+ # Prepare systemd-boot for booting when written to a disk (isohybrid)
911
+ _make_bootmode_uefi-x64.systemd-boot.esp () {
912
+ _msg_info " Setting up systemd-boot for x64 UEFI booting..."
913
+
914
+ # Prepare configuration files
915
+ _run_once _make_common_bootmode_systemd-boot_conf
916
+
917
+ # Prepare a FAT image for the EFI system partition
918
+ _run_once _make_common_bootmode_systemd-boot
919
+
920
+ # Copy systemd-boot EFI binary to the default/fallback boot path
921
+ mcopy -i " ${efibootimg} " \
922
+ " ${pacstrap_dir} /usr/lib/systemd/boot/efi/systemd-bootx64.efi" ::/EFI/BOOT/BOOTx64.EFI
923
+
924
+ # Copy systemd-boot configuration files
925
+ _run_once _make_common_bootmode_systemd-boot_conf.esp
855
926
856
927
# shellx64.efi is picked up automatically when on /
857
928
if [[ -e " ${pacstrap_dir} /usr/share/edk2-shell/x64/Shell_Full.efi" ]]; then
@@ -861,13 +932,16 @@ _make_bootmode_uefi-x64.systemd-boot.esp() {
861
932
862
933
# Copy kernel and initramfs to FAT image.
863
934
# systemd-boot can only access files from the EFI system partition it was launched from.
864
- _make_boot_on_fat
935
+ _run_once _make_boot_on_fat
865
936
866
- _msg_info " Done! systemd-boot set up for UEFI booting successfully."
937
+ _msg_info " Done! systemd-boot set up for x64 UEFI booting successfully."
867
938
}
868
939
869
940
# Prepare systemd-boot for El Torito booting
870
941
_make_bootmode_uefi-x64.systemd-boot.eltorito () {
942
+ # Prepare configuration files
943
+ _run_once _make_common_bootmode_systemd-boot_conf
944
+
871
945
# El Torito UEFI boot requires an image containing the EFI system partition.
872
946
# uefi-x64.systemd-boot.eltorito has the same requirements as uefi-x64.systemd-boot.esp
873
947
_run_once _make_bootmode_uefi-x64.systemd-boot.esp
@@ -883,14 +957,7 @@ _make_bootmode_uefi-x64.systemd-boot.eltorito() {
883
957
" ${isofs_dir} /EFI/BOOT/BOOTx64.EFI"
884
958
885
959
# Copy systemd-boot configuration files
886
- install -d -m 0755 -- " ${isofs_dir} /loader/entries"
887
- install -m 0644 -- " ${profile} /efiboot/loader/loader.conf" " ${isofs_dir} /loader/"
888
- for _conf in " ${profile} /efiboot/loader/entries/" * " .conf" ; do
889
- sed " s|%ARCHISO_LABEL%|${iso_label} |g;
890
- s|%INSTALL_DIR%|${install_dir} |g;
891
- s|%ARCH%|${arch} |g" \
892
- " ${_conf} " > " ${isofs_dir} /loader/entries/${_conf##*/ } "
893
- done
960
+ _run_once _make_common_bootmode_systemd-boot_conf.isofs
894
961
895
962
# edk2-shell based UEFI shell
896
963
# shellx64.efi is picked up automatically when on /
@@ -901,6 +968,65 @@ _make_bootmode_uefi-x64.systemd-boot.eltorito() {
901
968
_msg_info " Done!"
902
969
}
903
970
971
+ _make_bootmode_uefi-ia32.systemd-boot.esp () {
972
+ _msg_info " Setting up systemd-boot for IA32 UEFI booting..."
973
+
974
+ # Prepare configuration files
975
+ _run_once _make_common_bootmode_systemd-boot_conf
976
+
977
+ # Prepare a FAT image for the EFI system partition
978
+ _run_once _make_common_bootmode_systemd-boot
979
+
980
+ # Copy systemd-boot EFI binary to the default/fallback boot path
981
+ mcopy -i " ${efibootimg} " \
982
+ " ${pacstrap_dir} /usr/lib/systemd/boot/efi/systemd-bootia32.efi" ::/EFI/BOOT/BOOTIA32.EFI
983
+
984
+ # Copy systemd-boot configuration files
985
+ _run_once _make_common_bootmode_systemd-boot_conf.esp
986
+
987
+ # shellia32.efi is picked up automatically when on /
988
+ if [[ -e " ${pacstrap_dir} /usr/share/edk2-shell/ia32/Shell_Full.efi" ]]; then
989
+ mcopy -i " ${efibootimg} " \
990
+ " ${pacstrap_dir} /usr/share/edk2-shell/ia32/Shell_Full.efi" ::/shellia32.efi
991
+ fi
992
+
993
+ # Copy kernel and initramfs to FAT image.
994
+ # systemd-boot can only access files from the EFI system partition it was launched from.
995
+ _run_once _make_boot_on_fat
996
+
997
+ _msg_info " Done! systemd-boot set up for IA32 UEFI booting successfully."
998
+ }
999
+
1000
+ _make_bootmode_uefi-ia32.systemd-boot.eltorito () {
1001
+ # Prepare configuration files
1002
+ _run_once _make_common_bootmode_systemd-boot_conf
1003
+
1004
+ # El Torito UEFI boot requires an image containing the EFI system partition.
1005
+ # uefi-ia32.systemd-boot.eltorito has the same requirements as uefi-ia32.systemd-boot.esp
1006
+ _run_once _make_bootmode_uefi-ia32.systemd-boot.esp
1007
+
1008
+ # Additionally set up systemd-boot in ISO 9660. This allows creating a medium for the live environment by using
1009
+ # manual partitioning and simply copying the ISO 9660 file system contents.
1010
+ # This is not related to El Torito booting and no firmware uses these files.
1011
+ _msg_info " Preparing an /EFI directory for the ISO 9660 file system..."
1012
+ install -d -m 0755 -- " ${isofs_dir} /EFI/BOOT"
1013
+
1014
+ # Copy systemd-boot EFI binary to the default/fallback boot path
1015
+ install -m 0644 -- " ${pacstrap_dir} /usr/lib/systemd/boot/efi/systemd-bootia32.efi" \
1016
+ " ${isofs_dir} /EFI/BOOT/BOOTIA32.EFI"
1017
+
1018
+ # Copy systemd-boot configuration files
1019
+ _run_once _make_common_bootmode_systemd-boot_conf.isofs
1020
+
1021
+ # edk2-shell based UEFI shell
1022
+ # shellia32.efi is picked up automatically when on /
1023
+ if [[ -e " ${pacstrap_dir} /usr/share/edk2-shell/ia32/Shell_Full.efi" ]]; then
1024
+ install -m 0644 -- " ${pacstrap_dir} /usr/share/edk2-shell/ia32/Shell_Full.efi" " ${isofs_dir} /shellia32.efi"
1025
+ fi
1026
+
1027
+ _msg_info " Done!"
1028
+ }
1029
+
904
1030
_validate_requirements_bootmode_bios.syslinux.mbr () {
905
1031
# bios.syslinux.mbr requires bios.syslinux.eltorito
906
1032
# shellcheck disable=SC2076
@@ -944,12 +1070,7 @@ _validate_requirements_bootmode_bios.syslinux.eltorito() {
944
1070
_validate_requirements_bootmode_bios.syslinux.mbr
945
1071
}
946
1072
947
- _validate_requirements_bootmode_uefi-x64.systemd-boot.esp () {
948
- # shellcheck disable=SC2076
949
- if [[ " ${bootmodes[*]} " =~ ' uefi-x64.grub.esp ' ]]; then
950
- _msg_error " Validating '${bootmode} ': cannot be used with bootmode uefi-x64.grub.esp!" 0
951
- fi
952
-
1073
+ _validate_requirements_common_systemd-boot () {
953
1074
# Check if mkfs.fat is available
954
1075
if ! command -v mkfs.fat & > /dev/null; then
955
1076
(( validation_error= validation_error+ 1 ))
@@ -989,6 +1110,14 @@ _validate_requirements_bootmode_uefi-x64.systemd-boot.esp() {
989
1110
fi
990
1111
}
991
1112
1113
+ _validate_requirements_bootmode_uefi-x64.systemd-boot.esp () {
1114
+ # shellcheck disable=SC2076
1115
+ if [[ " ${bootmodes[*]} " =~ ' uefi-x64.grub.esp ' ]]; then
1116
+ _msg_error " Validating '${bootmode} ': cannot be used with bootmode uefi-x64.grub.esp!" 0
1117
+ fi
1118
+ _validate_requirements_common_systemd-boot
1119
+ }
1120
+
992
1121
_validate_requirements_bootmode_uefi-x64.systemd-boot.eltorito () {
993
1122
# shellcheck disable=SC2076
994
1123
if [[ " ${bootmodes[*]} " =~ ' uefi-x64.grub.eltorito ' ]]; then
@@ -999,6 +1128,25 @@ _validate_requirements_bootmode_uefi-x64.systemd-boot.eltorito() {
999
1128
_validate_requirements_bootmode_uefi-x64.systemd-boot.esp
1000
1129
}
1001
1130
1131
+ _validate_requirements_bootmode_uefi-ia32.systemd-boot.esp () {
1132
+ # shellcheck disable=SC2076
1133
+ if [[ " ${bootmodes[*]} " =~ ' uefi-ia32.grub.esp ' ]]; then
1134
+ _msg_error " Validating '${bootmode} ': cannot be used with bootmode uefi-ia32.grub.esp!" 0
1135
+ fi
1136
+
1137
+ _validate_requirements_common_systemd-boot
1138
+ }
1139
+
1140
+ _validate_requirements_bootmode_uefi-ia32.systemd-boot.eltorito () {
1141
+ # shellcheck disable=SC2076
1142
+ if [[ " ${bootmodes[*]} " =~ ' uefi-ia32.grub.eltorito ' ]]; then
1143
+ _msg_error " Validating '${bootmode} ': cannot be used with bootmode uefi-ia32.grub.eltorito!" 0
1144
+ fi
1145
+
1146
+ # uefi-ia32.systemd-boot.eltorito has the exact same requirements as uefi-ia32.systemd-boot.esp
1147
+ _validate_requirements_bootmode_uefi-x64.systemd-boot.esp
1148
+ }
1149
+
1002
1150
_validate_requirements_bootmode_uefi-ia32.grub.esp () {
1003
1151
# Check if GRUB is available
1004
1152
if ! command -v grub-mkstandalone & > /dev/null; then
@@ -1722,8 +1870,9 @@ _make_version() {
1722
1870
fi
1723
1871
if [[ " ${buildmode} " == " iso" ]]; then
1724
1872
# Write grubenv with version information to ISO 9660
1725
- # TODO: after sufficient time has passed, do not create this file anymore when GRUB boot modes are used.
1726
- # _make_common_bootmode_grub_cfg already creates ${isofs_dir}/boot/grub/grubenv
1873
+ # TODO: after sufficient time has passed, do not create this file anymore.
1874
+ # _make_common_bootmode_grub_cfg and _make_common_grubenv_and_loopbackcfg already create a
1875
+ # ${isofs_dir}/boot/grub/grubenv file
1727
1876
rm -f -- " ${isofs_dir} /${install_dir} /grubenv"
1728
1877
printf ' %.1024s' " $( printf ' # GRUB Environment Block\nNAME=%s\nVERSION=%s\n%s' \
1729
1878
" ${iso_name} " " ${iso_version} " " $( printf ' %0.1s' " #" {1..1024}) " ) " \
0 commit comments