Commit a4f89be9 authored by Anton Midyukov's avatar Anton Midyukov

tar2fs: do not install grub to /EFI/altlinux, install prebuilt grub image always

The idea is to not embed grub.cfg in the efi image, in order to determine the installed grub in EFI/BOOT/boot*.efi by grub.cfg. In the case of x86_64, the prebuilt uefi image is always used.
parent fab24192
...@@ -146,6 +146,25 @@ mkpart() { ...@@ -146,6 +146,25 @@ mkpart() {
parting mkpart primary "$CUR_FS" "$start"MiB "$end" parting mkpart primary "$CUR_FS" "$start"MiB "$end"
} }
create_inner_grub_cfg() {
local boot_path boot_uuid cfg_path
cfg_path=$1
[ -n "$cfg_path" ] || return 1
if [ -n "$BOOTUUID" ]; then
boot_uuid="$BOOTUUID"
boot_path=grub
else
boot_uuid="$ROOTUUID"
boot_path=boot/grub
fi
[ -n "$boot_uuid" ] || return 1
cat >"$cfg_path" <<-GRUB_EOF
search.fs_uuid $boot_uuid root
set prefix=(\$root)/$boot_path
configfile \$prefix/grub.cfg
GRUB_EOF
}
# a tarball containing chroot with a kernel # a tarball containing chroot with a kernel
TAR="$1" TAR="$1"
[ -s "$TAR" ] || fatal "source tarball doesn't really exist" [ -s "$TAR" ] || fatal "source tarball doesn't really exist"
...@@ -413,13 +432,10 @@ image=/boot/vmlinuz ...@@ -413,13 +432,10 @@ image=/boot/vmlinuz
grub-efi) grub-efi)
echo 'GRUB_DISABLE_OS_PROBER=true' >> "$ROOTFS"/etc/sysconfig/grub2 echo 'GRUB_DISABLE_OS_PROBER=true' >> "$ROOTFS"/etc/sysconfig/grub2
chroot "$ROOTFS" grub-mkconfig -o /boot/grub/grub.cfg chroot "$ROOTFS" grub-mkconfig -o /boot/grub/grub.cfg
mkdir -p "$ROOTFS"/boot/efi/EFI/BOOT
case "$ARCH" in case "$ARCH" in
x86_64) x86_64)
chroot "$ROOTFS" grub-install --target=i386-efi --recheck \ chroot "$ROOTFS" grub-install --target=i386-efi --recheck \
--no-nvram --uefi-secure-boot
chroot "$ROOTFS" grub-install --target=x86_64-efi --recheck \
--no-nvram --uefi-secure-boot
chroot "$ROOTFS" grub-install --target=i386-efi --recheck \
--removable --uefi-secure-boot --removable --uefi-secure-boot
chroot "$ROOTFS" grub-install --target=x86_64-efi --recheck \ chroot "$ROOTFS" grub-install --target=x86_64-efi --recheck \
--removable --uefi-secure-boot --removable --uefi-secure-boot
...@@ -429,25 +445,21 @@ grub-efi) ...@@ -429,25 +445,21 @@ grub-efi)
chroot "$ROOTFS" grub-install --target=i386-pc "$LOOPDEV" chroot "$ROOTFS" grub-install --target=i386-pc "$LOOPDEV"
;; ;;
aarch64) aarch64)
chroot "$ROOTFS" grub-install --target=arm64-efi --recheck \ cp "$ROOTFS"/usr/lib64/efi/grubaa64.efi \
--no-nvram --uefi-secure-boot "$ROOTFS"/boot/efi/EFI/BOOT/bootaa64.efi
chroot "$ROOTFS" grub-install --target=arm64-efi --recheck \
--removable --uefi-secure-boot
;; ;;
riscv64) riscv64)
chroot "$ROOTFS" grub-install --target=riscv64-efi --recheck \ cp "$ROOTFS"/usr/lib64/efi/grubriscv64.efi \
--no-nvram --uefi-secure-boot "$ROOTFS"/boot/efi/EFI/BOOT/bootriscv64.efi
chroot "$ROOTFS" grub-install --target=riscv64-efi --recheck \
--removable --uefi-secure-boot
;; ;;
loongarch64) loongarch64)
chroot "$ROOTFS" grub-install --target=loongarch64-efi --recheck \ cp "$ROOTFS"/usr/lib64/efi/grubloongarch64.efi \
--no-nvram --uefi-secure-boot "$ROOTFS"/boot/efi/EFI/BOOT/bootloongarch64.efi
chroot "$ROOTFS" grub-install --target=loongarch64-efi --recheck \
--removable --uefi-secure-boot
;; ;;
esac esac
sed -i '/GRUB_DISABLE_OS_PROBER=true/d' "$ROOTFS/etc/sysconfig/grub2" sed -i '/GRUB_DISABLE_OS_PROBER=true/d' "$ROOTFS/etc/sysconfig/grub2"
[ -s "$ROOTFS"/boot/efi/EFI/BOOT/grub.cfg ] ||
create_inner_grub_cfg "$ROOTFS"/boot/efi/EFI/BOOT/grub.cfg
;; ;;
grub) grub)
echo 'GRUB_DISABLE_OS_PROBER=true' >> "$ROOTFS"/etc/sysconfig/grub2 echo 'GRUB_DISABLE_OS_PROBER=true' >> "$ROOTFS"/etc/sysconfig/grub2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment