Skip to contentSkip to conversation

Date in version number

DISCUSSION Daniel Squires 2 participants 2 messages Oct 25, 2024

lore
Share & tools
lore
#0 lore raw

We have many internal projects that we build as part of our platform. These are all managed in git repositories. Our recipes therefore all point at git repositories.
After some internal discussions we have come to  the conclusion that having traditional version numbers of the form x.y.z is not very useful to anyone and is a chore to maintain.
We would like to generate our version numbers in the format YYYY.MM.DD-PR-SRCREV - e.g. 2024.10.25-1-abcdef12.
I found the SRCDATE variable in the glossary documented as "The date of the source code used to build the package. This variable applies only if the source was fetched from a Source Code Manager (SCM)." and initially thought great, and went ahead and set:

PV = "${SRCDATE}-${SRCPV}"

However what I find is that builds have the current date - i.e. the build date, not the date of the currently used commit to the source tree. Indeed SRCDATE it literally derived from DATE, the date when we run. This has a several problems:

1) Everything would be rebuilt every day as a new date changes the recipe
2) The builds are not reproducible
3) We want to be able to see at a glance the date a given packages source was committed, not when it happened to get built.

Does anybody know of a way to achieve this? I have tried looking through the docs and the output of bitbake <recipename> -e and come up empty.

If we were to implement a way to get this information in bitbake what are the chances of being able to get it merged upstream? would this be frowned upon or rejected on any grounds?

#1 lore raw
Quoted 25 lines · Daniel Squires via lists.yoctoproject.org

We have many internal projects that we build as part of our platform. These are all managed in git repositories. Our recipes therefore all point at git repositories.
After some internal discussions we have come to  the conclusion that having traditional version numbers of the form x.y.z is not very useful to anyone and is a chore to maintain.
We would like to generate our version numbers in the format YYYY.MM.DD-PR-SRCREV - e.g. 2024.10.25-1-abcdef12.
I found the SRCDATE variable in the glossary documented as "The date of the source code used to build the package. This variable applies only if the source was fetched from a Source Code Manager (SCM)." and initially thought great, and went ahead and set:

    PV = "${SRCDATE}-${SRCPV}"

However what I find is that builds have the current date - i.e. the build date, not the date of the currently used commit to the source tree. Indeed SRCDATE it literally derived from DATE, the date when we run. This has a several problems:

1) Everything would be rebuilt every day as a new date changes the recipe
2) The builds are not reproducible
3) We want to be able to see at a glance the date a given packages source was committed, not when it happened to get built.

Quoted 8 lines


Does anybody know of a way to achieve this? I have tried looking through the docs and the output of bitbake <recipename> -e and come up empty.

If we were to implement a way to get this information in bitbake what are the chances of being able to get it merged upstream? would this be frowned upon or rejected on any grounds?

I'm not sure we've ever done that for git repositories. The challenge is that the date isn't as linear as you might think. For starters, you'd need to use the commit date rather than the patch author date since patches aren't always merged in the date they're written. If the git repository contains merges, the dates may then also not quite follow what you'd expect depending on which side of the merge the commit was from.

There was work to inject "git-describe" output into the version field and I'd imagine you could do something similar for the date it you wanted to.

https://github.com/openembedded/meta-openembedded/blob/master/meta-oe/classes/gitpkgv.bbclass

We did get parts of that into the bitbake fetcher but I can't remember how far we got.

Cheers,

Richard