diff options
| author | Joshua Lock <joshua.g.lock@intel.com> | 2017-04-05 13:10:54 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-04-06 10:13:39 +0100 |
| commit | fa2e536c441218cca09f51c514de9799f76ef9cb (patch) | |
| tree | ee68a9f2105d1719b787b8ac3501b53ea04e8308 /meta | |
| parent | 04cf8ad80e11f88257fb8278755c2710dde2c7e7 (diff) | |
| download | poky-fa2e536c441218cca09f51c514de9799f76ef9cb.tar.gz | |
oeqa/utils/targetbuild: tmp dir improvements
Don't hard-code /tmp as the tmpdir, instead use WORKDIR as the tmpdir if the
instantiater doesn't specify a value.
(From OE-Core rev: c43c966e0ed4ed836bdf90b1d4c3f2f45426f1ec)
Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/lib/oeqa/utils/targetbuild.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py index 6f237b56f3..9249fa2635 100644 --- a/meta/lib/oeqa/utils/targetbuild.py +++ b/meta/lib/oeqa/utils/targetbuild.py | |||
| @@ -8,14 +8,19 @@ import os | |||
| 8 | import re | 8 | import re |
| 9 | import bb.utils | 9 | import bb.utils |
| 10 | import subprocess | 10 | import subprocess |
| 11 | import tempfile | ||
| 11 | from abc import ABCMeta, abstractmethod | 12 | from abc import ABCMeta, abstractmethod |
| 12 | 13 | ||
| 13 | class BuildProject(metaclass=ABCMeta): | 14 | class BuildProject(metaclass=ABCMeta): |
| 14 | 15 | ||
| 15 | def __init__(self, d, uri, foldername=None, tmpdir="/tmp/"): | 16 | def __init__(self, d, uri, foldername=None, tmpdir=None): |
| 16 | self.d = d | 17 | self.d = d |
| 17 | self.uri = uri | 18 | self.uri = uri |
| 18 | self.archive = os.path.basename(uri) | 19 | self.archive = os.path.basename(uri) |
| 20 | if not tmpdir: | ||
| 21 | tmpdir = self.d.getVar('WORKDIR') | ||
| 22 | if not tmpdir: | ||
| 23 | tmpdir = tempfile.mkdtemp(prefix='buildproject') | ||
| 19 | self.localarchive = os.path.join(tmpdir,self.archive) | 24 | self.localarchive = os.path.join(tmpdir,self.archive) |
| 20 | if foldername: | 25 | if foldername: |
| 21 | self.fname = foldername | 26 | self.fname = foldername |
| @@ -24,7 +29,6 @@ class BuildProject(metaclass=ABCMeta): | |||
| 24 | 29 | ||
| 25 | # Download self.archive to self.localarchive | 30 | # Download self.archive to self.localarchive |
| 26 | def _download_archive(self): | 31 | def _download_archive(self): |
| 27 | |||
| 28 | dl_dir = self.d.getVar("DL_DIR") | 32 | dl_dir = self.d.getVar("DL_DIR") |
| 29 | if dl_dir and os.path.exists(os.path.join(dl_dir, self.archive)): | 33 | if dl_dir and os.path.exists(os.path.join(dl_dir, self.archive)): |
| 30 | bb.utils.copyfile(os.path.join(dl_dir, self.archive), self.localarchive) | 34 | bb.utils.copyfile(os.path.join(dl_dir, self.archive), self.localarchive) |
| @@ -73,7 +77,7 @@ class TargetBuildProject(BuildProject): | |||
| 73 | def __init__(self, target, d, uri, foldername=None): | 77 | def __init__(self, target, d, uri, foldername=None): |
| 74 | self.target = target | 78 | self.target = target |
| 75 | self.targetdir = "~/" | 79 | self.targetdir = "~/" |
| 76 | BuildProject.__init__(self, d, uri, foldername, tmpdir="/tmp") | 80 | BuildProject.__init__(self, d, uri, foldername) |
| 77 | 81 | ||
| 78 | def download_archive(self): | 82 | def download_archive(self): |
| 79 | 83 | ||
