mirror of
https://git.yoctoproject.org/poky
synced 2026-01-29 21:08:42 +01:00
wic: Allow to use a custom config for bootloaders
This change will allow to use a user defined file as the configuration for the bootloaders (grub, gummiboot, syslinux). The config file is defined in the wks file with the "configfile" option in the bootloader line. [YOCTO #8728] (From OE-Core rev: d56546b0f312fd042b1a7df3bef97ac1c9b6a5b4) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
f95f729518
commit
70338732ac
@@ -29,6 +29,7 @@ import shutil
|
||||
|
||||
from wic import kickstart, msger
|
||||
from wic.pluginbase import SourcePlugin
|
||||
from wic.utils.misc import get_custom_config
|
||||
from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \
|
||||
BOOTDD_EXTRA_SPACE
|
||||
|
||||
@@ -45,22 +46,37 @@ class BootimgEFIPlugin(SourcePlugin):
|
||||
"""
|
||||
Create loader-specific (grub-efi) config
|
||||
"""
|
||||
options = creator.ks.handler.bootloader.appendLine
|
||||
configfile = kickstart.get_bootloader_file(creator.ks)
|
||||
custom_cfg = None
|
||||
if configfile:
|
||||
custom_cfg = get_custom_config(configfile)
|
||||
if custom_cfg:
|
||||
# Use a custom configuration for grub
|
||||
grubefi_conf = custom_cfg
|
||||
msger.debug("Using custom configuration file "
|
||||
"%s for grub.cfg" % configfile)
|
||||
else:
|
||||
msger.error("configfile is specified but failed to "
|
||||
"get it from %s." % configfile)
|
||||
|
||||
grubefi_conf = ""
|
||||
grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n"
|
||||
grubefi_conf += "default=boot\n"
|
||||
timeout = kickstart.get_timeout(creator.ks)
|
||||
if not timeout:
|
||||
timeout = 0
|
||||
grubefi_conf += "timeout=%s\n" % timeout
|
||||
grubefi_conf += "menuentry 'boot'{\n"
|
||||
if not custom_cfg:
|
||||
# Create grub configuration using parameters from wks file
|
||||
options = creator.ks.handler.bootloader.appendLine
|
||||
|
||||
kernel = "/bzImage"
|
||||
grubefi_conf = ""
|
||||
grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n"
|
||||
grubefi_conf += "default=boot\n"
|
||||
timeout = kickstart.get_timeout(creator.ks)
|
||||
if not timeout:
|
||||
timeout = 0
|
||||
grubefi_conf += "timeout=%s\n" % timeout
|
||||
grubefi_conf += "menuentry 'boot'{\n"
|
||||
|
||||
grubefi_conf += "linux %s root=%s rootwait %s\n" \
|
||||
% (kernel, creator.rootdev, options)
|
||||
grubefi_conf += "}\n"
|
||||
kernel = "/bzImage"
|
||||
|
||||
grubefi_conf += "linux %s root=%s rootwait %s\n" \
|
||||
% (kernel, creator.rootdev, options)
|
||||
grubefi_conf += "}\n"
|
||||
|
||||
msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \
|
||||
% cr_workdir)
|
||||
@@ -95,12 +111,27 @@ class BootimgEFIPlugin(SourcePlugin):
|
||||
cfg.write(loader_conf)
|
||||
cfg.close()
|
||||
|
||||
kernel = "/bzImage"
|
||||
configfile = kickstart.get_bootloader_file(creator.ks)
|
||||
custom_cfg = None
|
||||
if configfile:
|
||||
custom_cfg = get_custom_config(configfile)
|
||||
if custom_cfg:
|
||||
# Use a custom configuration for gummiboot
|
||||
boot_conf = custom_cfg
|
||||
msger.debug("Using custom configuration file "
|
||||
"%s for gummiboots's boot.conf" % configfile)
|
||||
else:
|
||||
msger.error("configfile is specified but failed to "
|
||||
"get it from %s." % configfile)
|
||||
|
||||
boot_conf = ""
|
||||
boot_conf += "title boot\n"
|
||||
boot_conf += "linux %s\n" % kernel
|
||||
boot_conf += "options LABEL=Boot root=%s %s\n" % (creator.rootdev, options)
|
||||
if not custom_cfg:
|
||||
# Create gummiboot configuration using parameters from wks file
|
||||
kernel = "/bzImage"
|
||||
|
||||
boot_conf = ""
|
||||
boot_conf += "title boot\n"
|
||||
boot_conf += "linux %s\n" % kernel
|
||||
boot_conf += "options LABEL=Boot root=%s %s\n" % (creator.rootdev, options)
|
||||
|
||||
msger.debug("Writing gummiboot config %s/hdd/boot/loader/entries/boot.conf" \
|
||||
% cr_workdir)
|
||||
|
||||
@@ -29,6 +29,7 @@ import os
|
||||
from wic.utils.errors import ImageError
|
||||
from wic import kickstart, msger
|
||||
from wic.utils import runner
|
||||
from wic.utils.misc import get_custom_config
|
||||
from wic.pluginbase import SourcePlugin
|
||||
from wic.utils.oe.misc import exec_cmd, exec_native_cmd, \
|
||||
get_bitbake_var, BOOTDD_EXTRA_SPACE
|
||||
@@ -83,34 +84,49 @@ class BootimgPcbiosPlugin(SourcePlugin):
|
||||
install_cmd = "install -d %s" % hdddir
|
||||
exec_cmd(install_cmd)
|
||||
|
||||
splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg")
|
||||
if os.path.exists(splash):
|
||||
splashline = "menu background splash.jpg"
|
||||
else:
|
||||
splashline = ""
|
||||
configfile = kickstart.get_bootloader_file(creator.ks)
|
||||
custom_cfg = None
|
||||
if configfile:
|
||||
custom_cfg = get_custom_config(configfile)
|
||||
if custom_cfg:
|
||||
# Use a custom configuration for grub
|
||||
syslinux_conf = custom_cfg
|
||||
msger.debug("Using custom configuration file "
|
||||
"%s for syslinux.cfg" % configfile)
|
||||
else:
|
||||
msger.error("configfile is specified but failed to "
|
||||
"get it from %s." % configfile)
|
||||
|
||||
options = creator.ks.handler.bootloader.appendLine
|
||||
if not custom_cfg:
|
||||
# Create syslinux configuration using parameters from wks file
|
||||
splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg")
|
||||
if os.path.exists(splash):
|
||||
splashline = "menu background splash.jpg"
|
||||
else:
|
||||
splashline = ""
|
||||
|
||||
syslinux_conf = ""
|
||||
syslinux_conf += "PROMPT 0\n"
|
||||
timeout = kickstart.get_timeout(creator.ks)
|
||||
if not timeout:
|
||||
timeout = 0
|
||||
syslinux_conf += "TIMEOUT " + str(timeout) + "\n"
|
||||
syslinux_conf += "\n"
|
||||
syslinux_conf += "ALLOWOPTIONS 1\n"
|
||||
syslinux_conf += "SERIAL 0 115200\n"
|
||||
syslinux_conf += "\n"
|
||||
if splashline:
|
||||
syslinux_conf += "%s\n" % splashline
|
||||
syslinux_conf += "DEFAULT boot\n"
|
||||
syslinux_conf += "LABEL boot\n"
|
||||
options = creator.ks.handler.bootloader.appendLine
|
||||
|
||||
kernel = "/vmlinuz"
|
||||
syslinux_conf += "KERNEL " + kernel + "\n"
|
||||
syslinux_conf = ""
|
||||
syslinux_conf += "PROMPT 0\n"
|
||||
timeout = kickstart.get_timeout(creator.ks)
|
||||
if not timeout:
|
||||
timeout = 0
|
||||
syslinux_conf += "TIMEOUT " + str(timeout) + "\n"
|
||||
syslinux_conf += "\n"
|
||||
syslinux_conf += "ALLOWOPTIONS 1\n"
|
||||
syslinux_conf += "SERIAL 0 115200\n"
|
||||
syslinux_conf += "\n"
|
||||
if splashline:
|
||||
syslinux_conf += "%s\n" % splashline
|
||||
syslinux_conf += "DEFAULT boot\n"
|
||||
syslinux_conf += "LABEL boot\n"
|
||||
|
||||
syslinux_conf += "APPEND label=boot root=%s %s\n" % \
|
||||
(creator.rootdev, options)
|
||||
kernel = "/vmlinuz"
|
||||
syslinux_conf += "KERNEL " + kernel + "\n"
|
||||
|
||||
syslinux_conf += "APPEND label=boot root=%s %s\n" % \
|
||||
(creator.rootdev, options)
|
||||
|
||||
msger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg" \
|
||||
% cr_workdir)
|
||||
|
||||
Reference in New Issue
Block a user