diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-10 14:35:29 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-12 15:27:17 +0100 |
| commit | fd1517e2b51a170f2427122c6b95396db251d827 (patch) | |
| tree | dabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/systemd-boot-cfg.bbclass | |
| parent | 10317912ee319ccf7f83605d438b5cbf9663f296 (diff) | |
| download | poky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz | |
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take
advantage of new bitbake functionality to check class scope/usage.
(From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/systemd-boot-cfg.bbclass')
| -rw-r--r-- | meta/classes-recipe/systemd-boot-cfg.bbclass | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/meta/classes-recipe/systemd-boot-cfg.bbclass b/meta/classes-recipe/systemd-boot-cfg.bbclass new file mode 100644 index 0000000000..366dd23738 --- /dev/null +++ b/meta/classes-recipe/systemd-boot-cfg.bbclass | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | # | ||
| 2 | # Copyright OpenEmbedded Contributors | ||
| 3 | # | ||
| 4 | # SPDX-License-Identifier: MIT | ||
| 5 | # | ||
| 6 | |||
| 7 | SYSTEMD_BOOT_CFG ?= "${S}/loader.conf" | ||
| 8 | SYSTEMD_BOOT_ENTRIES ?= "" | ||
| 9 | SYSTEMD_BOOT_TIMEOUT ?= "10" | ||
| 10 | |||
| 11 | # Uses MACHINE specific KERNEL_IMAGETYPE | ||
| 12 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
| 13 | |||
| 14 | # Need UUID utility code. | ||
| 15 | inherit fs-uuid | ||
| 16 | |||
| 17 | python build_efi_cfg() { | ||
| 18 | s = d.getVar("S") | ||
| 19 | labels = d.getVar('LABELS') | ||
| 20 | if not labels: | ||
| 21 | bb.debug(1, "LABELS not defined, nothing to do") | ||
| 22 | return | ||
| 23 | |||
| 24 | if labels == []: | ||
| 25 | bb.debug(1, "No labels, nothing to do") | ||
| 26 | return | ||
| 27 | |||
| 28 | cfile = d.getVar('SYSTEMD_BOOT_CFG') | ||
| 29 | cdir = os.path.dirname(cfile) | ||
| 30 | if not os.path.exists(cdir): | ||
| 31 | os.makedirs(cdir) | ||
| 32 | try: | ||
| 33 | cfgfile = open(cfile, 'w') | ||
| 34 | except OSError: | ||
| 35 | bb.fatal('Unable to open %s' % cfile) | ||
| 36 | |||
| 37 | cfgfile.write('# Automatically created by OE\n') | ||
| 38 | cfgfile.write('default %s\n' % (labels.split()[0])) | ||
| 39 | timeout = d.getVar('SYSTEMD_BOOT_TIMEOUT') | ||
| 40 | if timeout: | ||
| 41 | cfgfile.write('timeout %s\n' % timeout) | ||
| 42 | else: | ||
| 43 | cfgfile.write('timeout 10\n') | ||
| 44 | cfgfile.close() | ||
| 45 | |||
| 46 | for label in labels.split(): | ||
| 47 | localdata = d.createCopy() | ||
| 48 | |||
| 49 | entryfile = "%s/%s.conf" % (s, label) | ||
| 50 | if not os.path.exists(s): | ||
| 51 | os.makedirs(s) | ||
| 52 | d.appendVar("SYSTEMD_BOOT_ENTRIES", " " + entryfile) | ||
| 53 | try: | ||
| 54 | entrycfg = open(entryfile, "w") | ||
| 55 | except OSError: | ||
| 56 | bb.fatal('Unable to open %s' % entryfile) | ||
| 57 | |||
| 58 | entrycfg.write('title %s\n' % label) | ||
| 59 | |||
| 60 | kernel = localdata.getVar("KERNEL_IMAGETYPE") | ||
| 61 | entrycfg.write('linux /%s\n' % kernel) | ||
| 62 | |||
| 63 | append = localdata.getVar('APPEND') | ||
| 64 | initrd = localdata.getVar('INITRD') | ||
| 65 | |||
| 66 | if initrd: | ||
| 67 | entrycfg.write('initrd /initrd\n') | ||
| 68 | lb = label | ||
| 69 | if label == "install": | ||
| 70 | lb = "install-efi" | ||
| 71 | entrycfg.write('options LABEL=%s ' % lb) | ||
| 72 | if append: | ||
| 73 | append = replace_rootfs_uuid(d, append) | ||
| 74 | entrycfg.write('%s' % append) | ||
| 75 | entrycfg.write('\n') | ||
| 76 | entrycfg.close() | ||
| 77 | } | ||
