oeqa: don't litter /tmp with temporary directories

If we need to create a temporary directory in targetbuild or buildproject use
tempfile.TemporaryDirectory so that when the test case is finished, the
directory is deleted.

Also synchronise the logic and don't possibly store the temporary directory in
self.tmpdir as nothing uses that.

(From OE-Core rev: db0e658097130d146752785d0d45f46a3e0bad71)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ross Burton
2018-12-03 20:35:14 +00:00
committed by Richard Purdie
parent 8cd28e2f3f
commit affd7388f3
2 changed files with 5 additions and 3 deletions

View File

@@ -17,7 +17,8 @@ class BuildProject(metaclass=ABCMeta):
self.uri = uri
self.archive = os.path.basename(uri)
if not tmpdir:
tmpdir = tempfile.mkdtemp(prefix='buildproject')
self.tempdirobj = tempfile.TemporaryDirectory(prefix='buildproject-')
tmpdir = self.tempdirobj.name
self.localarchive = os.path.join(tmpdir, self.archive)
self.dl_dir = dl_dir
if foldername:

View File

@@ -20,8 +20,9 @@ class BuildProject(metaclass=ABCMeta):
if not tmpdir:
tmpdir = self.d.getVar('WORKDIR')
if not tmpdir:
tmpdir = tempfile.mkdtemp(prefix='buildproject')
self.localarchive = os.path.join(tmpdir,self.archive)
self.tempdirobj = tempfile.TemporaryDirectory(prefix='buildproject-')
tmpdir = self.tempdirobj.name
self.localarchive = os.path.join(tmpdir, self.archive)
if foldername:
self.fname = foldername
else: