bitbake: gitsm: Remove downloads/tmpdir when failed

The tmpdir such as downloads/tmplp3cnemv won't be removed without this fix.

(Bitbake rev: 6894f68204130713d3651fceacadc7f8061174a8)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 2ba8d3214759142afc11f0a88d80eb30a8bcde3a)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
This commit is contained in:
Robert Yang
2024-10-26 02:39:52 -07:00
committed by Steve Sakoman
parent d0073c82ad
commit 80bb376273

View File

@@ -152,9 +152,11 @@ class GitSM(Git):
# unpacked temporarily so that we can examine the .gitmodules file
if ud.shallow and os.path.exists(ud.fullshallow) and extra_check:
tmpdir = tempfile.mkdtemp(dir=d.getVar("DL_DIR"))
runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=tmpdir)
self.process_submodules(ud, tmpdir, subfunc, d)
shutil.rmtree(tmpdir)
try:
runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=tmpdir)
self.process_submodules(ud, tmpdir, subfunc, d)
finally:
shutil.rmtree(tmpdir)
else:
self.process_submodules(ud, ud.clonedir, subfunc, d)