source: mainline/boot/grub/meson.build

Last change on this file was 145a13b, checked in by Petr Pavlu <setup@…>, 5 years ago

Fix generating a boot image for grub-efi with mkisofs

A boot ISO image for grub-efi is currently generated using the
genisoimage-specific option '—efi-boot <grub_image>'. This is accepted
by genisoimage and 'xorriso -as genisoimage' but not by mkisofs:

/usr/bin/mkisofs -J -r -input-charset utf-8 -V HelenOS-CD —efi-boot boot/grub/efi.img -o boot/grub/image.iso boot/grub/grub_dist
Bad Option '—efi-boot' (error -1 BADFLAG).

When mkisofs is selected during the configure time, run the build
command with the equivalent options '-eltorito-platform efi
-eltorito-boot <grub_image> -no-emul-boot'.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1#
2# Copyright (c) 2019 Jiří Zárevúcky
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29if GRUB_ARCH == 'pc'
30 MULTIBOOT_CMD = 'multiboot'
31 MODULE_CMD = 'module'
32 INSMODS = [ 'insmod vbe', 'insmod vga' ]
33elif GRUB_ARCH == 'efi'
34 MULTIBOOT_CMD = 'multiboot2'
35 MODULE_CMD = 'module2'
36 INSMODS = [ 'insmod efi_gop', 'insmod efi_uga' ]
37endif
38
39# TODO
40install_snippet = 'mkdir -p ${DIST_DIR}/`dirname @1@`; cp @0@ ${DIST_DIR}/@1@'
41dist_dirname = 'grub_dist'
42
43if GRUB_LOADER == 'multiboot'
44 build_dist_text = []
45 build_dist_deps = []
46 foreach init : rd_init_binaries
47 target = 'boot/' + run_command(basename, init[1], check: true).stdout().strip()
48
49 build_dist_text += install_snippet.format(init[0].full_path(), target)
50 build_dist_deps += init[0]
51 endforeach
52
53 LOADS = [ 'echo \'Loading kernel\'' ]
54 LOADS += [ MULTIBOOT_CMD + ' /boot/kernel.elf' ]
55
56 MODULES = rd_init + [ 'boot/initrd.img' ]
57
58 foreach module : MODULES
59 module = '/boot/' + run_command(basename, module, check: true).stdout().strip()
60 LOADS += 'echo \'Loading @0@\''.format(module)
61 LOADS += '@0@ @1@ @1@'.format(MODULE_CMD, module)
62 endforeach
63endif
64
65if GRUB_LOADER == 'chainloader'
66 # init binaries are already part of the chainloaded boot image.
67 build_dist_text = [ install_snippet.format(boot_image.full_path(), 'boot/' + boot_image_name) ]
68 build_dist_deps = [ boot_image ]
69
70 LOADS = [
71 'echo \'Loading ' + boot_image_name + '\'',
72 'chainloader /boot/' + boot_image_name,
73 'boot',
74 ]
75endif
76
77build_dist_sh = configure_file(
78 input: 'build_dist.sh.in',
79 output: 'build_dist.sh',
80 configuration: { 'text' : '\n'.join(build_dist_text) },
81)
82
83
84grub_cfg = configure_file(
85 input: 'grub.cfg.in',
86 output: 'grub.cfg',
87 configuration: {
88 'INSMODS' : '\n'.join(INSMODS),
89 'RELEASE' : HELENOS_RELEASE,
90 'LOADS' : '\n'.join(LOADS),
91 },
92)
93
94grub_dir = meson.current_source_dir() / BARCH + '-' + GRUB_ARCH
95
96dist_dir = custom_target(dist_dirname,
97 output: dist_dirname,
98 input: [ build_dist_sh, grub_cfg, build_dist_deps ],
99 command: [ sh, '@INPUT0@', '@OUTPUT@', grub_dir, '@INPUT1@' ],
100)
101
102
103# Create .iso image.
104
105grub_image = 'boot/grub' / GRUB_ARCH + '.img'
106
107if GRUB_ARCH == 'pc'
108 genisoimage_args = [ '-eltorito-boot', grub_image, '-no-emul-boot', '-boot-info-table' ]
109elif GRUB_ARCH == 'efi'
110 if genisoimage_type == 'mkisofs'
111 genisoimage_args = [ '-eltorito-platform', 'efi', '-eltorito-boot', grub_image, '-no-emul-boot' ]
112 else
113 genisoimage_args = [ '--efi-boot', grub_image ]
114 endif
115endif
116
117image_iso = custom_target('image.iso',
118 output: 'image.iso',
119 input: dist_dir,
120 command: [
121 genisoimage,
122 '-J',
123 '-r',
124 '-input-charset', 'utf-8',
125 '-V', 'HelenOS-CD',
126 genisoimage_args,
127 '-o', '@OUTPUT@',
128 '@INPUT@',
129 ],
130)
131
132POST_INPUT = image_iso
Note: See TracBrowser for help on using the repository browser.