Change: The 'slct_locale', 'mkinitcpio_preset' & 'btldrcfg' functions have been refined

This commit is contained in:
Jane Doe
2026-04-04 14:01:55 +03:00
parent e5f8b3c728
commit e4d57713ae
+108 -101
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# Amelia installer for Archlinux
# Version: 1.4.2
# Version: 1.4.3
# Source: https://gitlab.com/prism7/archery
set -euo pipefail
@@ -471,7 +471,7 @@ slct_locale() {
elif [[ "${LOCALESET}" == "l" ]]; then
grep -E 'UTF-8' /usr/share/i18n/SUPPORTED | less
return 1
elif ! grep -q "^#\?$(sed 's/[].*[]/\\&/g' <<< "${LOCALESET}") " /usr/share/i18n/SUPPORTED; then
elif ! grep -qF "${LOCALESET} " /usr/share/i18n/SUPPORTED; then
invalid
return 1
else
@@ -3905,6 +3905,79 @@ CONF
stage_fail
fi
}
mkinitcpio_preset() {
if [[ "${uki}" == "y" ]]; then
if [[ ! -d "${esp_mount}"/EFI/Linux ]]; then
mkdir -p "${esp_mount}"/EFI/Linux
fi
if [[ "${setrescue}" == "y" ]]; then
local stage_prompt="Uki + Rescue Uki Creation"
if arch-chroot /mnt <<-UKI_RESCUE > "${void}" 2>&1 2> "${log}" ; then
mkdir /etc/cmdline.d
echo "rw ${boot_opts[*]}" | tee /etc/cmdline.d/cmdlined.conf
echo "systemd.unit=rescue.target rw ${boot_opts[*]}" | tee /etc/cmdline.d/rescued.conf
cp /etc/mkinitcpio.d/${kernel}.preset /etc/mkinitcpio.d/${kernel}.preset.bak
cat <<-MKINITCPIO_PRESET > /etc/mkinitcpio.d/${kernel}.preset
# mkinitcpio preset file for the '${kernel}' package
ALL_config="/etc/mkinitcpio.conf.d/mkinitcpiod.conf"
ALL_kver="/boot/vmlinuz-${kernel}"
PRESETS=('default' 'rescue')
default_uki="${btldr_esp_mount}/EFI/Linux/arch-${kernel}.efi"
default_options="--cmdline /etc/cmdline.d/cmdlined.conf"
rescue_uki="${btldr_esp_mount}/EFI/Linux/rescue.efi"
rescue_options="--cmdline /etc/cmdline.d/rescued.conf"
MKINITCPIO_PRESET
mkinitcpio -P
UKI_RESCUE
stage_ok
else
stage_fail
fi
elif [[ -z "${setrescue}" ]]; then
local stage_prompt="Uki Creation"
if arch-chroot /mnt <<-UKI > "${void}" 2>&1 2> "${log}" ; then
mkdir /etc/cmdline.d
echo "rw ${boot_opts[*]}" | tee /etc/cmdline.d/cmdlined.conf
cp /etc/mkinitcpio.d/${kernel}.preset /etc/mkinitcpio.d/${kernel}.preset.bak
cat <<-MKINITCPIO_PRESET > /etc/mkinitcpio.d/${kernel}.preset
# mkinitcpio preset file for the '${kernel}' package
ALL_config="/etc/mkinitcpio.conf.d/mkinitcpiod.conf"
ALL_kver="/boot/vmlinuz-${kernel}"
PRESETS=('default')
default_uki="${btldr_esp_mount}/EFI/Linux/arch-${kernel}.efi"
default_options="--cmdline /etc/cmdline.d/cmdlined.conf
MKINITCPIO_PRESET
mkinitcpio -P
UKI
stage_ok
else
stage_fail
fi
fi
for file in /mnt/boot/*.img; do
if [ -f "$file" ]; then
rm "$file"
fi
done
elif [[ "${uki}" == "n" ]]; then
local stage_prompt="Initramfs Creation"
if arch-chroot /mnt <<-INITRAMFS > "${void}" 2>&1 2> "${log}" ; then
cp /etc/mkinitcpio.d/${kernel}.preset /etc/mkinitcpio.d/${kernel}.preset.bak
cat <<-MKINITCPIO_PRESET > /etc/mkinitcpio.d/${kernel}.preset
# mkinitcpio preset file for the '${kernel}' package
ALL_config="/etc/mkinitcpio.conf.d/mkinitcpiod.conf"
ALL_kver="/boot/vmlinuz-${kernel}"
PRESETS=('default')
default_image="/boot/initramfs-${kernel}.img"
MKINITCPIO_PRESET
mkinitcpio -P
INITRAMFS
stage_ok
else
stage_fail
fi
fi
}
btldrcfg() {
if [[ "${bootloader}" == "1" ]]; then
local stage_prompt="Systemd-boot Configuration"
@@ -3943,6 +4016,20 @@ SDBOOT_XBOOTLDR_INSTL
else
stage_fail
fi
if [[ "${setrescue}" == "y" ]]; then
if arch-chroot -S /mnt <<-RESCUE_ENTRY > "${void}" 2>&1 2> "${log}" ; then
cat <<-XBOOTLDR_RESCUE_CONF > /boot/loader/entries/rescue.conf
title Arch Rescue
linux /vmlinuz-${kernel}
initrd /initramfs-${kernel}.img
options rw systemd.unit=rescue.target ${boot_opts[*]}
XBOOTLDR_RESCUE_CONF
RESCUE_ENTRY
stage_ok
else
stage_fail
fi
fi
fi
elif [[ "${bootloader}" == "2" ]]; then
local stage_prompt="Grub Configuration"
@@ -3961,7 +4048,7 @@ SDBOOT_XBOOTLDR_INSTL
GRUB_GFXPAYLOAD_LINUX=keep
GRUB_DISABLE_RECOVERY=true
GRUB_DISABLE_OS_PROBER=false
#GRUB_TERMINAL_OUTPUT=console
GRUB_TERMINAL_OUTPUT=console
CFG
GRUB_CONF
stage_ok
@@ -4008,6 +4095,19 @@ GRUB_INSTL_RMV
stage_fail
fi
fi
if [[ "${setrescue}" == "y" ]]; then
local stage_prompt="Rescue Entry Creation"
if arch-chroot /mnt <<-GRUB_RESCUE_ENTRY > "${void}" 2>&1 2> "${log}" ; then
touch /boot/grub/custom.cfg
grep -E -A 11 "'Arch Linux'" /boot/grub/grub.cfg > /boot/grub/custom.cfg
sed -i 's/Arch Linux/Rescue Environment/' /boot/grub/custom.cfg
sed -i '/vmlinuz/ s/$/ systemd.unit=rescue.target/' /boot/grub/custom.cfg
GRUB_RESCUE_ENTRY
stage_ok
else
stage_fail
fi
fi
if [[ "${fs}" == "2" ]]; then
local stage_prompt="Grub-Btrfsd Service Activation"
if arch-chroot /mnt <<-GRUB_BTRFSD > "${void}" 2>&1 2> "${log}" ; then
@@ -4109,100 +4209,7 @@ NVIDIA_HOOK
fi
fi
}
mkinitcpio_preset() {
local stage_prompt="Mkinitcpio Kernel Presets Configuration"
if [[ "${uki}" == "y" ]]; then
if [[ ! -e "${esp_mount}"/EFI/Linux ]]; then
mkdir -p "${esp_mount}"/EFI/Linux
fi
if arch-chroot /mnt <<-UKI > "${void}" 2>&1 2> "${log}" ; then
mkdir /etc/cmdline.d
echo "rw ${boot_opts[*]}" | tee /etc/cmdline.d/cmdlined.conf
cp /etc/mkinitcpio.d/${kernel}.preset /etc/mkinitcpio.d/${kernel}.preset.bak
cat <<-MKINITCPIO_PRESET > /etc/mkinitcpio.d/${kernel}.preset
# mkinitcpio preset file for the '${kernel}' package
ALL_config="/etc/mkinitcpio.conf.d/mkinitcpiod.conf"
ALL_kver="/boot/vmlinuz-${kernel}"
PRESETS=('default')
default_uki="${btldr_esp_mount}/EFI/Linux/arch-${kernel}.efi"
MKINITCPIO_PRESET
mkinitcpio -P
UKI
stage_ok
else
stage_fail
fi
for file in /mnt/boot/*.img; do
if [ -f "$file" ]; then
rm "$file"
fi
done
elif [[ "${uki}" == "n" ]]; then
if arch-chroot /mnt <<-NO_UKI > "${void}" 2>&1 2> "${log}" ; then
cp /etc/mkinitcpio.d/${kernel}.preset /etc/mkinitcpio.d/${kernel}.preset.bak
cat <<-MKINITCPIO_PRESET > /etc/mkinitcpio.d/${kernel}.preset
# mkinitcpio preset file for the '${kernel}' package
ALL_config="/etc/mkinitcpio.conf.d/mkinitcpiod.conf"
ALL_kver="/boot/vmlinuz-${kernel}"
PRESETS=('default')
default_image="/boot/initramfs-${kernel}.img"
MKINITCPIO_PRESET
mkinitcpio -P
NO_UKI
stage_ok
else
stage_fail
fi
fi
}
var_opts() {
if [[ "${sb_sign}" == "y" && "${setrescue}" == "y" ]]; then
local stage_prompt="Rescue Entry Creation"
if [[ "${bootloader}" == "1" && "${uki}" == "y" ]]; then
if arch-chroot /mnt <<-SDBOOT_RESCUE_ENTRY > "${void}" 2>&1 2> "${log}" ; then
echo "systemd.unit=rescue.target rw ${boot_opts[*]}" | tee /etc/cmdline.d/rescued.conf
cat <<-MKINITCPIO_PRESET > /etc/mkinitcpio.d/${kernel}.preset
# mkinitcpio preset file for the '${kernel}' package
ALL_config="/etc/mkinitcpio.conf.d/mkinitcpiod.conf"
ALL_kver="/boot/vmlinuz-${kernel}"
PRESETS=('default' 'rescue')
default_uki="${btldr_esp_mount}/EFI/Linux/arch-${kernel}.efi"
default_options="--cmdline /etc/cmdline.d/cmdlined.conf"
rescue_uki="${btldr_esp_mount}/EFI/Linux/rescue.efi"
rescue_options="--cmdline /etc/cmdline.d/rescued.conf"
MKINITCPIO_PRESET
mkinitcpio -P
SDBOOT_RESCUE_ENTRY
stage_ok
else
stage_fail
fi
elif [[ "${bootloader}" == "1" && "${uki}" == "n" ]]; then
if arch-chroot /mnt <<-SDBOOT_XBOOTLDR_RESCUE_ENTRY > "${void}" 2>&1 2> "${log}" ; then
cat <<-XBOOTLDR_RESCUE_CONF > /boot/loader/entries/rescue.conf
title Arch Rescue
linux /vmlinuz-${kernel}
initrd /initramfs-${kernel}.img
options rw systemd.unit=rescue.target ${boot_opts[*]}
XBOOTLDR_RESCUE_CONF
SDBOOT_XBOOTLDR_RESCUE_ENTRY
stage_ok
else
stage_fail
fi
elif [[ "${bootloader}" == "2" ]]; then
if arch-chroot /mnt <<-GRUB_RESCUE_ENTRY > "${void}" 2>&1 2> "${log}" ; then
touch /boot/grub/custom.cfg
grep -E -A 11 "'Arch Linux'" /boot/grub/grub.cfg > /boot/grub/custom.cfg
sed -i 's/Arch Linux/Rescue Environment/' /boot/grub/custom.cfg
sed -i '/vmlinuz/ s/$/ systemd.unit=rescue.target/' /boot/grub/custom.cfg
GRUB_RESCUE_ENTRY
stage_ok
else
stage_fail
fi
fi
fi
if [[ "${multilib}" == "y" ]]; then
local stage_prompt="Multilib Configuration"
if arch-chroot /mnt <<-MULTILIB > "${void}" 2>&1 2> "${log}" ; then
@@ -4512,10 +4519,10 @@ secboot_sign() {
if [[ "${sb_sign}" == "y" ]]; then
local stage_prompt="Secure-Boot Signing"
if arch-chroot /mnt <<-SECSIGN_MAIN > "${void}" 2>&1 2> "${log}" ; then
pacman -S --noconfirm sbctl
sbctl create-keys
sbctl enroll-keys -m
sbctl sign -s /boot/vmlinuz-${kernel}
pacman -S --noconfirm sbctl
sbctl create-keys
sbctl enroll-keys -m
sbctl sign -s /boot/vmlinuz-${kernel}
SECSIGN_MAIN
:
else
@@ -4746,12 +4753,12 @@ CUSTOM_SRVC
fi
fi
fi
mkinitcpio_preset
btldrcfg
trimcfg
vm_serv
zramcfg
nvidia_hook
mkinitcpio_preset
var_opts
foreign
optimizations