Always get the latest Git revision in a BitBake recipe

Posted on

When it comes to Yocto and BitBake I have strong and mixed feelings. But let's not get there.

If you have to write a Yocto/BitBake recipe to always fetch the latest revision (HEAD) of a Git repository, perhaps from a specific branch, the solution is something along these lines:

...
SRC_URI = "git://git@whatever_repo/something.git;protocol=ssh;branch=YOUR_BRANCH_HERE"
...
SRCREV = "${AUTOREV}"
PV = "0.1+git${SRCPV}"
...

The PV variable is needed to make BitBake always fetch the latest revision from the repo.

That's it.