mirror of
https://git.yoctoproject.org/poky
synced 2026-04-18 03:32:13 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
49c638264c
commit
dbe0736341
71
meta/classes/systemd-boot-cfg.bbclass
Normal file
71
meta/classes/systemd-boot-cfg.bbclass
Normal file
@@ -0,0 +1,71 @@
|
||||
SYSTEMD_BOOT_CFG ?= "${S}/loader.conf"
|
||||
SYSTEMD_BOOT_ENTRIES ?= ""
|
||||
SYSTEMD_BOOT_TIMEOUT ?= "10"
|
||||
|
||||
# Need UUID utility code.
|
||||
inherit fs-uuid
|
||||
|
||||
python build_efi_cfg() {
|
||||
s = d.getVar("S")
|
||||
labels = d.getVar('LABELS')
|
||||
if not labels:
|
||||
bb.debug(1, "LABELS not defined, nothing to do")
|
||||
return
|
||||
|
||||
if labels == []:
|
||||
bb.debug(1, "No labels, nothing to do")
|
||||
return
|
||||
|
||||
cfile = d.getVar('SYSTEMD_BOOT_CFG')
|
||||
cdir = os.path.dirname(cfile)
|
||||
if not os.path.exists(cdir):
|
||||
os.makedirs(cdir)
|
||||
try:
|
||||
cfgfile = open(cfile, 'w')
|
||||
except OSError:
|
||||
bb.fatal('Unable to open %s' % cfile)
|
||||
|
||||
cfgfile.write('# Automatically created by OE\n')
|
||||
cfgfile.write('default %s\n' % (labels.split()[0]))
|
||||
timeout = d.getVar('SYSTEMD_BOOT_TIMEOUT')
|
||||
if timeout:
|
||||
cfgfile.write('timeout %s\n' % timeout)
|
||||
else:
|
||||
cfgfile.write('timeout 10\n')
|
||||
cfgfile.close()
|
||||
|
||||
for label in labels.split():
|
||||
localdata = d.createCopy()
|
||||
|
||||
overrides = localdata.getVar('OVERRIDES')
|
||||
if not overrides:
|
||||
bb.fatal('OVERRIDES not defined')
|
||||
|
||||
entryfile = "%s/%s.conf" % (s, label)
|
||||
if not os.path.exists(s):
|
||||
os.makedirs(s)
|
||||
d.appendVar("SYSTEMD_BOOT_ENTRIES", " " + entryfile)
|
||||
try:
|
||||
entrycfg = open(entryfile, "w")
|
||||
except OSError:
|
||||
bb.fatal('Unable to open %s' % entryfile)
|
||||
localdata.setVar('OVERRIDES', label + ':' + overrides)
|
||||
|
||||
entrycfg.write('title %s\n' % label)
|
||||
entrycfg.write('linux /vmlinuz\n')
|
||||
|
||||
append = localdata.getVar('APPEND')
|
||||
initrd = localdata.getVar('INITRD')
|
||||
|
||||
if initrd:
|
||||
entrycfg.write('initrd /initrd\n')
|
||||
lb = label
|
||||
if label == "install":
|
||||
lb = "install-efi"
|
||||
entrycfg.write('options LABEL=%s ' % lb)
|
||||
if append:
|
||||
append = replace_rootfs_uuid(d, append)
|
||||
entrycfg.write('%s' % append)
|
||||
entrycfg.write('\n')
|
||||
entrycfg.close()
|
||||
}
|
||||
@@ -12,11 +12,6 @@
|
||||
do_bootimg[depends] += "${MLPREFIX}systemd-boot:do_deploy"
|
||||
|
||||
EFIDIR = "/EFI/BOOT"
|
||||
|
||||
SYSTEMD_BOOT_CFG ?= "${S}/loader.conf"
|
||||
SYSTEMD_BOOT_ENTRIES ?= ""
|
||||
SYSTEMD_BOOT_TIMEOUT ?= "10"
|
||||
|
||||
# Need UUID utility code.
|
||||
inherit fs-uuid
|
||||
|
||||
@@ -62,67 +57,4 @@ efi_hddimg_populate() {
|
||||
efi_populate $1
|
||||
}
|
||||
|
||||
python build_efi_cfg() {
|
||||
s = d.getVar("S")
|
||||
labels = d.getVar('LABELS')
|
||||
if not labels:
|
||||
bb.debug(1, "LABELS not defined, nothing to do")
|
||||
return
|
||||
|
||||
if labels == []:
|
||||
bb.debug(1, "No labels, nothing to do")
|
||||
return
|
||||
|
||||
cfile = d.getVar('SYSTEMD_BOOT_CFG')
|
||||
cdir = os.path.dirname(cfile)
|
||||
if not os.path.exists(cdir):
|
||||
os.makedirs(cdir)
|
||||
try:
|
||||
cfgfile = open(cfile, 'w')
|
||||
except OSError:
|
||||
bb.fatal('Unable to open %s' % cfile)
|
||||
|
||||
cfgfile.write('# Automatically created by OE\n')
|
||||
cfgfile.write('default %s\n' % (labels.split()[0]))
|
||||
timeout = d.getVar('SYSTEMD_BOOT_TIMEOUT')
|
||||
if timeout:
|
||||
cfgfile.write('timeout %s\n' % timeout)
|
||||
else:
|
||||
cfgfile.write('timeout 10\n')
|
||||
cfgfile.close()
|
||||
|
||||
for label in labels.split():
|
||||
localdata = d.createCopy()
|
||||
|
||||
overrides = localdata.getVar('OVERRIDES')
|
||||
if not overrides:
|
||||
bb.fatal('OVERRIDES not defined')
|
||||
|
||||
entryfile = "%s/%s.conf" % (s, label)
|
||||
if not os.path.exists(s):
|
||||
os.makedirs(s)
|
||||
d.appendVar("SYSTEMD_BOOT_ENTRIES", " " + entryfile)
|
||||
try:
|
||||
entrycfg = open(entryfile, "w")
|
||||
except OSError:
|
||||
bb.fatal('Unable to open %s' % entryfile)
|
||||
localdata.setVar('OVERRIDES', label + ':' + overrides)
|
||||
|
||||
entrycfg.write('title %s\n' % label)
|
||||
entrycfg.write('linux /vmlinuz\n')
|
||||
|
||||
append = localdata.getVar('APPEND')
|
||||
initrd = localdata.getVar('INITRD')
|
||||
|
||||
if initrd:
|
||||
entrycfg.write('initrd /initrd\n')
|
||||
lb = label
|
||||
if label == "install":
|
||||
lb = "install-efi"
|
||||
entrycfg.write('options LABEL=%s ' % lb)
|
||||
if append:
|
||||
append = replace_rootfs_uuid(d, append)
|
||||
entrycfg.write('%s' % append)
|
||||
entrycfg.write('\n')
|
||||
entrycfg.close()
|
||||
}
|
||||
inherit systemd-boot-cfg
|
||||
|
||||
Reference in New Issue
Block a user