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