]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/installer/hw.c
installer: Intialize part_boot_efi_idx
[ipfire-2.x.git] / src / installer / hw.c
index 0cfeb521fcff01271d2b54e7fb0c349959d61126..71a1f1cce369fb027ce65a2e5b5ae919f4a6ae66 100644 (file)
@@ -78,13 +78,9 @@ struct hw* hw_init() {
        if (ret == 0)
                snprintf(hw->arch, sizeof(hw->arch), "%s", uname_data.machine);
 
-       // Detect if we are running in EFI mode
-       ret = access("/sys/firmware/efi", R_OK);
-       if (ret == 0)
-               hw->efi_supported = 1;
-
        // Should we install in EFI mode?
-       hw->efi = 1;
+       if ((strcmp(hw->arch, "x86_64") == 0) || (strcmp(hw->arch, "aarch64") == 0))
+               hw->efi = 1;
 
        return hw;
 }
@@ -150,14 +146,7 @@ int hw_mount(const char* source, const char* target, const char* fs, int flags)
                }
        }
 
-       int r = mount(source, target, fs, flags, NULL);
-
-       if (r) {
-               fprintf(stderr, "Error mounting %s to %s (fs = %s, flags = %d): %s\n",
-                               source, target, fs, flags, strerror(r));
-       }
-
-       return r;
+       return mount(source, target, fs, flags, NULL);
 }
 
 int hw_umount(const char* target) {
@@ -558,8 +547,10 @@ static int hw_calculate_partition_table(struct hw* hw, struct hw_destination* de
 
                snprintf(dest->part_boot_efi, sizeof(dest->part_boot_efi),
                        "%s%d", path, part_idx++);
-       } else
+       } else {
                *dest->part_boot_efi = '\0';
+               dest->part_boot_efi_idx = 0;
+       }
 
        if (dest->size_swap > 0)
                snprintf(dest->part_swap, sizeof(dest->part_swap), "%s%d", path, part_idx++);
@@ -717,7 +708,6 @@ int hw_create_partitions(struct hw_destination* dest, const char* output) {
                if (*dest->part_bootldr) {
                        asprintf(&cmd, "%s set %d bios_grub on", cmd, dest->part_boot_idx);
                }
-               asprintf(&cmd, "%s disk_set pmbr_boot on", cmd);
        }
 
        r = mysystem(output, cmd);
@@ -1040,43 +1030,9 @@ int hw_stop_all_raid_arrays(const char* output) {
 
 int hw_install_bootloader(struct hw* hw, struct hw_destination* dest, const char* output) {
        char cmd[STRING_SIZE];
-       int r;
-
-       char cmd_grub[STRING_SIZE];
-       snprintf(cmd_grub, sizeof(cmd_grub), "/usr/sbin/grub-install --target=i386-pc"
-                       " --no-floppy --recheck");
-
-       if (dest->is_raid) {
-               snprintf(cmd, sizeof(cmd), "%s %s", cmd_grub, dest->disk1->path);
-               r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
-               if (r)
-                       return r;
-
-               snprintf(cmd, sizeof(cmd), "%s %s", cmd_grub, dest->disk2->path);
-               r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
-               if (r)
-                       return r;
-       } else {
-               snprintf(cmd, sizeof(cmd), "%s %s", cmd_grub, dest->path);
-               r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
-               if (r)
-                       return r;
-       }
-
-       // Install GRUB in EFI mode
-       if (hw->efi) {
-               snprintf(cmd, sizeof(cmd), "/usr/sbin/grub-install"
-                       " --target=%s-efi --efi-directory=%s %s", hw->arch, HW_PATH_BOOT_EFI,
-                       (hw->efi_supported) ? "" : "--no-nvram");
-
-               r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
-               if (r)
-                       return r;
-       }
 
-       // Generate configuration file
-       snprintf(cmd, sizeof(cmd), "/usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg");
-       r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
+       snprintf(cmd, sizeof(cmd), "/usr/bin/install-bootloader %s", dest->path);
+       int r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
        if (r)
                return r;