diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-25 16:14:47 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-26 16:35:00 +0100 |
commit | 694a1ae8f81ed8c6d93e541918465a0d2b5277ed (patch) | |
tree | 3e7c369422a551367691948cadc9c0b2b673323d | |
parent | 4252b898656ff71e373f0550522f4dcc2ec5c355 (diff) | |
download | poky-694a1ae8f81ed8c6d93e541918465a0d2b5277ed.tar.gz |
oeqa/buildproject: Ensure temp directories are cleaned up
(From OE-Core rev: d10aff865120a5feecc42c24726bd119364e0188)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/utils/buildproject.py | 3 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/targetbuild.py | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/buildproject.py b/meta/lib/oeqa/utils/buildproject.py index e6d80cc8dc..dfb9661868 100644 --- a/meta/lib/oeqa/utils/buildproject.py +++ b/meta/lib/oeqa/utils/buildproject.py | |||
@@ -18,6 +18,7 @@ class BuildProject(metaclass=ABCMeta): | |||
18 | def __init__(self, uri, foldername=None, tmpdir=None, dl_dir=None): | 18 | def __init__(self, uri, foldername=None, tmpdir=None, dl_dir=None): |
19 | self.uri = uri | 19 | self.uri = uri |
20 | self.archive = os.path.basename(uri) | 20 | self.archive = os.path.basename(uri) |
21 | self.tempdirobj = None | ||
21 | if not tmpdir: | 22 | if not tmpdir: |
22 | self.tempdirobj = tempfile.TemporaryDirectory(prefix='buildproject-') | 23 | self.tempdirobj = tempfile.TemporaryDirectory(prefix='buildproject-') |
23 | tmpdir = self.tempdirobj.name | 24 | tmpdir = self.tempdirobj.name |
@@ -57,6 +58,8 @@ class BuildProject(metaclass=ABCMeta): | |||
57 | return self._run('cd %s; make install %s' % (self.targetdir, install_args)) | 58 | return self._run('cd %s; make install %s' % (self.targetdir, install_args)) |
58 | 59 | ||
59 | def clean(self): | 60 | def clean(self): |
61 | if self.tempdirobj: | ||
62 | self.tempdirobj.cleanup() | ||
60 | if not self.needclean: | 63 | if not self.needclean: |
61 | return | 64 | return |
62 | self._run('rm -rf %s' % self.targetdir) | 65 | self._run('rm -rf %s' % self.targetdir) |
diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py index 1055810ca3..09738add1d 100644 --- a/meta/lib/oeqa/utils/targetbuild.py +++ b/meta/lib/oeqa/utils/targetbuild.py | |||
@@ -19,6 +19,7 @@ class BuildProject(metaclass=ABCMeta): | |||
19 | self.d = d | 19 | self.d = d |
20 | self.uri = uri | 20 | self.uri = uri |
21 | self.archive = os.path.basename(uri) | 21 | self.archive = os.path.basename(uri) |
22 | self.tempdirobj = None | ||
22 | if not tmpdir: | 23 | if not tmpdir: |
23 | tmpdir = self.d.getVar('WORKDIR') | 24 | tmpdir = self.d.getVar('WORKDIR') |
24 | if not tmpdir: | 25 | if not tmpdir: |
@@ -71,9 +72,10 @@ class BuildProject(metaclass=ABCMeta): | |||
71 | return self._run('cd %s; make install %s' % (self.targetdir, install_args)) | 72 | return self._run('cd %s; make install %s' % (self.targetdir, install_args)) |
72 | 73 | ||
73 | def clean(self): | 74 | def clean(self): |
75 | if self.tempdirobj: | ||
76 | self.tempdirobj.cleanup() | ||
74 | self._run('rm -rf %s' % self.targetdir) | 77 | self._run('rm -rf %s' % self.targetdir) |
75 | subprocess.check_call('rm -f %s' % self.localarchive, shell=True) | 78 | subprocess.check_call('rm -f %s' % self.localarchive, shell=True) |
76 | pass | ||
77 | 79 | ||
78 | class TargetBuildProject(BuildProject): | 80 | class TargetBuildProject(BuildProject): |
79 | 81 | ||