Yocto, GIT-LFS and Submodules

Reading Time: < 1 minute

Recently I was trying to make a Yocto image by including a project which is using git-lfs and also contains a lot of submodules. So what could go wrong in this, well I was in for a surprise here,

  • git-lfs needs to be installed on host system. Well that’s understandable.
  • You need to use gitsm fetcher instead of git fetcher in your SRC_URI so that all the submodules also get downloaded.

I was using the following version of YOCTO as per the file meta-poky/conf/distro/poky.conf

DISTRO_NAME = "Poky (Yocto Project Reference Distro)"
DISTRO_VERSION = "3.2.3"
DISTRO_CODENAME = "gatesgarth"
 

When using gitsm fetcher I kept getting error in the unpacking of submodule(s) which would report somewhat cryptic message that

module is unavailable or not upto date which happens because the submodule isn’t downloaded and a checkout is attempted which fails. Then I found that there’s a patch which probably isn’t available for gatesgarthand below versions. The following is the patch


diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 8740e9c05f..112b833f87 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -388,7 +388,7 @@ class Git(FetchMethod):
             tmpdir = tempfile.mkdtemp(dir=d.getVar('DL_DIR'))
             try:
                 # Do the checkout. This implicitly involves a Git LFS
fetch.
-                self.unpack(ud, tmpdir, d)
+                Git.unpack(self, ud, tmpdir, d)

                 # Scoop up a copy of any stuff that Git LFS downloaded.
Merge them into
                 # the bare clonedir.
--
2.25.1
 

Once the patch above was applied, the gitsmfetcher was happy and things seemed to work fine post that. Thanks to Niels Avonds for the patch!

 

Leave a Reply