[oe-commits] [openembedded-core] 01/08: oeqa: don't litter /tmp with temporary directories

git at git.openembedded.org git at git.openembedded.org
Mon Dec 3 14:37:29 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 7c96bd100398ecec33e39f0b9b92c3f4f621ec86
Author: Ross Burton <ross.burton at intel.com>
AuthorDate: Mon Dec 3 12:31:00 2018 +0000

    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.
    
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/lib/oeqa/utils/buildproject.py | 5 ++++-
 meta/lib/oeqa/utils/targetbuild.py  | 5 +++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/meta/lib/oeqa/utils/buildproject.py b/meta/lib/oeqa/utils/buildproject.py
index 7e9b849..c52007f 100644
--- a/meta/lib/oeqa/utils/buildproject.py
+++ b/meta/lib/oeqa/utils/buildproject.py
@@ -17,7 +17,10 @@ class BuildProject(metaclass=ABCMeta):
         self.uri = uri
         self.archive = os.path.basename(uri)
         if not tmpdir:
-            tmpdir = tempfile.mkdtemp(prefix='buildproject')
+            tmpdir = self.d.getVar('WORKDIR')
+            if not tmpdir:
+                self.tempdirobj = tempfile.mkdtemp(prefix='buildproject-')
+                tmpdir = self.tempdirobj.name
         self.localarchive = os.path.join(tmpdir, self.archive)
         self.dl_dir = dl_dir
         if foldername:
diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py
index 1202d57..b8db7b2 100644
--- a/meta/lib/oeqa/utils/targetbuild.py
+++ b/meta/lib/oeqa/utils/targetbuild.py
@@ -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:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list