summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2021-01-19 16:26:06 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-01-20 22:46:18 +0000
commit4e6cb084f53bff1ef2d8dab6eb5a4f0e73eed018 (patch)
treeb991a6508445535572cef4a802a1adcc01007871
parentd710a8013e14396f028ee05fcecd82722d2608f4 (diff)
downloadpoky-4e6cb084f53bff1ef2d8dab6eb5a4f0e73eed018.tar.gz
wic: Ensure internal workdir is not reused
If a path is specified for the internal wic working directory using the -w/--workdir argument then it must not already exist. Re-using a previous workdir could easily result in rootfs and intermediate files from a previous build being added to the current image. (From OE-Core rev: 2e40c8d4109024ff704c5ce40d98050ca7f34dd5) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index b329568c7a..f107e60089 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -62,7 +62,7 @@ class DirectPlugin(ImagerPlugin):
62 62
63 self.name = "%s-%s" % (os.path.splitext(os.path.basename(wks_file))[0], 63 self.name = "%s-%s" % (os.path.splitext(os.path.basename(wks_file))[0],
64 strftime("%Y%m%d%H%M")) 64 strftime("%Y%m%d%H%M"))
65 self.workdir = options.workdir or tempfile.mkdtemp(dir=self.outdir, prefix='tmp.wic.') 65 self.workdir = self.setup_workdir(options.workdir)
66 self._image = None 66 self._image = None
67 self.ptable_format = self.ks.bootloader.ptable 67 self.ptable_format = self.ks.bootloader.ptable
68 self.parts = self.ks.partitions 68 self.parts = self.ks.partitions
@@ -78,6 +78,16 @@ class DirectPlugin(ImagerPlugin):
78 self._image = PartitionedImage(image_path, self.ptable_format, 78 self._image = PartitionedImage(image_path, self.ptable_format,
79 self.parts, self.native_sysroot) 79 self.parts, self.native_sysroot)
80 80
81 def setup_workdir(self, workdir):
82 if workdir:
83 if os.path.exists(workdir):
84 raise WicError("Internal workdir '%s' specified in wic arguments already exists!" % (workdir))
85
86 os.makedirs(workdir)
87 return workdir
88 else:
89 return tempfile.mkdtemp(dir=self.outdir, prefix='tmp.wic.')
90
81 def do_create(self): 91 def do_create(self):
82 """ 92 """
83 Plugin entry point. 93 Plugin entry point.