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;
}
}
}
- 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) {
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++);
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);
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;