I have a git repo with different sdk versions in a .zip
format in a separate commits. That practically means that there is a whole files in git history and when you clone the repo you will get everything because diff
between binary files are the whole files.
The problem is that after just a few commits, the size of the repo will be very big (1 commit aprox. 500Mb).
I am using Yocto project and SRC_URI
is cloning the whole repo with history and that is where the things start to go down, since it download a lot of unnecessary data and that is time and storage consuming.
Is there any way to get only one (the last) commit downloaded in fetch task with SRC_URI
without history (shallow clone)? Or maybe to change do_fetch task somehow?
This is something I want to achieve in Yocto:
git clone --depth repo_url
I don't believe this is entirely supported, at least according to the Bitbake manual:
Support for shallow clones is not currently implemented as git does not directly support shallow cloning a particular git commit hash (it only supports cloning from a tag or branch reference).
What is supported seems to be cloning the repo once, and generating a shallow tarball for it (bitbake generates tarballs all the time to avoid re-cloning repos), which should speed things up for you, you just cant avoid the initial full clone.
What you want to try is using BB_GIT_SHALLOW , BB_GENERATE_SHALLOW_TARBALLS and BB_GIT_SHALLOW_DEPTH.
Setting BB_GENERATE_SHALLOW_TARBALLS
to “1” when BB_GIT_SHALLOW
is also set to “1” causes bitbake to generate shallow mirror tarballs when fetching git repositories. The number of commits included in the shallow mirror tarballs is controlled by BB_GIT_SHALLOW_DEPTH
.
Something like the following snippet should do it:
BB_GIT_SHALLOW ?= "1"
# Keep only the top commit
BB_GIT_SHALLOW_DEPTH ?= "1"
BB_GENERATE_SHALLOW_TARBALLS ?= "1"