install.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2013 Free Software Foundation, Inc.
  4. *
  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.
  9. *
  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.
  14. *
  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/>.
  17. */
  18. #ifndef GRUB_UTIL_INSTALL_HEADER
  19. #define GRUB_UTIL_INSTALL_HEADER 1
  20. #include <sys/types.h>
  21. #include <stdio.h>
  22. #include <grub/device.h>
  23. #include <grub/disk.h>
  24. #include <grub/emu/hostfile.h>
  25. #define GRUB_INSTALL_OPTIONS \
  26. { "modules", GRUB_INSTALL_OPTIONS_MODULES, N_("MODULES"), \
  27. 0, N_("pre-load specified modules MODULES"), 1 }, \
  28. { "dtb", GRUB_INSTALL_OPTIONS_DTB, N_("FILE"), \
  29. 0, N_("embed a specific DTB"), 1 }, \
  30. { "install-modules", GRUB_INSTALL_OPTIONS_INSTALL_MODULES, \
  31. N_("MODULES"), 0, \
  32. N_("install only MODULES and their dependencies [default=all]"), 1 }, \
  33. { "themes", GRUB_INSTALL_OPTIONS_INSTALL_THEMES, N_("THEMES"), \
  34. 0, N_("install THEMES [default=%s]"), 1 }, \
  35. { "fonts", GRUB_INSTALL_OPTIONS_INSTALL_FONTS, N_("FONTS"), \
  36. 0, N_("install FONTS [default=%s]"), 1 }, \
  37. { "locales", GRUB_INSTALL_OPTIONS_INSTALL_LOCALES, N_("LOCALES"),\
  38. 0, N_("install only LOCALES [default=all]"), 1 }, \
  39. { "compress", GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, \
  40. "no|xz|gz|lzo", 0, \
  41. N_("compress GRUB files [optional]"), 1 }, \
  42. {"core-compress", GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, \
  43. "xz|none|auto", \
  44. 0, N_("choose the compression to use for core image"), 2}, \
  45. /* TRANSLATORS: platform here isn't identifier. It can be translated. */ \
  46. { "directory", 'd', N_("DIR"), 0, \
  47. N_("use images and modules under DIR [default=%s/<platform>]"), 1 }, \
  48. { "override-directory", GRUB_INSTALL_OPTIONS_DIRECTORY2, \
  49. N_("DIR"), OPTION_HIDDEN, \
  50. N_("use images and modules under DIR [default=%s/<platform>]"), 1 }, \
  51. { "locale-directory", GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, \
  52. N_("DIR"), 0, \
  53. N_("use translations under DIR [default=%s]"), 1 }, \
  54. { "themes-directory", GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY, \
  55. N_("DIR"), OPTION_HIDDEN, \
  56. N_("use themes under DIR [default=%s]"), 1 }, \
  57. { "grub-mkimage", GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, \
  58. "FILE", OPTION_HIDDEN, 0, 1 }, \
  59. /* TRANSLATORS: "embed" is a verb (command description). "*/ \
  60. { "pubkey", 'k', N_("FILE"), 0, \
  61. N_("embed FILE as public key for signature checking"), 0}, \
  62. { "verbose", 'v', 0, 0, \
  63. N_("print verbose messages."), 1 }
  64. int
  65. grub_install_parse (int key, char *arg);
  66. void
  67. grub_install_push_module (const char *val);
  68. void
  69. grub_install_pop_module (void);
  70. char *
  71. grub_install_help_filter (int key, const char *text,
  72. void *input __attribute__ ((unused)));
  73. enum grub_install_plat
  74. {
  75. GRUB_INSTALL_PLATFORM_I386_PC,
  76. GRUB_INSTALL_PLATFORM_I386_EFI,
  77. GRUB_INSTALL_PLATFORM_I386_QEMU,
  78. GRUB_INSTALL_PLATFORM_I386_COREBOOT,
  79. GRUB_INSTALL_PLATFORM_I386_MULTIBOOT,
  80. GRUB_INSTALL_PLATFORM_I386_IEEE1275,
  81. GRUB_INSTALL_PLATFORM_X86_64_EFI,
  82. GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON,
  83. GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275,
  84. GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275,
  85. GRUB_INSTALL_PLATFORM_MIPSEL_ARC,
  86. GRUB_INSTALL_PLATFORM_MIPS_ARC,
  87. GRUB_INSTALL_PLATFORM_IA64_EFI,
  88. GRUB_INSTALL_PLATFORM_ARM_UBOOT,
  89. GRUB_INSTALL_PLATFORM_ARM_EFI,
  90. GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS,
  91. GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS,
  92. GRUB_INSTALL_PLATFORM_I386_XEN,
  93. GRUB_INSTALL_PLATFORM_X86_64_XEN,
  94. GRUB_INSTALL_PLATFORM_ARM64_EFI,
  95. GRUB_INSTALL_PLATFORM_ARM_COREBOOT,
  96. GRUB_INSTALL_PLATFORM_MAX
  97. };
  98. enum grub_install_options {
  99. GRUB_INSTALL_OPTIONS_DIRECTORY = 'd',
  100. GRUB_INSTALL_OPTIONS_VERBOSITY = 'v',
  101. GRUB_INSTALL_OPTIONS_MODULES = 0x201,
  102. GRUB_INSTALL_OPTIONS_INSTALL_MODULES,
  103. GRUB_INSTALL_OPTIONS_INSTALL_THEMES,
  104. GRUB_INSTALL_OPTIONS_INSTALL_FONTS,
  105. GRUB_INSTALL_OPTIONS_INSTALL_LOCALES,
  106. GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS,
  107. GRUB_INSTALL_OPTIONS_DIRECTORY2,
  108. GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY,
  109. GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY,
  110. GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE,
  111. GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS,
  112. GRUB_INSTALL_OPTIONS_DTB
  113. };
  114. extern char *grub_install_source_directory;
  115. enum grub_install_plat
  116. grub_install_get_target (const char *src);
  117. void
  118. grub_install_mkdir_p (const char *dst);
  119. void
  120. grub_install_copy_files (const char *src,
  121. const char *dst,
  122. enum grub_install_plat platid);
  123. char *
  124. grub_install_get_platform_name (enum grub_install_plat platid);
  125. const char *
  126. grub_install_get_platform_cpu (enum grub_install_plat platid);
  127. const char *
  128. grub_install_get_platform_platform (enum grub_install_plat platid);
  129. char *
  130. grub_install_get_platforms_string (void);
  131. typedef enum {
  132. GRUB_COMPRESSION_AUTO,
  133. GRUB_COMPRESSION_NONE,
  134. GRUB_COMPRESSION_XZ,
  135. GRUB_COMPRESSION_LZMA
  136. } grub_compression_t;
  137. void
  138. grub_install_make_image_wrap (const char *dir, const char *prefix,
  139. const char *outname, char *memdisk_path,
  140. char *config_path,
  141. const char *format, int note);
  142. void
  143. grub_install_make_image_wrap_file (const char *dir, const char *prefix,
  144. FILE *fp, const char *outname,
  145. char *memdisk_path,
  146. char *config_path,
  147. const char *mkimage_target, int note);
  148. int
  149. grub_install_copy_file (const char *src,
  150. const char *dst,
  151. int is_critical);
  152. struct grub_install_image_target_desc;
  153. void
  154. grub_install_generate_image (const char *dir, const char *prefix,
  155. FILE *out,
  156. const char *outname, char *mods[],
  157. char *memdisk_path, char **pubkey_paths,
  158. size_t npubkeys,
  159. char *config_path,
  160. const struct grub_install_image_target_desc *image_target,
  161. int note,
  162. grub_compression_t comp, const char *dtb_file);
  163. const struct grub_install_image_target_desc *
  164. grub_install_get_image_target (const char *arg);
  165. void
  166. grub_util_bios_setup (const char *dir,
  167. const char *boot_file, const char *core_file,
  168. const char *dest, int force,
  169. int fs_probe, int allow_floppy,
  170. int add_rs_codes);
  171. void
  172. grub_util_sparc_setup (const char *dir,
  173. const char *boot_file, const char *core_file,
  174. const char *dest, int force,
  175. int fs_probe, int allow_floppy,
  176. int add_rs_codes);
  177. char *
  178. grub_install_get_image_targets_string (void);
  179. const char *
  180. grub_util_get_target_dirname (const struct grub_install_image_target_desc *t);
  181. void
  182. grub_install_create_envblk_file (const char *name);
  183. const char *
  184. grub_install_get_default_x86_platform (void);
  185. void
  186. grub_install_register_efi (grub_device_t efidir_grub_dev,
  187. const char *efifile_path,
  188. const char *efi_distributor);
  189. void
  190. grub_install_register_ieee1275 (int is_prep, const char *install_device,
  191. int partno, const char *relpath);
  192. void
  193. grub_install_sgi_setup (const char *install_device,
  194. const char *imgfile, const char *destname);
  195. int
  196. grub_install_compress_gzip (const char *src, const char *dest);
  197. int
  198. grub_install_compress_lzop (const char *src, const char *dest);
  199. int
  200. grub_install_compress_xz (const char *src, const char *dest);
  201. void
  202. grub_install_get_blocklist (grub_device_t root_dev,
  203. const char *core_path, const char *core_img,
  204. size_t core_size,
  205. void (*callback) (grub_disk_addr_t sector,
  206. unsigned offset,
  207. unsigned length,
  208. void *data),
  209. void *hook_data);
  210. void
  211. grub_util_create_envblk_file (const char *name);
  212. void
  213. grub_util_glue_efi (const char *file32, const char *file64, const char *out);
  214. void
  215. grub_util_render_label (const char *label_font,
  216. const char *label_bgcolor,
  217. const char *label_color,
  218. const char *label_string,
  219. const char *label);
  220. const char *
  221. grub_util_get_target_name (const struct grub_install_image_target_desc *t);
  222. extern char *grub_install_copy_buffer;
  223. #define GRUB_INSTALL_COPY_BUFFER_SIZE 1048576
  224. #endif