summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source/bootimg-efi.py
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/lib/wic/plugins/source/bootimg-efi.py
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/lib/wic/plugins/source/bootimg-efi.py')
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-efi.py60
1 files changed, 36 insertions, 24 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