diff options
Diffstat (limited to 'scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py')
-rw-r--r-- | scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py index 9e79a139da..ed5fbdfa9c 100644 --- a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py +++ b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py | |||
@@ -18,15 +18,18 @@ | |||
18 | # Adrian Freihofer <adrian.freihofer (at] neratec.com> | 18 | # Adrian Freihofer <adrian.freihofer (at] neratec.com> |
19 | # | 19 | # |
20 | 20 | ||
21 | import logging | ||
21 | import os | 22 | import os |
22 | import re | 23 | import re |
24 | import sys | ||
23 | 25 | ||
24 | from wic import msger | ||
25 | from wic.utils import runner | 26 | from wic.utils import runner |
26 | from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd | 27 | from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd |
27 | from wic.utils.errors import ImageError | 28 | from wic.utils.errors import ImageError |
28 | from wic.pluginbase import SourcePlugin | 29 | from wic.pluginbase import SourcePlugin |
29 | 30 | ||
31 | logger = logging.getLogger('wic') | ||
32 | |||
30 | def serial_console_form_kargs(kernel_args): | 33 | def serial_console_form_kargs(kernel_args): |
31 | """ | 34 | """ |
32 | Create SERIAL... line from kernel parameters | 35 | Create SERIAL... line from kernel parameters |
@@ -48,16 +51,16 @@ def serial_console_form_kargs(kernel_args): | |||
48 | syslinux_conf += " " + param_match.group(2) | 51 | syslinux_conf += " " + param_match.group(2) |
49 | # parity | 52 | # parity |
50 | if param_match.group(3) and param_match.group(3) != 'n': | 53 | if param_match.group(3) and param_match.group(3) != 'n': |
51 | msger.warning("syslinux does not support parity for console. {} is ignored." | 54 | logger.warning("syslinux does not support parity for console. " |
52 | .format(param_match.group(3))) | 55 | "%s is ignored.", param_match.group(3)) |
53 | # number of bits | 56 | # number of bits |
54 | if param_match.group(4) and param_match.group(4) != '8': | 57 | if param_match.group(4) and param_match.group(4) != '8': |
55 | msger.warning("syslinux supports 8 bit console configuration only. {} is ignored." | 58 | logger.warning("syslinux supports 8 bit console configuration " |
56 | .format(param_match.group(4))) | 59 | "only. %s is ignored.", param_match.group(4)) |
57 | # flow control | 60 | # flow control |
58 | if param_match.group(5) and param_match.group(5) != '': | 61 | if param_match.group(5) and param_match.group(5) != '': |
59 | msger.warning("syslinux console flowcontrol configuration. {} is ignored." | 62 | logger.warning("syslinux console flowcontrol configuration. " |
60 | .format(param_match.group(5))) | 63 | "%s is ignored.", param_match.group(5)) |
61 | break | 64 | break |
62 | 65 | ||
63 | return syslinux_conf | 66 | return syslinux_conf |
@@ -96,10 +99,10 @@ class RootfsPlugin(SourcePlugin): | |||
96 | 99 | ||
97 | image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) | 100 | image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) |
98 | if not os.path.isdir(image_rootfs_dir): | 101 | if not os.path.isdir(image_rootfs_dir): |
99 | msg = "No valid artifact IMAGE_ROOTFS from image named" | 102 | logger.error("No valid artifact IMAGE_ROOTFS from image named %s " |
100 | msg += " %s has been found at %s, exiting.\n" % \ | 103 | "has been found at %s, exiting.\n", |
101 | (rootfs_dir, image_rootfs_dir) | 104 | rootfs_dir, image_rootfs_dir) |
102 | msger.error(msg) | 105 | sys.exit(1) |
103 | 106 | ||
104 | return image_rootfs_dir | 107 | return image_rootfs_dir |
105 | 108 | ||
@@ -132,7 +135,7 @@ class RootfsPlugin(SourcePlugin): | |||
132 | (image_creator.rootdev, bootloader.append) | 135 | (image_creator.rootdev, bootloader.append) |
133 | 136 | ||
134 | syslinux_cfg = os.path.join(image_creator.rootfs_dir['ROOTFS_DIR'], "boot", "syslinux.cfg") | 137 | syslinux_cfg = os.path.join(image_creator.rootfs_dir['ROOTFS_DIR'], "boot", "syslinux.cfg") |
135 | msger.debug("Writing syslinux config %s" % syslinux_cfg) | 138 | logger.debug("Writing syslinux config %s", syslinux_cfg) |
136 | with open(syslinux_cfg, "w") as cfg: | 139 | with open(syslinux_cfg, "w") as cfg: |
137 | cfg.write(syslinux_conf) | 140 | cfg.write(syslinux_conf) |
138 | 141 | ||
@@ -154,15 +157,17 @@ class RootfsPlugin(SourcePlugin): | |||
154 | # Make sure syslinux-nomtools is available in native sysroot or fail | 157 | # Make sure syslinux-nomtools is available in native sysroot or fail |
155 | native_syslinux_nomtools = os.path.join(native_sysroot, "usr/bin/syslinux-nomtools") | 158 | native_syslinux_nomtools = os.path.join(native_sysroot, "usr/bin/syslinux-nomtools") |
156 | if not is_exe(native_syslinux_nomtools): | 159 | if not is_exe(native_syslinux_nomtools): |
157 | msger.info("building syslinux-native...") | 160 | logger.info("building syslinux-native...") |
158 | exec_cmd("bitbake syslinux-native") | 161 | exec_cmd("bitbake syslinux-native") |
159 | if not is_exe(native_syslinux_nomtools): | 162 | if not is_exe(native_syslinux_nomtools): |
160 | msger.error("Couldn't find syslinux-nomtools (%s), exiting\n" % | 163 | logger.error("Couldn't find syslinux-nomtools (%s), exiting\n", |
161 | native_syslinux_nomtools) | 164 | native_syslinux_nomtools) |
165 | sys.exit(1) | ||
162 | 166 | ||
163 | if part.rootfs is None: | 167 | if part.rootfs is None: |
164 | if 'ROOTFS_DIR' not in krootfs_dir: | 168 | if 'ROOTFS_DIR' not in krootfs_dir: |
165 | msger.error("Couldn't find --rootfs-dir, exiting") | 169 | logger.error("Couldn't find --rootfs-dir, exiting") |
170 | sys.exit(1) | ||
166 | rootfs_dir = krootfs_dir['ROOTFS_DIR'] | 171 | rootfs_dir = krootfs_dir['ROOTFS_DIR'] |
167 | else: | 172 | else: |
168 | if part.rootfs in krootfs_dir: | 173 | if part.rootfs in krootfs_dir: |
@@ -170,9 +175,9 @@ class RootfsPlugin(SourcePlugin): | |||
170 | elif part.rootfs: | 175 | elif part.rootfs: |
171 | rootfs_dir = part.rootfs | 176 | rootfs_dir = part.rootfs |
172 | else: | 177 | else: |
173 | msg = "Couldn't find --rootfs-dir=%s connection" | 178 | logger.error("Couldn't find --rootfs-dir=%s connection or " |
174 | msg += " or it is not a valid path, exiting" | 179 | "it is not a valid path, exiting", part.rootfs) |
175 | msger.error(msg % part.rootfs) | 180 | sys.exit(1) |
176 | 181 | ||
177 | real_rootfs_dir = cls._get_rootfs_dir(rootfs_dir) | 182 | real_rootfs_dir = cls._get_rootfs_dir(rootfs_dir) |
178 | 183 | ||
@@ -198,15 +203,18 @@ class RootfsPlugin(SourcePlugin): | |||
198 | elif image_creator.ptable_format == 'gpt': | 203 | elif image_creator.ptable_format == 'gpt': |
199 | mbrfile += "gptmbr.bin" | 204 | mbrfile += "gptmbr.bin" |
200 | else: | 205 | else: |
201 | msger.error("Unsupported partition table: %s" % \ | 206 | logger.error("Unsupported partition table: %s", |
202 | image_creator.ptable_format) | 207 | image_creator.ptable_format) |
208 | sys.exit(1) | ||
203 | 209 | ||
204 | if not os.path.exists(mbrfile): | 210 | if not os.path.exists(mbrfile): |
205 | msger.error("Couldn't find %s. Has syslinux-native been baked?" % mbrfile) | 211 | logger.error("Couldn't find %s. Has syslinux-native been baked?", |
212 | mbrfile) | ||
213 | sys.exit(1) | ||
206 | 214 | ||
207 | full_path = disk.path | 215 | full_path = disk.path |
208 | msger.debug("Installing MBR on disk %s as %s with size %s bytes" \ | 216 | logger.debug("Installing MBR on disk %s as %s with size %s bytes", |
209 | % (disk_name, full_path, disk.min_size)) | 217 | disk_name, full_path, disk.min_size) |
210 | 218 | ||
211 | ret_code = runner.show(['dd', 'if=%s' % mbrfile, 'of=%s' % full_path, 'conv=notrunc']) | 219 | ret_code = runner.show(['dd', 'if=%s' % mbrfile, 'of=%s' % full_path, 'conv=notrunc']) |
212 | if ret_code != 0: | 220 | if ret_code != 0: |