diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-01-24 15:43:51 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-31 14:38:31 +0000 |
commit | e9bd1ed67395fef82a5283e407480229857d448c (patch) | |
tree | d90fb155a855063596a0d57891359670b4c462b9 | |
parent | 75318c7b0c0ce1f811fb020692abe572c5192743 (diff) | |
download | poky-e9bd1ed67395fef82a5283e407480229857d448c.tar.gz |
wic: make workdir a temporary directory
Wic used hardcoded path /var/tmp/wic/ as a work directory,
which caused conflicts if two wic instances run in parallel.
Made work directory unique and temporary. Moved results from
work directory to output directory when they're ready.
[YOCTO #10783]
(From OE-Core rev: 5d948f04823dedfa26a879aa6a5dc23de2bb9354)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/lib/wic/imager/direct.py | 27 |
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 @@ | |||
27 | import os | 27 | import os |
28 | import shutil | 28 | import shutil |
29 | import uuid | 29 | import uuid |
30 | import tempfile | ||
30 | 31 | ||
31 | from wic import msger | 32 | from wic import msger |
32 | from wic.utils.oe.misc import get_bitbake_var | 33 | from 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 | |||