diff options
author | Paulo Neves <paulo@myneves.com> | 2023-02-17 17:01:16 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-02-22 12:03:39 +0000 |
commit | 97b258985a59fd4cfe982f694f95018dcab22c61 (patch) | |
tree | ee4a81d23ac4903d0e1045eae855365957ee2f57 /bitbake/lib/bb/fetch2/git.py | |
parent | d085dcb4499750d45a2b429d836eefa347cd2450 (diff) | |
download | poky-97b258985a59fd4cfe982f694f95018dcab22c61.tar.gz |
bitbake: fetch/git: Replace mkdtemp with TemporaryDirectory and avoid exception masking
Due to using mkdtemp instead of TemporaryDirectory we needed to
manually cleanup the directory in a try finally block.
With tempfile.TemporaryDirectory we can handle the cleanup with
a "with" statement and not need to manually clean up oursevels.
(Bitbake rev: 36a231d2a45e7c87172196538d18ded81a234774)
Signed-off-by: Paulo Neves <paulo@myneves.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/git.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 7ea8974204..5bb8393133 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -417,8 +417,7 @@ class Git(FetchMethod): | |||
417 | # It would be nice to just do this inline here by running 'git-lfs fetch' | 417 | # It would be nice to just do this inline here by running 'git-lfs fetch' |
418 | # on the bare clonedir, but that operation requires a working copy on some | 418 | # on the bare clonedir, but that operation requires a working copy on some |
419 | # releases of Git LFS. | 419 | # releases of Git LFS. |
420 | tmpdir = tempfile.mkdtemp(dir=d.getVar('DL_DIR')) | 420 | with tempfile.TemporaryDirectory(dir=d.getVar('DL_DIR')) as tmpdir: |
421 | try: | ||
422 | # Do the checkout. This implicitly involves a Git LFS fetch. | 421 | # Do the checkout. This implicitly involves a Git LFS fetch. |
423 | Git.unpack(self, ud, tmpdir, d) | 422 | Git.unpack(self, ud, tmpdir, d) |
424 | 423 | ||
@@ -436,8 +435,6 @@ class Git(FetchMethod): | |||
436 | # downloaded. | 435 | # downloaded. |
437 | if os.path.exists(os.path.join(tmpdir, "git", ".git", "lfs")): | 436 | if os.path.exists(os.path.join(tmpdir, "git", ".git", "lfs")): |
438 | runfetchcmd("tar -cf - lfs | tar -xf - -C %s" % ud.clonedir, d, workdir="%s/git/.git" % tmpdir) | 437 | runfetchcmd("tar -cf - lfs | tar -xf - -C %s" % ud.clonedir, d, workdir="%s/git/.git" % tmpdir) |
439 | finally: | ||
440 | bb.utils.remove(tmpdir, recurse=True) | ||
441 | 438 | ||
442 | def build_mirror_data(self, ud, d): | 439 | def build_mirror_data(self, ud, d): |
443 | 440 | ||