diff options
| author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
|---|---|---|
| committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
| commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
| tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /meta/classes/grub-efi.bbclass | |
| download | poky-daisy-140929.tar.gz | |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta/classes/grub-efi.bbclass')
| -rw-r--r-- | meta/classes/grub-efi.bbclass | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass new file mode 100644 index 0000000000..5c80c177de --- /dev/null +++ b/meta/classes/grub-efi.bbclass | |||
| @@ -0,0 +1,141 @@ | |||
| 1 | # grub-efi.bbclass | ||
| 2 | # Copyright (c) 2011, Intel Corporation. | ||
| 3 | # All rights reserved. | ||
| 4 | # | ||
| 5 | # Released under the MIT license (see packages/COPYING) | ||
| 6 | |||
| 7 | # Provide grub-efi specific functions for building bootable images. | ||
| 8 | |||
| 9 | # External variables | ||
| 10 | # ${INITRD} - indicates a filesystem image to use as an initrd (optional) | ||
| 11 | # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional) | ||
| 12 | # ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu | ||
| 13 | # ${LABELS} - a list of targets for the automatic config | ||
| 14 | # ${APPEND} - an override list of append strings for each label | ||
| 15 | # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional) | ||
| 16 | # ${GRUB_TIMEOUT} - timeout before executing the deault label (optional) | ||
| 17 | |||
| 18 | do_bootimg[depends] += "grub-efi:do_deploy" | ||
| 19 | do_bootdirectdisk[depends] += "grub-efi:do_deploy" | ||
| 20 | |||
| 21 | GRUB_SERIAL ?= "console=ttyS0,115200" | ||
| 22 | GRUBCFG = "${S}/grub.cfg" | ||
| 23 | GRUB_TIMEOUT ?= "10" | ||
| 24 | #FIXME: build this from the machine config | ||
| 25 | GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" | ||
| 26 | |||
| 27 | EFIDIR = "/EFI/BOOT" | ||
| 28 | |||
| 29 | efi_populate() { | ||
| 30 | # DEST must be the root of the image so that EFIDIR is not | ||
| 31 | # nested under a top level directory. | ||
| 32 | DEST=$1 | ||
| 33 | |||
| 34 | install -d ${DEST}${EFIDIR} | ||
| 35 | |||
| 36 | GRUB_IMAGE="bootia32.efi" | ||
| 37 | if [ "${TARGET_ARCH}" = "x86_64" ]; then | ||
| 38 | GRUB_IMAGE="bootx64.efi" | ||
| 39 | fi | ||
| 40 | install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST}${EFIDIR} | ||
| 41 | |||
| 42 | install -m 0644 ${GRUBCFG} ${DEST}${EFIDIR} | ||
| 43 | } | ||
| 44 | |||
| 45 | efi_iso_populate() { | ||
| 46 | iso_dir=$1 | ||
| 47 | efi_populate $iso_dir | ||
| 48 | # Build a EFI directory to create efi.img | ||
| 49 | mkdir -p ${EFIIMGDIR}/${EFIDIR} | ||
| 50 | cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR} | ||
| 51 | cp $iso_dir/vmlinuz ${EFIIMGDIR} | ||
| 52 | echo "${GRUB_IMAGE}" > ${EFIIMGDIR}/startup.nsh | ||
| 53 | if [ -f "$iso_dir/initrd" ] ; then | ||
| 54 | cp $iso_dir/initrd ${EFIIMGDIR} | ||
| 55 | fi | ||
| 56 | } | ||
| 57 | |||
| 58 | efi_hddimg_populate() { | ||
| 59 | efi_populate $1 | ||
| 60 | } | ||
| 61 | |||
| 62 | python build_efi_cfg() { | ||
| 63 | import sys | ||
| 64 | |||
| 65 | workdir = d.getVar('WORKDIR', True) | ||
| 66 | if not workdir: | ||
| 67 | bb.error("WORKDIR not defined, unable to package") | ||
| 68 | return | ||
| 69 | |||
| 70 | gfxserial = d.getVar('GRUB_GFXSERIAL', True) or "" | ||
| 71 | |||
| 72 | labels = d.getVar('LABELS', True) | ||
| 73 | if not labels: | ||
| 74 | bb.debug(1, "LABELS not defined, nothing to do") | ||
| 75 | return | ||
| 76 | |||
| 77 | if labels == []: | ||
| 78 | bb.debug(1, "No labels, nothing to do") | ||
| 79 | return | ||
| 80 | |||
| 81 | cfile = d.getVar('GRUBCFG', True) | ||
| 82 | if not cfile: | ||
| 83 | raise bb.build.FuncFailed('Unable to read GRUBCFG') | ||
| 84 | |||
| 85 | try: | ||
| 86 | cfgfile = file(cfile, 'w') | ||
| 87 | except OSError: | ||
| 88 | raise bb.build.funcFailed('Unable to open %s' % (cfile)) | ||
| 89 | |||
| 90 | cfgfile.write('# Automatically created by OE\n') | ||
| 91 | |||
| 92 | opts = d.getVar('GRUB_OPTS', True) | ||
| 93 | if opts: | ||
| 94 | for opt in opts.split(';'): | ||
| 95 | cfgfile.write('%s\n' % opt) | ||
| 96 | |||
| 97 | cfgfile.write('default=%s\n' % (labels.split()[0])) | ||
| 98 | |||
| 99 | timeout = d.getVar('GRUB_TIMEOUT', True) | ||
| 100 | if timeout: | ||
| 101 | cfgfile.write('timeout=%s\n' % timeout) | ||
| 102 | else: | ||
| 103 | cfgfile.write('timeout=50\n') | ||
| 104 | |||
| 105 | if gfxserial == "1": | ||
| 106 | btypes = [ [ " graphics console", "" ], | ||
| 107 | [ " serial console", d.getVar('GRUB_SERIAL', True) or "" ] ] | ||
| 108 | else: | ||
| 109 | btypes = [ [ "", "" ] ] | ||
| 110 | |||
| 111 | for label in labels.split(): | ||
| 112 | localdata = d.createCopy() | ||
| 113 | |||
| 114 | overrides = localdata.getVar('OVERRIDES', True) | ||
| 115 | if not overrides: | ||
| 116 | raise bb.build.FuncFailed('OVERRIDES not defined') | ||
| 117 | |||
| 118 | for btype in btypes: | ||
| 119 | localdata.setVar('OVERRIDES', label + ':' + overrides) | ||
| 120 | bb.data.update_data(localdata) | ||
| 121 | |||
| 122 | cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0])) | ||
| 123 | lb = label | ||
| 124 | if label == "install": | ||
| 125 | lb = "install-efi" | ||
| 126 | cfgfile.write('linux /vmlinuz LABEL=%s' % (lb)) | ||
| 127 | |||
| 128 | append = localdata.getVar('APPEND', True) | ||
| 129 | initrd = localdata.getVar('INITRD', True) | ||
| 130 | |||
| 131 | if append: | ||
| 132 | cfgfile.write('%s' % (append)) | ||
| 133 | cfgfile.write(' %s' % btype[1]) | ||
| 134 | cfgfile.write('\n') | ||
| 135 | |||
| 136 | if initrd: | ||
| 137 | cfgfile.write('initrd /initrd') | ||
| 138 | cfgfile.write('\n}\n') | ||
| 139 | |||
| 140 | cfgfile.close() | ||
| 141 | } | ||
