summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/wic/__version__.py1
-rw-r--r--scripts/lib/wic/engine.py2
-rw-r--r--scripts/lib/wic/help.py4
-rw-r--r--scripts/lib/wic/partition.py11
-rw-r--r--scripts/lib/wic/plugin.py3
-rw-r--r--scripts/lib/wic/pluginbase.py1
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py3
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-efi.py14
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-partition.py4
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-pcbios.py4
-rw-r--r--scripts/lib/wic/plugins/source/isoimage-isohybrid.py11
-rw-r--r--scripts/lib/wic/plugins/source/rawcopy.py1
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py4
-rw-r--r--scripts/lib/wic/utils/misc.py9
-rw-r--r--scripts/lib/wic/utils/partitionedfs.py7
15 files changed, 36 insertions, 43 deletions
diff --git a/scripts/lib/wic/__version__.py b/scripts/lib/wic/__version__.py
deleted file mode 100644
index 5452a46712..0000000000
--- a/scripts/lib/wic/__version__.py
+++ /dev/null
@@ -1 +0,0 @@
1VERSION = "2.00"
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 685bc8898f..592ef77bba 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -190,7 +190,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
190 crobj = creator.Creator() 190 crobj = creator.Creator()
191 191
192 cmdline = ["direct", native_sysroot, kernel_dir, bootimg_dir, rootfs_dir, 192 cmdline = ["direct", native_sysroot, kernel_dir, bootimg_dir, rootfs_dir,
193 wks_file, image_output_dir, oe_builddir, compressor or ""] 193 wks_file, image_output_dir, oe_builddir, compressor or ""]
194 if bmap: 194 if bmap:
195 cmdline.append('--bmap') 195 cmdline.append('--bmap')
196 196
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index daa11bf489..1bd411deeb 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -31,7 +31,7 @@ import logging
31from wic.plugin import pluginmgr, PLUGIN_TYPES 31from wic.plugin import pluginmgr, PLUGIN_TYPES
32 32
33def subcommand_error(args): 33def subcommand_error(args):
34 logging.info("invalid subcommand %s" % args[0]) 34 logging.info("invalid subcommand %s", args[0])
35 35
36 36
37def display_help(subcommand, subcommands): 37def display_help(subcommand, subcommands):
@@ -87,7 +87,7 @@ def invoke_subcommand(args, parser, main_command_usage, subcommands):
87 elif args[0] == "help": 87 elif args[0] == "help":
88 wic_help(args, main_command_usage, subcommands) 88 wic_help(args, main_command_usage, subcommands)
89 elif args[0] not in subcommands: 89 elif args[0] not in subcommands:
90 logging.error("Unsupported subcommand %s, exiting\n" % (args[0])) 90 logging.error("Unsupported subcommand %s, exiting\n", args[0])
91 parser.print_help() 91 parser.print_help()
92 return 1 92 return 1
93 else: 93 else:
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 31a03506ca..69b369ce32 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -182,7 +182,7 @@ class Partition():
182 182
183 # further processing required Partition.size to be an integer, make 183 # further processing required Partition.size to be an integer, make
184 # sure that it is one 184 # sure that it is one
185 if type(self.size) is not int: 185 if not isinstance(self.size, int):
186 msger.error("Partition %s internal size is not an integer. " \ 186 msger.error("Partition %s internal size is not an integer. " \
187 "This a bug in source plugin %s and needs to be fixed." \ 187 "This a bug in source plugin %s and needs to be fixed." \
188 % (self.mountpoint, self.source)) 188 % (self.mountpoint, self.source))
@@ -242,7 +242,10 @@ class Partition():
242 # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE 242 # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE
243 rsize_bb = get_bitbake_var('ROOTFS_SIZE') 243 rsize_bb = get_bitbake_var('ROOTFS_SIZE')
244 if rsize_bb: 244 if rsize_bb:
245 msger.warning('overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied') 245 msger.warning('overhead-factor was specified, but size was not,'
246 ' so bitbake variables will be used for the size.'
247 ' In this case both IMAGE_OVERHEAD_FACTOR and '
248 '--overhead-factor will be applied')
246 self.size = int(round(float(rsize_bb))) 249 self.size = int(round(float(rsize_bb)))
247 250
248 for prefix in ("ext", "btrfs", "vfat", "squashfs"): 251 for prefix in ("ext", "btrfs", "vfat", "squashfs"):
@@ -402,7 +405,8 @@ class Partition():
402 "Proceeding as requested." % self.mountpoint) 405 "Proceeding as requested." % self.mountpoint)
403 406
404 path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) 407 path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype)
405 os.path.isfile(path) and os.remove(path) 408 if os.path.isfile(path):
409 os.remove(path)
406 410
407 # it is not possible to create a squashfs without source data, 411 # it is not possible to create a squashfs without source data,
408 # thus prepare an empty temp dir that is used as source 412 # thus prepare an empty temp dir that is used as source
@@ -436,4 +440,3 @@ class Partition():
436 label_str = "-L %s" % self.label 440 label_str = "-L %s" % self.label
437 mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path) 441 mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path)
438 exec_native_cmd(mkswap_cmd, native_sysroot) 442 exec_native_cmd(mkswap_cmd, native_sysroot)
439
diff --git a/scripts/lib/wic/plugin.py b/scripts/lib/wic/plugin.py
index 6b06ed654d..f04a0343d9 100644
--- a/scripts/lib/wic/plugin.py
+++ b/scripts/lib/wic/plugin.py
@@ -15,7 +15,8 @@
15# with this program; if not, write to the Free Software Foundation, Inc., 59 15# with this program; if not, write to the Free Software Foundation, Inc., 59
16# Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 17
18import os, sys 18import os
19import sys
19 20
20from wic import msger 21from wic import msger
21from wic import pluginbase 22from wic import pluginbase
diff --git a/scripts/lib/wic/pluginbase.py b/scripts/lib/wic/pluginbase.py
index e737dee7bc..2f747a91de 100644
--- a/scripts/lib/wic/pluginbase.py
+++ b/scripts/lib/wic/pluginbase.py
@@ -17,7 +17,6 @@
17 17
18__all__ = ['ImagerPlugin', 'SourcePlugin', 'get_plugins'] 18__all__ = ['ImagerPlugin', 'SourcePlugin', 'get_plugins']
19 19
20import sys
21from collections import defaultdict 20from collections import defaultdict
22 21
23from wic import msger 22from wic import msger
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 592412a634..4637fbf302 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -29,7 +29,6 @@ import uuid
29import tempfile 29import tempfile
30 30
31from time import strftime 31from time import strftime
32from os.path import basename, splitext
33 32
34from wic import msger 33from wic import msger
35from wic.ksparser import KickStart, KickStartError 34from wic.ksparser import KickStart, KickStartError
@@ -65,7 +64,7 @@ class DirectPlugin(ImagerPlugin):
65 except KickStartError as err: 64 except KickStartError as err:
66 msger.error(str(err)) 65 msger.error(str(err))
67 66
68 name = "%s-%s" % (splitext(basename(ksconf))[0], 67 name = "%s-%s" % (os.path.splitext(os.path.basename(ksconf))[0],
69 strftime("%Y%m%d%H%M")) 68 strftime("%Y%m%d%H%M"))
70 69
71 # parse possible 'rootfs=name' items 70 # parse possible 'rootfs=name' items
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 2b66a58d6e..dd6c920267 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -42,7 +42,7 @@ class BootimgEFIPlugin(SourcePlugin):
42 name = 'bootimg-efi' 42 name = 'bootimg-efi'
43 43
44 @classmethod 44 @classmethod
45 def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): 45 def do_configure_grubefi(cls, creator, cr_workdir):
46 """ 46 """
47 Create loader-specific (grub-efi) config 47 Create loader-specific (grub-efi) config
48 """ 48 """
@@ -54,10 +54,10 @@ class BootimgEFIPlugin(SourcePlugin):
54 # Use a custom configuration for grub 54 # Use a custom configuration for grub
55 grubefi_conf = custom_cfg 55 grubefi_conf = custom_cfg
56 msger.debug("Using custom configuration file " 56 msger.debug("Using custom configuration file "
57 "%s for grub.cfg" % configfile) 57 "%s for grub.cfg" % configfile)
58 else: 58 else:
59 msger.error("configfile is specified but failed to " 59 msger.error("configfile is specified but failed to "
60 "get it from %s." % configfile) 60 "get it from %s." % configfile)
61 61
62 if not custom_cfg: 62 if not custom_cfg:
63 # Create grub configuration using parameters from wks file 63 # Create grub configuration using parameters from wks file
@@ -125,10 +125,10 @@ class BootimgEFIPlugin(SourcePlugin):
125 # Use a custom configuration for systemd-boot 125 # Use a custom configuration for systemd-boot
126 boot_conf = custom_cfg 126 boot_conf = custom_cfg
127 msger.debug("Using custom configuration file " 127 msger.debug("Using custom configuration file "
128 "%s for systemd-boots's boot.conf" % configfile) 128 "%s for systemd-boots's boot.conf" % configfile)
129 else: 129 else:
130 msger.error("configfile is specified but failed to " 130 msger.error("configfile is specified but failed to "
131 "get it from %s." % configfile) 131 "get it from %s." % configfile)
132 132
133 if not custom_cfg: 133 if not custom_cfg:
134 # Create systemd-boot configuration using parameters from wks file 134 # Create systemd-boot configuration using parameters from wks file
@@ -164,7 +164,7 @@ class BootimgEFIPlugin(SourcePlugin):
164 164
165 try: 165 try:
166 if source_params['loader'] == 'grub-efi': 166 if source_params['loader'] == 'grub-efi':
167 cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params) 167 cls.do_configure_grubefi(creator, cr_workdir)
168 elif source_params['loader'] == 'systemd-boot': 168 elif source_params['loader'] == 'systemd-boot':
169 cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params) 169 cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
170 else: 170 else:
@@ -185,7 +185,7 @@ class BootimgEFIPlugin(SourcePlugin):
185 if not bootimg_dir: 185 if not bootimg_dir:
186 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 186 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
187 if not bootimg_dir: 187 if not bootimg_dir:
188 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") 188 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
189 # just so the result notes display it 189 # just so the result notes display it
190 creator.set_bootimg_dir(bootimg_dir) 190 creator.set_bootimg_dir(bootimg_dir)
191 191
diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
index f94dfabb6a..e0d9a50585 100644
--- a/scripts/lib/wic/plugins/source/bootimg-partition.py
+++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
@@ -26,10 +26,11 @@
26import os 26import os
27import re 27import re
28 28
29from glob import glob
30
29from wic import msger 31from wic import msger
30from wic.pluginbase import SourcePlugin 32from wic.pluginbase import SourcePlugin
31from wic.utils.misc import exec_cmd, get_bitbake_var 33from wic.utils.misc import exec_cmd, get_bitbake_var
32from glob import glob
33 34
34class BootimgPartitionPlugin(SourcePlugin): 35class BootimgPartitionPlugin(SourcePlugin):
35 """ 36 """
@@ -137,4 +138,3 @@ class BootimgPartitionPlugin(SourcePlugin):
137 msger.debug('Prepare boot partition using rootfs in %s' % (hdddir)) 138 msger.debug('Prepare boot partition using rootfs in %s' % (hdddir))
138 part.prepare_rootfs(cr_workdir, oe_builddir, hdddir, 139 part.prepare_rootfs(cr_workdir, oe_builddir, hdddir,
139 native_sysroot) 140 native_sysroot)
140
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index d796433d1d..4b9b26552a 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -198,7 +198,5 @@ class BootimgPcbiosPlugin(SourcePlugin):
198 out = exec_cmd(du_cmd) 198 out = exec_cmd(du_cmd)
199 bootimg_size = out.split()[0] 199 bootimg_size = out.split()[0]
200 200
201 part.size = int(out.split()[0]) 201 part.size = int(bootimg_size)
202 part.source_file = bootimg 202 part.source_file = bootimg
203
204
diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
index 6df375655c..56bb62d786 100644
--- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
+++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py
@@ -100,10 +100,10 @@ class IsoImagePlugin(SourcePlugin):
100 grubefi_conf = get_custom_config(configfile) 100 grubefi_conf = get_custom_config(configfile)
101 if grubefi_conf: 101 if grubefi_conf:
102 msger.debug("Using custom configuration file " 102 msger.debug("Using custom configuration file "
103 "%s for grub.cfg" % configfile) 103 "%s for grub.cfg" % configfile)
104 else: 104 else:
105 msger.error("configfile is specified but failed to " 105 msger.error("configfile is specified but failed to "
106 "get it from %s." % configfile) 106 "get it from %s." % configfile)
107 else: 107 else:
108 splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg") 108 splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg")
109 if os.path.exists(splash): 109 if os.path.exists(splash):
@@ -285,6 +285,7 @@ class IsoImagePlugin(SourcePlugin):
285 if not deploy_dir: 285 if not deploy_dir:
286 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") 286 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
287 cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir) 287 cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir)
288 exec_cmd(cp_cmd)
288 else: 289 else:
289 # Prepare initial ramdisk 290 # Prepare initial ramdisk
290 initrd = "%s/initrd" % deploy_dir 291 initrd = "%s/initrd" % deploy_dir
@@ -293,8 +294,7 @@ class IsoImagePlugin(SourcePlugin):
293 if not os.path.isfile(initrd): 294 if not os.path.isfile(initrd):
294 initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir) 295 initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir)
295 296
296 install_cmd = "install -m 0644 %s %s/initrd" \ 297 install_cmd = "install -m 0644 %s %s/initrd" % (initrd, isodir)
297 % (initrd, isodir)
298 exec_cmd(install_cmd) 298 exec_cmd(install_cmd)
299 299
300 # Remove the temporary file created by _build_initramfs_path function 300 # Remove the temporary file created by _build_initramfs_path function
@@ -303,7 +303,7 @@ class IsoImagePlugin(SourcePlugin):
303 303
304 # Install bzImage 304 # Install bzImage
305 install_cmd = "install -m 0644 %s/bzImage %s/bzImage" % \ 305 install_cmd = "install -m 0644 %s/bzImage %s/bzImage" % \
306 (kernel_dir, isodir) 306 (kernel_dir, isodir)
307 exec_cmd(install_cmd) 307 exec_cmd(install_cmd)
308 308
309 #Create bootloader for efi boot 309 #Create bootloader for efi boot
@@ -362,7 +362,6 @@ class IsoImagePlugin(SourcePlugin):
362 exec_native_cmd(grub_cmd, native_sysroot) 362 exec_native_cmd(grub_cmd, native_sysroot)
363 363
364 else: 364 else:
365 # TODO: insert gummiboot stuff
366 msger.error("unrecognized bootimg-efi loader: %s" \ 365 msger.error("unrecognized bootimg-efi loader: %s" \
367 % source_params['loader']) 366 % source_params['loader'])
368 except KeyError: 367 except KeyError:
diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py
index 79e41cad27..4e42e3edea 100644
--- a/scripts/lib/wic/plugins/source/rawcopy.py
+++ b/scripts/lib/wic/plugins/source/rawcopy.py
@@ -84,4 +84,3 @@ class RawCopyPlugin(SourcePlugin):
84 part.size = filesize 84 part.size = filesize
85 85
86 part.source_file = dst 86 part.source_file = dst
87
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index 891f095564..9d959fa7d7 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -79,5 +79,5 @@ class RootfsPlugin(SourcePlugin):
79 real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) 79 real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir)
80 80
81 part.rootfs_dir = real_rootfs_dir 81 part.rootfs_dir = real_rootfs_dir
82 part.prepare_rootfs(cr_workdir, oe_builddir, real_rootfs_dir, native_sysroot) 82 part.prepare_rootfs(cr_workdir, oe_builddir,
83 83 real_rootfs_dir, native_sysroot)
diff --git a/scripts/lib/wic/utils/misc.py b/scripts/lib/wic/utils/misc.py
index 6781d8381a..edb9c5b484 100644
--- a/scripts/lib/wic/utils/misc.py
+++ b/scripts/lib/wic/utils/misc.py
@@ -77,18 +77,15 @@ def _exec_cmd(cmd_and_args, as_shell=False, catch=3):
77 msger.debug("_exec_cmd: output for %s (rc = %d): %s" % \ 77 msger.debug("_exec_cmd: output for %s (rc = %d): %s" % \
78 (cmd_and_args, ret, out)) 78 (cmd_and_args, ret, out))
79 79
80 return (ret, out) 80 return ret, out
81 81
82 82
83def exec_cmd(cmd_and_args, as_shell=False, catch=3): 83def exec_cmd(cmd_and_args, as_shell=False, catch=3):
84 """ 84 """
85 Execute command, catching stderr, stdout 85 Execute command, return output
86
87 Exits if rc non-zero
88 """ 86 """
89 ret, out = _exec_cmd(cmd_and_args, as_shell, catch) 87 return _exec_cmd(cmd_and_args, as_shell, catch)[1]
90 88
91 return out
92 89
93def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""): 90def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""):
94 """ 91 """
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index eb4d7e6a51..5fc5765d65 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -21,7 +21,7 @@
21import os 21import os
22from wic import msger 22from wic import msger
23from wic.utils.errors import ImageError 23from wic.utils.errors import ImageError
24from wic.utils.misc import exec_cmd, exec_native_cmd 24from wic.utils.misc import exec_native_cmd
25from wic.filemap import sparse_copy 25from wic.filemap import sparse_copy
26 26
27# Overhead of the MBR partitioning scheme (just one sector) 27# Overhead of the MBR partitioning scheme (just one sector)
@@ -350,10 +350,9 @@ class Image():
350 if self.disks: 350 if self.disks:
351 for dev in self.disks: 351 for dev in self.disks:
352 disk = self.disks[dev] 352 disk = self.disks[dev]
353 try: 353 if hasattr(disk['disk'], 'cleanup'):
354 disk['disk'].cleanup() 354 disk['disk'].cleanup()
355 except: 355
356 pass
357 # remove partition images 356 # remove partition images
358 for image in self.partimages: 357 for image in self.partimages:
359 if os.path.isfile(image): 358 if os.path.isfile(image):