2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <grub/types.h>
21 #include <grub/emu/misc.h>
22 #include <grub/util/misc.h>
23 #include <grub/misc.h>
24 #include <grub/device.h>
25 #include <grub/disk.h>
26 #include <grub/file.h>
29 #include <grub/term.h>
31 #include <grub/lib/hexdump.h>
32 #include <grub/crypto.h>
33 #include <grub/command.h>
34 #include <grub/i18n.h>
35 #include <grub/zfs/zfs.h>
36 #include <grub/util/install.h>
37 #include <grub/emu/getroot.h>
38 #include <grub/diskfilter.h>
39 #include <grub/cryptodisk.h>
40 #include <grub/legacy_parse.h>
41 #include <grub/gpt_partition.h>
42 #include <grub/emu/config.h>
43 #include <grub/util/ofpath.h>
52 static int removable
= 0;
53 static int recheck
= 0;
54 static int update_nvram
= 1;
55 static char *install_device
= NULL
;
56 static char *debug_image
= NULL
;
57 static char *rootdir
= NULL
;
58 static char *bootdir
= NULL
;
59 static int allow_floppy
= 0;
60 static int force_file_id
= 0;
61 static char *disk_module
= NULL
;
62 static char *efidir
= NULL
;
64 static int have_abstractions
= 0;
65 static int have_cryptodisk
= 0;
66 static char * bootloader_id
;
67 static int have_load_cfg
= 0;
68 static FILE * load_cfg_f
= NULL
;
69 static char *load_cfg
;
70 static int install_bootsector
= 1;
71 static int add_rs_codes
= 1;
75 OPTION_BOOT_DIRECTORY
= 0x301,
76 OPTION_ROOT_DIRECTORY
,
101 static int fs_probe
= 1;
104 argp_parser (int key
, char *arg
, struct argp_state
*state
)
106 if (grub_install_parse (key
, arg
))
110 case OPTION_FORCE_FILE_ID
:
118 if (!grub_strstr (arg
, "setup"))
119 install_bootsector
= 0;
122 /* Accept and ignore for compatibility. */
124 case OPTION_MKRELPATH
:
127 case OPTION_MKDEVICEMAP
:
128 case OPTION_NO_FLOPPY
:
130 case OPTION_ROOT_DIRECTORY
:
131 /* Accept for compatibility. */
133 rootdir
= xstrdup (arg
);
136 case OPTION_BOOT_DIRECTORY
:
138 bootdir
= xstrdup (arg
);
141 case OPTION_EFI_DIRECTORY
:
143 efidir
= xstrdup (arg
);
146 case OPTION_DISK_MODULE
:
148 disk_module
= xstrdup (arg
);
153 target
= xstrdup (arg
);
156 case OPTION_DEBUG_IMAGE
:
158 debug_image
= xstrdup (arg
);
161 case OPTION_NO_NVRAM
:
173 case OPTION_REMOVABLE
:
177 case OPTION_ALLOW_FLOPPY
:
181 case OPTION_NO_BOOTSECTOR
:
182 install_bootsector
= 0;
185 case OPTION_NO_RS_CODES
:
193 case OPTION_BOOTLOADER_ID
:
194 free (bootloader_id
);
195 bootloader_id
= xstrdup (arg
);
200 grub_util_error ("%s", _("More than one install device?"));
201 install_device
= xstrdup (arg
);
205 return ARGP_ERR_UNKNOWN
;
210 static struct argp_option options
[] = {
211 GRUB_INSTALL_OPTIONS
,
212 {"boot-directory", OPTION_BOOT_DIRECTORY
, N_("DIR"),
213 0, N_("install GRUB images under the directory DIR/%s instead of the %s directory"), 2},
214 {"root-directory", OPTION_ROOT_DIRECTORY
, N_("DIR"),
215 OPTION_HIDDEN
, 0, 2},
216 {"font", OPTION_FONT
, N_("FILE"),
217 OPTION_HIDDEN
, 0, 2},
218 {"target", OPTION_TARGET
, N_("TARGET"),
219 /* TRANSLATORS: "TARGET" as in "target platform". */
220 0, N_("install GRUB for TARGET platform [default=%s]"), 2},
221 {"grub-setup", OPTION_SETUP
, "FILE", OPTION_HIDDEN
, 0, 2},
222 {"grub-mkrelpath", OPTION_MKRELPATH
, "FILE", OPTION_HIDDEN
, 0, 2},
223 {"grub-mkdevicemap", OPTION_MKDEVICEMAP
, "FILE", OPTION_HIDDEN
, 0, 2},
224 {"grub-probe", OPTION_PROBE
, "FILE", OPTION_HIDDEN
, 0, 2},
225 {"grub-editenv", OPTION_EDITENV
, "FILE", OPTION_HIDDEN
, 0, 2},
226 {"allow-floppy", OPTION_ALLOW_FLOPPY
, 0, 0,
227 /* TRANSLATORS: "may break" doesn't just mean that option wouldn't have any
228 effect but that it will make the resulting install unbootable from HDD. */
229 N_("make the drive also bootable as floppy (default for fdX devices)."
230 " May break on some BIOSes."), 2},
231 {"recheck", OPTION_RECHECK
, 0, 0,
232 N_("delete device map if it already exists"), 2},
233 {"force", OPTION_FORCE
, 0, 0,
234 N_("install even if problems are detected"), 2},
235 {"force-file-id", OPTION_FORCE_FILE_ID
, 0, 0,
236 N_("use identifier file even if UUID is available"), 2},
237 {"disk-module", OPTION_MODULE
, N_("MODULE"), 0,
238 N_("disk module to use (biosdisk or native). "
239 "This option is only available on BIOS target."), 2},
240 {"no-nvram", OPTION_NO_NVRAM
, 0, 0,
241 N_("don't update the `boot-device'/`Boot*' NVRAM variables. "
242 "This option is only available on EFI and IEEE1275 targets."), 2},
243 {"skip-fs-probe",'s',0, 0,
244 N_("do not probe for filesystems in DEVICE"), 0},
245 {"no-bootsector", OPTION_NO_BOOTSECTOR
, 0, 0,
246 N_("do not install bootsector"), 0},
247 {"no-rs-codes", OPTION_NO_RS_CODES
, 0, 0,
248 N_("Do not apply any reed-solomon codes when embedding core.img. "
249 "This option is only available on x86 BIOS targets."), 0},
251 {"debug", OPTION_DEBUG
, 0, OPTION_HIDDEN
, 0, 2},
252 {"no-floppy", OPTION_NO_FLOPPY
, 0, OPTION_HIDDEN
, 0, 2},
253 {"debug-image", OPTION_DEBUG_IMAGE
, "STR", OPTION_HIDDEN
, 0, 2},
254 {"removable", OPTION_REMOVABLE
, 0, 0,
255 N_("the installation device is removable. "
256 "This option is only available on EFI."), 2},
257 {"bootloader-id", OPTION_BOOTLOADER_ID
, N_("ID"), 0,
258 N_("the ID of bootloader. This option is only available on EFI."), 2},
259 {"efi-directory", OPTION_EFI_DIRECTORY
, N_("DIR"), 0,
260 N_("use DIR as the EFI System Partition root."), 2},
265 get_default_platform (void)
268 return "powerpc-ieee1275";
269 #elif defined (__sparc__) || defined (__sparc64__)
270 return "sparc64-ieee1275";
271 #elif defined (__MIPSEL__)
272 return "mipsel-loongson";
273 #elif defined (__MIPSEB__)
275 #elif defined (__ia64__)
277 #elif defined (__arm__)
279 #elif defined (__aarch64__)
281 #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__)
282 return grub_install_get_default_x86_platform ();
289 help_filter (int key
, const char *text
, void *input
__attribute__ ((unused
)))
293 case OPTION_BOOT_DIRECTORY
:
294 return xasprintf (text
, GRUB_DIR_NAME
, GRUB_BOOT_DIR_NAME
"/" GRUB_DIR_NAME
);
296 return xasprintf (text
, get_default_platform ());
297 case ARGP_KEY_HELP_POST_DOC
:
298 return xasprintf (text
, program_name
, GRUB_BOOT_DIR_NAME
"/" GRUB_DIR_NAME
);
300 return grub_install_help_filter (key
, text
, input
);
304 /* TRANSLATORS: INSTALL_DEVICE isn't an identifier and is the DEVICE you
307 options
, argp_parser
, N_("[OPTION] [INSTALL_DEVICE]"),
308 N_("Install GRUB on your drive.")"\v"
309 N_("INSTALL_DEVICE must be system device filename.\n"
310 "%s copies GRUB images into %s. On some platforms, it"
311 " may also install GRUB into the boot sector."),
312 NULL
, help_filter
, NULL
316 probe_raid_level (grub_disk_t disk
)
318 /* disk might be NULL in the case of a LVM physical volume with no LVM
319 signature. Ignore such cases here. */
323 if (disk
->dev
->id
!= GRUB_DISK_DEVICE_DISKFILTER_ID
)
326 if (disk
->name
[0] != 'm' || disk
->name
[1] != 'd')
329 if (!((struct grub_diskfilter_lv
*) disk
->data
)->segments
)
331 return ((struct grub_diskfilter_lv
*) disk
->data
)->segments
->type
;
335 push_partmap_module (const char *map
)
339 if (strcmp (map
, "openbsd") == 0 || strcmp (map
, "netbsd") == 0)
341 grub_install_push_module ("part_bsd");
345 snprintf (buf
, sizeof (buf
), "part_%s", map
);
346 grub_install_push_module (buf
);
350 probe_mods (grub_disk_t disk
)
352 grub_partition_t part
;
353 grub_disk_memberlist_t list
= NULL
, tmp
;
356 if (disk
->partition
== NULL
)
357 grub_util_info ("no partition map found for %s", disk
->name
);
359 for (part
= disk
->partition
; part
; part
= part
->parent
)
360 push_partmap_module (part
->partmap
->name
);
362 if (disk
->dev
->id
== GRUB_DISK_DEVICE_DISKFILTER_ID
)
364 grub_diskfilter_get_partmap (disk
, push_partmap_module
);
365 have_abstractions
= 1;
368 if (disk
->dev
->id
== GRUB_DISK_DEVICE_DISKFILTER_ID
369 && (grub_memcmp (disk
->name
, "lvm/", sizeof ("lvm/") - 1) == 0 ||
370 grub_memcmp (disk
->name
, "lvmid/", sizeof ("lvmid/") - 1) == 0))
371 grub_install_push_module ("lvm");
373 if (disk
->dev
->id
== GRUB_DISK_DEVICE_DISKFILTER_ID
374 && grub_memcmp (disk
->name
, "ldm/", sizeof ("ldm/") - 1) == 0)
375 grub_install_push_module ("ldm");
377 if (disk
->dev
->id
== GRUB_DISK_DEVICE_CRYPTODISK_ID
)
379 grub_util_cryptodisk_get_abstraction (disk
,
380 grub_install_push_module
);
381 have_abstractions
= 1;
385 raid_level
= probe_raid_level (disk
);
388 grub_install_push_module ("diskfilter");
389 if (disk
->dev
->raidname
)
390 grub_install_push_module (disk
->dev
->raidname (disk
));
393 grub_install_push_module ("raid5rec");
395 grub_install_push_module ("raid6rec");
397 /* In case of LVM/RAID, check the member devices as well. */
398 if (disk
->dev
->memberlist
)
399 list
= disk
->dev
->memberlist (disk
);
402 probe_mods (list
->disk
);
410 have_bootdev (enum grub_install_plat pl
)
414 case GRUB_INSTALL_PLATFORM_I386_PC
:
415 case GRUB_INSTALL_PLATFORM_I386_EFI
:
416 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
417 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
418 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
419 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
420 case GRUB_INSTALL_PLATFORM_I386_IEEE1275
:
421 case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275
:
422 case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
:
423 case GRUB_INSTALL_PLATFORM_MIPSEL_ARC
:
424 case GRUB_INSTALL_PLATFORM_MIPS_ARC
:
427 case GRUB_INSTALL_PLATFORM_I386_QEMU
:
428 case GRUB_INSTALL_PLATFORM_I386_COREBOOT
:
429 case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT
:
430 case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS
:
431 case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS
:
433 case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON
:
434 case GRUB_INSTALL_PLATFORM_ARM_UBOOT
:
436 case GRUB_INSTALL_PLATFORM_I386_XEN
:
437 case GRUB_INSTALL_PLATFORM_X86_64_XEN
:
440 /* pacify warning. */
441 case GRUB_INSTALL_PLATFORM_MAX
:
448 probe_cryptodisk_uuid (grub_disk_t disk
)
450 grub_disk_memberlist_t list
= NULL
, tmp
;
452 /* In case of LVM/RAID, check the member devices as well. */
453 if (disk
->dev
->memberlist
)
455 list
= disk
->dev
->memberlist (disk
);
459 probe_cryptodisk_uuid (list
->disk
);
464 if (disk
->dev
->id
== GRUB_DISK_DEVICE_CRYPTODISK_ID
)
466 const char *uuid
= grub_util_cryptodisk_get_uuid (disk
);
468 load_cfg_f
= grub_util_fopen (load_cfg
, "wb");
471 fprintf (load_cfg_f
, "cryptomount -u %s\n",
477 is_same_disk (const char *a
, const char *b
)
481 if ((*a
== ',' || *a
== '\0') && (*b
== ',' || *b
== '\0'))
501 grub_uint8_t rnd
[15];
502 const size_t sz
= sizeof (rnd
) * GRUB_CHAR_BIT
/ 5;
503 char * ret
= xmalloc (sz
+ 1);
505 if (grub_get_random (rnd
, sizeof (rnd
)))
506 grub_util_error ("%s", _("couldn't retrieve random data"));
507 for (i
= 0; i
< sz
; i
++)
509 grub_size_t b
= i
* 5;
511 grub_size_t f1
= GRUB_CHAR_BIT
- b
% GRUB_CHAR_BIT
;
516 r
= (rnd
[b
/ GRUB_CHAR_BIT
] >> (b
% GRUB_CHAR_BIT
)) & ((1 << f1
) - 1);
518 r
|= (rnd
[b
/ GRUB_CHAR_BIT
+ 1] & ((1 << f2
) - 1)) << f1
;
522 ret
[i
] = 'a' + (r
- 10);
529 escape (const char *in
)
535 for (ptr
= (char*)in
; *ptr
; ptr
++)
538 ret
= grub_malloc (ptr
- in
+ overhead
+ 1);
542 grub_strchrsub (ret
, in
, '\'', "'\\''");
546 static struct grub_util_config config
;
549 device_map_check_duplicates (const char *dev_map
)
552 char buf
[1024]; /* XXX */
558 d
= xmalloc (alloced
* sizeof (d
[0]));
560 if (dev_map
[0] == '\0')
563 fp
= grub_util_fopen (dev_map
, "r");
567 while (fgets (buf
, sizeof (buf
), fp
))
572 /* Skip leading spaces. */
573 while (*p
&& grub_isspace (*p
))
576 /* If the first character is `#' or NUL, skip this line. */
577 if (*p
== '\0' || *p
== '#')
590 if (filled
>= alloced
)
593 d
= xrealloc (d
, alloced
* sizeof (d
[0]));
598 d
[filled
++] = xstrdup (e
);
603 qsort (d
, filled
, sizeof (d
[0]), grub_qsort_strcmp
);
605 for (i
= 0; i
+ 1 < filled
; i
++)
606 if (strcmp (d
[i
], d
[i
+1]) == 0)
608 grub_util_error ("the drive %s is defined multiple times in the device map %s",
612 for (i
= 0; i
< filled
; i
++)
619 write_to_disk (grub_device_t dev
, const char *fn
)
625 core_size
= grub_util_get_image_size (fn
);
627 core_img
= grub_util_read_image (fn
);
629 err
= grub_disk_write (dev
->disk
, 0, 0,
630 core_size
, core_img
);
636 is_prep_partition (grub_device_t dev
)
640 if (!dev
->disk
->partition
)
642 if (strcmp(dev
->disk
->partition
->partmap
->name
, "msdos") == 0)
643 return (dev
->disk
->partition
->msdostype
== 0x41);
645 if (strcmp (dev
->disk
->partition
->partmap
->name
, "gpt") == 0)
647 struct grub_gpt_partentry gptdata
;
648 grub_partition_t p
= dev
->disk
->partition
;
650 dev
->disk
->partition
= dev
->disk
->partition
->parent
;
652 if (grub_disk_read (dev
->disk
, p
->offset
, p
->index
,
653 sizeof (gptdata
), &gptdata
) == 0)
655 const grub_gpt_part_type_t
template = {
656 grub_cpu_to_le32_compile_time (0x9e1a2d38),
657 grub_cpu_to_le16_compile_time (0xc612),
658 grub_cpu_to_le16_compile_time (0x4316),
659 { 0xaa, 0x26, 0x8b, 0x49, 0x52, 0x1e, 0x5a, 0x8b }
662 ret
= grub_memcmp (&template, &gptdata
.type
,
663 sizeof (template)) == 0;
665 dev
->disk
->partition
= p
;
673 is_prep_empty (grub_device_t dev
)
675 grub_disk_addr_t dsize
, addr
;
676 grub_uint32_t buffer
[32768];
678 dsize
= grub_disk_get_size (dev
->disk
);
679 for (addr
= 0; addr
< dsize
;
680 addr
+= sizeof (buffer
) / GRUB_DISK_SECTOR_SIZE
)
682 grub_size_t sz
= sizeof (buffer
);
685 if (sizeof (buffer
) / GRUB_DISK_SECTOR_SIZE
> dsize
- addr
)
686 sz
= (dsize
- addr
) * GRUB_DISK_SECTOR_SIZE
;
687 grub_disk_read (dev
->disk
, addr
, 0, sz
, buffer
);
689 if (addr
== 0 && grub_memcmp (buffer
, ELFMAG
, SELFMAG
) == 0)
692 for (ptr
= buffer
; ptr
< buffer
+ sz
/ sizeof (*buffer
); ptr
++)
701 main (int argc
, char *argv
[])
704 const char *efi_distributor
= NULL
;
705 const char *efi_file
= NULL
;
708 grub_device_t grub_dev
= NULL
;
709 enum grub_install_plat platform
;
710 char *grubdir
, *device_map
;
711 char **curdev
, **curdrive
;
713 char *relative_grubdir
;
714 char **efidir_device_names
= NULL
;
715 grub_device_t efidir_grub_dev
= NULL
;
716 char *efidir_grub_devname
;
718 grub_util_host_init (&argc
, &argv
);
720 argp_parse (&argp
, argc
, argv
, 0, 0, 0);
723 grub_env_set ("debug", "all");
725 grub_util_load_config (&config
);
727 if (!bootloader_id
&& config
.grub_distributor
)
730 bootloader_id
= xstrdup (config
.grub_distributor
);
731 for (ptr
= bootloader_id
; *ptr
&& *ptr
!= ' '; ptr
++)
732 if (*ptr
>= 'A' && *ptr
<= 'Z')
733 *ptr
= *ptr
- 'A' + 'a';
736 if (!bootloader_id
|| bootloader_id
[0] == '\0')
738 free (bootloader_id
);
739 bootloader_id
= xstrdup ("grub");
742 if (!grub_install_source_directory
)
747 t
= get_default_platform ();
749 grub_util_error ("%s",
750 _("Unable to determine your platform."
753 target
= xstrdup (t
);
755 grub_install_source_directory
756 = grub_util_path_concat (2, grub_util_get_pkglibdir (), target
);
759 platform
= grub_install_get_target (grub_install_source_directory
);
763 case GRUB_INSTALL_PLATFORM_I386_PC
:
765 disk_module
= xstrdup ("biosdisk");
767 case GRUB_INSTALL_PLATFORM_I386_EFI
:
768 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
769 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
770 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
771 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
772 case GRUB_INSTALL_PLATFORM_I386_IEEE1275
:
773 case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275
:
774 case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
:
775 case GRUB_INSTALL_PLATFORM_MIPSEL_ARC
:
776 case GRUB_INSTALL_PLATFORM_MIPS_ARC
:
777 case GRUB_INSTALL_PLATFORM_ARM_UBOOT
:
778 case GRUB_INSTALL_PLATFORM_I386_XEN
:
779 case GRUB_INSTALL_PLATFORM_X86_64_XEN
:
782 case GRUB_INSTALL_PLATFORM_I386_QEMU
:
783 case GRUB_INSTALL_PLATFORM_I386_COREBOOT
:
784 case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT
:
785 case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON
:
786 case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS
:
787 case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS
:
788 disk_module
= xstrdup ("native");
791 /* pacify warning. */
792 case GRUB_INSTALL_PLATFORM_MAX
:
798 case GRUB_INSTALL_PLATFORM_I386_PC
:
799 case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275
:
801 grub_util_error ("%s", _("install device isn't specified"));
803 case GRUB_INSTALL_PLATFORM_MIPS_ARC
:
804 case GRUB_INSTALL_PLATFORM_MIPSEL_ARC
:
805 case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
:
807 case GRUB_INSTALL_PLATFORM_I386_EFI
:
808 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
809 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
810 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
811 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
812 case GRUB_INSTALL_PLATFORM_I386_IEEE1275
:
813 case GRUB_INSTALL_PLATFORM_ARM_UBOOT
:
814 case GRUB_INSTALL_PLATFORM_I386_QEMU
:
815 case GRUB_INSTALL_PLATFORM_I386_COREBOOT
:
816 case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT
:
817 case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON
:
818 case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS
:
819 case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS
:
820 case GRUB_INSTALL_PLATFORM_I386_XEN
:
821 case GRUB_INSTALL_PLATFORM_X86_64_XEN
:
822 free (install_device
);
823 install_device
= NULL
;
826 /* pacify warning. */
827 case GRUB_INSTALL_PLATFORM_MAX
:
832 bootdir
= grub_util_path_concat (3, "/", rootdir
, GRUB_BOOT_DIR_NAME
);
835 char * t
= grub_util_path_concat (2, bootdir
, GRUB_DIR_NAME
);
836 grub_install_mkdir_p (t
);
837 grubdir
= canonicalize_file_name (t
);
839 grub_util_error (_("failed to get canonical path of `%s'"), t
);
842 device_map
= grub_util_path_concat (2, grubdir
, "device.map");
845 grub_util_unlink (device_map
);
847 device_map_check_duplicates (device_map
);
848 grub_util_biosdisk_init (device_map
);
850 /* Initialize all modules. */
852 grub_gcry_init_all ();
855 case GRUB_INSTALL_PLATFORM_I386_EFI
:
856 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
857 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
858 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
859 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
866 /* pacify warning. */
867 case GRUB_INSTALL_PLATFORM_MAX
:
871 /* Find the EFI System Partition. */
876 free (install_device
);
877 install_device
= NULL
;
880 char *d
= grub_util_path_concat (2, bootdir
, "efi");
882 if (!grub_util_is_directory (d
))
885 d
= grub_util_path_concat (2, bootdir
, "EFI");
888 The EFI System Partition may have been given directly using
891 if (!grub_util_is_directory (d
)
892 && rootdir
&& grub_strcmp (rootdir
, "/") != 0)
895 d
= xstrdup (rootdir
);
897 if (grub_util_is_directory (d
))
898 dr
= grub_make_system_path_relative_to_its_root (d
);
899 /* Is it a mount point? */
900 if (dr
&& dr
[0] == '\0')
907 grub_util_error ("%s", _("cannot find EFI directory"));
908 efidir_device_names
= grub_guess_root_devices (efidir
);
909 if (!efidir_device_names
|| !efidir_device_names
[0])
910 grub_util_error (_("cannot find a device for %s (is /dev mounted?)"),
912 install_device
= efidir_device_names
[0];
914 for (curdev
= efidir_device_names
; *curdev
; curdev
++)
915 grub_util_pull_device (*curdev
);
917 efidir_grub_devname
= grub_util_get_grub_dev (efidir_device_names
[0]);
918 if (!efidir_grub_devname
)
919 grub_util_error (_("cannot find a GRUB drive for %s. Check your device.map"),
920 efidir_device_names
[0]);
922 efidir_grub_dev
= grub_device_open (efidir_grub_devname
);
923 if (! efidir_grub_dev
)
924 grub_util_error ("%s", grub_errmsg
);
926 fs
= grub_fs_probe (efidir_grub_dev
);
928 grub_util_error ("%s", grub_errmsg
);
930 if (grub_strcmp (fs
->name
, "fat") != 0)
931 grub_util_error (_("%s doesn't look like an EFI partition.\n"), efidir
);
933 /* The EFI specification requires that an EFI System Partition must
934 contain an "EFI" subdirectory, and that OS loaders are stored in
935 subdirectories below EFI. Vendors are expected to pick names that do
936 not collide with other vendors. To minimise collisions, we use the
937 name of our distributor if possible.
940 efi_distributor
= bootloader_id
;
943 /* The specification makes stricter requirements of removable
944 devices, in order that only one image can be automatically loaded
945 from them. The image must always reside under /EFI/BOOT, and it
946 must have a specific file name depending on the architecture.
948 efi_distributor
= "BOOT";
951 case GRUB_INSTALL_PLATFORM_I386_EFI
:
952 efi_file
= "BOOTIA32.EFI";
954 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
955 efi_file
= "BOOTX64.EFI";
957 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
958 efi_file
= "BOOTIA64.EFI";
960 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
961 efi_file
= "BOOTARM.EFI";
963 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
964 efi_file
= "BOOTAARCH64.EFI";
967 grub_util_error ("%s", _("You've found a bug"));
973 /* It is convenient for each architecture to have a different
974 efi_file, so that different versions can be installed in parallel.
978 case GRUB_INSTALL_PLATFORM_I386_EFI
:
979 efi_file
= "grubia32.efi";
981 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
982 efi_file
= "grubx64.efi";
984 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
985 efi_file
= "grubia64.efi";
987 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
988 efi_file
= "grubarm.efi";
990 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
991 efi_file
= "grubarm64.efi";
994 efi_file
= "grub.efi";
998 t
= grub_util_path_concat (3, efidir
, "EFI", efi_distributor
);
1001 grub_install_mkdir_p (efidir
);
1004 grub_install_copy_files (grub_install_source_directory
,
1007 char *envfile
= grub_util_path_concat (2, grubdir
, "grubenv");
1008 if (!grub_util_is_regular (envfile
))
1009 grub_util_create_envblk_file (envfile
);
1013 /* Write device to a variable so we don't have to traverse /dev every time. */
1014 grub_devices
= grub_guess_root_devices (grubdir
);
1015 if (!grub_devices
|| !grub_devices
[0])
1016 grub_util_error (_("cannot find a device for %s (is /dev mounted?)"),
1019 for (curdev
= grub_devices
; *curdev
; curdev
++)
1021 grub_util_pull_device (*curdev
);
1025 grub_drives
= xmalloc (sizeof (grub_drives
[0]) * (ndev
+ 1));
1027 for (curdev
= grub_devices
, curdrive
= grub_drives
; *curdev
; curdev
++,
1030 *curdrive
= grub_util_get_grub_dev (*curdev
);
1032 grub_util_error (_("cannot find a GRUB drive for %s. Check your device.map"),
1037 grub_dev
= grub_device_open (grub_drives
[0]);
1039 grub_util_error ("%s", grub_errmsg
);
1041 grub_fs
= grub_fs_probe (grub_dev
);
1043 grub_util_error ("%s", grub_errmsg
);
1045 grub_install_push_module (grub_fs
->name
);
1048 probe_mods (grub_dev
->disk
);
1050 for (curdrive
= grub_drives
+ 1; *curdrive
; curdrive
++)
1052 grub_device_t dev
= grub_device_open (*curdrive
);
1056 probe_mods (dev
->disk
);
1057 grub_device_close (dev
);
1060 if (!config
.is_cryptodisk_enabled
&& have_cryptodisk
)
1061 grub_util_error (_("attempt to install to cryptodisk without cryptodisk enabled. "
1062 "Set `%s' in file `%s'."), "GRUB_ENABLE_CRYPTODISK=1",
1063 grub_util_get_config_filename ());
1065 if (disk_module
&& grub_strcmp (disk_module
, "ata") == 0)
1066 grub_install_push_module ("pata");
1067 else if (disk_module
&& grub_strcmp (disk_module
, "native") == 0)
1069 grub_install_push_module ("pata");
1070 grub_install_push_module ("ahci");
1071 grub_install_push_module ("ohci");
1072 grub_install_push_module ("uhci");
1073 grub_install_push_module ("usbms");
1075 else if (disk_module
&& disk_module
[0])
1076 grub_install_push_module (disk_module
);
1078 relative_grubdir
= grub_make_system_path_relative_to_its_root (grubdir
);
1079 if (relative_grubdir
[0] == '\0')
1081 free (relative_grubdir
);
1082 relative_grubdir
= xstrdup ("/");
1085 char *platname
= grub_install_get_platform_name (platform
);
1088 char *t
= grub_util_path_concat (2, grubdir
,
1090 platdir
= canonicalize_file_name (t
);
1092 grub_util_error (_("failed to get canonical path of `%s'"),
1096 load_cfg
= grub_util_path_concat (2, platdir
,
1099 grub_util_unlink (load_cfg
);
1101 if (debug_image
&& debug_image
[0])
1103 load_cfg_f
= grub_util_fopen (load_cfg
, "wb");
1105 fprintf (load_cfg_f
, "set debug='%s'\n",
1108 char *prefix_drive
= NULL
;
1109 char *install_drive
= NULL
;
1113 if (install_device
[0] == '('
1114 && install_device
[grub_strlen (install_device
) - 1] == ')')
1116 size_t len
= grub_strlen (install_device
) - 2;
1117 install_drive
= xmalloc (len
+ 1);
1118 memcpy (install_drive
, install_device
+ 1, len
);
1119 install_drive
[len
] = '\0';
1123 grub_util_pull_device (install_device
);
1124 install_drive
= grub_util_get_grub_dev (install_device
);
1126 grub_util_error (_("cannot find a GRUB drive for %s. Check your device.map"),
1131 if (!have_abstractions
)
1133 if ((disk_module
&& grub_strcmp (disk_module
, "biosdisk") != 0)
1136 && platform
!= GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
)
1137 || (install_drive
&& !is_same_disk (grub_drives
[0], install_drive
))
1138 || !have_bootdev (platform
))
1141 /* generic method (used on coreboot and ata mod). */
1142 if (!force_file_id
&& grub_fs
->uuid
&& grub_fs
->uuid (grub_dev
,
1145 grub_print_error ();
1151 load_cfg_f
= grub_util_fopen (load_cfg
, "wb");
1155 fprintf (load_cfg_f
, "search.fs_uuid %s root ",
1157 grub_install_push_module ("search_fs_uuid");
1161 char *rndstr
= get_rndstr ();
1162 char *fl
= grub_util_path_concat (3, grubdir
,
1164 char *fldir
= grub_util_path_concat (2, grubdir
,
1168 grub_install_mkdir_p (fldir
);
1169 flf
= grub_util_fopen (fl
, "w");
1171 grub_util_error ("Can't create file: %s", strerror (errno
));
1173 relfl
= grub_make_system_path_relative_to_its_root (fl
);
1174 fprintf (load_cfg_f
, "search.file %s root ",
1176 grub_install_push_module ("search_fs_file");
1178 for (curdev
= grub_devices
, curdrive
= grub_drives
; *curdev
; curdev
++,
1184 if (curdrive
== grub_drives
)
1187 dev
= grub_device_open (*curdrive
);
1191 if (dev
->disk
->dev
->id
!= GRUB_DISK_DEVICE_HOSTDISK_ID
)
1193 grub_util_fprint_full_disk_name (load_cfg_f
,
1196 fprintf (load_cfg_f
, " ");
1197 if (dev
!= grub_dev
)
1198 grub_device_close (dev
);
1202 map
= grub_util_biosdisk_get_compatibility_hint (dev
->disk
);
1206 grub_util_fprint_full_disk_name (load_cfg_f
, map
, dev
);
1207 fprintf (load_cfg_f
, " ");
1211 if (disk_module
&& disk_module
[0]
1212 && grub_strcmp (disk_module
, "biosdisk") != 0)
1213 g
= grub_util_guess_baremetal_drive (*curdev
);
1217 case GRUB_INSTALL_PLATFORM_I386_PC
:
1218 g
= grub_util_guess_bios_drive (*curdev
);
1220 case GRUB_INSTALL_PLATFORM_I386_EFI
:
1221 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
1222 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
1223 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
1224 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
1225 g
= grub_util_guess_efi_drive (*curdev
);
1227 case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275
:
1228 case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
:
1229 case GRUB_INSTALL_PLATFORM_I386_IEEE1275
:
1231 const char * ofpath
= grub_util_devname_to_ofpath (*curdev
);
1232 g
= xasprintf ("ieee1275/%s", ofpath
);
1235 case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON
:
1236 case GRUB_INSTALL_PLATFORM_I386_QEMU
:
1237 case GRUB_INSTALL_PLATFORM_I386_COREBOOT
:
1238 case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT
:
1239 case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS
:
1240 case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS
:
1241 g
= grub_util_guess_baremetal_drive (*curdev
);
1243 case GRUB_INSTALL_PLATFORM_MIPS_ARC
:
1244 case GRUB_INSTALL_PLATFORM_MIPSEL_ARC
:
1245 case GRUB_INSTALL_PLATFORM_ARM_UBOOT
:
1246 case GRUB_INSTALL_PLATFORM_I386_XEN
:
1247 case GRUB_INSTALL_PLATFORM_X86_64_XEN
:
1248 grub_util_warn ("%s", _("no hints available for your platform. Expect reduced performance"));
1250 /* pacify warning. */
1251 case GRUB_INSTALL_PLATFORM_MAX
:
1256 grub_util_fprint_full_disk_name (load_cfg_f
, g
, dev
);
1257 fprintf (load_cfg_f
, " ");
1259 if (dev
!= grub_dev
)
1260 grub_device_close (dev
);
1262 fprintf (load_cfg_f
, "\n");
1263 char *escaped_relpath
= escape (relative_grubdir
);
1264 fprintf (load_cfg_f
, "set prefix=($root)'%s'\n",
1269 /* We need to hardcode the partition number in the core image's prefix. */
1271 for (p
= grub_drives
[0]; *p
; )
1273 if (*p
== '\\' && p
[1])
1278 if (*p
== ',' || *p
== '\0')
1282 prefix_drive
= xasprintf ("(%s)", p
);
1287 if (config
.is_cryptodisk_enabled
)
1290 probe_cryptodisk_uuid (grub_dev
->disk
);
1292 for (curdrive
= grub_drives
+ 1; *curdrive
; curdrive
++)
1294 grub_device_t dev
= grub_device_open (*curdrive
);
1298 probe_cryptodisk_uuid (dev
->disk
);
1299 grub_device_close (dev
);
1302 prefix_drive
= xasprintf ("(%s)", grub_drives
[0]);
1305 char mkimage_target
[200];
1306 const char *core_name
= NULL
;
1310 case GRUB_INSTALL_PLATFORM_I386_EFI
:
1311 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
1312 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
1313 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
1314 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
1315 core_name
= "core.efi";
1316 snprintf (mkimage_target
, sizeof (mkimage_target
),
1318 grub_install_get_platform_cpu (platform
),
1319 grub_install_get_platform_platform (platform
));
1321 case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON
:
1322 case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS
:
1323 case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS
:
1324 core_name
= "core.elf";
1325 snprintf (mkimage_target
, sizeof (mkimage_target
),
1327 grub_install_get_platform_cpu (platform
),
1328 grub_install_get_platform_platform (platform
));
1331 case GRUB_INSTALL_PLATFORM_I386_COREBOOT
:
1332 case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT
:
1333 case GRUB_INSTALL_PLATFORM_I386_IEEE1275
:
1334 case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
:
1335 case GRUB_INSTALL_PLATFORM_I386_XEN
:
1336 case GRUB_INSTALL_PLATFORM_X86_64_XEN
:
1337 core_name
= "core.elf";
1338 snprintf (mkimage_target
, sizeof (mkimage_target
),
1340 grub_install_get_platform_cpu (platform
),
1341 grub_install_get_platform_platform (platform
));
1345 case GRUB_INSTALL_PLATFORM_I386_PC
:
1346 case GRUB_INSTALL_PLATFORM_MIPSEL_ARC
:
1347 case GRUB_INSTALL_PLATFORM_MIPS_ARC
:
1348 case GRUB_INSTALL_PLATFORM_ARM_UBOOT
:
1349 case GRUB_INSTALL_PLATFORM_I386_QEMU
:
1350 snprintf (mkimage_target
, sizeof (mkimage_target
),
1352 grub_install_get_platform_cpu (platform
),
1353 grub_install_get_platform_platform (platform
));
1354 core_name
= "core.img";
1356 case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275
:
1357 strcpy (mkimage_target
, "sparc64-ieee1275-raw");
1358 core_name
= "core.img";
1360 /* pacify warning. */
1361 case GRUB_INSTALL_PLATFORM_MAX
:
1366 grub_util_error ("%s", _("You've found a bug"));
1369 fclose (load_cfg_f
);
1371 char *imgfile
= grub_util_path_concat (2, platdir
,
1373 char *prefix
= xasprintf ("%s%s", prefix_drive
? : "",
1375 grub_install_make_image_wrap (/* source dir */ grub_install_source_directory
,
1377 /* output */ imgfile
,
1379 have_load_cfg
? load_cfg
: NULL
,
1380 /* image target */ mkimage_target
, 0);
1381 /* Backward-compatibility kludges. */
1384 case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON
:
1386 char *dst
= grub_util_path_concat (2, bootdir
, "grub.elf");
1387 grub_install_copy_file (imgfile
, dst
, 1);
1392 case GRUB_INSTALL_PLATFORM_I386_IEEE1275
:
1393 case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
:
1395 char *dst
= grub_util_path_concat (2, grubdir
, "grub");
1396 grub_install_copy_file (imgfile
, dst
, 1);
1401 case GRUB_INSTALL_PLATFORM_I386_EFI
:
1402 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
1404 char *dst
= grub_util_path_concat (2, platdir
, "grub.efi");
1405 grub_install_make_image_wrap (/* source dir */ grub_install_source_directory
,
1409 have_load_cfg
? load_cfg
: NULL
,
1410 /* image target */ mkimage_target
, 0);
1413 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
1414 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
1415 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
1416 case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS
:
1417 case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS
:
1418 case GRUB_INSTALL_PLATFORM_I386_COREBOOT
:
1419 case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT
:
1420 case GRUB_INSTALL_PLATFORM_I386_PC
:
1421 case GRUB_INSTALL_PLATFORM_MIPSEL_ARC
:
1422 case GRUB_INSTALL_PLATFORM_MIPS_ARC
:
1423 case GRUB_INSTALL_PLATFORM_ARM_UBOOT
:
1424 case GRUB_INSTALL_PLATFORM_I386_QEMU
:
1425 case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275
:
1426 case GRUB_INSTALL_PLATFORM_I386_XEN
:
1427 case GRUB_INSTALL_PLATFORM_X86_64_XEN
:
1429 /* pacify warning. */
1430 case GRUB_INSTALL_PLATFORM_MAX
:
1434 /* Perform the platform-dependent install */
1438 case GRUB_INSTALL_PLATFORM_I386_PC
:
1440 char *boot_img_src
= grub_util_path_concat (2,
1441 grub_install_source_directory
,
1443 char *boot_img
= grub_util_path_concat (2, platdir
,
1445 grub_install_copy_file (boot_img_src
, boot_img
, 1);
1447 grub_util_info ("%sgrub-bios-setup %s %s %s %s %s --directory='%s' --device-map='%s' '%s'",
1448 install_bootsector
? "" : "NOT RUNNING: ",
1449 allow_floppy
? "--allow-floppy " : "",
1450 verbosity
? "--verbose " : "",
1451 force
? "--force " : "",
1452 !fs_probe
? "--skip-fs-probe" : "",
1453 !add_rs_codes
? "--no-rs-codes" : "",
1458 /* Now perform the installation. */
1459 if (install_bootsector
)
1460 grub_util_bios_setup (platdir
, "boot.img", "core.img",
1461 install_drive
, force
,
1462 fs_probe
, allow_floppy
, add_rs_codes
);
1465 case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275
:
1467 char *boot_img_src
= grub_util_path_concat (2,
1468 grub_install_source_directory
,
1470 char *boot_img
= grub_util_path_concat (2, platdir
,
1472 grub_install_copy_file (boot_img_src
, boot_img
, 1);
1474 grub_util_info ("%sgrub-sparc64-setup %s %s %s %s --directory='%s' --device-map='%s' '%s'",
1475 install_bootsector
? "" : "NOT RUNNING: ",
1476 allow_floppy
? "--allow-floppy " : "",
1477 verbosity
? "--verbose " : "",
1478 force
? "--force " : "",
1479 !fs_probe
? "--skip-fs-probe" : "",
1484 /* Now perform the installation. */
1485 if (install_bootsector
)
1486 grub_util_sparc_setup (platdir
, "boot.img", "core.img",
1487 install_device
, force
,
1488 fs_probe
, allow_floppy
,
1493 case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
:
1494 /* If a install device is defined, copy the core.elf to PReP partition. */
1495 if (install_device
&& install_device
[0])
1497 grub_device_t ins_dev
;
1498 ins_dev
= grub_device_open (install_drive
);
1499 if (!ins_dev
|| !is_prep_partition (ins_dev
))
1501 grub_util_error ("%s", _("the chosen partition is not a PReP partition"));
1503 if (is_prep_empty (ins_dev
))
1505 if (write_to_disk (ins_dev
, imgfile
))
1506 grub_util_error ("%s", _("failed to copy Grub to the PReP partition"));
1510 char *s
= xasprintf ("dd if=/dev/zero of=%s", install_device
);
1511 grub_util_error ("the PReP partition is not empty. If you are sure you want to use it, run dd to clear it: `%s'",
1514 grub_device_close (ins_dev
);
1517 case GRUB_INSTALL_PLATFORM_I386_IEEE1275
:
1520 if (platform
!= GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
1522 || install_device
[0] == '\0')
1527 relpath
= grub_make_system_path_relative_to_its_root (imgfile
);
1528 partno
= grub_dev
->disk
->partition
1529 ? grub_dev
->disk
->partition
->number
+ 1 : 0;
1530 dev
= grub_util_get_os_disk (grub_devices
[0]);
1531 grub_install_register_ieee1275 (0, dev
,
1535 grub_install_register_ieee1275 (1, grub_util_get_os_disk (install_device
),
1539 case GRUB_INSTALL_PLATFORM_MIPS_ARC
:
1540 grub_install_sgi_setup (install_device
, imgfile
, "grub");
1543 case GRUB_INSTALL_PLATFORM_I386_EFI
:
1545 char *dst
= grub_util_path_concat (2, efidir
, "grub.efi");
1546 /* For old macs. Suggested by Peter Jones. */
1547 grub_install_copy_file (imgfile
, dst
, 1);
1551 case GRUB_INSTALL_PLATFORM_X86_64_EFI
:
1552 case GRUB_INSTALL_PLATFORM_ARM_EFI
:
1553 case GRUB_INSTALL_PLATFORM_ARM64_EFI
:
1554 case GRUB_INSTALL_PLATFORM_IA64_EFI
:
1556 char *dst
= grub_util_path_concat (2, efidir
, efi_file
);
1557 grub_install_copy_file (imgfile
, dst
, 1);
1560 if (!removable
&& update_nvram
)
1564 char * efifile_path
;
1566 /* Try to make this image bootable using the EFI Boot Manager, if available. */
1567 if (!efi_distributor
|| efi_distributor
[0] == '\0')
1568 grub_util_error ("%s", "EFI distributor id isn't specified.");
1569 efidir_disk
= grub_util_get_os_disk (efidir_device_names
[0]);
1570 efidir_part
= efidir_grub_dev
->disk
->partition
? efidir_grub_dev
->disk
->partition
->number
+ 1 : 1;
1571 efifile_path
= xasprintf ("\\EFI\\%s\\%s",
1574 grub_install_register_efi (efidir_disk
, efidir_part
,
1575 efifile_path
, efi_distributor
);
1579 case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON
:
1580 case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS
:
1581 case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS
:
1582 case GRUB_INSTALL_PLATFORM_I386_COREBOOT
:
1583 case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT
:
1584 case GRUB_INSTALL_PLATFORM_MIPSEL_ARC
:
1585 case GRUB_INSTALL_PLATFORM_ARM_UBOOT
:
1586 case GRUB_INSTALL_PLATFORM_I386_QEMU
:
1587 case GRUB_INSTALL_PLATFORM_I386_XEN
:
1588 case GRUB_INSTALL_PLATFORM_X86_64_XEN
:
1589 grub_util_warn ("%s",
1590 _("WARNING: no platform-specific install was performed"));
1592 /* pacify warning. */
1593 case GRUB_INSTALL_PLATFORM_MAX
:
1597 fprintf (stderr
, "%s\n", _("Installation finished. No error reported."));
1599 /* Free resources. */
1600 grub_gcry_fini_all ();