diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2015-12-01 07:43:35 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-09 08:48:24 +0000 |
commit | 70338732ac7d6cf8a012e6861c316bcbd66e1328 (patch) | |
tree | ffad4916a8735fd07161a94e32954e2b31d50086 /scripts/lib/wic/plugins/source/bootimg-efi.py | |
parent | f95f729518296177a6280a6e19a0c1433d499710 (diff) | |
download | poky-70338732ac7d6cf8a012e6861c316bcbd66e1328.tar.gz |
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>
Diffstat (limited to 'scripts/lib/wic/plugins/source/bootimg-efi.py')
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index fa63c6abda..5feb79dbf1 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py | |||
@@ -29,6 +29,7 @@ import shutil | |||
29 | 29 | ||
30 | from wic import kickstart, msger | 30 | from wic import kickstart, msger |
31 | from wic.pluginbase import SourcePlugin | 31 | from wic.pluginbase import SourcePlugin |
32 | from wic.utils.misc import get_custom_config | ||
32 | from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \ | 33 | from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \ |
33 | BOOTDD_EXTRA_SPACE | 34 | BOOTDD_EXTRA_SPACE |
34 | 35 | ||
@@ -45,22 +46,37 @@ class BootimgEFIPlugin(SourcePlugin): | |||
45 | """ | 46 | """ |
46 | Create loader-specific (grub-efi) config | 47 | Create loader-specific (grub-efi) config |
47 | """ | 48 | """ |
48 | options = creator.ks.handler.bootloader.appendLine | 49 | configfile = kickstart.get_bootloader_file(creator.ks) |
50 | custom_cfg = None | ||
51 | if configfile: | ||
52 | custom_cfg = get_custom_config(configfile) | ||
53 | if custom_cfg: | ||
54 | # Use a custom configuration for grub | ||
55 | grubefi_conf = custom_cfg | ||
56 | msger.debug("Using custom configuration file " | ||
57 | "%s for grub.cfg" % configfile) | ||
58 | else: | ||
59 | msger.error("configfile is specified but failed to " | ||
60 | "get it from %s." % configfile) | ||
49 | 61 | ||
50 | grubefi_conf = "" | 62 | if not custom_cfg: |
51 | grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n" | 63 | # Create grub configuration using parameters from wks file |
52 | grubefi_conf += "default=boot\n" | 64 | options = creator.ks.handler.bootloader.appendLine |
53 | timeout = kickstart.get_timeout(creator.ks) | 65 | |
54 | if not timeout: | 66 | grubefi_conf = "" |
55 | timeout = 0 | 67 | grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n" |
56 | grubefi_conf += "timeout=%s\n" % timeout | 68 | grubefi_conf += "default=boot\n" |
57 | grubefi_conf += "menuentry 'boot'{\n" | 69 | timeout = kickstart.get_timeout(creator.ks) |
70 | if not timeout: | ||
71 | timeout = 0 | ||
72 | grubefi_conf += "timeout=%s\n" % timeout | ||
73 | grubefi_conf += "menuentry 'boot'{\n" | ||
58 | 74 | ||
59 | kernel = "/bzImage" | 75 | kernel = "/bzImage" |
60 | 76 | ||
61 | grubefi_conf += "linux %s root=%s rootwait %s\n" \ | 77 | grubefi_conf += "linux %s root=%s rootwait %s\n" \ |
62 | % (kernel, creator.rootdev, options) | 78 | % (kernel, creator.rootdev, options) |
63 | grubefi_conf += "}\n" | 79 | grubefi_conf += "}\n" |
64 | 80 | ||
65 | msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \ | 81 | msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \ |
66 | % cr_workdir) | 82 | % cr_workdir) |
@@ -95,12 +111,27 @@ class BootimgEFIPlugin(SourcePlugin): | |||
95 | cfg.write(loader_conf) | 111 | cfg.write(loader_conf) |
96 | cfg.close() | 112 | cfg.close() |
97 | 113 | ||
98 | kernel = "/bzImage" | 114 | configfile = kickstart.get_bootloader_file(creator.ks) |
115 | custom_cfg = None | ||
116 | if configfile: | ||
117 | custom_cfg = get_custom_config(configfile) | ||
118 | if custom_cfg: | ||
119 | # Use a custom configuration for gummiboot | ||
120 | boot_conf = custom_cfg | ||
121 | msger.debug("Using custom configuration file " | ||
122 | "%s for gummiboots's boot.conf" % configfile) | ||
123 | else: | ||
124 | msger.error("configfile is specified but failed to " | ||
125 | "get it from %s." % configfile) | ||
126 | |||
127 | if not custom_cfg: | ||
128 | # Create gummiboot configuration using parameters from wks file | ||
129 | kernel = "/bzImage" | ||
99 | 130 | ||
100 | boot_conf = "" | 131 | boot_conf = "" |
101 | boot_conf += "title boot\n" | 132 | boot_conf += "title boot\n" |
102 | boot_conf += "linux %s\n" % kernel | 133 | boot_conf += "linux %s\n" % kernel |
103 | boot_conf += "options LABEL=Boot root=%s %s\n" % (creator.rootdev, options) | 134 | boot_conf += "options LABEL=Boot root=%s %s\n" % (creator.rootdev, options) |
104 | 135 | ||
105 | msger.debug("Writing gummiboot config %s/hdd/boot/loader/entries/boot.conf" \ | 136 | msger.debug("Writing gummiboot config %s/hdd/boot/loader/entries/boot.conf" \ |
106 | % cr_workdir) | 137 | % cr_workdir) |