summaryrefslogtreecommitdiffstats
path: root/meta/classes/systemd-boot.bbclass
diff options
context:
space:
mode:
authorJianxun Zhang <jianxun.zhang@linux.intel.com>2016-05-05 11:20:37 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-03 13:13:25 +0100
commitc71f5ab37416629793b9f826480d440d67531791 (patch)
tree3a605787ba786549c99b8923133ea38c24f4af3d /meta/classes/systemd-boot.bbclass
parent408297489d1b368e8cc539ce93fbe566976b0f3a (diff)
downloadpoky-c71f5ab37416629793b9f826480d440d67531791.tar.gz
systemd: support systemd-boot as a stand-alone EFI bootloader
The "systemd-boot" is gummiboot now included into systemd project. The old gummiboot project supported in OE is dead. Our intention is to get a gummiboot-like EFI bootloader without much dependency on systemd and its features. This work is largely derived from the existing bbclass and recipes of gummiboot and systemd. (commit tip: ee25d0e3987d7732a2e46e1640693b4cf419a9fc) Please refer to the history up to the tip for authorship and credit information for the original works. To enable the systemd-boot in build, add this line EFI_PROVIDER = "systemd-boot" in your machine conf file. (From OE-Core rev: e9add1cd01e498d2aa52528ec52342cae48a387a) Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/systemd-boot.bbclass')
-rw-r--r--meta/classes/systemd-boot.bbclass124
1 files changed, 124 insertions, 0 deletions
diff --git a/meta/classes/systemd-boot.bbclass b/meta/classes/systemd-boot.bbclass
new file mode 100644
index 0000000000..9e9398a2a5
--- /dev/null
+++ b/meta/classes/systemd-boot.bbclass
@@ -0,0 +1,124 @@
1# Copyright (C) 2016 Intel Corporation
2#
3# Released under the MIT license (see COPYING.MIT)
4
5# systemd-boot.bbclass - The "systemd-boot" is essentially the gummiboot merged into systemd.
6# The original standalone gummiboot project is dead without any more
7# maintenance. As a start point, we replace all gummitboot occurrences
8# with systemd-boot in gummiboot.bbclass to have a base version of this
9# systemd-boot.bbclass.
10#
11# Set EFI_PROVIDER = "systemd-boot" to use systemd-boot on your live images instead of grub-efi
12# (images built by image-live.bbclass or image-vm.bbclass)
13
14do_bootimg[depends] += "${MLPREFIX}systemd-boot:do_deploy"
15do_bootdirectdisk[depends] += "${MLPREFIX}systemd-boot:do_deploy"
16
17EFIDIR = "/EFI/BOOT"
18
19SYSTEMD_BOOT_CFG ?= "${S}/loader.conf"
20SYSTEMD_BOOT_ENTRIES ?= ""
21SYSTEMD_BOOT_TIMEOUT ?= "10"
22
23# Need UUID utility code.
24inherit fs-uuid
25
26efi_populate() {
27 DEST=$1
28
29 EFI_IMAGE="systemd-bootia32.efi"
30 DEST_EFI_IMAGE="bootia32.efi"
31 if [ "${TARGET_ARCH}" = "x86_64" ]; then
32 EFI_IMAGE="systemd-bootx64.efi"
33 DEST_EFI_IMAGE="bootx64.efi"
34 fi
35
36 install -d ${DEST}${EFIDIR}
37 # systemd-boot requires these paths for configuration files
38 # they are not customizable so no point in new vars
39 install -d ${DEST}/loader
40 install -d ${DEST}/loader/entries
41 install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE} ${DEST}${EFIDIR}/${DEST_EFI_IMAGE}
42 install -m 0644 ${SYSTEMD_BOOT_CFG} ${DEST}/loader/loader.conf
43 for i in ${SYSTEMD_BOOT_ENTRIES}; do
44 install -m 0644 ${i} ${DEST}/loader/entries
45 done
46}
47
48efi_iso_populate() {
49 iso_dir=$1
50 efi_populate $iso_dir
51 mkdir -p ${EFIIMGDIR}/${EFIDIR}
52 cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
53 cp $iso_dir/vmlinuz ${EFIIMGDIR}
54 EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
55 echo "fs0:${EFIPATH}\\${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
56 if [ -f "$iso_dir/initrd" ] ; then
57 cp $iso_dir/initrd ${EFIIMGDIR}
58 fi
59}
60
61efi_hddimg_populate() {
62 efi_populate $1
63}
64
65python build_efi_cfg() {
66 s = d.getVar("S", True)
67 labels = d.getVar('LABELS', True)
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', True)
77 try:
78 cfgfile = open(cfile, 'w')
79 except OSError:
80 raise bb.build.funcFailed('Unable to open %s' % (cfile))
81
82 cfgfile.write('# Automatically created by OE\n')
83 cfgfile.write('default %s\n' % (labels.split()[0]))
84 timeout = d.getVar('SYSTEMD_BOOT_TIMEOUT', True)
85 if timeout:
86 cfgfile.write('timeout %s\n' % timeout)
87 else:
88 cfgfile.write('timeout 10\n')
89 cfgfile.close()
90
91 for label in labels.split():
92 localdata = d.createCopy()
93
94 overrides = localdata.getVar('OVERRIDES', True)
95 if not overrides:
96 raise bb.build.FuncFailed('OVERRIDES not defined')
97
98 entryfile = "%s/%s.conf" % (s, label)
99 d.appendVar("SYSTEMD_BOOT_ENTRIES", " " + entryfile)
100 try:
101 entrycfg = open(entryfile, "w")
102 except OSError:
103 raise bb.build.funcFailed('Unable to open %s' % (entryfile))
104 localdata.setVar('OVERRIDES', label + ':' + overrides)
105 bb.data.update_data(localdata)
106
107 entrycfg.write('title %s\n' % label)
108 entrycfg.write('linux /vmlinuz\n')
109
110 append = localdata.getVar('APPEND', True)
111 initrd = localdata.getVar('INITRD', True)
112
113 if initrd:
114 entrycfg.write('initrd /initrd\n')
115 lb = label
116 if label == "install":
117 lb = "install-efi"
118 entrycfg.write('options LABEL=%s ' % lb)
119 if append:
120 append = replace_rootfs_uuid(d, append)
121 entrycfg.write('%s' % append)
122 entrycfg.write('\n')
123 entrycfg.close()
124}