]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: don't update $ESP/EFI/BOOTX64.EFI twice
authorLennart Poettering <lennart@poettering.net>
Tue, 2 Sep 2025 20:44:35 +0000 (22:44 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 19 Sep 2025 15:47:46 +0000 (00:47 +0900)
We update BOOTX64.EFI explicitly once (because we know that it's the
main entry point of UEFI) and then a second time when we update
everything in $ESP/EFI/*.EFI. That's redundant and pretty ugly/confusing
in the log output. Hence exclude the file we already updated explicitly
from the 2nd run.

src/bootctl/bootctl-install.c

index df5065b7986e939ca80b43dd0d2f14fd9b2ef073..89a82192f87637dd313e9c41b5ba8745c2e5dd94 100644 (file)
@@ -334,7 +334,11 @@ static int create_subdirs(const char *root, const char * const *subdirs) {
         return 0;
 }
 
-static int update_efi_boot_binaries(const char *esp_path, const char *source_path) {
+static int update_efi_boot_binaries(
+                const char *esp_path,
+                const char *source_path,
+                const char *ignore_filename) {
+
         _cleanup_closedir_ DIR *d = NULL;
         _cleanup_free_ char *p = NULL;
         int r, ret = 0;
@@ -354,6 +358,9 @@ static int update_efi_boot_binaries(const char *esp_path, const char *source_pat
                 if (!endswith_no_case(de->d_name, ".efi"))
                         continue;
 
+                if (strcaseeq_ptr(ignore_filename, de->d_name))
+                        continue;
+
                 fd = xopenat_full(dirfd(d), de->d_name, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY|O_NOFOLLOW, XO_REGULAR, /* mode= */ 0);
                 if (fd < 0)
                         return log_error_errno(fd, "Failed to open \"%s/%s\" for reading: %m", p, de->d_name);
@@ -425,7 +432,7 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) {
 
                 /* Create the EFI default boot loader name (specified for removable devices) */
                 v = strjoina("/EFI/BOOT/BOOT", e);
-                ascii_strupper(strrchr(v, '/') + 1);
+                const char *boot_dot_efi = ascii_strupper(strrchr(v, '/') + 1);
 
                 r = chase(v, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_NONEXISTENT|CHASE_TRIGGER_AUTOFS, &default_dest_path, NULL);
                 if (r < 0)
@@ -433,10 +440,10 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) {
 
                 RET_GATHER(ret, copy_file_with_version_check(source_path, default_dest_path, force));
 
-                /* If we were installed under any other name in /EFI/BOOT, make sure we update those binaries
+                /* If we were installed under any other name in /EFI/BOOT/, make sure we update those binaries
                  * as well. */
                 if (!force)
-                        RET_GATHER(ret, update_efi_boot_binaries(esp_path, source_path));
+                        RET_GATHER(ret, update_efi_boot_binaries(esp_path, source_path, boot_dot_efi));
         }
 
         return ret;