summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source/bootimg-pcbios.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/plugins/source/bootimg-pcbios.py')
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-pcbios.py41
1 files changed, 24 insertions, 17 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index e5f6a328ed..590d3d6784 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -24,9 +24,10 @@
24# Tom Zanussi <tom.zanussi (at] linux.intel.com> 24# Tom Zanussi <tom.zanussi (at] linux.intel.com>
25# 25#
26 26
27import logging
27import os 28import os
29import sys
28 30
29from wic import msger
30from wic.engine import get_custom_config 31from wic.engine import get_custom_config
31from wic.utils import runner 32from wic.utils import runner
32from wic.utils.errors import ImageError 33from wic.utils.errors import ImageError
@@ -34,6 +35,8 @@ from wic.pluginbase import SourcePlugin
34from wic.utils.misc import (exec_cmd, exec_native_cmd, 35from wic.utils.misc import (exec_cmd, exec_native_cmd,
35 get_bitbake_var, BOOTDD_EXTRA_SPACE) 36 get_bitbake_var, BOOTDD_EXTRA_SPACE)
36 37
38logger = logging.getLogger('wic')
39
37class BootimgPcbiosPlugin(SourcePlugin): 40class BootimgPcbiosPlugin(SourcePlugin):
38 """ 41 """
39 Create MBR boot partition and install syslinux on it. 42 Create MBR boot partition and install syslinux on it.
@@ -54,16 +57,18 @@ class BootimgPcbiosPlugin(SourcePlugin):
54 elif creator.ptable_format == 'gpt': 57 elif creator.ptable_format == 'gpt':
55 mbrfile += "gptmbr.bin" 58 mbrfile += "gptmbr.bin"
56 else: 59 else:
57 msger.error("Unsupported partition table: %s" % creator.ptable_format) 60 logger.error("Unsupported partition table: %s", creator.ptable_format)
61 sys.exit(1)
58 62
59 if not os.path.exists(mbrfile): 63 if not os.path.exists(mbrfile):
60 msger.error("Couldn't find %s. If using the -e option, do you " 64 logger.error("Couldn't find %s. If using the -e option, do you "
61 "have the right MACHINE set in local.conf? If not, " 65 "have the right MACHINE set in local.conf? If not, "
62 "is the bootimg_dir path correct?" % mbrfile) 66 "is the bootimg_dir path correct?", mbrfile)
67 sys.exit(1)
63 68
64 full_path = creator._full_path(workdir, disk_name, "direct") 69 full_path = creator._full_path(workdir, disk_name, "direct")
65 msger.debug("Installing MBR on disk %s as %s with size %s bytes" \ 70 logger.debug("Installing MBR on disk %s as %s with size %s bytes",
66 % (disk_name, full_path, disk.min_size)) 71 disk_name, full_path, disk.min_size)
67 72
68 rcode = runner.show(['dd', 'if=%s' % mbrfile, 73 rcode = runner.show(['dd', 'if=%s' % mbrfile,
69 'of=%s' % full_path, 'conv=notrunc']) 74 'of=%s' % full_path, 'conv=notrunc'])
@@ -90,11 +95,11 @@ class BootimgPcbiosPlugin(SourcePlugin):
90 if custom_cfg: 95 if custom_cfg:
91 # Use a custom configuration for grub 96 # Use a custom configuration for grub
92 syslinux_conf = custom_cfg 97 syslinux_conf = custom_cfg
93 msger.debug("Using custom configuration file " 98 logger.debug("Using custom configuration file %s "
94 "%s for syslinux.cfg" % bootloader.configfile) 99 "for syslinux.cfg", bootloader.configfile)
95 else: 100 else:
96 msger.error("configfile is specified but failed to " 101 logger.error("configfile is specified but failed to "
97 "get it from %s." % bootloader.configfile) 102 "get it from %s.", bootloader.configfile)
98 103
99 if not custom_cfg: 104 if not custom_cfg:
100 # Create syslinux configuration using parameters from wks file 105 # Create syslinux configuration using parameters from wks file
@@ -122,8 +127,8 @@ class BootimgPcbiosPlugin(SourcePlugin):
122 syslinux_conf += "APPEND label=boot root=%s %s\n" % \ 127 syslinux_conf += "APPEND label=boot root=%s %s\n" % \
123 (creator.rootdev, bootloader.append) 128 (creator.rootdev, bootloader.append)
124 129
125 msger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg" \ 130 logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg",
126 % cr_workdir) 131 cr_workdir)
127 cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w") 132 cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w")
128 cfg.write(syslinux_conf) 133 cfg.write(syslinux_conf)
129 cfg.close() 134 cfg.close()
@@ -147,9 +152,11 @@ class BootimgPcbiosPlugin(SourcePlugin):
147 if not _has_syslinux(bootimg_dir): 152 if not _has_syslinux(bootimg_dir):
148 bootimg_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools") 153 bootimg_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools")
149 if not bootimg_dir: 154 if not bootimg_dir:
150 msger.error("Couldn't find STAGING_DATADIR, exiting\n") 155 logger.error("Couldn't find STAGING_DATADIR, exiting\n")
156 sys.exit(1)
151 if not _has_syslinux(bootimg_dir): 157 if not _has_syslinux(bootimg_dir):
152 msger.error("Please build syslinux first\n") 158 logger.error("Please build syslinux first\n")
159 sys.exit(1)
153 # just so the result notes display it 160 # just so the result notes display it
154 creator.bootimg_dir = bootimg_dir 161 creator.bootimg_dir = bootimg_dir
155 162
@@ -176,8 +183,8 @@ class BootimgPcbiosPlugin(SourcePlugin):
176 183
177 blocks += extra_blocks 184 blocks += extra_blocks
178 185
179 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ 186 logger.debug("Added %d extra blocks to %s to get to %d total blocks",
180 (extra_blocks, part.mountpoint, blocks)) 187 extra_blocks, part.mountpoint, blocks)
181 188
182 # dosfs image, created by mkdosfs 189 # dosfs image, created by mkdosfs
183 bootimg = "%s/boot.img" % cr_workdir 190 bootimg = "%s/boot.img" % cr_workdir