summaryrefslogtreecommitdiffstats
path: root/meta/classes/systemd-boot-cfg.bbclass
diff options
context:
space:
mode:
authorCalifornia Sullivan <california.l.sullivan@intel.com>2018-02-28 18:15:08 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-03-06 06:35:42 -0800
commitdbe0736341abf008e45558abc65b275a83fc9db9 (patch)
treed869d058845d4c5a17e0381637cd0c92e9fd07d7 /meta/classes/systemd-boot-cfg.bbclass
parent49c638264c9fd83241ff75194439af0bb5b9e005 (diff)
downloadpoky-dbe0736341abf008e45558abc65b275a83fc9db9.tar.gz
systemd-boot.bbclass: break out configuration creation
This class is useful on its own and can be used to create configuration recipes. (From OE-Core rev: 5d14ff6e25d3b334d4cc9363a6ddeb16f4c2911d) Signed-off-by: California Sullivan <california.l.sullivan@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/systemd-boot-cfg.bbclass')
-rw-r--r--meta/classes/systemd-boot-cfg.bbclass71
1 files changed, 71 insertions, 0 deletions
diff --git a/meta/classes/systemd-boot-cfg.bbclass b/meta/classes/systemd-boot-cfg.bbclass
new file mode 100644
index 0000000000..46eeae126a
--- /dev/null
+++ b/meta/classes/systemd-boot-cfg.bbclass
@@ -0,0 +1,71 @@
1SYSTEMD_BOOT_CFG ?= "${S}/loader.conf"
2SYSTEMD_BOOT_ENTRIES ?= ""
3SYSTEMD_BOOT_TIMEOUT ?= "10"
4
5# Need UUID utility code.
6inherit fs-uuid
7
8python build_efi_cfg() {
9 s = d.getVar("S")
10 labels = d.getVar('LABELS')
11 if not labels:
12 bb.debug(1, "LABELS not defined, nothing to do")
13 return
14
15 if labels == []:
16 bb.debug(1, "No labels, nothing to do")
17 return
18
19 cfile = d.getVar('SYSTEMD_BOOT_CFG')
20 cdir = os.path.dirname(cfile)
21 if not os.path.exists(cdir):
22 os.makedirs(cdir)
23 try:
24 cfgfile = open(cfile, 'w')
25 except OSError:
26 bb.fatal('Unable to open %s' % cfile)
27
28 cfgfile.write('# Automatically created by OE\n')
29 cfgfile.write('default %s\n' % (labels.split()[0]))
30 timeout = d.getVar('SYSTEMD_BOOT_TIMEOUT')
31 if timeout:
32 cfgfile.write('timeout %s\n' % timeout)
33 else:
34 cfgfile.write('timeout 10\n')
35 cfgfile.close()
36
37 for label in labels.split():
38 localdata = d.createCopy()
39
40 overrides = localdata.getVar('OVERRIDES')
41 if not overrides:
42 bb.fatal('OVERRIDES not defined')
43
44 entryfile = "%s/%s.conf" % (s, label)
45 if not os.path.exists(s):
46 os.makedirs(s)
47 d.appendVar("SYSTEMD_BOOT_ENTRIES", " " + entryfile)
48 try:
49 entrycfg = open(entryfile, "w")
50 except OSError:
51 bb.fatal('Unable to open %s' % entryfile)
52 localdata.setVar('OVERRIDES', label + ':' + overrides)
53
54 entrycfg.write('title %s\n' % label)
55 entrycfg.write('linux /vmlinuz\n')
56
57 append = localdata.getVar('APPEND')
58 initrd = localdata.getVar('INITRD')
59
60 if initrd:
61 entrycfg.write('initrd /initrd\n')
62 lb = label
63 if label == "install":
64 lb = "install-efi"
65 entrycfg.write('options LABEL=%s ' % lb)
66 if append:
67 append = replace_rootfs_uuid(d, append)
68 entrycfg.write('%s' % append)
69 entrycfg.write('\n')
70 entrycfg.close()
71}