summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-06-27 12:16:38 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-02 23:08:37 +0100
commite9237bf0fae2734f5fbbd6b8a418314ce6db5f5f (patch)
tree9437f548109ce42b130acb287c2d2bd8de3c87fa /scripts/lib
parent992f78939e82635d94022ebc1341ab366e2dfb30 (diff)
downloadpoky-e9237bf0fae2734f5fbbd6b8a418314ce6db5f5f.tar.gz
wic: Refactor prepare_rootfs API
Moved code out of prepare_roots* methods to avoid code duplication. (From OE-Core rev: ab1c845758d4f80c82ffcf481007803905e45c29) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/wic/kickstart/custom_commands/partition.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py
index 324ea690ec..489ebe359c 100644
--- a/scripts/lib/wic/kickstart/custom_commands/partition.py
+++ b/scripts/lib/wic/kickstart/custom_commands/partition.py
@@ -219,34 +219,36 @@ class Wic_PartData(Mic_PartData):
219 pseudo += "export PSEUDO_NOSYMLINKEXP=%s;" % p_nosymlinkexp 219 pseudo += "export PSEUDO_NOSYMLINKEXP=%s;" % p_nosymlinkexp
220 pseudo += "%s/usr/bin/pseudo " % native_sysroot 220 pseudo += "%s/usr/bin/pseudo " % native_sysroot
221 221
222 rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
223 if os.path.isfile(rootfs):
224 os.remove(rootfs)
225
222 if self.fstype.startswith("ext"): 226 if self.fstype.startswith("ext"):
223 return self.prepare_rootfs_ext(cr_workdir, oe_builddir, 227 return self.prepare_rootfs_ext(rootfs, oe_builddir,
224 rootfs_dir, native_sysroot, 228 rootfs_dir, native_sysroot,
225 pseudo) 229 pseudo)
226 elif self.fstype.startswith("btrfs"): 230 elif self.fstype.startswith("btrfs"):
227 return self.prepare_rootfs_btrfs(cr_workdir, oe_builddir, 231 return self.prepare_rootfs_btrfs(rootfs, oe_builddir,
228 rootfs_dir, native_sysroot, 232 rootfs_dir, native_sysroot,
229 pseudo) 233 pseudo)
230 234
231 elif self.fstype.startswith("vfat"): 235 elif self.fstype.startswith("vfat"):
232 return self.prepare_rootfs_vfat(cr_workdir, oe_builddir, 236 return self.prepare_rootfs_vfat(rootfs, oe_builddir,
233 rootfs_dir, native_sysroot, 237 rootfs_dir, native_sysroot,
234 pseudo) 238 pseudo)
235 elif self.fstype.startswith("squashfs"): 239 elif self.fstype.startswith("squashfs"):
236 return self.prepare_rootfs_squashfs(cr_workdir, oe_builddir, 240 return self.prepare_rootfs_squashfs(rootfs, oe_builddir,
237 rootfs_dir, native_sysroot, 241 rootfs_dir, native_sysroot,
238 pseudo) 242 pseudo)
239 243
240 def prepare_rootfs_ext(self, cr_workdir, oe_builddir, rootfs_dir, 244 def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir,
241 native_sysroot, pseudo): 245 native_sysroot, pseudo):
242 """ 246 """
243 Prepare content for an ext2/3/4 rootfs partition. 247 Prepare content for an ext2/3/4 rootfs partition.
244 """ 248 """
245 249
246 image_rootfs = rootfs_dir 250 image_rootfs = rootfs_dir
247 rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
248 251
249 os.path.isfile(rootfs) and os.remove(rootfs)
250 du_cmd = "du -ks %s" % image_rootfs 252 du_cmd = "du -ks %s" % image_rootfs
251 out = exec_cmd(du_cmd) 253 out = exec_cmd(du_cmd)
252 actual_rootfs_size = int(out.split()[0]) 254 actual_rootfs_size = int(out.split()[0])
@@ -285,7 +287,7 @@ class Wic_PartData(Mic_PartData):
285 287
286 return 0 288 return 0
287 289
288 def prepare_rootfs_btrfs(self, cr_workdir, oe_builddir, rootfs_dir, 290 def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir,
289 native_sysroot, pseudo): 291 native_sysroot, pseudo):
290 """ 292 """
291 Prepare content for a btrfs rootfs partition. 293 Prepare content for a btrfs rootfs partition.
@@ -293,9 +295,7 @@ class Wic_PartData(Mic_PartData):
293 Currently handles ext2/3/4 and btrfs. 295 Currently handles ext2/3/4 and btrfs.
294 """ 296 """
295 image_rootfs = rootfs_dir 297 image_rootfs = rootfs_dir
296 rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
297 298
298 os.path.isfile(rootfs) and os.remove(rootfs)
299 du_cmd = "du -ks %s" % image_rootfs 299 du_cmd = "du -ks %s" % image_rootfs
300 out = exec_cmd(du_cmd) 300 out = exec_cmd(du_cmd)
301 actual_rootfs_size = int(out.split()[0]) 301 actual_rootfs_size = int(out.split()[0])
@@ -330,15 +330,13 @@ class Wic_PartData(Mic_PartData):
330 self.size = rootfs_size 330 self.size = rootfs_size
331 self.source_file = rootfs 331 self.source_file = rootfs
332 332
333 def prepare_rootfs_vfat(self, cr_workdir, oe_builddir, rootfs_dir, 333 def prepare_rootfs_vfat(self, rootfs, oe_builddir, rootfs_dir,
334 native_sysroot, pseudo): 334 native_sysroot, pseudo):
335 """ 335 """
336 Prepare content for a vfat rootfs partition. 336 Prepare content for a vfat rootfs partition.
337 """ 337 """
338 image_rootfs = rootfs_dir 338 image_rootfs = rootfs_dir
339 rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
340 339
341 os.path.isfile(rootfs) and os.remove(rootfs)
342 du_cmd = "du -bks %s" % image_rootfs 340 du_cmd = "du -bks %s" % image_rootfs
343 out = exec_cmd(du_cmd) 341 out = exec_cmd(du_cmd)
344 blocks = int(out.split()[0]) 342 blocks = int(out.split()[0])
@@ -381,15 +379,13 @@ class Wic_PartData(Mic_PartData):
381 self.set_size(rootfs_size) 379 self.set_size(rootfs_size)
382 self.set_source_file(rootfs) 380 self.set_source_file(rootfs)
383 381
384 def prepare_rootfs_squashfs(self, cr_workdir, oe_builddir, rootfs_dir, 382 def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir,
385 native_sysroot, pseudo): 383 native_sysroot, pseudo):
386 """ 384 """
387 Prepare content for a squashfs rootfs partition. 385 Prepare content for a squashfs rootfs partition.
388 """ 386 """
389 image_rootfs = rootfs_dir 387 image_rootfs = rootfs_dir
390 rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
391 388
392 os.path.isfile(rootfs) and os.remove(rootfs)
393 squashfs_cmd = "mksquashfs %s %s -noappend" % \ 389 squashfs_cmd = "mksquashfs %s %s -noappend" % \
394 (image_rootfs, rootfs) 390 (image_rootfs, rootfs)
395 exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) 391 exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)