summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-02-14 20:13:46 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-04 23:18:16 +0000
commit1dd8cca63102b1718609c5e2903e1ea468c4c469 (patch)
treef777759b24a40426cbfbf6332f65f8f7d16b52ad /scripts
parent7c163ada95d2b304371f4d7a5dbef73ac37c1836 (diff)
downloadpoky-1dd8cca63102b1718609c5e2903e1ea468c4c469.tar.gz
wic: use wic logger in wic source plugins
Replaced msger with wic logger in wic source plugins. (From OE-Core rev: 19a868e9ad12fb27a7f713685d12f3d310fd6961) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-efi.py60
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-partition.py28
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-pcbios.py41
-rw-r--r--scripts/lib/wic/plugins/source/fsimage.py16
-rw-r--r--scripts/lib/wic/plugins/source/isoimage-isohybrid.py96
-rw-r--r--scripts/lib/wic/plugins/source/rawcopy.py14
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py24
-rw-r--r--scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py56
8 files changed, 200 insertions, 135 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 95316c80c0..e4c845129e 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -24,15 +24,18 @@
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
28import shutil 29import shutil
30import sys
29 31
30from wic import msger
31from wic.engine import get_custom_config 32from wic.engine import get_custom_config
32from wic.pluginbase import SourcePlugin 33from wic.pluginbase import SourcePlugin
33from wic.utils.misc import (exec_cmd, exec_native_cmd, get_bitbake_var, 34from wic.utils.misc import (exec_cmd, exec_native_cmd, get_bitbake_var,
34 BOOTDD_EXTRA_SPACE) 35 BOOTDD_EXTRA_SPACE)
35 36
37logger = logging.getLogger('wic')
38
36class BootimgEFIPlugin(SourcePlugin): 39class BootimgEFIPlugin(SourcePlugin):
37 """ 40 """
38 Create EFI boot partition. 41 Create EFI boot partition.
@@ -53,11 +56,12 @@ class BootimgEFIPlugin(SourcePlugin):
53 if custom_cfg: 56 if custom_cfg:
54 # Use a custom configuration for grub 57 # Use a custom configuration for grub
55 grubefi_conf = custom_cfg 58 grubefi_conf = custom_cfg
56 msger.debug("Using custom configuration file " 59 logger.debug("Using custom configuration file "
57 "%s for grub.cfg" % configfile) 60 "%s for grub.cfg", configfile)
58 else: 61 else:
59 msger.error("configfile is specified but failed to " 62 logger.error("configfile is specified but failed to "
60 "get it from %s." % configfile) 63 "get it from %s.", configfile)
64 sys.exit(1)
61 65
62 if not custom_cfg: 66 if not custom_cfg:
63 # Create grub configuration using parameters from wks file 67 # Create grub configuration using parameters from wks file
@@ -75,8 +79,8 @@ class BootimgEFIPlugin(SourcePlugin):
75 % (kernel, creator.rootdev, bootloader.append) 79 % (kernel, creator.rootdev, bootloader.append)
76 grubefi_conf += "}\n" 80 grubefi_conf += "}\n"
77 81
78 msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \ 82 logger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg",
79 % cr_workdir) 83 cr_workdir)
80 cfg = open("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, "w") 84 cfg = open("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, "w")
81 cfg.write(grubefi_conf) 85 cfg.write(grubefi_conf)
82 cfg.close() 86 cfg.close()
@@ -104,15 +108,16 @@ class BootimgEFIPlugin(SourcePlugin):
104 # obviously we need to have a common common deploy var 108 # obviously we need to have a common common deploy var
105 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 109 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
106 if not bootimg_dir: 110 if not bootimg_dir:
107 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") 111 logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
112 sys.exit(1)
108 113
109 cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir) 114 cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir)
110 exec_cmd(cp_cmd, True) 115 exec_cmd(cp_cmd, True)
111 else: 116 else:
112 msger.debug("Ignoring missing initrd") 117 logger.debug("Ignoring missing initrd")
113 118
114 msger.debug("Writing systemd-boot config %s/hdd/boot/loader/loader.conf" \ 119 logger.debug("Writing systemd-boot config "
115 % cr_workdir) 120 "%s/hdd/boot/loader/loader.conf", cr_workdir)
116 cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w") 121 cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w")
117 cfg.write(loader_conf) 122 cfg.write(loader_conf)
118 cfg.close() 123 cfg.close()
@@ -124,11 +129,12 @@ class BootimgEFIPlugin(SourcePlugin):
124 if custom_cfg: 129 if custom_cfg:
125 # Use a custom configuration for systemd-boot 130 # Use a custom configuration for systemd-boot
126 boot_conf = custom_cfg 131 boot_conf = custom_cfg
127 msger.debug("Using custom configuration file " 132 logger.debug("Using custom configuration file "
128 "%s for systemd-boots's boot.conf" % configfile) 133 "%s for systemd-boots's boot.conf", configfile)
129 else: 134 else:
130 msger.error("configfile is specified but failed to " 135 logger.error("configfile is specified but failed to "
131 "get it from %s." % configfile) 136 "get it from %s.", configfile)
137 sys.exit(1)
132 138
133 if not custom_cfg: 139 if not custom_cfg:
134 # Create systemd-boot configuration using parameters from wks file 140 # Create systemd-boot configuration using parameters from wks file
@@ -143,8 +149,8 @@ class BootimgEFIPlugin(SourcePlugin):
143 if initrd: 149 if initrd:
144 boot_conf += "initrd /%s\n" % initrd 150 boot_conf += "initrd /%s\n" % initrd
145 151
146 msger.debug("Writing systemd-boot config %s/hdd/boot/loader/entries/boot.conf" \ 152 logger.debug("Writing systemd-boot config "
147 % cr_workdir) 153 "%s/hdd/boot/loader/entries/boot.conf", cr_workdir)
148 cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w") 154 cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w")
149 cfg.write(boot_conf) 155 cfg.write(boot_conf)
150 cfg.close() 156 cfg.close()
@@ -168,9 +174,11 @@ class BootimgEFIPlugin(SourcePlugin):
168 elif source_params['loader'] == 'systemd-boot': 174 elif source_params['loader'] == 'systemd-boot':
169 cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params) 175 cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
170 else: 176 else:
171 msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader']) 177 logger.error("unrecognized bootimg-efi loader: %s", source_params['loader'])
178 sys.exit(1)
172 except KeyError: 179 except KeyError:
173 msger.error("bootimg-efi requires a loader, none specified") 180 logger.error("bootimg-efi requires a loader, none specified")
181 sys.exit(1)
174 182
175 183
176 @classmethod 184 @classmethod
@@ -185,7 +193,8 @@ class BootimgEFIPlugin(SourcePlugin):
185 if not bootimg_dir: 193 if not bootimg_dir:
186 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 194 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
187 if not bootimg_dir: 195 if not bootimg_dir:
188 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") 196 logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
197 sys.exit(1)
189 # just so the result notes display it 198 # just so the result notes display it
190 creator.bootimg_dir = bootimg_dir 199 creator.bootimg_dir = bootimg_dir
191 200
@@ -212,9 +221,12 @@ class BootimgEFIPlugin(SourcePlugin):
212 cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (bootimg_dir, mod, hdddir, mod[8:]) 221 cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (bootimg_dir, mod, hdddir, mod[8:])
213 exec_cmd(cp_cmd, True) 222 exec_cmd(cp_cmd, True)
214 else: 223 else:
215 msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader']) 224 logger.error("unrecognized bootimg-efi loader: %s",
225 source_params['loader'])
226 sys.exit(1)
216 except KeyError: 227 except KeyError:
217 msger.error("bootimg-efi requires a loader, none specified") 228 logger.error("bootimg-efi requires a loader, none specified")
229 sys.exit(1)
218 230
219 startup = os.path.join(bootimg_dir, "startup.nsh") 231 startup = os.path.join(bootimg_dir, "startup.nsh")
220 if os.path.exists(startup): 232 if os.path.exists(startup):
@@ -232,8 +244,8 @@ class BootimgEFIPlugin(SourcePlugin):
232 244
233 blocks += extra_blocks 245 blocks += extra_blocks
234 246
235 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ 247 logger.debug("Added %d extra blocks to %s to get to %d total blocks",
236 (extra_blocks, part.mountpoint, blocks)) 248 extra_blocks, part.mountpoint, blocks)
237 249
238 # dosfs image, created by mkdosfs 250 # dosfs image, created by mkdosfs
239 bootimg = "%s/boot.img" % cr_workdir 251 bootimg = "%s/boot.img" % cr_workdir
diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
index e0d9a50585..b4869154fe 100644
--- a/scripts/lib/wic/plugins/source/bootimg-partition.py
+++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
@@ -23,15 +23,18 @@
23# Maciej Borzecki <maciej.borzecki (at] open-rnd.pl> 23# Maciej Borzecki <maciej.borzecki (at] open-rnd.pl>
24# 24#
25 25
26import logging
26import os 27import os
27import re 28import re
29import sys
28 30
29from glob import glob 31from glob import glob
30 32
31from wic import msger
32from wic.pluginbase import SourcePlugin 33from wic.pluginbase import SourcePlugin
33from wic.utils.misc import exec_cmd, get_bitbake_var 34from wic.utils.misc import exec_cmd, get_bitbake_var
34 35
36logger = logging.getLogger('wic')
37
35class BootimgPartitionPlugin(SourcePlugin): 38class BootimgPartitionPlugin(SourcePlugin):
36 """ 39 """
37 Create an image of boot partition, copying over files 40 Create an image of boot partition, copying over files
@@ -78,16 +81,18 @@ class BootimgPartitionPlugin(SourcePlugin):
78 if not bootimg_dir: 81 if not bootimg_dir:
79 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 82 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
80 if not bootimg_dir: 83 if not bootimg_dir:
81 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") 84 logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
85 sys.exit(1)
82 86
83 msger.debug('Bootimg dir: %s' % bootimg_dir) 87 logger.debug('Bootimg dir: %s', bootimg_dir)
84 88
85 boot_files = get_bitbake_var("IMAGE_BOOT_FILES") 89 boot_files = get_bitbake_var("IMAGE_BOOT_FILES")
86 90
87 if not boot_files: 91 if not boot_files:
88 msger.error('No boot files defined, IMAGE_BOOT_FILES unset') 92 logger.error('No boot files defined, IMAGE_BOOT_FILES unset')
93 sys.exit(1)
89 94
90 msger.debug('Boot files: %s' % boot_files) 95 logger.debug('Boot files: %s', boot_files)
91 96
92 # list of tuples (src_name, dst_name) 97 # list of tuples (src_name, dst_name)
93 deploy_files = [] 98 deploy_files = []
@@ -95,11 +100,12 @@ class BootimgPartitionPlugin(SourcePlugin):
95 if ';' in src_entry: 100 if ';' in src_entry:
96 dst_entry = tuple(src_entry.split(';')) 101 dst_entry = tuple(src_entry.split(';'))
97 if not dst_entry[0] or not dst_entry[1]: 102 if not dst_entry[0] or not dst_entry[1]:
98 msger.error('Malformed boot file entry: %s' % (src_entry)) 103 logger.error('Malformed boot file entry: %s', src_entry)
104 sys.exit(1)
99 else: 105 else:
100 dst_entry = (src_entry, src_entry) 106 dst_entry = (src_entry, src_entry)
101 107
102 msger.debug('Destination entry: %r' % (dst_entry,)) 108 logger.debug('Destination entry: %r', dst_entry)
103 deploy_files.append(dst_entry) 109 deploy_files.append(dst_entry)
104 110
105 for deploy_entry in deploy_files: 111 for deploy_entry in deploy_files:
@@ -117,7 +123,7 @@ class BootimgPartitionPlugin(SourcePlugin):
117 123
118 srcs = glob(os.path.join(bootimg_dir, src)) 124 srcs = glob(os.path.join(bootimg_dir, src))
119 125
120 msger.debug('Globbed sources: %s' % (', '.join(srcs))) 126 logger.debug('Globbed sources: %s', ', '.join(srcs))
121 for entry in srcs: 127 for entry in srcs:
122 entry_dst_name = entry_name_fn(entry) 128 entry_dst_name = entry_name_fn(entry)
123 install_task.append((entry, 129 install_task.append((entry,
@@ -129,12 +135,12 @@ class BootimgPartitionPlugin(SourcePlugin):
129 135
130 for task in install_task: 136 for task in install_task:
131 src_path, dst_path = task 137 src_path, dst_path = task
132 msger.debug('Install %s as %s' % (os.path.basename(src_path), 138 logger.debug('Install %s as %s',
133 dst_path)) 139 os.path.basename(src_path), dst_path)
134 install_cmd = "install -m 0644 -D %s %s" \ 140 install_cmd = "install -m 0644 -D %s %s" \
135 % (src_path, dst_path) 141 % (src_path, dst_path)
136 exec_cmd(install_cmd) 142 exec_cmd(install_cmd)
137 143
138 msger.debug('Prepare boot partition using rootfs in %s' % (hdddir)) 144 logger.debug('Prepare boot partition using rootfs in %s', hdddir)
139 part.prepare_rootfs(cr_workdir, oe_builddir, hdddir, 145 part.prepare_rootfs(cr_workdir, oe_builddir, hdddir,
140 native_sysroot) 146 native_sysroot)
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
diff --git a/scripts/lib/wic/plugins/source/fsimage.py b/scripts/lib/wic/plugins/source/fsimage.py
index 9193892ae1..35fb78b832 100644
--- a/scripts/lib/wic/plugins/source/fsimage.py
+++ b/scripts/lib/wic/plugins/source/fsimage.py
@@ -15,12 +15,15 @@
15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16# 16#
17 17
18import logging
18import os 19import os
20import sys
19 21
20from wic import msger
21from wic.pluginbase import SourcePlugin 22from wic.pluginbase import SourcePlugin
22from wic.utils.misc import get_bitbake_var 23from wic.utils.misc import get_bitbake_var
23 24
25logger = logging.getLogger('wic')
26
24class FSImagePlugin(SourcePlugin): 27class FSImagePlugin(SourcePlugin):
25 """ 28 """
26 Add an already existing filesystem image to the partition layout. 29 Add an already existing filesystem image to the partition layout.
@@ -58,16 +61,17 @@ class FSImagePlugin(SourcePlugin):
58 if not bootimg_dir: 61 if not bootimg_dir:
59 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 62 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
60 if not bootimg_dir: 63 if not bootimg_dir:
61 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") 64 logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
65 sys.exit(1)
62 66
63 msger.debug('Bootimg dir: %s' % bootimg_dir) 67 logger.debug('Bootimg dir: %s', bootimg_dir)
64 68
65 if 'file' not in source_params: 69 if 'file' not in source_params:
66 msger.error("No file specified\n") 70 logger.error("No file specified\n")
67 return 71 sys.exit(1)
68 72
69 src = os.path.join(bootimg_dir, source_params['file']) 73 src = os.path.join(bootimg_dir, source_params['file'])
70 74
71 75
72 msger.debug('Preparing partition using image %s' % (src)) 76 logger.debug('Preparing partition using image %s', src)
73 part.prepare_rootfs_from_fs_image(cr_workdir, src, "") 77 part.prepare_rootfs_from_fs_image(cr_workdir, src, "")
diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
index fb34235631..33de6d8db5 100644
--- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
+++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
@@ -20,16 +20,19 @@
20# AUTHORS 20# AUTHORS
21# Mihaly Varga <mihaly.varga (at] ni.com> 21# Mihaly Varga <mihaly.varga (at] ni.com>
22 22
23import glob
24import logging
23import os 25import os
24import re 26import re
25import shutil 27import shutil
26import glob 28import sys
27 29
28from wic import msger
29from wic.engine import get_custom_config 30from wic.engine import get_custom_config
30from wic.pluginbase import SourcePlugin 31from wic.pluginbase import SourcePlugin
31from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var 32from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var
32 33
34logger = logging.getLogger('wic')
35
33class IsoImagePlugin(SourcePlugin): 36class IsoImagePlugin(SourcePlugin):
34 """ 37 """
35 Create a bootable ISO image 38 Create a bootable ISO image
@@ -85,8 +88,9 @@ class IsoImagePlugin(SourcePlugin):
85 syslinux_conf += "APPEND initrd=/initrd LABEL=boot %s\n" \ 88 syslinux_conf += "APPEND initrd=/initrd LABEL=boot %s\n" \
86 % bootloader.append 89 % bootloader.append
87 90
88 msger.debug("Writing syslinux config %s/ISO/isolinux/isolinux.cfg" \ 91 logger.debug("Writing syslinux config %s/ISO/isolinux/isolinux.cfg",
89 % cr_workdir) 92 cr_workdir)
93
90 with open("%s/ISO/isolinux/isolinux.cfg" % cr_workdir, "w") as cfg: 94 with open("%s/ISO/isolinux/isolinux.cfg" % cr_workdir, "w") as cfg:
91 cfg.write(syslinux_conf) 95 cfg.write(syslinux_conf)
92 96
@@ -99,11 +103,12 @@ class IsoImagePlugin(SourcePlugin):
99 if configfile: 103 if configfile:
100 grubefi_conf = get_custom_config(configfile) 104 grubefi_conf = get_custom_config(configfile)
101 if grubefi_conf: 105 if grubefi_conf:
102 msger.debug("Using custom configuration file " 106 logger.debug("Using custom configuration file %s for grub.cfg",
103 "%s for grub.cfg" % configfile) 107 configfile)
104 else: 108 else:
105 msger.error("configfile is specified but failed to " 109 logger.error("configfile is specified "
106 "get it from %s." % configfile) 110 "but failed to get it from %s", configfile)
111 sys.exit(1)
107 else: 112 else:
108 splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg") 113 splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg")
109 if os.path.exists(splash): 114 if os.path.exists(splash):
@@ -133,8 +138,8 @@ class IsoImagePlugin(SourcePlugin):
133 if splashline: 138 if splashline:
134 grubefi_conf += "%s\n" % splashline 139 grubefi_conf += "%s\n" % splashline
135 140
136 msger.debug("Writing grubefi config %s/EFI/BOOT/grub.cfg" \ 141 logger.debug("Writing grubefi config %s/EFI/BOOT/grub.cfg", cr_workdir)
137 % cr_workdir) 142
138 with open("%s/EFI/BOOT/grub.cfg" % cr_workdir, "w") as cfg: 143 with open("%s/EFI/BOOT/grub.cfg" % cr_workdir, "w") as cfg:
139 cfg.write(grubefi_conf) 144 cfg.write(grubefi_conf)
140 145
@@ -148,19 +153,23 @@ class IsoImagePlugin(SourcePlugin):
148 if not initrd: 153 if not initrd:
149 initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 154 initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
150 if not initrd_dir: 155 if not initrd_dir:
151 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting.\n") 156 logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting.\n")
157 sys.exit(1)
152 158
153 image_name = get_bitbake_var("IMAGE_BASENAME") 159 image_name = get_bitbake_var("IMAGE_BASENAME")
154 if not image_name: 160 if not image_name:
155 msger.error("Couldn't find IMAGE_BASENAME, exiting.\n") 161 logger.error("Couldn't find IMAGE_BASENAME, exiting.\n")
162 sys.exit(1)
156 163
157 image_type = get_bitbake_var("INITRAMFS_FSTYPES") 164 image_type = get_bitbake_var("INITRAMFS_FSTYPES")
158 if not image_type: 165 if not image_type:
159 msger.error("Couldn't find INITRAMFS_FSTYPES, exiting.\n") 166 logger.error("Couldn't find INITRAMFS_FSTYPES, exiting.\n")
167 sys.exit(1)
160 168
161 target_arch = get_bitbake_var("TRANSLATED_TARGET_ARCH") 169 target_arch = get_bitbake_var("TRANSLATED_TARGET_ARCH")
162 if not target_arch: 170 if not target_arch:
163 msger.error("Couldn't find TRANSLATED_TARGET_ARCH, exiting.\n") 171 logger.error("Couldn't find TRANSLATED_TARGET_ARCH, exiting.\n")
172 sys.exit(1)
164 173
165 initrd = glob.glob('%s/%s*%s.%s' % (initrd_dir, image_name, target_arch, image_type))[0] 174 initrd = glob.glob('%s/%s*%s.%s' % (initrd_dir, image_name, target_arch, image_type))[0]
166 175
@@ -183,7 +192,8 @@ class IsoImagePlugin(SourcePlugin):
183 os.symlink(os.readlink("%s/sbin/init" % rootfs_dir), \ 192 os.symlink(os.readlink("%s/sbin/init" % rootfs_dir), \
184 "%s/init" % initrd_dir) 193 "%s/init" % initrd_dir)
185 else: 194 else:
186 msger.error("Couldn't find or build initrd, exiting.\n") 195 logger.error("Couldn't find or build initrd, exiting.\n")
196 sys.exit(1)
187 197
188 exec_cmd("cd %s && find . | cpio -o -H newc -R +0:+0 >./initrd.cpio " \ 198 exec_cmd("cd %s && find . | cpio -o -H newc -R +0:+0 >./initrd.cpio " \
189 % initrd_dir, as_shell=True) 199 % initrd_dir, as_shell=True)
@@ -209,11 +219,11 @@ class IsoImagePlugin(SourcePlugin):
209 exec_cmd(install_cmd) 219 exec_cmd(install_cmd)
210 220
211 # Overwrite the name of the created image 221 # Overwrite the name of the created image
212 msger.debug("%s" % source_params) 222 logger.debug(source_params)
213 if 'image_name' in source_params and \ 223 if 'image_name' in source_params and \
214 source_params['image_name'].strip(): 224 source_params['image_name'].strip():
215 creator.name = source_params['image_name'].strip() 225 creator.name = source_params['image_name'].strip()
216 msger.debug("The name of the image is: %s" % creator.name) 226 logger.debug("The name of the image is: %s", creator.name)
217 227
218 @classmethod 228 @classmethod
219 def do_prepare_partition(cls, part, source_params, creator, cr_workdir, 229 def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
@@ -229,7 +239,8 @@ class IsoImagePlugin(SourcePlugin):
229 239
230 if part.rootfs_dir is None: 240 if part.rootfs_dir is None:
231 if not 'ROOTFS_DIR' in rootfs_dir: 241 if not 'ROOTFS_DIR' in rootfs_dir:
232 msger.error("Couldn't find --rootfs-dir, exiting.\n") 242 logger.error("Couldn't find --rootfs-dir, exiting.\n")
243 sys.exit(1)
233 rootfs_dir = rootfs_dir['ROOTFS_DIR'] 244 rootfs_dir = rootfs_dir['ROOTFS_DIR']
234 else: 245 else:
235 if part.rootfs_dir in rootfs_dir: 246 if part.rootfs_dir in rootfs_dir:
@@ -237,14 +248,16 @@ class IsoImagePlugin(SourcePlugin):
237 elif part.rootfs_dir: 248 elif part.rootfs_dir:
238 rootfs_dir = part.rootfs_dir 249 rootfs_dir = part.rootfs_dir
239 else: 250 else:
240 msg = "Couldn't find --rootfs-dir=%s connection " 251 logger.error("Couldn't find --rootfs-dir=%s connection "
241 msg += "or it is not a valid path, exiting.\n" 252 "or it is not a valid path, exiting.\n",
242 msger.error(msg % part.rootfs_dir) 253 part.rootfs_dir)
254 sys.exit(1)
243 255
244 if not os.path.isdir(rootfs_dir): 256 if not os.path.isdir(rootfs_dir):
245 rootfs_dir = get_bitbake_var("IMAGE_ROOTFS") 257 rootfs_dir = get_bitbake_var("IMAGE_ROOTFS")
246 if not os.path.isdir(rootfs_dir): 258 if not os.path.isdir(rootfs_dir):
247 msger.error("Couldn't find IMAGE_ROOTFS, exiting.\n") 259 logger.error("Couldn't find IMAGE_ROOTFS, exiting.\n")
260 sys.exit(1)
248 261
249 part.rootfs_dir = rootfs_dir 262 part.rootfs_dir = rootfs_dir
250 263
@@ -283,7 +296,8 @@ class IsoImagePlugin(SourcePlugin):
283 if source_params.get('initrd'): 296 if source_params.get('initrd'):
284 initrd = source_params['initrd'] 297 initrd = source_params['initrd']
285 if not deploy_dir: 298 if not deploy_dir:
286 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") 299 logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
300 sys.exit(1)
287 cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir) 301 cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir)
288 exec_cmd(cp_cmd) 302 exec_cmd(cp_cmd)
289 else: 303 else:
@@ -326,7 +340,8 @@ class IsoImagePlugin(SourcePlugin):
326 # didn't contains it 340 # didn't contains it
327 target_arch = get_bitbake_var("TARGET_SYS") 341 target_arch = get_bitbake_var("TARGET_SYS")
328 if not target_arch: 342 if not target_arch:
329 msger.error("Coludn't find target architecture\n") 343 logger.error("Coludn't find target architecture\n")
344 sys.exit(1)
330 345
331 if re.match("x86_64", target_arch): 346 if re.match("x86_64", target_arch):
332 grub_target = 'x86_64-efi' 347 grub_target = 'x86_64-efi'
@@ -335,18 +350,21 @@ class IsoImagePlugin(SourcePlugin):
335 grub_target = 'i386-efi' 350 grub_target = 'i386-efi'
336 grub_image = "bootia32.efi" 351 grub_image = "bootia32.efi"
337 else: 352 else:
338 msger.error("grub-efi is incompatible with target %s\n" \ 353 logger.error("grub-efi is incompatible with target %s\n",
339 % target_arch) 354 target_arch)
355 sys.exit(1)
340 356
341 if not os.path.isfile("%s/EFI/BOOT/%s" \ 357 if not os.path.isfile("%s/EFI/BOOT/%s" \
342 % (bootimg_dir, grub_image)): 358 % (bootimg_dir, grub_image)):
343 grub_path = get_bitbake_var("STAGING_LIBDIR", "wic-tools") 359 grub_path = get_bitbake_var("STAGING_LIBDIR", "wic-tools")
344 if not grub_path: 360 if not grub_path:
345 msger.error("Couldn't find STAGING_LIBDIR, exiting.\n") 361 logger.error("Couldn't find STAGING_LIBDIR, exiting.\n")
362 sys.exit(1)
346 363
347 grub_core = "%s/grub/%s" % (grub_path, grub_target) 364 grub_core = "%s/grub/%s" % (grub_path, grub_target)
348 if not os.path.exists(grub_core): 365 if not os.path.exists(grub_core):
349 msger.error("Please build grub-efi first\n") 366 logger.error("Please build grub-efi first\n")
367 sys.exit(1)
350 368
351 grub_cmd = "grub-mkimage -p '/EFI/BOOT' " 369 grub_cmd = "grub-mkimage -p '/EFI/BOOT' "
352 grub_cmd += "-d %s " % grub_core 370 grub_cmd += "-d %s " % grub_core
@@ -362,10 +380,12 @@ class IsoImagePlugin(SourcePlugin):
362 exec_native_cmd(grub_cmd, native_sysroot) 380 exec_native_cmd(grub_cmd, native_sysroot)
363 381
364 else: 382 else:
365 msger.error("unrecognized bootimg-efi loader: %s" \ 383 logger.error("unrecognized bootimg-efi loader: %s",
366 % source_params['loader']) 384 source_params['loader'])
385 sys.exit(1)
367 except KeyError: 386 except KeyError:
368 msger.error("bootimg-efi requires a loader, none specified") 387 logger.error("bootimg-efi requires a loader, none specified")
388 sys.exit(1)
369 389
370 if os.path.exists("%s/EFI/BOOT" % isodir): 390 if os.path.exists("%s/EFI/BOOT" % isodir):
371 shutil.rmtree("%s/EFI/BOOT" % isodir) 391 shutil.rmtree("%s/EFI/BOOT" % isodir)
@@ -388,9 +408,8 @@ class IsoImagePlugin(SourcePlugin):
388 blocks = int(out.split()[0]) 408 blocks = int(out.split()[0])
389 # Add some extra space for file system overhead 409 # Add some extra space for file system overhead
390 blocks += 100 410 blocks += 100
391 msg = "Added 100 extra blocks to %s to get to %d total blocks" \ 411 logger.debug("Added 100 extra blocks to %s to get to %d "
392 % (part.mountpoint, blocks) 412 "total blocks", part.mountpoint, blocks)
393 msger.debug(msg)
394 413
395 # dosfs image for EFI boot 414 # dosfs image for EFI boot
396 bootimg = "%s/efi.img" % isodir 415 bootimg = "%s/efi.img" % isodir
@@ -412,7 +431,8 @@ class IsoImagePlugin(SourcePlugin):
412 # Prepare files for legacy boot 431 # Prepare files for legacy boot
413 syslinux_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools") 432 syslinux_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools")
414 if not syslinux_dir: 433 if not syslinux_dir:
415 msger.error("Couldn't find STAGING_DATADIR, exiting.\n") 434 logger.error("Couldn't find STAGING_DATADIR, exiting.\n")
435 sys.exit(1)
416 436
417 if os.path.exists("%s/isolinux" % isodir): 437 if os.path.exists("%s/isolinux" % isodir):
418 shutil.rmtree("%s/isolinux" % isodir) 438 shutil.rmtree("%s/isolinux" % isodir)
@@ -452,7 +472,7 @@ class IsoImagePlugin(SourcePlugin):
452 mkisofs_cmd += "-eltorito-platform 0xEF -eltorito-boot %s " % efi_img 472 mkisofs_cmd += "-eltorito-platform 0xEF -eltorito-boot %s " % efi_img
453 mkisofs_cmd += "-no-emul-boot %s " % isodir 473 mkisofs_cmd += "-no-emul-boot %s " % isodir
454 474
455 msger.debug("running command: %s" % mkisofs_cmd) 475 logger.debug("running command: %s", mkisofs_cmd)
456 exec_native_cmd(mkisofs_cmd, native_sysroot) 476 exec_native_cmd(mkisofs_cmd, native_sysroot)
457 477
458 shutil.rmtree(isodir) 478 shutil.rmtree(isodir)
@@ -478,14 +498,14 @@ class IsoImagePlugin(SourcePlugin):
478 full_path_iso = creator._full_path(workdir, disk_name, "iso") 498 full_path_iso = creator._full_path(workdir, disk_name, "iso")
479 499
480 isohybrid_cmd = "isohybrid -u %s" % iso_img 500 isohybrid_cmd = "isohybrid -u %s" % iso_img
481 msger.debug("running command: %s" % isohybrid_cmd) 501 logger.debug("running command: %s", isohybrid_cmd)
482 exec_native_cmd(isohybrid_cmd, native_sysroot) 502 exec_native_cmd(isohybrid_cmd, native_sysroot)
483 503
484 # Replace the image created by direct plugin with the one created by 504 # Replace the image created by direct plugin with the one created by
485 # mkisofs command. This is necessary because the iso image created by 505 # mkisofs command. This is necessary because the iso image created by
486 # mkisofs has a very specific MBR is system area of the ISO image, and 506 # mkisofs has a very specific MBR is system area of the ISO image, and
487 # direct plugin adds and configures an another MBR. 507 # direct plugin adds and configures an another MBR.
488 msger.debug("Replaceing the image created by direct plugin\n") 508 logger.debug("Replaceing the image created by direct plugin\n")
489 os.remove(disk.path) 509 os.remove(disk.path)
490 shutil.copy2(iso_img, full_path_iso) 510 shutil.copy2(iso_img, full_path_iso)
491 shutil.copy2(full_path_iso, full_path) 511 shutil.copy2(full_path_iso, full_path)
diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py
index 4e42e3edea..c5c3be3c2e 100644
--- a/scripts/lib/wic/plugins/source/rawcopy.py
+++ b/scripts/lib/wic/plugins/source/rawcopy.py
@@ -15,13 +15,16 @@
15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16# 16#
17 17
18import logging
18import os 19import os
20import sys
19 21
20from wic import msger
21from wic.pluginbase import SourcePlugin 22from wic.pluginbase import SourcePlugin
22from wic.utils.misc import exec_cmd, get_bitbake_var 23from wic.utils.misc import exec_cmd, get_bitbake_var
23from wic.filemap import sparse_copy 24from wic.filemap import sparse_copy
24 25
26logger = logging.getLogger('wic')
27
25class RawCopyPlugin(SourcePlugin): 28class RawCopyPlugin(SourcePlugin):
26 """ 29 """
27 Populate partition content from raw image file. 30 Populate partition content from raw image file.
@@ -59,13 +62,14 @@ class RawCopyPlugin(SourcePlugin):
59 if not bootimg_dir: 62 if not bootimg_dir:
60 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 63 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
61 if not bootimg_dir: 64 if not bootimg_dir:
62 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") 65 logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
66 sys.exit(1)
63 67
64 msger.debug('Bootimg dir: %s' % bootimg_dir) 68 logger.debug('Bootimg dir: %s', bootimg_dir)
65 69
66 if 'file' not in source_params: 70 if 'file' not in source_params:
67 msger.error("No file specified\n") 71 logger.error("No file specified\n")
68 return 72 sys.exit(1)
69 73
70 src = os.path.join(bootimg_dir, source_params['file']) 74 src = os.path.join(bootimg_dir, source_params['file'])
71 dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno)) 75 dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno))
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index c57a4341d1..21b653925c 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -25,15 +25,18 @@
25# Joao Henrique Ferreira de Freitas <joaohf (at] gmail.com> 25# Joao Henrique Ferreira de Freitas <joaohf (at] gmail.com>
26# 26#
27 27
28import logging
28import os 29import os
29import shutil 30import shutil
31import sys
30 32
31from oe.path import copyhardlinktree 33from oe.path import copyhardlinktree
32 34
33from wic import msger
34from wic.pluginbase import SourcePlugin 35from wic.pluginbase import SourcePlugin
35from wic.utils.misc import get_bitbake_var, exec_cmd 36from wic.utils.misc import get_bitbake_var, exec_cmd
36 37
38logger = logging.getLogger('wic')
39
37class RootfsPlugin(SourcePlugin): 40class RootfsPlugin(SourcePlugin):
38 """ 41 """
39 Populate partition content from a rootfs directory. 42 Populate partition content from a rootfs directory.
@@ -48,10 +51,10 @@ class RootfsPlugin(SourcePlugin):
48 51
49 image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) 52 image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir)
50 if not os.path.isdir(image_rootfs_dir): 53 if not os.path.isdir(image_rootfs_dir):
51 msg = "No valid artifact IMAGE_ROOTFS from image named" 54 logger.error("No valid artifact IMAGE_ROOTFS from image named %s "
52 msg += " %s has been found at %s, exiting.\n" % \ 55 "has been found at %s, exiting.\n",
53 (rootfs_dir, image_rootfs_dir) 56 rootfs_dir, image_rootfs_dir)
54 msger.error(msg) 57 sys.exit(1)
55 58
56 return image_rootfs_dir 59 return image_rootfs_dir
57 60
@@ -66,8 +69,9 @@ class RootfsPlugin(SourcePlugin):
66 """ 69 """
67 if part.rootfs_dir is None: 70 if part.rootfs_dir is None:
68 if not 'ROOTFS_DIR' in krootfs_dir: 71 if not 'ROOTFS_DIR' in krootfs_dir:
69 msg = "Couldn't find --rootfs-dir, exiting" 72 logger.error("Couldn't find --rootfs-dir, exiting")
70 msger.error(msg) 73 sys.exit(1)
74
71 rootfs_dir = krootfs_dir['ROOTFS_DIR'] 75 rootfs_dir = krootfs_dir['ROOTFS_DIR']
72 else: 76 else:
73 if part.rootfs_dir in krootfs_dir: 77 if part.rootfs_dir in krootfs_dir:
@@ -75,9 +79,9 @@ class RootfsPlugin(SourcePlugin):
75 elif part.rootfs_dir: 79 elif part.rootfs_dir:
76 rootfs_dir = part.rootfs_dir 80 rootfs_dir = part.rootfs_dir
77 else: 81 else:
78 msg = "Couldn't find --rootfs-dir=%s connection" 82 logger.error("Couldn't find --rootfs-dir=%s connection or "
79 msg += " or it is not a valid path, exiting" 83 "it is not a valid path, exiting", part.rootfs_dir)
80 msger.error(msg % part.rootfs_dir) 84 sys.exit(1)
81 85
82 real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) 86 real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir)
83 87
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
21import logging
21import os 22import os
22import re 23import re
24import sys
23 25
24from wic import msger
25from wic.utils import runner 26from wic.utils import runner
26from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd 27from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd
27from wic.utils.errors import ImageError 28from wic.utils.errors import ImageError
28from wic.pluginbase import SourcePlugin 29from wic.pluginbase import SourcePlugin
29 30
31logger = logging.getLogger('wic')
32
30def serial_console_form_kargs(kernel_args): 33def 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: