diff options
Diffstat (limited to 'scripts/lib/wic/partition.py')
-rw-r--r-- | scripts/lib/wic/partition.py | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py index 1221f691dc..a68dc6fd6d 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py | |||
@@ -24,13 +24,16 @@ | |||
24 | # Tom Zanussi <tom.zanussi (at] linux.intel.com> | 24 | # Tom Zanussi <tom.zanussi (at] linux.intel.com> |
25 | # Ed Bartosh <ed.bartosh> (at] linux.intel.com> | 25 | # Ed Bartosh <ed.bartosh> (at] linux.intel.com> |
26 | 26 | ||
27 | import logging | ||
27 | import os | 28 | import os |
29 | import sys | ||
28 | import tempfile | 30 | import tempfile |
29 | 31 | ||
30 | from wic import msger | ||
31 | from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var | 32 | from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var |
32 | from wic.plugin import pluginmgr | 33 | from wic.plugin import pluginmgr |
33 | 34 | ||
35 | logger = logging.getLogger('wic') | ||
36 | |||
34 | class Partition(): | 37 | class Partition(): |
35 | 38 | ||
36 | def __init__(self, args, lineno): | 39 | def __init__(self, args, lineno): |
@@ -69,16 +72,16 @@ class Partition(): | |||
69 | number of (1k) blocks we need to add to get to --size, 0 if | 72 | number of (1k) blocks we need to add to get to --size, 0 if |
70 | we're already there or beyond. | 73 | we're already there or beyond. |
71 | """ | 74 | """ |
72 | msger.debug("Requested partition size for %s: %d" % \ | 75 | logger.debug("Requested partition size for %s: %d", |
73 | (self.mountpoint, self.size)) | 76 | self.mountpoint, self.size) |
74 | 77 | ||
75 | if not self.size: | 78 | if not self.size: |
76 | return 0 | 79 | return 0 |
77 | 80 | ||
78 | requested_blocks = self.size | 81 | requested_blocks = self.size |
79 | 82 | ||
80 | msger.debug("Requested blocks %d, current_blocks %d" % \ | 83 | logger.debug("Requested blocks %d, current_blocks %d", |
81 | (requested_blocks, current_blocks)) | 84 | requested_blocks, current_blocks) |
82 | 85 | ||
83 | if requested_blocks > current_blocks: | 86 | if requested_blocks > current_blocks: |
84 | return requested_blocks - current_blocks | 87 | return requested_blocks - current_blocks |
@@ -96,8 +99,9 @@ class Partition(): | |||
96 | if self.fixed_size: | 99 | if self.fixed_size: |
97 | rootfs_size = self.fixed_size | 100 | rootfs_size = self.fixed_size |
98 | if actual_rootfs_size > rootfs_size: | 101 | if actual_rootfs_size > rootfs_size: |
99 | msger.error("Actual rootfs size (%d kB) is larger than allowed size %d kB" \ | 102 | logger.error("Actual rootfs size (%d kB) is larger than allowed size %d kB", |
100 | %(actual_rootfs_size, rootfs_size)) | 103 | actual_rootfs_size, rootfs_size) |
104 | sys.exit(1) | ||
101 | else: | 105 | else: |
102 | extra_blocks = self.get_extra_block_count(actual_rootfs_size) | 106 | extra_blocks = self.get_extra_block_count(actual_rootfs_size) |
103 | if extra_blocks < self.extra_space: | 107 | if extra_blocks < self.extra_space: |
@@ -106,8 +110,8 @@ class Partition(): | |||
106 | rootfs_size = actual_rootfs_size + extra_blocks | 110 | rootfs_size = actual_rootfs_size + extra_blocks |
107 | rootfs_size *= self.overhead_factor | 111 | rootfs_size *= self.overhead_factor |
108 | 112 | ||
109 | msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \ | 113 | logger.debug("Added %d extra blocks to %s to get to %d total blocks", |
110 | (extra_blocks, self.mountpoint, rootfs_size)) | 114 | extra_blocks, self.mountpoint, rootfs_size) |
111 | 115 | ||
112 | return rootfs_size | 116 | return rootfs_size |
113 | 117 | ||
@@ -128,9 +132,10 @@ class Partition(): | |||
128 | """ | 132 | """ |
129 | if not self.source: | 133 | if not self.source: |
130 | if not self.size and not self.fixed_size: | 134 | if not self.size and not self.fixed_size: |
131 | msger.error("The %s partition has a size of zero. Please " | 135 | logger.error("The %s partition has a size of zero. Please " |
132 | "specify a non-zero --size/--fixed-size for that partition." % \ | 136 | "specify a non-zero --size/--fixed-size for that " |
133 | self.mountpoint) | 137 | "partition.", self.mountpoint) |
138 | sys.exit(1) | ||
134 | if self.fstype and self.fstype == "swap": | 139 | if self.fstype and self.fstype == "swap": |
135 | self.prepare_swap_partition(cr_workdir, oe_builddir, | 140 | self.prepare_swap_partition(cr_workdir, oe_builddir, |
136 | native_sysroot) | 141 | native_sysroot) |
@@ -152,11 +157,12 @@ class Partition(): | |||
152 | plugins = pluginmgr.get_source_plugins() | 157 | plugins = pluginmgr.get_source_plugins() |
153 | 158 | ||
154 | if self.source not in plugins: | 159 | if self.source not in plugins: |
155 | msger.error("The '%s' --source specified for %s doesn't exist.\n\t" | 160 | logger.error("The '%s' --source specified for %s doesn't exist.\n\t" |
156 | "See 'wic list source-plugins' for a list of available" | 161 | "See 'wic list source-plugins' for a list of available" |
157 | " --sources.\n\tSee 'wic help source-plugins' for " | 162 | " --sources.\n\tSee 'wic help source-plugins' for " |
158 | "details on adding a new source plugin." % \ | 163 | "details on adding a new source plugin.", |
159 | (self.source, self.mountpoint)) | 164 | self.source, self.mountpoint) |
165 | sys.exit(1) | ||
160 | 166 | ||
161 | srcparams_dict = {} | 167 | srcparams_dict = {} |
162 | if self.sourceparams: | 168 | if self.sourceparams: |
@@ -186,15 +192,16 @@ class Partition(): | |||
186 | # further processing required Partition.size to be an integer, make | 192 | # further processing required Partition.size to be an integer, make |
187 | # sure that it is one | 193 | # sure that it is one |
188 | if not isinstance(self.size, int): | 194 | if not isinstance(self.size, int): |
189 | msger.error("Partition %s internal size is not an integer. " \ | 195 | logger.error("Partition %s internal size is not an integer. " |
190 | "This a bug in source plugin %s and needs to be fixed." \ | 196 | "This a bug in source plugin %s and needs to be fixed.", |
191 | % (self.mountpoint, self.source)) | 197 | self.mountpoint, self.source) |
198 | sys.exit(1) | ||
192 | 199 | ||
193 | if self.fixed_size and self.size > self.fixed_size: | 200 | if self.fixed_size and self.size > self.fixed_size: |
194 | msger.error("File system image of partition %s is larger (%d kB) than its"\ | 201 | logger.error("File system image of partition %s is larger (%d kB) " |
195 | "allowed size %d kB" % (self.mountpoint, | 202 | "than its allowed size %d kB", |
196 | self.size, self.fixed_size)) | 203 | self.mountpoint, self.size, self.fixed_size) |
197 | 204 | sys.exit(1) | |
198 | 205 | ||
199 | def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir, | 206 | def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir, |
200 | rootfs_dir): | 207 | rootfs_dir): |
@@ -234,8 +241,9 @@ class Partition(): | |||
234 | os.remove(rootfs) | 241 | os.remove(rootfs) |
235 | 242 | ||
236 | if not self.fstype: | 243 | if not self.fstype: |
237 | msger.error("File system for partition %s not specified in kickstart, " \ | 244 | logger.error("File system for partition %s not specified in kickstart, " |
238 | "use --fstype option" % (self.mountpoint)) | 245 | "use --fstype option", self.mountpoint) |
246 | sys.exit(1) | ||
239 | 247 | ||
240 | # Get rootfs size from bitbake variable if it's not set in .ks file | 248 | # Get rootfs size from bitbake variable if it's not set in .ks file |
241 | if not self.size: | 249 | if not self.size: |
@@ -245,10 +253,10 @@ class Partition(): | |||
245 | # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE | 253 | # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE |
246 | rsize_bb = get_bitbake_var('ROOTFS_SIZE') | 254 | rsize_bb = get_bitbake_var('ROOTFS_SIZE') |
247 | if rsize_bb: | 255 | if rsize_bb: |
248 | msger.warning('overhead-factor was specified, but size was not,' | 256 | logger.warning('overhead-factor was specified, but size was not,' |
249 | ' so bitbake variables will be used for the size.' | 257 | ' so bitbake variables will be used for the size.' |
250 | ' In this case both IMAGE_OVERHEAD_FACTOR and ' | 258 | ' In this case both IMAGE_OVERHEAD_FACTOR and ' |
251 | '--overhead-factor will be applied') | 259 | '--overhead-factor will be applied') |
252 | self.size = int(round(float(rsize_bb))) | 260 | self.size = int(round(float(rsize_bb))) |
253 | 261 | ||
254 | for prefix in ("ext", "btrfs", "vfat", "squashfs"): | 262 | for prefix in ("ext", "btrfs", "vfat", "squashfs"): |
@@ -404,8 +412,8 @@ class Partition(): | |||
404 | """ | 412 | """ |
405 | Prepare an empty squashfs partition. | 413 | Prepare an empty squashfs partition. |
406 | """ | 414 | """ |
407 | msger.warning("Creating of an empty squashfs %s partition was attempted. " \ | 415 | logger.warning("Creating of an empty squashfs %s partition was attempted. " |
408 | "Proceeding as requested." % self.mountpoint) | 416 | "Proceeding as requested.", self.mountpoint) |
409 | 417 | ||
410 | path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 418 | path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
411 | if os.path.isfile(path): | 419 | if os.path.isfile(path): |