From: Ross Burton <ross.burton@intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 1/3] oeqa: don't litter /tmp with temporary directories
Date: Mon, 3 Dec 2018 20:35:14 +0000 [thread overview]
Message-ID: <20181203203516.26461-1-ross.burton@intel.com> (raw)
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@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 7e9b84955f5..524015ede4b 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.TemporaryDirectory(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 1202d579fb0..b8db7b2aca0 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:
--
2.11.0
next reply other threads:[~2018-12-03 20:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-03 20:35 Ross Burton [this message]
2018-12-03 20:35 ` [PATCH 2/3] oeqa/selftest/esdk: run selftest inside workdir not /tmp Ross Burton
2018-12-03 20:35 ` [PATCH 3/3] insane: clarify GNU_HASH warning Ross Burton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181203203516.26461-1-ross.burton@intel.com \
--to=ross.burton@intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox