From patchwork Fri Feb 17 17:00:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Neves X-Patchwork-Id: 19696 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AE3EC636D6 for ; Fri, 17 Feb 2023 17:00:35 +0000 (UTC) Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) by mx.groups.io with SMTP id smtpd.web11.11712.1676653229564130668 for ; Fri, 17 Feb 2023 09:00:31 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@myneves.com header.s=protonmail header.b=WTUdqrII; spf=pass (domain: myneves.com, ip: 185.70.43.23, mailfrom: paulo@myneves.com) Date: Fri, 17 Feb 2023 17:00:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=myneves.com; s=protonmail; t=1676653227; x=1676912427; bh=B4QxJYOBZ83ED7NjutyYOcTTHtptQViXkiWz5HnE97w=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=WTUdqrIIm2eqq8PARc76sqZIvBNN/7vCP2yGfdNRG77Nk03U49+WFMlwca+xwKAhk guu+Rz+ZHJTh30cHTSnLc5hlSceqfBNtnusEGxLYQjyzogL5K8jUJBNxhDQrPZxbvM fs+2Vd/NjKd13pEFpQhusFT9Hxnf3AO2I+T32cBBfhOqcWxcRVAhv5HahCg9/Jwlj4 3hkj44HXIduh6A3vEB83CN1h0fX0s+h0HOr/OcI/pSgGgQfNxZVstns9HHH08TWaNf uzIilRTmuml/yIXDD+yBo2g8OCaKH4zLNoX361nl7CugANx0ZNv/c7zGaMFSCKlwlV 9wDuIsTFTH0ZA== To: bitbake-devel@lists.openembedded.org From: Paulo Neves Cc: Paulo Neves Subject: [PATCH 1/5] tests: git-lfs: Restore _find_git_lfs Message-ID: <20230217170009.58707-1-paulo@myneves.com> Feedback-ID: 59941854:user:proton MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 17 Feb 2023 17:00:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/14460 Not restoring the mocked _find_git_lfs leads to other tests failing. Signed-off-by: Paulo Neves --- lib/bb/tests/fetch.py | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) -- 2.34.1 diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index f3890321d..6d16cf59a 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -2250,12 +2250,16 @@ class GitLfsTest(FetcherTest): shutil.rmtree(self.gitdir, ignore_errors=True) fetcher.unpack(self.d.getVar('WORKDIR')) - # If git-lfs cannot be found, the unpack should throw an error - with self.assertRaises(bb.fetch2.FetchError): - fetcher.download() - ud.method._find_git_lfs = lambda d: False - shutil.rmtree(self.gitdir, ignore_errors=True) - fetcher.unpack(self.d.getVar('WORKDIR')) + old_find_git_lfs = ud.method._find_git_lfs + try: + # If git-lfs cannot be found, the unpack should throw an error + with self.assertRaises(bb.fetch2.FetchError): + fetcher.download() + ud.method._find_git_lfs = lambda d: False + shutil.rmtree(self.gitdir, ignore_errors=True) + fetcher.unpack(self.d.getVar('WORKDIR')) + finally: + ud.method._find_git_lfs = old_find_git_lfs def test_lfs_disabled(self): import shutil @@ -2270,17 +2274,21 @@ class GitLfsTest(FetcherTest): fetcher, ud = self.fetch() self.assertIsNotNone(ud.method._find_git_lfs) - # If git-lfs can be found, the unpack should be successful. A - # live copy of git-lfs is not required for this case, so - # unconditionally forge its presence. - ud.method._find_git_lfs = lambda d: True - shutil.rmtree(self.gitdir, ignore_errors=True) - fetcher.unpack(self.d.getVar('WORKDIR')) + old_find_git_lfs = ud.method._find_git_lfs + try: + # If git-lfs can be found, the unpack should be successful. A + # live copy of git-lfs is not required for this case, so + # unconditionally forge its presence. + ud.method._find_git_lfs = lambda d: True + shutil.rmtree(self.gitdir, ignore_errors=True) + fetcher.unpack(self.d.getVar('WORKDIR')) + # If git-lfs cannot be found, the unpack should be successful - # If git-lfs cannot be found, the unpack should be successful - ud.method._find_git_lfs = lambda d: False - shutil.rmtree(self.gitdir, ignore_errors=True) - fetcher.unpack(self.d.getVar('WORKDIR')) + ud.method._find_git_lfs = lambda d: False + shutil.rmtree(self.gitdir, ignore_errors=True) + fetcher.unpack(self.d.getVar('WORKDIR')) + finally: + ud.method._find_git_lfs = old_find_git_lfs class GitURLWithSpacesTest(FetcherTest): test_git_urls = { From patchwork Fri Feb 17 17:00:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Neves X-Patchwork-Id: 19697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10586C6379F for ; Fri, 17 Feb 2023 17:00:55 +0000 (UTC) Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) by mx.groups.io with SMTP id smtpd.web10.11891.1676653248591436865 for ; Fri, 17 Feb 2023 09:00:49 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@myneves.com header.s=protonmail header.b=Ht0xnLQ+; spf=pass (domain: myneves.com, ip: 185.70.40.22, mailfrom: paulo@myneves.com) Date: Fri, 17 Feb 2023 17:00:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=myneves.com; s=protonmail; t=1676653245; x=1676912445; bh=n3di+MqqcUMuB5k5EXJZhiiGTgk05JCqwl7gYGdF0Bo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Ht0xnLQ+snuyf1+L7dWTKmOPnWEg0mJefYsOF986BS9Cu4i8a3gq3oUrC/pwp0niZ 2R+vWpACxlUtAPfUQPwuZvWBtu0++NNzcLhqdWa1CUldtvqgNE7JS46yJ4sIM8URB9 bMkKHZ07vOA6x8YZRpIqV3p3//PPFgKSMtUwLY5J9ACJ88p3OlT4nvw05RBImQ7sfq lPSpy6alpjB8iMhjBXgKSmVRT9AJSrV+ZgbOTiqNvuf37GIdjEAbuZJBbkqWYceEW6 e4OOpYyLFv+TKu2ppGcExv30WbsBDaNopHvA0jNLzYV24X8E7jXU6kaXxx8ZdXhMMl mW5vV0I6Bsevg== To: bitbake-devel@lists.openembedded.org From: Paulo Neves Cc: Paulo Neves Subject: [PATCH 2/5] test: Add real git lfs tests and decorator Message-ID: <20230217170009.58707-2-paulo@myneves.com> In-Reply-To: <20230217170009.58707-1-paulo@myneves.com> References: <20230217170009.58707-1-paulo@myneves.com> Feedback-ID: 59941854:user:proton MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 17 Feb 2023 17:00:55 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/14461 Added tests that verify that git-lfs works with an actual real git-lfs server. This was not previously the case because the repo in the test was a simulation of git-lfs but not a real git lfs repo. The 2 added tests are almost the same but test that the git lfs file checkout is successfult with or without the lfs=1 flag. The lfs=1 URI parameter is a quirk that triggers 2 different code paths for git lfs. lfs=1, when used on git lfs repositories triggers the git lfs downloading at the fetch bare stage. lfs query parameter unset triggers the git lfs downloading only on checkout as an implicit behavior of git. This leads to possible network access on the unpack stage and outside the DL_DIR. lfs=0 actually disables git-lfs functionality even if supported. Signed-off-by: Paulo Neves --- lib/bb/tests/fetch.py | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.34.1 diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index 6d16cf59a..54148b3fd 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -2199,6 +2199,12 @@ class GitShallowTest(FetcherTest): self.assertIn("fstests.doap", dir) class GitLfsTest(FetcherTest): + def skipIfNoGitLFS(): + import shutil + if not shutil.which('git-lfs'): + return unittest.skip('git-lfs not installed') + return lambda f: f + def setUp(self): FetcherTest.setUp(self) @@ -2232,6 +2238,44 @@ class GitLfsTest(FetcherTest): ud = fetcher.ud[uri] return fetcher, ud + def get_real_git_lfs_file(self): + self.d.setVar('PATH', os.environ.get('PATH')) + fetcher, ud = self.fetch() + fetcher.unpack(self.d.getVar('WORKDIR')) + unpacked_lfs_file = os.path.join(self.d.getVar('WORKDIR'), 'git', "Cat_poster_1.jpg") + return unpacked_lfs_file + + @skipIfNoGitLFS() + @skipIfNoNetwork() + def test_real_git_lfs_repo_succeeds_without_lfs_param(self): + self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master") + f = self.get_real_git_lfs_file() + self.assertTrue(os.path.exists(f)) + self.assertEqual("c0baab607a97839c9a328b4310713307", bb.utils.md5_file(f)) + + @skipIfNoGitLFS() + @skipIfNoNetwork() + def test_real_git_lfs_repo_succeeds(self): + self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master;lfs=1") + f = self.get_real_git_lfs_file() + self.assertTrue(os.path.exists(f)) + self.assertEqual("c0baab607a97839c9a328b4310713307", bb.utils.md5_file(f)) + + @skipIfNoGitLFS() + @skipIfNoNetwork() + def test_real_git_lfs_repo_succeeds(self): + self.d.setVar('SRC_URI', "git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master;lfs=0") + f = self.get_real_git_lfs_file() + # This is the actual non-smudged placeholder file on the repo if git-lfs does not run + lfs_file = ( + 'version https://git-lfs.github.com/spec/v1\n' + 'oid sha256:34be66b1a39a1955b46a12588df9d5f6fc1da790e05cf01f3c7422f4bbbdc26b\n' + 'size 11423554\n' + ) + + with open(f) as fh: + self.assertEqual(lfs_file, fh.read()) + def test_lfs_enabled(self): import shutil From patchwork Fri Feb 17 17:00:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Neves X-Patchwork-Id: 19698 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A9E8C05027 for ; Fri, 17 Feb 2023 17:00:55 +0000 (UTC) Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) by mx.groups.io with SMTP id smtpd.web11.11728.1676653252957390427 for ; Fri, 17 Feb 2023 09:00:53 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@myneves.com header.s=protonmail header.b=dzUzV5Oh; spf=pass (domain: myneves.com, ip: 185.70.43.23, mailfrom: paulo@myneves.com) Date: Fri, 17 Feb 2023 17:00:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=myneves.com; s=protonmail; t=1676653250; x=1676912450; bh=nn5fllmPlowIcbnTx7D9zdeU9B8OPSZbjcmL16jZSmQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=dzUzV5OhkCotgaELMHJxPR/cvmn6xrkVRI+LtquhO67hOpc3+i0bL213J86lwBP0G c/FCgpaU90c1+MKSMt29CV3hBiQB0USJX4NXvH3fmzgJ7SLho00eITBqJ5/n+iKy0x uKP1yeTAbHVPYYWq6qTmW0q487IapeJ96rLcpX48ipNnNJYc/onFOA3VumNYaAkZoR u/aCdWSlZtCdT3M4K3fdZKlNhOe1pFsMzJwarIns23upc+ycyRJ8l5E8RtkDPPXKNF 3MOX+sPtrUcxsZdjB+OPvdOhdoteUcGw+m5jOTrY0+uCpbcLFrrNdrjQ/MPLXjIpy7 PWObz++cfLMDQ== To: bitbake-devel@lists.openembedded.org From: Paulo Neves Cc: Paulo Neves Subject: [PATCH 3/5] git: Remove is None check on _find_git_lfs Message-ID: <20230217170009.58707-3-paulo@myneves.com> In-Reply-To: <20230217170009.58707-1-paulo@myneves.com> References: <20230217170009.58707-1-paulo@myneves.com> Feedback-ID: 59941854:user:proton MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 17 Feb 2023 17:00:55 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/14462 shutil.which returns None when the argument is not found. As per documentation[1] None is evaluated to False and everything else is True, so it is safe to have _find_git_lfs just return the value of shutil.which [1] https://docs.python.org/3/library/stdtypes.html#truth-value-testing Signed-off-by: Paulo Neves --- lib/bb/fetch2/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.34.1 diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py index 2e3d32515..a3f29d2b9 100644 --- a/lib/bb/fetch2/git.py +++ b/lib/bb/fetch2/git.py @@ -687,7 +687,7 @@ class Git(FetchMethod): Return True if git-lfs can be found, False otherwise. """ import shutil - return shutil.which("git-lfs", path=d.getVar('PATH')) is not None + return shutil.which("git-lfs", path=d.getVar('PATH')) def _get_repo_url(self, ud): """ From patchwork Fri Feb 17 17:01:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Neves X-Patchwork-Id: 19699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A4F2C05027 for ; Fri, 17 Feb 2023 17:01:15 +0000 (UTC) Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) by mx.groups.io with SMTP id smtpd.web11.11736.1676653269687568188 for ; Fri, 17 Feb 2023 09:01:10 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@myneves.com header.s=protonmail header.b=kS0av9DQ; spf=pass (domain: myneves.com, ip: 185.70.43.23, mailfrom: paulo@myneves.com) Date: Fri, 17 Feb 2023 17:01:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=myneves.com; s=protonmail; t=1676653267; x=1676912467; bh=nL2BFtyRnRMsipC0tdgdOUkhOEuPoq7UM9OSXeEWMVM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=kS0av9DQmwRzMV9f/JjaTZrSEHUTmGrKtJMZS7hiG7jCkrrJw8i1Zt1yXNZdR6i9O x6BNMwSc9zJitoCKjZH79mw//PVfcI/4dEGLYFyX4Mc+TzhPOuC+dz/pX2uU/OW1iG 12umG0mXdX9qjFUNolZSnkKfC0unaJbwWiTbBSc42jQKl0kZMOGaOaQEvRBZGBbrOt S/rHQFFZfcslt5bow7zhBiP+/ScDSE+3P+4FOBVySc8t5nJf8hNGUwH8F3HEbf45Tm 6bWEt4MD3Zc98U1MSFmepWo0wQUIOFTs41xdVtmlXRe9gCZY6YG1kQbz9Pqq+2ygUU UxpQWqxS98iQA== To: bitbake-devel@lists.openembedded.org From: Paulo Neves Cc: Paulo Neves Subject: [PATCH 4/5] git.py: @_contains_lfs: Removed unused variables Message-ID: <20230217170009.58707-4-paulo@myneves.com> In-Reply-To: <20230217170009.58707-1-paulo@myneves.com> References: <20230217170009.58707-1-paulo@myneves.com> Feedback-ID: 59941854:user:proton MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 17 Feb 2023 17:01:15 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/14463 branchname was set but never used in the context of _contains_lfs method. Signed-off-by: Paulo Neves --- lib/bb/fetch2/git.py | 5 ----- 1 file changed, 5 deletions(-) -- 2.34.1 diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py index a3f29d2b9..fcd70fdcf 100644 --- a/lib/bb/fetch2/git.py +++ b/lib/bb/fetch2/git.py @@ -660,11 +660,6 @@ class Git(FetchMethod): Check if the repository has 'lfs' (large file) content """ - if not ud.nobranch: - branchname = ud.branches[ud.names[0]] - else: - branchname = "master" - # The bare clonedir doesn't use the remote names; it has the branch immediately. if wd == ud.clonedir: refname = ud.branches[ud.names[0]] From patchwork Fri Feb 17 17:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Neves X-Patchwork-Id: 19700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11CABC05027 for ; Fri, 17 Feb 2023 17:01:35 +0000 (UTC) Received: from mail-40136.proton.ch (mail-40136.proton.ch [185.70.40.136]) by mx.groups.io with SMTP id smtpd.web10.11910.1676653289086809480 for ; Fri, 17 Feb 2023 09:01:29 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@myneves.com header.s=protonmail header.b=FVY2mZGc; spf=pass (domain: myneves.com, ip: 185.70.40.136, mailfrom: paulo@myneves.com) Date: Fri, 17 Feb 2023 17:01:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=myneves.com; s=protonmail; t=1676653285; x=1676912485; bh=O1ZiNKHGGNeFVe0vbBdvtx/YrSfAh+Od5fw9XiOws0A=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=FVY2mZGcnPskLtyglFK5ztxfMtVHia9oEtKqg0tvrYJzVGS1QSi/PEmseZcMD7MHS wg11OAlIDcr3+R9aoCxD2ZckawCtyL9TxpNVnboLR1I/thGU2XrxhVB3xqbHvBa0xN bapPa06ZtYEa63tzwfXttxnVxFK+aBWvC/oqrW/zhGPDH0ku+FFKljdBsqRrST/Djd K6VLDHQwK+7/NUYNpGMAfh8FG6cvWtHSl83tEv6gnAxbi6ElCR48rn1OOe3KzECaG5 cI99qu/YoFbPkFSu9T6Ig6uemxFN5mZiU2mwun5ISRS7ArNXASGzDqZl5kWCSruFre ltVXD2GLzECUg== To: bitbake-devel@lists.openembedded.org From: Paulo Neves Cc: Paulo Neves Subject: [PATCH 5/5] git.py Replace mkdtemp with TemporaryDirectory and avoid exception masking Message-ID: <20230217170009.58707-5-paulo@myneves.com> In-Reply-To: <20230217170009.58707-1-paulo@myneves.com> References: <20230217170009.58707-1-paulo@myneves.com> Feedback-ID: 59941854:user:proton MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 17 Feb 2023 17:01:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/14464 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. Signed-off-by: Paulo Neves --- lib/bb/fetch2/git.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.34.1 diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py index fcd70fdcf..9445643e5 100644 --- a/lib/bb/fetch2/git.py +++ b/lib/bb/fetch2/git.py @@ -417,8 +417,7 @@ class Git(FetchMethod): # It would be nice to just do this inline here by running 'git-lfs fetch' # on the bare clonedir, but that operation requires a working copy on some # releases of Git LFS. - tmpdir = tempfile.mkdtemp(dir=d.getVar('DL_DIR')) - try: + with tempfile.TemporaryDirectory(dir=d.getVar('DL_DIR')) as tmpdir: # Do the checkout. This implicitly involves a Git LFS fetch. Git.unpack(self, ud, tmpdir, d) @@ -436,8 +435,6 @@ class Git(FetchMethod): # downloaded. if os.path.exists(os.path.join(tmpdir, "git", ".git", "lfs")): runfetchcmd("tar -cf - lfs | tar -xf - -C %s" % ud.clonedir, d, workdir="%s/git/.git" % tmpdir) - finally: - bb.utils.remove(tmpdir, recurse=True) def build_mirror_data(self, ud, d):