gityoctobitbakeopenembedded

How to set SRCREV for git tag in Yocto?


I'm trying to fetch specific tag from a git repository, however I keep running into problems with SRCREV.

When I use the tag's commit hash like this:

SRC_URI = "git://example.com/repo.git;protocol=https;branch=main;tag=${PV}"
SRCREV = "2bd3465aa7eac0d2de55c9918ce66cac1bcc048f"

I get the following error (6.44 is the version from ${PV} and a tag name):

Bitbake Fetcher Error: FetchError('Conflicting revisions (2bd3465aa7eac0d2de55c9918ce66cac1bcc048f from SRCREV and 6.44 from the url) found, please specify one valid value', None)

If I then specify SRCREV to be the same as in URL (SRCREV = "${PV}") I get this:

Bitbake Fetcher Error: FetchError("Recipe uses a floating tag/branch '6.44' for repo 'example.com/repo.git' without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).", None)

I'm not sure what the use SRCPV in PV for OE means but if I then do PV = "${SRCPV}" I quite understandably get an error regarding cyclical variable expansion:

The variable dependency chain for the failure is: SRCPV -> PV -> SRCREV -> SRCPV -> PV -> BP -> FILESPATH

I found many solutions for getting the latest commit from a branch, but seemingly nothing regarding properly setting up specific tag. How do I do that?


Solution

  • If you set the tag in the SRC_URI then you don't need a SRCREV, but latest releases really don't like you using "floating" references for determinism reasons. A tag is a floating reference, because you can move the tag.

    If you want to checkout 6.44 then identify the SHA that tag points at, and just set SRCREV to that sha.