* [bitbake][dunfell][1.46][PATCH 0/4] Patch review
@ 2021-02-03 14:22 Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 1/4] git.py: skip smudging if lfs=0 is set Steve Sakoman
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Steve Sakoman @ 2021-02-03 14:22 UTC (permalink / raw)
To: bitbake-devel
Please review this set of patches for dunfell/1.46 and have comments back by
end of day Friday.
Passed a-full on autobuilder:
https://autobuilder.yoctoproject.org/typhoon/#/builders/83/builds/1815
The following changes since commit 418c00c570a60845556204b4f52de047b284dd8e:
data_smart: Ensure hash reflects vardepvalue flags correctly (2021-01-26 15:45:01 +0000)
are available in the Git repository at:
git://git.openembedded.org/bitbake-contrib stable/1.46-nut
http://cgit.openembedded.org/bitbake-contrib/log/?h=stable/1.46-nut
Matt Hoosier (1):
fetch/git: download LFS content too during do_fetch
Mauro Queirós (3):
git.py: skip smudging if lfs=0 is set
git.py: LFS bitbake note should not be printed if need_lfs is not set.
git.py: Use the correct branch to check if the repository has LFS
objects.
lib/bb/fetch2/git.py | 56 +++++++++++++++++++++++++++++++++++++++----
lib/bb/tests/fetch.py | 28 +++++++++++++++-------
2 files changed, 72 insertions(+), 12 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [bitbake][dunfell][1.46][PATCH 1/4] git.py: skip smudging if lfs=0 is set
2021-02-03 14:22 [bitbake][dunfell][1.46][PATCH 0/4] Patch review Steve Sakoman
@ 2021-02-03 14:22 ` Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 2/4] git.py: LFS bitbake note should not be printed if need_lfs is not set Steve Sakoman
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Steve Sakoman @ 2021-02-03 14:22 UTC (permalink / raw)
To: bitbake-devel
From: Mauro Queirós <maurofrqueiros@gmail.com>
Git-LFS objects were being fetched even when lfs=0 was not set.
This patch disables LFS smudging when lfs=0. That way, only the LFS pointers
are downloaded during checkout.
Signed-off-by: Mauro Queiros <maurofrqueiros@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 646d86df7de774255246a3d7051c308e43eb257d)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
lib/bb/fetch2/git.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index dcecff5d..59afc32d 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -475,6 +475,9 @@ class Git(FetchMethod):
need_lfs = ud.parm.get("lfs", "1") == "1"
+ if not need_lfs:
+ ud.basecmd = "GIT_LFS_SKIP_SMUDGE=1 " + ud.basecmd
+
source_found = False
source_error = []
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bitbake][dunfell][1.46][PATCH 2/4] git.py: LFS bitbake note should not be printed if need_lfs is not set.
2021-02-03 14:22 [bitbake][dunfell][1.46][PATCH 0/4] Patch review Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 1/4] git.py: skip smudging if lfs=0 is set Steve Sakoman
@ 2021-02-03 14:22 ` Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 3/4] git.py: Use the correct branch to check if the repository has LFS objects Steve Sakoman
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Steve Sakoman @ 2021-02-03 14:22 UTC (permalink / raw)
To: bitbake-devel
From: Mauro Queirós <maurofrqueiros@gmail.com>
The message "Repository %s has LFS content but it is not being fetched" was
being printed, even when Git-LFS was available and "lfs=1" was set. In those
situations, we want to fetch LFS content, so that message would not make sense.
Signed-off-by: Mauro Queiros <maurofrqueiros@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 45028dfda5a29a34ab408cb3f11d72ae17963340)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
lib/bb/fetch2/git.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 59afc32d..bdbfe5c0 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -509,7 +509,7 @@ class Git(FetchMethod):
if self._contains_lfs(ud, d, destdir):
if need_lfs and not self._find_git_lfs(d):
raise bb.fetch2.FetchError("Repository %s has LFS content, install git-lfs on host to download (or set lfs=0 to ignore it)" % (repourl))
- else:
+ elif not need_lfs:
bb.note("Repository %s has LFS content but it is not being fetched" % (repourl))
if not ud.nocheckout:
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bitbake][dunfell][1.46][PATCH 3/4] git.py: Use the correct branch to check if the repository has LFS objects.
2021-02-03 14:22 [bitbake][dunfell][1.46][PATCH 0/4] Patch review Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 1/4] git.py: skip smudging if lfs=0 is set Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 2/4] git.py: LFS bitbake note should not be printed if need_lfs is not set Steve Sakoman
@ 2021-02-03 14:22 ` Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 4/4] fetch/git: download LFS content too during do_fetch Steve Sakoman
2021-02-03 15:36 ` [bitbake-devel] [bitbake][dunfell][1.46][PATCH 0/4] Patch review Mikko Rapeli
4 siblings, 0 replies; 6+ messages in thread
From: Steve Sakoman @ 2021-02-03 14:22 UTC (permalink / raw)
To: bitbake-devel
From: Mauro Queirós <maurofrqueiros@gmail.com>
Function "contains_lfs" was only looking at the master branch when searching for LFS
content. LFS may be configured in specific branches only, so we need to use the
correct branch.
Signed-off-by: Mauro Queiros <maurofrqueiros@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 4fa67c2af830035a1ddedc14592ee25a15ebff22)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
lib/bb/fetch2/git.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index bdbfe5c0..07064c69 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -566,8 +566,15 @@ class Git(FetchMethod):
"""
Check if the repository has 'lfs' (large file) content
"""
- cmd = "%s grep lfs HEAD:.gitattributes | wc -l" % (
- ud.basecmd)
+
+ if not ud.nobranch:
+ branchname = ud.branches[ud.names[0]]
+ else:
+ branchname = "master"
+
+ cmd = "%s grep lfs origin/%s:.gitattributes | wc -l" % (
+ ud.basecmd, ud.branches[ud.names[0]])
+
try:
output = runfetchcmd(cmd, d, quiet=True, workdir=wd)
if int(output) > 0:
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bitbake][dunfell][1.46][PATCH 4/4] fetch/git: download LFS content too during do_fetch
2021-02-03 14:22 [bitbake][dunfell][1.46][PATCH 0/4] Patch review Steve Sakoman
` (2 preceding siblings ...)
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 3/4] git.py: Use the correct branch to check if the repository has LFS objects Steve Sakoman
@ 2021-02-03 14:22 ` Steve Sakoman
2021-02-03 15:36 ` [bitbake-devel] [bitbake][dunfell][1.46][PATCH 0/4] Patch review Mikko Rapeli
4 siblings, 0 replies; 6+ messages in thread
From: Steve Sakoman @ 2021-02-03 14:22 UTC (permalink / raw)
To: bitbake-devel
From: Matt Hoosier <matt.hoosier@garmin.com>
Insert an explicit pass to fetch all blobs needed by Git LFS, during the
fetch() function. This avoids the default behavior of Git LFS to wait
until 'git checkout' to begin downloading the blobs pointed to by LFS records.
Network access is not allowed at that point in the recipe's lifecycle.
[YOCTO #14191]
Signed-off-by: Matt Hoosier <matt.hoosier@garmin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 0efac66043662e7a2027192f50e92e982db2ba1c)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
lib/bb/fetch2/git.py | 44 ++++++++++++++++++++++++++++++++++++++++---
lib/bb/tests/fetch.py | 28 +++++++++++++++++++--------
2 files changed, 61 insertions(+), 11 deletions(-)
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 07064c69..8740e9c0 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -378,6 +378,35 @@ class Git(FetchMethod):
if missing_rev:
raise bb.fetch2.FetchError("Unable to find revision %s even from upstream" % missing_rev)
+ if self._contains_lfs(ud, d, ud.clonedir) and self._need_lfs(ud):
+ # Unpack temporary working copy, use it to run 'git checkout' to force pre-fetching
+ # of all LFS blobs needed at the the srcrev.
+ #
+ # 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:
+ # Do the checkout. This implicitly involves a Git LFS fetch.
+ self.unpack(ud, tmpdir, d)
+
+ # Scoop up a copy of any stuff that Git LFS downloaded. Merge them into
+ # the bare clonedir.
+ #
+ # As this procedure is invoked repeatedly on incremental fetches as
+ # a recipe's SRCREV is bumped throughout its lifetime, this will
+ # result in a gradual accumulation of LFS blobs in <ud.clonedir>/lfs
+ # corresponding to all the blobs reachable from the different revs
+ # fetched across time.
+ #
+ # Only do this if the unpack resulted in a .git/lfs directory being
+ # created; this only happens if at least one blob needed to be
+ # 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):
if ud.shallow and ud.write_shallow_tarballs:
if not os.path.exists(ud.fullshallow):
@@ -473,7 +502,7 @@ class Git(FetchMethod):
if os.path.exists(destdir):
bb.utils.prunedir(destdir)
- need_lfs = ud.parm.get("lfs", "1") == "1"
+ need_lfs = self._need_lfs(ud)
if not need_lfs:
ud.basecmd = "GIT_LFS_SKIP_SMUDGE=1 " + ud.basecmd
@@ -562,6 +591,9 @@ class Git(FetchMethod):
raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
return output.split()[0] != "0"
+ def _need_lfs(self, ud):
+ return ud.parm.get("lfs", "1") == "1"
+
def _contains_lfs(self, ud, d, wd):
"""
Check if the repository has 'lfs' (large file) content
@@ -572,8 +604,14 @@ class Git(FetchMethod):
else:
branchname = "master"
- cmd = "%s grep lfs origin/%s:.gitattributes | wc -l" % (
- ud.basecmd, ud.branches[ud.names[0]])
+ # The bare clonedir doesn't use the remote names; it has the branch immediately.
+ if wd == ud.clonedir:
+ refname = ud.branches[ud.names[0]]
+ else:
+ refname = "origin/%s" % ud.branches[ud.names[0]]
+
+ cmd = "%s grep lfs %s:.gitattributes | wc -l" % (
+ ud.basecmd, refname)
try:
output = runfetchcmd(cmd, d, quiet=True, workdir=wd)
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 4702c99a..9453c90d 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -2046,13 +2046,14 @@ class GitLfsTest(FetcherTest):
cwd = self.gitdir
return bb.process.run(cmd, cwd=cwd)[0]
- def fetch(self, uri=None):
+ def fetch(self, uri=None, download=True):
uris = self.d.getVar('SRC_URI').split()
uri = uris[0]
d = self.d
fetcher = bb.fetch2.Fetch(uris, d)
- fetcher.download()
+ if download:
+ fetcher.download()
ud = fetcher.ud[uri]
return fetcher, ud
@@ -2062,16 +2063,21 @@ class GitLfsTest(FetcherTest):
uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir
self.d.setVar('SRC_URI', uri)
- fetcher, ud = self.fetch()
+ # Careful: suppress initial attempt at downloading until
+ # we know whether git-lfs is installed.
+ fetcher, ud = self.fetch(uri=None, download=False)
self.assertIsNotNone(ud.method._find_git_lfs)
- # If git-lfs can be found, the unpack should be successful
- ud.method._find_git_lfs = lambda d: True
- shutil.rmtree(self.gitdir, ignore_errors=True)
- fetcher.unpack(self.d.getVar('WORKDIR'))
+ # If git-lfs can be found, the unpack should be successful. Only
+ # attempt this with the real live copy of git-lfs installed.
+ if ud.method._find_git_lfs(self.d):
+ fetcher.download()
+ 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'))
@@ -2082,10 +2088,16 @@ class GitLfsTest(FetcherTest):
uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir
self.d.setVar('SRC_URI', uri)
+ # In contrast to test_lfs_enabled(), allow the implicit download
+ # done by self.fetch() to occur here. The point of this test case
+ # is to verify that the fetcher can survive even if the source
+ # repository has Git LFS usage configured.
fetcher, ud = self.fetch()
self.assertIsNotNone(ud.method._find_git_lfs)
- # If git-lfs can be found, the unpack should be successful
+ # 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'))
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [bitbake-devel] [bitbake][dunfell][1.46][PATCH 0/4] Patch review
2021-02-03 14:22 [bitbake][dunfell][1.46][PATCH 0/4] Patch review Steve Sakoman
` (3 preceding siblings ...)
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 4/4] fetch/git: download LFS content too during do_fetch Steve Sakoman
@ 2021-02-03 15:36 ` Mikko Rapeli
4 siblings, 0 replies; 6+ messages in thread
From: Mikko Rapeli @ 2021-02-03 15:36 UTC (permalink / raw)
To: steve; +Cc: bitbake-devel
Hi,
On Wed, Feb 03, 2021 at 04:22:05AM -1000, Steve Sakoman wrote:
> Please review this set of patches for dunfell/1.46 and have comments back by
> end of day Friday.
>
> Passed a-full on autobuilder:
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/83/builds/1815
>
> The following changes since commit 418c00c570a60845556204b4f52de047b284dd8e:
>
> data_smart: Ensure hash reflects vardepvalue flags correctly (2021-01-26 15:45:01 +0000)
>
> are available in the Git repository at:
>
> git://git.openembedded.org/bitbake-contrib stable/1.46-nut
> http://cgit.openembedded.org/bitbake-contrib/log/?h=stable/1.46-nut
>
> Matt Hoosier (1):
> fetch/git: download LFS content too during do_fetch
>
> Mauro Queirós (3):
> git.py: skip smudging if lfs=0 is set
> git.py: LFS bitbake note should not be printed if need_lfs is not set.
> git.py: Use the correct branch to check if the repository has LFS
> objects.
Acked-by: Mikko Rapeli <mikko.rapeli@bmw.de>
FWIW, I'm using git lfs on dunfell with only patches:
git.py: Search for LFS objects on the correct branch.
git.py: skip smudging if lfs=0 is set
bitbake: fetch2/svn: Fix SVN repository concurrent update race
but I don't see any harm in adding the fourth patch:
bitbake: git.py: LFS bitbake note should not be printed if need_lfs is not set.
Cheers,
-Mikko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-02-03 15:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 14:22 [bitbake][dunfell][1.46][PATCH 0/4] Patch review Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 1/4] git.py: skip smudging if lfs=0 is set Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 2/4] git.py: LFS bitbake note should not be printed if need_lfs is not set Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 3/4] git.py: Use the correct branch to check if the repository has LFS objects Steve Sakoman
2021-02-03 14:22 ` [bitbake][dunfell][1.46][PATCH 4/4] fetch/git: download LFS content too during do_fetch Steve Sakoman
2021-02-03 15:36 ` [bitbake-devel] [bitbake][dunfell][1.46][PATCH 0/4] Patch review Mikko Rapeli
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.