summaryrefslogtreecommitdiff
path: root/meta/classes/grub-efi.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/grub-efi.bbclass')
-rw-r--r--meta/classes/grub-efi.bbclass69
1 files changed, 44 insertions, 25 deletions
diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
index 5c80c177de..df7fe18a79 100644
--- a/meta/classes/grub-efi.bbclass
+++ b/meta/classes/grub-efi.bbclass
@@ -7,24 +7,31 @@
# Provide grub-efi specific functions for building bootable images.
# External variables
-# ${INITRD} - indicates a filesystem image to use as an initrd (optional)
+# ${INITRD} - indicates a list of filesystem images to concatenate and use as an initrd (optional)
# ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
# ${LABELS} - a list of targets for the automatic config
# ${APPEND} - an override list of append strings for each label
# ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
# ${GRUB_TIMEOUT} - timeout before executing the deault label (optional)
+# ${GRUB_ROOT} - grub's root device.
-do_bootimg[depends] += "grub-efi:do_deploy"
-do_bootdirectdisk[depends] += "grub-efi:do_deploy"
+do_bootimg[depends] += "${MLPREFIX}grub-efi:do_deploy"
+do_bootdirectdisk[depends] += "${MLPREFIX}grub-efi:do_deploy"
GRUB_SERIAL ?= "console=ttyS0,115200"
-GRUBCFG = "${S}/grub.cfg"
+GRUB_CFG_VM = "${S}/grub_vm.cfg"
+GRUB_CFG_LIVE = "${S}/grub_live.cfg"
GRUB_TIMEOUT ?= "10"
#FIXME: build this from the machine config
GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
EFIDIR = "/EFI/BOOT"
+GRUB_ROOT ?= "${ROOT}"
+APPEND ?= ""
+
+# Need UUID utility code.
+inherit fs-uuid
efi_populate() {
# DEST must be the root of the image so that EFIDIR is not
@@ -33,13 +40,17 @@ efi_populate() {
install -d ${DEST}${EFIDIR}
- GRUB_IMAGE="bootia32.efi"
+ GRUB_IMAGE="grub-efi-bootia32.efi"
+ DEST_IMAGE="bootia32.efi"
if [ "${TARGET_ARCH}" = "x86_64" ]; then
- GRUB_IMAGE="bootx64.efi"
+ GRUB_IMAGE="grub-efi-bootx64.efi"
+ DEST_IMAGE="bootx64.efi"
fi
- install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST}${EFIDIR}
+ install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST}${EFIDIR}/${DEST_IMAGE}
+ EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
+ printf 'fs0:%s\%s\n' "$EFIPATH" "$DEST_IMAGE" >${DEST}/startup.nsh
- install -m 0644 ${GRUBCFG} ${DEST}${EFIDIR}
+ install -m 0644 ${GRUB_CFG} ${DEST}${EFIDIR}/grub.cfg
}
efi_iso_populate() {
@@ -49,7 +60,8 @@ efi_iso_populate() {
mkdir -p ${EFIIMGDIR}/${EFIDIR}
cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
cp $iso_dir/vmlinuz ${EFIIMGDIR}
- echo "${GRUB_IMAGE}" > ${EFIIMGDIR}/startup.nsh
+ EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
+ printf 'fs0:%s\%s\n' "$EFIPATH" "$GRUB_IMAGE" > ${EFIIMGDIR}/startup.nsh
if [ -f "$iso_dir/initrd" ] ; then
cp $iso_dir/initrd ${EFIIMGDIR}
fi
@@ -62,14 +74,14 @@ efi_hddimg_populate() {
python build_efi_cfg() {
import sys
- workdir = d.getVar('WORKDIR', True)
+ workdir = d.getVar('WORKDIR')
if not workdir:
bb.error("WORKDIR not defined, unable to package")
return
- gfxserial = d.getVar('GRUB_GFXSERIAL', True) or ""
+ gfxserial = d.getVar('GRUB_GFXSERIAL') or ""
- labels = d.getVar('LABELS', True)
+ labels = d.getVar('LABELS')
if not labels:
bb.debug(1, "LABELS not defined, nothing to do")
return
@@ -78,46 +90,49 @@ python build_efi_cfg() {
bb.debug(1, "No labels, nothing to do")
return
- cfile = d.getVar('GRUBCFG', True)
+ cfile = d.getVar('GRUB_CFG')
if not cfile:
- raise bb.build.FuncFailed('Unable to read GRUBCFG')
+ bb.fatal('Unable to read GRUB_CFG')
try:
- cfgfile = file(cfile, 'w')
+ cfgfile = open(cfile, 'w')
except OSError:
- raise bb.build.funcFailed('Unable to open %s' % (cfile))
+ bb.fatal('Unable to open %s' % cfile)
cfgfile.write('# Automatically created by OE\n')
- opts = d.getVar('GRUB_OPTS', True)
+ opts = d.getVar('GRUB_OPTS')
if opts:
for opt in opts.split(';'):
cfgfile.write('%s\n' % opt)
cfgfile.write('default=%s\n' % (labels.split()[0]))
- timeout = d.getVar('GRUB_TIMEOUT', True)
+ timeout = d.getVar('GRUB_TIMEOUT')
if timeout:
cfgfile.write('timeout=%s\n' % timeout)
else:
cfgfile.write('timeout=50\n')
+ root = d.getVar('GRUB_ROOT')
+ if not root:
+ bb.fatal('GRUB_ROOT not defined')
+
if gfxserial == "1":
btypes = [ [ " graphics console", "" ],
- [ " serial console", d.getVar('GRUB_SERIAL', True) or "" ] ]
+ [ " serial console", d.getVar('GRUB_SERIAL') or "" ] ]
else:
btypes = [ [ "", "" ] ]
for label in labels.split():
localdata = d.createCopy()
- overrides = localdata.getVar('OVERRIDES', True)
+ overrides = localdata.getVar('OVERRIDES')
if not overrides:
- raise bb.build.FuncFailed('OVERRIDES not defined')
+ bb.fatal('OVERRIDES not defined')
for btype in btypes:
localdata.setVar('OVERRIDES', label + ':' + overrides)
- bb.data.update_data(localdata)
cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
lb = label
@@ -125,11 +140,15 @@ python build_efi_cfg() {
lb = "install-efi"
cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
- append = localdata.getVar('APPEND', True)
- initrd = localdata.getVar('INITRD', True)
+ cfgfile.write(' %s' % replace_rootfs_uuid(d, root))
+
+ append = localdata.getVar('APPEND')
+ initrd = localdata.getVar('INITRD')
if append:
- cfgfile.write('%s' % (append))
+ append = replace_rootfs_uuid(d, append)
+ cfgfile.write(' %s' % (append))
+
cfgfile.write(' %s' % btype[1])
cfgfile.write('\n')