summaryrefslogtreecommitdiffstats
path: root/meta/classes/grub-efi-cfg.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-cfg.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-cfg.bbclass')
-rw-r--r--meta/classes/grub-efi-cfg.bbclass119
1 files changed, 119 insertions, 0 deletions
diff --git a/meta/classes/grub-efi-cfg.bbclass b/meta/classes/grub-efi-cfg.bbclass
new file mode 100644
index 0000000000..730323c72e
--- /dev/null
+++ b/meta/classes/grub-efi-cfg.bbclass
@@ -0,0 +1,119 @@
1# grub-efi.bbclass
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
19GRUB_SERIAL ?= "console=ttyS0,115200"
20GRUB_CFG_VM = "${S}/grub_vm.cfg"
21GRUB_CFG_LIVE = "${S}/grub_live.cfg"
22GRUB_TIMEOUT ?= "10"
23#FIXME: build this from the machine config
24GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
25
26EFIDIR = "/EFI/BOOT"
27GRUB_ROOT ?= "${ROOT}"
28APPEND ?= ""
29
30# Need UUID utility code.
31inherit fs-uuid
32
33python build_efi_cfg() {
34 import sys
35
36 workdir = d.getVar('WORKDIR')
37 if not workdir:
38 bb.error("WORKDIR not defined, unable to package")
39 return
40
41 gfxserial = d.getVar('GRUB_GFXSERIAL') or ""
42
43 labels = d.getVar('LABELS')
44 if not labels:
45 bb.debug(1, "LABELS not defined, nothing to do")
46 return
47
48 if labels == []:
49 bb.debug(1, "No labels, nothing to do")
50 return
51
52 cfile = d.getVar('GRUB_CFG')
53 if not cfile:
54 bb.fatal('Unable to read GRUB_CFG')
55
56 try:
57 cfgfile = open(cfile, 'w')
58 except OSError:
59 bb.fatal('Unable to open %s' % cfile)
60
61 cfgfile.write('# Automatically created by OE\n')
62
63 opts = d.getVar('GRUB_OPTS')
64 if opts:
65 for opt in opts.split(';'):
66 cfgfile.write('%s\n' % opt)
67
68 cfgfile.write('default=%s\n' % (labels.split()[0]))
69
70 timeout = d.getVar('GRUB_TIMEOUT')
71 if timeout:
72 cfgfile.write('timeout=%s\n' % timeout)
73 else:
74 cfgfile.write('timeout=50\n')
75
76 root = d.getVar('GRUB_ROOT')
77 if not root:
78 bb.fatal('GRUB_ROOT not defined')
79
80 if gfxserial == "1":
81 btypes = [ [ " graphics console", "" ],
82 [ " serial console", d.getVar('GRUB_SERIAL') or "" ] ]
83 else:
84 btypes = [ [ "", "" ] ]
85
86 for label in labels.split():
87 localdata = d.createCopy()
88
89 overrides = localdata.getVar('OVERRIDES')
90 if not overrides:
91 bb.fatal('OVERRIDES not defined')
92
93 for btype in btypes:
94 localdata.setVar('OVERRIDES', label + ':' + overrides)
95
96 cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
97 lb = label
98 if label == "install":
99 lb = "install-efi"
100 cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
101
102 cfgfile.write(' %s' % replace_rootfs_uuid(d, root))
103
104 append = localdata.getVar('APPEND')
105 initrd = localdata.getVar('INITRD')
106
107 if append:
108 append = replace_rootfs_uuid(d, append)
109 cfgfile.write(' %s' % (append))
110
111 cfgfile.write(' %s' % btype[1])
112 cfgfile.write('\n')
113
114 if initrd:
115 cfgfile.write('initrd /initrd')
116 cfgfile.write('\n}\n')
117
118 cfgfile.close()
119}