blob: 3d9c08bbc9736ed33c1c33b5c990bd0e295159c5 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Copyright (C) 2014 Intel Corporation
2#
3# Released under the MIT license (see COPYING.MIT)
4
5# gummiboot.bbclass - equivalent of grub-efi.bbclass
6# Set EFI_PROVIDER = "gummiboot" to use gummiboot on your live images instead of grub-efi
7# (images built by bootimage.bbclass or boot-directdisk.bbclass)
8
9do_bootimg[depends] += "${MLPREFIX}gummiboot:do_deploy"
10do_bootdirectdisk[depends] += "${MLPREFIX}gummiboot:do_deploy"
11
12EFIDIR = "/EFI/BOOT"
13
14GUMMIBOOT_CFG ?= "${S}/loader.conf"
15GUMMIBOOT_ENTRIES ?= ""
16GUMMIBOOT_TIMEOUT ?= "10"
17
18# Need UUID utility code.
19inherit fs-uuid
20
21efi_populate() {
22 DEST=$1
23
24 EFI_IMAGE="gummibootia32.efi"
25 DEST_EFI_IMAGE="bootia32.efi"
26 if [ "${TARGET_ARCH}" = "x86_64" ]; then
27 EFI_IMAGE="gummibootx64.efi"
28 DEST_EFI_IMAGE="bootx64.efi"
29 fi
30
31 install -d ${DEST}${EFIDIR}
32 # gummiboot requires these paths for configuration files
33 # they are not customizable so no point in new vars
34 install -d ${DEST}/loader
35 install -d ${DEST}/loader/entries
36 install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE} ${DEST}${EFIDIR}/${DEST_EFI_IMAGE}
37 install -m 0644 ${GUMMIBOOT_CFG} ${DEST}/loader/loader.conf
38 for i in ${GUMMIBOOT_ENTRIES}; do
39 install -m 0644 ${i} ${DEST}/loader/entries
40 done
41}
42
43efi_iso_populate() {
44 iso_dir=$1
45 efi_populate $iso_dir
46 mkdir -p ${EFIIMGDIR}/${EFIDIR}
47 cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
48 cp $iso_dir/vmlinuz ${EFIIMGDIR}
49 echo "${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
50 if [ -f "$iso_dir/initrd" ] ; then
51 cp $iso_dir/initrd ${EFIIMGDIR}
52 fi
53}
54
55efi_hddimg_populate() {
56 efi_populate $1
57}
58
59python build_efi_cfg() {
60 s = d.getVar("S", True)
61 labels = d.getVar('LABELS', True)
62 if not labels:
63 bb.debug(1, "LABELS not defined, nothing to do")
64 return
65
66 if labels == []:
67 bb.debug(1, "No labels, nothing to do")
68 return
69
70 cfile = d.getVar('GUMMIBOOT_CFG', True)
71 try:
72 cfgfile = open(cfile, 'w')
73 except OSError:
74 raise bb.build.funcFailed('Unable to open %s' % (cfile))
75
76 cfgfile.write('# Automatically created by OE\n')
77 cfgfile.write('default %s\n' % (labels.split()[0]))
78 timeout = d.getVar('GUMMIBOOT_TIMEOUT', True)
79 if timeout:
80 cfgfile.write('timeout %s\n' % timeout)
81 else:
82 cfgfile.write('timeout 10\n')
83 cfgfile.close()
84
85 for label in labels.split():
86 localdata = d.createCopy()
87
88 overrides = localdata.getVar('OVERRIDES', True)
89 if not overrides:
90 raise bb.build.FuncFailed('OVERRIDES not defined')
91
92 entryfile = "%s/%s.conf" % (s, label)
93 d.appendVar("GUMMIBOOT_ENTRIES", " " + entryfile)
94 try:
95 entrycfg = open(entryfile, "w")
96 except OSError:
97 raise bb.build.funcFailed('Unable to open %s' % (entryfile))
98 localdata.setVar('OVERRIDES', label + ':' + overrides)
99 bb.data.update_data(localdata)
100
101 entrycfg.write('title %s\n' % label)
102 entrycfg.write('linux /vmlinuz\n')
103
104 append = localdata.getVar('APPEND', True)
105 initrd = localdata.getVar('INITRD', True)
106
107 if initrd:
108 entrycfg.write('initrd /initrd\n')
109 lb = label
110 if label == "install":
111 lb = "install-efi"
112 entrycfg.write('options LABEL=%s ' % lb)
113 if append:
114 append = replace_rootfs_uuid(d, append)
115 entrycfg.write('%s' % append)
116 entrycfg.write('\n')
117 entrycfg.close()
118}