diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-06-27 13:37:27 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-02 23:08:37 +0100 |
commit | 4023377baef3f1746351bed4bb0399f9bee5b99c (patch) | |
tree | 32cca52ce4d5e5992e4e6012c7b592cd2deaae07 /scripts | |
parent | b5dce25ddce631eaa7ebfdfbd3cc0bd4ab3845ca (diff) | |
download | poky-4023377baef3f1746351bed4bb0399f9bee5b99c.tar.gz |
wic: Remove duplicated code
Moved duplicated code of geting rootfs size
out of prepare_rootfs* methods.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/wic/kickstart/custom_commands/partition.py | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py index 4e8a6a89b0..72f617a1b6 100644 --- a/scripts/lib/wic/kickstart/custom_commands/partition.py +++ b/scripts/lib/wic/kickstart/custom_commands/partition.py | |||
@@ -234,8 +234,16 @@ class Wic_PartData(Mic_PartData): | |||
234 | for prefix in ("ext", "btrfs", "vfat", "squashfs"): | 234 | for prefix in ("ext", "btrfs", "vfat", "squashfs"): |
235 | if self.fstype.startswith(prefix): | 235 | if self.fstype.startswith(prefix): |
236 | method = getattr(self, "prepare_rootfs_" + prefix) | 236 | method = getattr(self, "prepare_rootfs_" + prefix) |
237 | return method(rootfs, oe_builddir, rootfs_dir, | 237 | method(rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo) |
238 | native_sysroot, pseudo) | 238 | |
239 | self.source_file = rootfs | ||
240 | |||
241 | # get the rootfs size in the right units for kickstart (kB) | ||
242 | du_cmd = "du -Lbks %s" % rootfs | ||
243 | out = exec_cmd(du_cmd) | ||
244 | self.size = out.split()[0] | ||
245 | |||
246 | break | ||
239 | 247 | ||
240 | def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir, | 248 | def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir, |
241 | native_sysroot, pseudo): | 249 | native_sysroot, pseudo): |
@@ -270,16 +278,6 @@ class Wic_PartData(Mic_PartData): | |||
270 | (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir) | 278 | (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir) |
271 | exec_native_cmd(pseudo + mkfs_cmd, native_sysroot) | 279 | exec_native_cmd(pseudo + mkfs_cmd, native_sysroot) |
272 | 280 | ||
273 | # get the rootfs size in the right units for kickstart (kB) | ||
274 | du_cmd = "du -Lbks %s" % rootfs | ||
275 | out = exec_cmd(du_cmd) | ||
276 | rootfs_size = out.split()[0] | ||
277 | |||
278 | self.size = rootfs_size | ||
279 | self.source_file = rootfs | ||
280 | |||
281 | return 0 | ||
282 | |||
283 | def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir, | 281 | def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir, |
284 | native_sysroot, pseudo): | 282 | native_sysroot, pseudo): |
285 | """ | 283 | """ |
@@ -313,14 +311,6 @@ class Wic_PartData(Mic_PartData): | |||
313 | (self.fstype, rootfs_size * 1024, rootfs_dir, label_str, rootfs) | 311 | (self.fstype, rootfs_size * 1024, rootfs_dir, label_str, rootfs) |
314 | exec_native_cmd(pseudo + mkfs_cmd, native_sysroot) | 312 | exec_native_cmd(pseudo + mkfs_cmd, native_sysroot) |
315 | 313 | ||
316 | # get the rootfs size in the right units for kickstart (kB) | ||
317 | du_cmd = "du -Lbks %s" % rootfs | ||
318 | out = exec_cmd(du_cmd) | ||
319 | rootfs_size = out.split()[0] | ||
320 | |||
321 | self.size = rootfs_size | ||
322 | self.source_file = rootfs | ||
323 | |||
324 | def prepare_rootfs_vfat(self, rootfs, oe_builddir, rootfs_dir, | 314 | def prepare_rootfs_vfat(self, rootfs, oe_builddir, rootfs_dir, |
325 | native_sysroot, pseudo): | 315 | native_sysroot, pseudo): |
326 | """ | 316 | """ |
@@ -360,14 +350,6 @@ class Wic_PartData(Mic_PartData): | |||
360 | chmod_cmd = "chmod 644 %s" % rootfs | 350 | chmod_cmd = "chmod 644 %s" % rootfs |
361 | exec_cmd(chmod_cmd) | 351 | exec_cmd(chmod_cmd) |
362 | 352 | ||
363 | # get the rootfs size in the right units for kickstart (kB) | ||
364 | du_cmd = "du -Lbks %s" % rootfs | ||
365 | out = exec_cmd(du_cmd) | ||
366 | rootfs_size = out.split()[0] | ||
367 | |||
368 | self.set_size(rootfs_size) | ||
369 | self.set_source_file(rootfs) | ||
370 | |||
371 | def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir, | 353 | def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir, |
372 | native_sysroot, pseudo): | 354 | native_sysroot, pseudo): |
373 | """ | 355 | """ |
@@ -377,16 +359,6 @@ class Wic_PartData(Mic_PartData): | |||
377 | (rootfs_dir, rootfs) | 359 | (rootfs_dir, rootfs) |
378 | exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) | 360 | exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) |
379 | 361 | ||
380 | # get the rootfs size in the right units for kickstart (kB) | ||
381 | du_cmd = "du -Lbks %s" % rootfs | ||
382 | out = exec_cmd(du_cmd) | ||
383 | rootfs_size = out.split()[0] | ||
384 | |||
385 | self.size = rootfs_size | ||
386 | self.source_file = rootfs | ||
387 | |||
388 | return 0 | ||
389 | |||
390 | def prepare_empty_partition_ext(self, rootfs, oe_builddir, | 362 | def prepare_empty_partition_ext(self, rootfs, oe_builddir, |
391 | native_sysroot): | 363 | native_sysroot): |
392 | """ | 364 | """ |