summaryrefslogtreecommitdiffstats
path: root/meta/classes/grub-efi.bbclass
diff options
context:
space:
mode:
authorCalifornia Sullivan <california.l.sullivan@intel.com>2018-02-28 18:14:58 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-03-06 06:35:42 -0800
commita9921f64a7183e1c09e674a768fdcc2f52778ac3 (patch)
treed4d0344a835b9fe5609332c1bac99470a29d3754 /meta/classes/grub-efi.bbclass
parent00ab4a3a54fcaa714ae4968389c6bddb75e7166e (diff)
downloadpoky-a9921f64a7183e1c09e674a768fdcc2f52778ac3.tar.gz
grub-efi.bbclass: split out configuration portion
This part is useful on its own, whereas the whole class together is specific for image-live. (From OE-Core rev: 8daf2c544eb40d97d99a41627ddc5529c0e23f3c) Signed-off-by: California Sullivan <california.l.sullivan@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/grub-efi.bbclass')
-rw-r--r--meta/classes/grub-efi.bbclass122
1 files changed, 1 insertions, 121 deletions
diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
index 610479b85d..4b5704c19c 100644
--- a/meta/classes/grub-efi.bbclass
+++ b/meta/classes/grub-efi.bbclass
@@ -1,36 +1,4 @@
1# grub-efi.bbclass 1inherit grub-efi-cfg
2# Copyright (c) 2011, Intel Corporation.
3# All rights reserved.
4#
5# Released under the MIT license (see packages/COPYING)
6
7# Provide grub-efi specific functions for building bootable images.
8
9# External variables
10# ${INITRD} - indicates a list of filesystem images to concatenate and use as an initrd (optional)
11# ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
12# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
13# ${LABELS} - a list of targets for the automatic config
14# ${APPEND} - an override list of append strings for each label
15# ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
16# ${GRUB_TIMEOUT} - timeout before executing the deault label (optional)
17# ${GRUB_ROOT} - grub's root device.
18
19do_bootimg[depends] += "${MLPREFIX}grub-efi:do_deploy"
20
21GRUB_SERIAL ?= "console=ttyS0,115200"
22GRUB_CFG_VM = "${S}/grub_vm.cfg"
23GRUB_CFG_LIVE = "${S}/grub_live.cfg"
24GRUB_TIMEOUT ?= "10"
25#FIXME: build this from the machine config
26GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
27
28EFIDIR = "/EFI/BOOT"
29GRUB_ROOT ?= "${ROOT}"
30APPEND ?= ""
31
32# Need UUID utility code.
33inherit fs-uuid
34 2
35efi_populate() { 3efi_populate() {
36 # DEST must be the root of the image so that EFIDIR is not 4 # DEST must be the root of the image so that EFIDIR is not
@@ -69,91 +37,3 @@ efi_iso_populate() {
69efi_hddimg_populate() { 37efi_hddimg_populate() {
70 efi_populate $1 38 efi_populate $1
71} 39}
72
73python build_efi_cfg() {
74 import sys
75
76 workdir = d.getVar('WORKDIR')
77 if not workdir:
78 bb.error("WORKDIR not defined, unable to package")
79 return
80
81 gfxserial = d.getVar('GRUB_GFXSERIAL') or ""
82
83 labels = d.getVar('LABELS')
84 if not labels:
85 bb.debug(1, "LABELS not defined, nothing to do")
86 return
87
88 if labels == []:
89 bb.debug(1, "No labels, nothing to do")
90 return
91
92 cfile = d.getVar('GRUB_CFG')
93 if not cfile:
94 bb.fatal('Unable to read GRUB_CFG')
95
96 try:
97 cfgfile = open(cfile, 'w')
98 except OSError:
99 bb.fatal('Unable to open %s' % cfile)
100
101 cfgfile.write('# Automatically created by OE\n')
102
103 opts = d.getVar('GRUB_OPTS')
104 if opts:
105 for opt in opts.split(';'):
106 cfgfile.write('%s\n' % opt)
107
108 cfgfile.write('default=%s\n' % (labels.split()[0]))
109
110 timeout = d.getVar('GRUB_TIMEOUT')
111 if timeout:
112 cfgfile.write('timeout=%s\n' % timeout)
113 else:
114 cfgfile.write('timeout=50\n')
115
116 root = d.getVar('GRUB_ROOT')
117 if not root:
118 bb.fatal('GRUB_ROOT not defined')
119
120 if gfxserial == "1":
121 btypes = [ [ " graphics console", "" ],
122 [ " serial console", d.getVar('GRUB_SERIAL') or "" ] ]
123 else:
124 btypes = [ [ "", "" ] ]
125
126 for label in labels.split():
127 localdata = d.createCopy()
128
129 overrides = localdata.getVar('OVERRIDES')
130 if not overrides:
131 bb.fatal('OVERRIDES not defined')
132
133 for btype in btypes:
134 localdata.setVar('OVERRIDES', label + ':' + overrides)
135
136 cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
137 lb = label
138 if label == "install":
139 lb = "install-efi"
140 cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
141
142 cfgfile.write(' %s' % replace_rootfs_uuid(d, root))
143
144 append = localdata.getVar('APPEND')
145 initrd = localdata.getVar('INITRD')
146
147 if append:
148 append = replace_rootfs_uuid(d, append)
149 cfgfile.write(' %s' % (append))
150
151 cfgfile.write(' %s' % btype[1])
152 cfgfile.write('\n')
153
154 if initrd:
155 cfgfile.write('initrd /initrd')
156 cfgfile.write('\n}\n')
157
158 cfgfile.close()
159}