diff options
| author | California Sullivan <california.l.sullivan@intel.com> | 2018-02-28 18:14:58 -0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-03-06 06:35:42 -0800 |
| commit | a9921f64a7183e1c09e674a768fdcc2f52778ac3 (patch) | |
| tree | d4d0344a835b9fe5609332c1bac99470a29d3754 /meta/classes | |
| parent | 00ab4a3a54fcaa714ae4968389c6bddb75e7166e (diff) | |
| download | poky-a9921f64a7183e1c09e674a768fdcc2f52778ac3.tar.gz | |
grub-efi.bbclass: split out configuration portion
This part is useful on its own, whereas the whole class together is
specific for image-live.
(From OE-Core rev: 8daf2c544eb40d97d99a41627ddc5529c0e23f3c)
Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
| -rw-r--r-- | meta/classes/grub-efi-cfg.bbclass | 119 | ||||
| -rw-r--r-- | meta/classes/grub-efi.bbclass | 122 |
2 files changed, 120 insertions, 121 deletions
diff --git a/meta/classes/grub-efi-cfg.bbclass b/meta/classes/grub-efi-cfg.bbclass new file mode 100644 index 0000000000..730323c72e --- /dev/null +++ b/meta/classes/grub-efi-cfg.bbclass | |||
| @@ -0,0 +1,119 @@ | |||
| 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 list of filesystem images to concatenate and 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 | # ${GRUB_ROOT} - grub's root device. | ||
| 18 | |||
| 19 | GRUB_SERIAL ?= "console=ttyS0,115200" | ||
| 20 | GRUB_CFG_VM = "${S}/grub_vm.cfg" | ||
| 21 | GRUB_CFG_LIVE = "${S}/grub_live.cfg" | ||
| 22 | GRUB_TIMEOUT ?= "10" | ||
| 23 | #FIXME: build this from the machine config | ||
| 24 | GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" | ||
| 25 | |||
| 26 | EFIDIR = "/EFI/BOOT" | ||
| 27 | GRUB_ROOT ?= "${ROOT}" | ||
| 28 | APPEND ?= "" | ||
| 29 | |||
| 30 | # Need UUID utility code. | ||
| 31 | inherit fs-uuid | ||
| 32 | |||
| 33 | python build_efi_cfg() { | ||
| 34 | import sys | ||
| 35 | |||
| 36 | workdir = d.getVar('WORKDIR') | ||
| 37 | if not workdir: | ||
| 38 | bb.error("WORKDIR not defined, unable to package") | ||
| 39 | return | ||
| 40 | |||
| 41 | gfxserial = d.getVar('GRUB_GFXSERIAL') or "" | ||
| 42 | |||
| 43 | labels = d.getVar('LABELS') | ||
| 44 | if not labels: | ||
| 45 | bb.debug(1, "LABELS not defined, nothing to do") | ||
| 46 | return | ||
| 47 | |||
| 48 | if labels == []: | ||
| 49 | bb.debug(1, "No labels, nothing to do") | ||
| 50 | return | ||
| 51 | |||
| 52 | cfile = d.getVar('GRUB_CFG') | ||
| 53 | if not cfile: | ||
| 54 | bb.fatal('Unable to read GRUB_CFG') | ||
| 55 | |||
| 56 | try: | ||
| 57 | cfgfile = open(cfile, 'w') | ||
| 58 | except OSError: | ||
| 59 | bb.fatal('Unable to open %s' % cfile) | ||
| 60 | |||
| 61 | cfgfile.write('# Automatically created by OE\n') | ||
| 62 | |||
| 63 | opts = d.getVar('GRUB_OPTS') | ||
| 64 | if opts: | ||
| 65 | for opt in opts.split(';'): | ||
| 66 | cfgfile.write('%s\n' % opt) | ||
| 67 | |||
| 68 | cfgfile.write('default=%s\n' % (labels.split()[0])) | ||
| 69 | |||
| 70 | timeout = d.getVar('GRUB_TIMEOUT') | ||
| 71 | if timeout: | ||
| 72 | cfgfile.write('timeout=%s\n' % timeout) | ||
| 73 | else: | ||
| 74 | cfgfile.write('timeout=50\n') | ||
| 75 | |||
| 76 | root = d.getVar('GRUB_ROOT') | ||
| 77 | if not root: | ||
| 78 | bb.fatal('GRUB_ROOT not defined') | ||
| 79 | |||
| 80 | if gfxserial == "1": | ||
| 81 | btypes = [ [ " graphics console", "" ], | ||
| 82 | [ " serial console", d.getVar('GRUB_SERIAL') or "" ] ] | ||
| 83 | else: | ||
| 84 | btypes = [ [ "", "" ] ] | ||
| 85 | |||
| 86 | for label in labels.split(): | ||
| 87 | localdata = d.createCopy() | ||
| 88 | |||
| 89 | overrides = localdata.getVar('OVERRIDES') | ||
| 90 | if not overrides: | ||
| 91 | bb.fatal('OVERRIDES not defined') | ||
| 92 | |||
| 93 | for btype in btypes: | ||
| 94 | localdata.setVar('OVERRIDES', label + ':' + overrides) | ||
| 95 | |||
| 96 | cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0])) | ||
| 97 | lb = label | ||
| 98 | if label == "install": | ||
| 99 | lb = "install-efi" | ||
| 100 | cfgfile.write('linux /vmlinuz LABEL=%s' % (lb)) | ||
| 101 | |||
| 102 | cfgfile.write(' %s' % replace_rootfs_uuid(d, root)) | ||
| 103 | |||
| 104 | append = localdata.getVar('APPEND') | ||
| 105 | initrd = localdata.getVar('INITRD') | ||
| 106 | |||
| 107 | if append: | ||
| 108 | append = replace_rootfs_uuid(d, append) | ||
| 109 | cfgfile.write(' %s' % (append)) | ||
| 110 | |||
| 111 | cfgfile.write(' %s' % btype[1]) | ||
| 112 | cfgfile.write('\n') | ||
| 113 | |||
| 114 | if initrd: | ||
| 115 | cfgfile.write('initrd /initrd') | ||
| 116 | cfgfile.write('\n}\n') | ||
| 117 | |||
| 118 | cfgfile.close() | ||
| 119 | } | ||
diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass index 610479b85d..4b5704c19c 100644 --- a/meta/classes/grub-efi.bbclass +++ b/meta/classes/grub-efi.bbclass | |||
| @@ -1,36 +1,4 @@ | |||
| 1 | # grub-efi.bbclass | 1 | inherit grub-efi-cfg |
| 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 list of filesystem images to concatenate and 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 | # ${GRUB_ROOT} - grub's root device. | ||
| 18 | |||
| 19 | do_bootimg[depends] += "${MLPREFIX}grub-efi:do_deploy" | ||
| 20 | |||
| 21 | GRUB_SERIAL ?= "console=ttyS0,115200" | ||
| 22 | GRUB_CFG_VM = "${S}/grub_vm.cfg" | ||
| 23 | GRUB_CFG_LIVE = "${S}/grub_live.cfg" | ||
| 24 | GRUB_TIMEOUT ?= "10" | ||
| 25 | #FIXME: build this from the machine config | ||
| 26 | GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" | ||
| 27 | |||
| 28 | EFIDIR = "/EFI/BOOT" | ||
| 29 | GRUB_ROOT ?= "${ROOT}" | ||
| 30 | APPEND ?= "" | ||
| 31 | |||
| 32 | # Need UUID utility code. | ||
| 33 | inherit fs-uuid | ||
| 34 | 2 | ||
| 35 | efi_populate() { | 3 | efi_populate() { |
| 36 | # DEST must be the root of the image so that EFIDIR is not | 4 | # DEST must be the root of the image so that EFIDIR is not |
| @@ -69,91 +37,3 @@ efi_iso_populate() { | |||
| 69 | efi_hddimg_populate() { | 37 | efi_hddimg_populate() { |
| 70 | efi_populate $1 | 38 | efi_populate $1 |
| 71 | } | 39 | } |
| 72 | |||
| 73 | python build_efi_cfg() { | ||
| 74 | import sys | ||
| 75 | |||
| 76 | workdir = d.getVar('WORKDIR') | ||
| 77 | if not workdir: | ||
| 78 | bb.error("WORKDIR not defined, unable to package") | ||
| 79 | return | ||
| 80 | |||
| 81 | gfxserial = d.getVar('GRUB_GFXSERIAL') or "" | ||
| 82 | |||
| 83 | labels = d.getVar('LABELS') | ||
| 84 | if not labels: | ||
| 85 | bb.debug(1, "LABELS not defined, nothing to do") | ||
| 86 | return | ||
| 87 | |||
| 88 | if labels == []: | ||
| 89 | bb.debug(1, "No labels, nothing to do") | ||
| 90 | return | ||
| 91 | |||
| 92 | cfile = d.getVar('GRUB_CFG') | ||
| 93 | if not cfile: | ||
| 94 | bb.fatal('Unable to read GRUB_CFG') | ||
| 95 | |||
| 96 | try: | ||
| 97 | cfgfile = open(cfile, 'w') | ||
| 98 | except OSError: | ||
| 99 | bb.fatal('Unable to open %s' % cfile) | ||
| 100 | |||
| 101 | cfgfile.write('# Automatically created by OE\n') | ||
| 102 | |||
| 103 | opts = d.getVar('GRUB_OPTS') | ||
| 104 | if opts: | ||
| 105 | for opt in opts.split(';'): | ||
| 106 | cfgfile.write('%s\n' % opt) | ||
| 107 | |||
| 108 | cfgfile.write('default=%s\n' % (labels.split()[0])) | ||
| 109 | |||
| 110 | timeout = d.getVar('GRUB_TIMEOUT') | ||
| 111 | if timeout: | ||
| 112 | cfgfile.write('timeout=%s\n' % timeout) | ||
| 113 | else: | ||
| 114 | cfgfile.write('timeout=50\n') | ||
| 115 | |||
| 116 | root = d.getVar('GRUB_ROOT') | ||
| 117 | if not root: | ||
| 118 | bb.fatal('GRUB_ROOT not defined') | ||
| 119 | |||
| 120 | if gfxserial == "1": | ||
| 121 | btypes = [ [ " graphics console", "" ], | ||
| 122 | [ " serial console", d.getVar('GRUB_SERIAL') or "" ] ] | ||
| 123 | else: | ||
| 124 | btypes = [ [ "", "" ] ] | ||
| 125 | |||
| 126 | for label in labels.split(): | ||
| 127 | localdata = d.createCopy() | ||
| 128 | |||
| 129 | overrides = localdata.getVar('OVERRIDES') | ||
| 130 | if not overrides: | ||
| 131 | bb.fatal('OVERRIDES not defined') | ||
| 132 | |||
| 133 | for btype in btypes: | ||
| 134 | localdata.setVar('OVERRIDES', label + ':' + overrides) | ||
| 135 | |||
| 136 | cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0])) | ||
| 137 | lb = label | ||
| 138 | if label == "install": | ||
| 139 | lb = "install-efi" | ||
| 140 | cfgfile.write('linux /vmlinuz LABEL=%s' % (lb)) | ||
| 141 | |||
| 142 | cfgfile.write(' %s' % replace_rootfs_uuid(d, root)) | ||
| 143 | |||
| 144 | append = localdata.getVar('APPEND') | ||
| 145 | initrd = localdata.getVar('INITRD') | ||
| 146 | |||
| 147 | if append: | ||
| 148 | append = replace_rootfs_uuid(d, append) | ||
| 149 | cfgfile.write(' %s' % (append)) | ||
| 150 | |||
| 151 | cfgfile.write(' %s' % btype[1]) | ||
| 152 | cfgfile.write('\n') | ||
| 153 | |||
| 154 | if initrd: | ||
| 155 | cfgfile.write('initrd /initrd') | ||
| 156 | cfgfile.write('\n}\n') | ||
| 157 | |||
| 158 | cfgfile.close() | ||
| 159 | } | ||
