From 6531f6c6cdca3808ffe53c25dfbcdf22a3eb014e Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Sat, 19 Jun 2021 19:39:01 +0100 Subject: [PATCH 1/2] Avoid mistakenly invoking `update-grub` on Red Hat/Fedora The missing `else` meant that `grub2-mkconfig` was being invoked (correctly) but then `update-grub` was also being invoked. This is part 1 of the fix for #423. --- src/Core/Main.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Main.vala b/src/Core/Main.vala index 414afd60..1f6c0995 100644 --- a/src/Core/Main.vala +++ b/src/Core/Main.vala @@ -2387,7 +2387,7 @@ public class Main : GLib.Object{ if (target_distro.dist_type == "redhat"){ sh += "%s grub2-mkconfig -o /boot/grub2/grub.cfg \n".printf(chroot); } - if (target_distro.dist_type == "arch"){ + else if (target_distro.dist_type == "arch"){ sh += "%s grub-mkconfig -o /boot/grub/grub.cfg \n".printf(chroot); } else{ From 7c27b2c4016e9e62b2196931fc1eb1ae8964995f Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Sat, 19 Jun 2021 22:17:31 +0100 Subject: [PATCH 2/2] For UEFI Fedora/Red Hat systems, update the UEFI grub.cfg file Fedora and Red Hat documentation directs users to directly update the grub.cfg at /boot/efi/EFI/{redhat|fedora}/grub.cfg when they manually update GRUB, and so that file no longer pulls in /boot/grub2/grub.cfg. As a result, Timeshift restores were broken for users who updated their GRUB config, since Timeshift only updated the latter file prior to this patch. This patch makes Timeshift directly update the appropriate EFI grub.cfg file. This is part 2 of the fix for #423 --- src/Core/Main.vala | 6 +++++- src/Utility/LinuxDistro.vala | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Core/Main.vala b/src/Core/Main.vala index 1f6c0995..2746a511 100644 --- a/src/Core/Main.vala +++ b/src/Core/Main.vala @@ -2385,7 +2385,11 @@ public class Main : GLib.Object{ sh += "echo '" + _("Updating GRUB menu...") + "' \n"; if (target_distro.dist_type == "redhat"){ - sh += "%s grub2-mkconfig -o /boot/grub2/grub.cfg \n".printf(chroot); + if (target_distro.is_efi){ + sh += "%s grub2-mkconfig -o /boot/efi/EFI/%s/grub.cfg \n".printf(chroot, target_distro.dist_id); + else{ + sh += "%s grub2-mkconfig -o /boot/grub2/grub.cfg \n".printf(chroot); + } } else if (target_distro.dist_type == "arch"){ sh += "%s grub-mkconfig -o /boot/grub/grub.cfg \n".printf(chroot); diff --git a/src/Utility/LinuxDistro.vala b/src/Utility/LinuxDistro.vala index ea38e473..0f50719d 100644 --- a/src/Utility/LinuxDistro.vala +++ b/src/Utility/LinuxDistro.vala @@ -34,6 +34,7 @@ public class LinuxDistro : GLib.Object{ public string description = ""; public string release = ""; public string codename = ""; + public bool is_efi = true; public LinuxDistro(){ @@ -41,6 +42,7 @@ public class LinuxDistro : GLib.Object{ description = ""; release = ""; codename = ""; + is_efi = true; } public string full_name(){ @@ -64,6 +66,9 @@ public class LinuxDistro : GLib.Object{ LinuxDistro info = new LinuxDistro(); + string efi_dir = root_path + "/sys/firmware/efi"; + info.is_efi = File.parse_name(efi_dir).query_exists(); + string dist_file = root_path + "/etc/lsb-release"; var f = File.new_for_path(dist_file); if (f.query_exists()){