Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | SYSTEMD_BOOT_CFG ?= "${S}/loader.conf" |
| 2 | SYSTEMD_BOOT_ENTRIES ?= "" |
| 3 | SYSTEMD_BOOT_TIMEOUT ?= "10" |
| 4 | |
| 5 | # Need UUID utility code. |
| 6 | inherit fs-uuid |
| 7 | |
| 8 | python 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 | entryfile = "%s/%s.conf" % (s, label) |
| 41 | if not os.path.exists(s): |
| 42 | os.makedirs(s) |
| 43 | d.appendVar("SYSTEMD_BOOT_ENTRIES", " " + entryfile) |
| 44 | try: |
| 45 | entrycfg = open(entryfile, "w") |
| 46 | except OSError: |
| 47 | bb.fatal('Unable to open %s' % entryfile) |
| 48 | |
| 49 | entrycfg.write('title %s\n' % label) |
| 50 | |
| 51 | kernel = localdata.getVar("KERNEL_IMAGETYPE") |
| 52 | entrycfg.write('linux /%s\n' % kernel) |
| 53 | |
| 54 | append = localdata.getVar('APPEND') |
| 55 | initrd = localdata.getVar('INITRD') |
| 56 | |
| 57 | if initrd: |
| 58 | entrycfg.write('initrd /initrd\n') |
| 59 | lb = label |
| 60 | if label == "install": |
| 61 | lb = "install-efi" |
| 62 | entrycfg.write('options LABEL=%s ' % lb) |
| 63 | if append: |
| 64 | append = replace_rootfs_uuid(d, append) |
| 65 | entrycfg.write('%s' % append) |
| 66 | entrycfg.write('\n') |
| 67 | entrycfg.close() |
| 68 | } |