]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/utils/targetbuild: tmp dir improvements
authorJoshua Lock <joshua.g.lock@intel.com>
Wed, 5 Apr 2017 12:10:54 +0000 (13:10 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 6 Apr 2017 09:13:34 +0000 (10:13 +0100)
Don't hard-code /tmp as the tmpdir, instead use WORKDIR as the tmpdir if the
instantiater doesn't specify a value.

Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/utils/targetbuild.py

index 6f237b56f3d835be0bf4680fa9d54c9c03c0415f..9249fa26359f7e5176c7fc8b371c5ea398616090 100644 (file)
@@ -8,14 +8,19 @@ import os
 import re
 import bb.utils
 import subprocess
+import tempfile
 from abc import ABCMeta, abstractmethod
 
 class BuildProject(metaclass=ABCMeta):
 
-    def __init__(self, d, uri, foldername=None, tmpdir="/tmp/"):
+    def __init__(self, d, uri, foldername=None, tmpdir=None):
         self.d = d
         self.uri = uri
         self.archive = os.path.basename(uri)
+        if not tmpdir:
+            tmpdir = self.d.getVar('WORKDIR')
+            if not tmpdir:
+                tmpdir = tempfile.mkdtemp(prefix='buildproject')
         self.localarchive = os.path.join(tmpdir,self.archive)
         if foldername:
             self.fname = foldername
@@ -24,7 +29,6 @@ class BuildProject(metaclass=ABCMeta):
 
     # Download self.archive to self.localarchive
     def _download_archive(self):
-
         dl_dir = self.d.getVar("DL_DIR")
         if dl_dir and os.path.exists(os.path.join(dl_dir, self.archive)):
             bb.utils.copyfile(os.path.join(dl_dir, self.archive), self.localarchive)
@@ -73,7 +77,7 @@ class TargetBuildProject(BuildProject):
     def __init__(self, target, d, uri, foldername=None):
         self.target = target
         self.targetdir = "~/"
-        BuildProject.__init__(self, d, uri, foldername, tmpdir="/tmp")
+        BuildProject.__init__(self, d, uri, foldername)
 
     def download_archive(self):