summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--meta/classes/systemd-boot-cfg.bbclass71
-rw-r--r--meta/classes/systemd-boot.bbclass70
2 files changed, 72 insertions, 69 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}
diff --git a/meta/classes/systemd-boot.bbclass b/meta/classes/systemd-boot.bbclass
index 937307076f..14538fe2d7 100644
--- a/meta/classes/systemd-boot.bbclass
+++ b/meta/classes/systemd-boot.bbclass
@@ -12,11 +12,6 @@
12do_bootimg[depends] += "${MLPREFIX}systemd-boot:do_deploy" 12do_bootimg[depends] += "${MLPREFIX}systemd-boot:do_deploy"
13 13
14EFIDIR = "/EFI/BOOT" 14EFIDIR = "/EFI/BOOT"
15
16SYSTEMD_BOOT_CFG ?= "${S}/loader.conf"
17SYSTEMD_BOOT_ENTRIES ?= ""
18SYSTEMD_BOOT_TIMEOUT ?= "10"
19
20# Need UUID utility code. 15# Need UUID utility code.
21inherit fs-uuid 16inherit fs-uuid
22 17
@@ -62,67 +57,4 @@ efi_hddimg_populate() {
62 efi_populate $1 57 efi_populate $1
63} 58}
64 59
65python build_efi_cfg() { 60inherit systemd-boot-cfg
66 s = d.getVar("S")
67 labels = d.getVar('LABELS')
68 if not labels:
69 bb.debug(1, "LABELS not defined, nothing to do")
70 return
71
72 if labels == []:
73 bb.debug(1, "No labels, nothing to do")
74 return
75
76 cfile = d.getVar('SYSTEMD_BOOT_CFG')
77 cdir = os.path.dirname(cfile)
78 if not os.path.exists(cdir):
79 os.makedirs(cdir)
80 try:
81 cfgfile = open(cfile, 'w')
82 except OSError:
83 bb.fatal('Unable to open %s' % cfile)
84
85 cfgfile.write('# Automatically created by OE\n')
86 cfgfile.write('default %s\n' % (labels.split()[0]))
87 timeout = d.getVar('SYSTEMD_BOOT_TIMEOUT')
88 if timeout:
89 cfgfile.write('timeout %s\n' % timeout)
90 else:
91 cfgfile.write('timeout 10\n')
92 cfgfile.close()
93
94 for label in labels.split():
95 localdata = d.createCopy()
96
97 overrides = localdata.getVar('OVERRIDES')
98 if not overrides:
99 bb.fatal('OVERRIDES not defined')
100
101 entryfile = "%s/%s.conf" % (s, label)
102 if not os.path.exists(s):
103 os.makedirs(s)
104 d.appendVar("SYSTEMD_BOOT_ENTRIES", " " + entryfile)
105 try:
106 entrycfg = open(entryfile, "w")
107 except OSError:
108 bb.fatal('Unable to open %s' % entryfile)
109 localdata.setVar('OVERRIDES', label + ':' + overrides)
110
111 entrycfg.write('title %s\n' % label)
112 entrycfg.write('linux /vmlinuz\n')
113
114 append = localdata.getVar('APPEND')
115 initrd = localdata.getVar('INITRD')
116
117 if initrd:
118 entrycfg.write('initrd /initrd\n')
119 lb = label
120 if label == "install":
121 lb = "install-efi"
122 entrycfg.write('options LABEL=%s ' % lb)
123 if append:
124 append = replace_rootfs_uuid(d, append)
125 entrycfg.write('%s' % append)
126 entrycfg.write('\n')
127 entrycfg.close()
128}