Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # 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 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7 | # (images built by image-live.bbclass or image-vm.bbclass) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | |
| 9 | do_bootimg[depends] += "${MLPREFIX}gummiboot:do_deploy" |
| 10 | do_bootdirectdisk[depends] += "${MLPREFIX}gummiboot:do_deploy" |
| 11 | |
| 12 | EFIDIR = "/EFI/BOOT" |
| 13 | |
| 14 | GUMMIBOOT_CFG ?= "${S}/loader.conf" |
| 15 | GUMMIBOOT_ENTRIES ?= "" |
| 16 | GUMMIBOOT_TIMEOUT ?= "10" |
| 17 | |
| 18 | # Need UUID utility code. |
| 19 | inherit fs-uuid |
| 20 | |
| 21 | efi_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 | |
| 43 | efi_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} |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 49 | EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') |
| 50 | echo "fs0:${EFIPATH}\\${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | if [ -f "$iso_dir/initrd" ] ; then |
| 52 | cp $iso_dir/initrd ${EFIIMGDIR} |
| 53 | fi |
| 54 | } |
| 55 | |
| 56 | efi_hddimg_populate() { |
| 57 | efi_populate $1 |
| 58 | } |
| 59 | |
| 60 | python build_efi_cfg() { |
| 61 | s = d.getVar("S", True) |
| 62 | labels = d.getVar('LABELS', True) |
| 63 | if not labels: |
| 64 | bb.debug(1, "LABELS not defined, nothing to do") |
| 65 | return |
| 66 | |
| 67 | if labels == []: |
| 68 | bb.debug(1, "No labels, nothing to do") |
| 69 | return |
| 70 | |
| 71 | cfile = d.getVar('GUMMIBOOT_CFG', True) |
| 72 | try: |
| 73 | cfgfile = open(cfile, 'w') |
| 74 | except OSError: |
| 75 | raise bb.build.funcFailed('Unable to open %s' % (cfile)) |
| 76 | |
| 77 | cfgfile.write('# Automatically created by OE\n') |
| 78 | cfgfile.write('default %s\n' % (labels.split()[0])) |
| 79 | timeout = d.getVar('GUMMIBOOT_TIMEOUT', True) |
| 80 | if timeout: |
| 81 | cfgfile.write('timeout %s\n' % timeout) |
| 82 | else: |
| 83 | cfgfile.write('timeout 10\n') |
| 84 | cfgfile.close() |
| 85 | |
| 86 | for label in labels.split(): |
| 87 | localdata = d.createCopy() |
| 88 | |
| 89 | overrides = localdata.getVar('OVERRIDES', True) |
| 90 | if not overrides: |
| 91 | raise bb.build.FuncFailed('OVERRIDES not defined') |
| 92 | |
| 93 | entryfile = "%s/%s.conf" % (s, label) |
| 94 | d.appendVar("GUMMIBOOT_ENTRIES", " " + entryfile) |
| 95 | try: |
| 96 | entrycfg = open(entryfile, "w") |
| 97 | except OSError: |
| 98 | raise bb.build.funcFailed('Unable to open %s' % (entryfile)) |
| 99 | localdata.setVar('OVERRIDES', label + ':' + overrides) |
| 100 | bb.data.update_data(localdata) |
| 101 | |
| 102 | entrycfg.write('title %s\n' % label) |
| 103 | entrycfg.write('linux /vmlinuz\n') |
| 104 | |
| 105 | append = localdata.getVar('APPEND', True) |
| 106 | initrd = localdata.getVar('INITRD', True) |
| 107 | |
| 108 | if initrd: |
| 109 | entrycfg.write('initrd /initrd\n') |
| 110 | lb = label |
| 111 | if label == "install": |
| 112 | lb = "install-efi" |
| 113 | entrycfg.write('options LABEL=%s ' % lb) |
| 114 | if append: |
| 115 | append = replace_rootfs_uuid(d, append) |
| 116 | entrycfg.write('%s' % append) |
| 117 | entrycfg.write('\n') |
| 118 | entrycfg.close() |
| 119 | } |