summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/wic/imager/direct.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index 825c9d7f6e..63f1fa1d39 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -27,6 +27,7 @@
27import os 27import os
28import shutil 28import shutil
29import uuid 29import uuid
30import tempfile
30 31
31from wic import msger 32from wic import msger
32from wic.utils.oe.misc import get_bitbake_var 33from wic.utils.oe.misc import get_bitbake_var
@@ -79,16 +80,11 @@ class DirectImageCreator:
79 80
80 This method takes the same arguments as ImageCreator.__init__() 81 This method takes the same arguments as ImageCreator.__init__()
81 """ 82 """
82
83 self.name = creatoropts['name'] 83 self.name = creatoropts['name']
84 self.outdir = image_output_dir
85 self.workdir = tempfile.mktemp(prefix='wic')
84 self.ks = creatoropts['ks'] 86 self.ks = creatoropts['ks']
85 87
86 self.tmpdir = "/var/tmp/wic"
87 self.workdir = "/var/tmp/wic/build"
88
89 if not os.path.exists(self.tmpdir):
90 os.makedirs(self.tmpdir)
91
92 self.__image = None 88 self.__image = None
93 self.__disks = {} 89 self.__disks = {}
94 self.__disk_format = "direct" 90 self.__disk_format = "direct"
@@ -96,8 +92,6 @@ class DirectImageCreator:
96 self.ptable_format = self.ks.bootloader.ptable 92 self.ptable_format = self.ks.bootloader.ptable
97 93
98 self.oe_builddir = oe_builddir 94 self.oe_builddir = oe_builddir
99 if image_output_dir:
100 self.tmpdir = image_output_dir
101 self.rootfs_dir = rootfs_dir 95 self.rootfs_dir = rootfs_dir
102 self.bootimg_dir = bootimg_dir 96 self.bootimg_dir = bootimg_dir
103 self.kernel_dir = kernel_dir 97 self.kernel_dir = kernel_dir
@@ -270,9 +264,6 @@ class DirectImageCreator:
270 264
271 fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) 265 fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR"))
272 266
273 shutil.rmtree(self.workdir)
274 os.mkdir(self.workdir)
275
276 for part in parts: 267 for part in parts:
277 # get rootfs size from bitbake variable if it's not set in .ks file 268 # get rootfs size from bitbake variable if it's not set in .ks file
278 if not part.size: 269 if not part.size:
@@ -425,3 +416,15 @@ class DirectImageCreator:
425 except ImageError as err: 416 except ImageError as err:
426 msger.warning("%s" % err) 417 msger.warning("%s" % err)
427 418
419 # Move results to the output dir
420 if not os.path.exists(self.outdir):
421 os.makedirs(self.outdir)
422
423 for fname in os.listdir(self.workdir):
424 path = os.path.join(self.workdir, fname)
425 if os.path.isfile(path):
426 shutil.move(path, os.path.join(self.outdir, fname))
427
428 # remove work directory
429 shutil.rmtree(self.workdir, ignore_errors=True)
430