[libcamera-devel] libcamera: Add build time to version string

Message ID 20200805125700.2254511-1-niklas.soderlund@ragnatech.se
State Accepted
Headers show
Series
  • [libcamera-devel] libcamera: Add build time to version string
Related show

Commit Message

Niklas Söderlund Aug. 5, 2020, 12:57 p.m. UTC
Having the build time in the version string is useful when building from
a dirty worktree and deploying to targets as a quick way to identify the
binary have been deployed successfully.

Before this change the version string is reported as

    libcamera v0.0.0+1692-aaff196a-dirty

While with this change the version string is reported as

    libcamera v0.0.0+1692-aaff196a-dirty 2020-08-05T12:55:11+00:00

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 utils/gen-version.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Aug. 5, 2020, 2:29 p.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Wed, Aug 05, 2020 at 02:57:00PM +0200, Niklas Söderlund wrote:
> Having the build time in the version string is useful when building from
> a dirty worktree and deploying to targets as a quick way to identify the
> binary have been deployed successfully.
> 
> Before this change the version string is reported as
> 
>     libcamera v0.0.0+1692-aaff196a-dirty
> 
> While with this change the version string is reported as
> 
>     libcamera v0.0.0+1692-aaff196a-dirty 2020-08-05T12:55:11+00:00
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

This will get in the way of reproducible builds, especially for tagged
releases. I would at least restrict this feature to dirty builds, and
even then, I'll let Kieran comment on whether reproducible builds are
important.

> ---
>  utils/gen-version.sh | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/utils/gen-version.sh b/utils/gen-version.sh
> index 7f7872ceba7b038a..93bc97d6d8a8a24a 100755
> --- a/utils/gen-version.sh
> +++ b/utils/gen-version.sh
> @@ -32,4 +32,6 @@ git diff-index --quiet HEAD || version="$version-dirty"
>  # of the git SHA1 and remove the initial 'v'.
>  version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 2-)
>  
> -echo "$version"
> +buildtime=$(date --iso-8601=seconds --utc)
> +
> +echo "$version $buildtime"
Kieran Bingham Aug. 5, 2020, 2:34 p.m. UTC | #2
Hi all,

On 05/08/2020 15:29, Laurent Pinchart wrote:
> Hi Niklas,
> 
> Thank you for the patch.
> 
> On Wed, Aug 05, 2020 at 02:57:00PM +0200, Niklas Söderlund wrote:
>> Having the build time in the version string is useful when building from
>> a dirty worktree and deploying to targets as a quick way to identify the
>> binary have been deployed successfully.
>>
>> Before this change the version string is reported as
>>
>>     libcamera v0.0.0+1692-aaff196a-dirty
>>
>> While with this change the version string is reported as
>>
>>     libcamera v0.0.0+1692-aaff196a-dirty 2020-08-05T12:55:11+00:00
>>
>> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> 
> This will get in the way of reproducible builds, especially for tagged
> releases. I would at least restrict this feature to dirty builds, and
> even then, I'll let Kieran comment on whether reproducible builds are
> important.

I think I recall determining that reproducible builds were already
broken due to the way meson handles RPATH/RUNPATH.

I too frequently use the version string to make sure I am running the
same code I expect, and having a build-time stamp in there (for debug)
builds would be quite nice.

Restricting this to DEBUG builds might be quite nice, then release
builds from packagers just get a clean version.

Adding only for release builds also removes any worries of reproducible
builds from the equation anyway ;-)

--
Kieran


>> ---
>>  utils/gen-version.sh | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/utils/gen-version.sh b/utils/gen-version.sh
>> index 7f7872ceba7b038a..93bc97d6d8a8a24a 100755
>> --- a/utils/gen-version.sh
>> +++ b/utils/gen-version.sh
>> @@ -32,4 +32,6 @@ git diff-index --quiet HEAD || version="$version-dirty"
>>  # of the git SHA1 and remove the initial 'v'.
>>  version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 2-)
>>  
>> -echo "$version"
>> +buildtime=$(date --iso-8601=seconds --utc)
>> +
>> +echo "$version $buildtime"
>
Laurent Pinchart Aug. 5, 2020, 2:47 p.m. UTC | #3
Hi Kieran,

On Wed, Aug 05, 2020 at 03:34:01PM +0100, Kieran Bingham wrote:
> On 05/08/2020 15:29, Laurent Pinchart wrote:
> > On Wed, Aug 05, 2020 at 02:57:00PM +0200, Niklas Söderlund wrote:
> >> Having the build time in the version string is useful when building from
> >> a dirty worktree and deploying to targets as a quick way to identify the
> >> binary have been deployed successfully.
> >>
> >> Before this change the version string is reported as
> >>
> >>     libcamera v0.0.0+1692-aaff196a-dirty
> >>
> >> While with this change the version string is reported as
> >>
> >>     libcamera v0.0.0+1692-aaff196a-dirty 2020-08-05T12:55:11+00:00
> >>
> >> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > 
> > This will get in the way of reproducible builds, especially for tagged
> > releases. I would at least restrict this feature to dirty builds, and
> > even then, I'll let Kieran comment on whether reproducible builds are
> > important.
> 
> I think I recall determining that reproducible builds were already
> broken due to the way meson handles RPATH/RUNPATH.
> 
> I too frequently use the version string to make sure I am running the
> same code I expect, and having a build-time stamp in there (for debug)
> builds would be quite nice.
> 
> Restricting this to DEBUG builds might be quite nice, then release
> builds from packagers just get a clean version.
> 
> Adding only for release builds also removes any worries of reproducible
> builds from the equation anyway ;-)

Would adding a timestamp for dirty builds be more generic ? Presumably
if the working tree is clean you don't need to differentiate between
different builds with the same commti sha1, as they should all be the
same :-)

> >> ---
> >>  utils/gen-version.sh | 4 +++-
> >>  1 file changed, 3 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/utils/gen-version.sh b/utils/gen-version.sh
> >> index 7f7872ceba7b038a..93bc97d6d8a8a24a 100755
> >> --- a/utils/gen-version.sh
> >> +++ b/utils/gen-version.sh
> >> @@ -32,4 +32,6 @@ git diff-index --quiet HEAD || version="$version-dirty"
> >>  # of the git SHA1 and remove the initial 'v'.
> >>  version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 2-)
> >>  
> >> -echo "$version"
> >> +buildtime=$(date --iso-8601=seconds --utc)
> >> +
> >> +echo "$version $buildtime"
Niklas Söderlund Aug. 5, 2020, 6:41 p.m. UTC | #4
Hi,

On 2020-08-05 17:47:05 +0300, Laurent Pinchart wrote:
> Hi Kieran,
> 
> On Wed, Aug 05, 2020 at 03:34:01PM +0100, Kieran Bingham wrote:
> > On 05/08/2020 15:29, Laurent Pinchart wrote:
> > > On Wed, Aug 05, 2020 at 02:57:00PM +0200, Niklas Söderlund wrote:
> > >> Having the build time in the version string is useful when building from
> > >> a dirty worktree and deploying to targets as a quick way to identify the
> > >> binary have been deployed successfully.
> > >>
> > >> Before this change the version string is reported as
> > >>
> > >>     libcamera v0.0.0+1692-aaff196a-dirty
> > >>
> > >> While with this change the version string is reported as
> > >>
> > >>     libcamera v0.0.0+1692-aaff196a-dirty 2020-08-05T12:55:11+00:00
> > >>
> > >> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > > 
> > > This will get in the way of reproducible builds, especially for tagged
> > > releases. I would at least restrict this feature to dirty builds, and
> > > even then, I'll let Kieran comment on whether reproducible builds are
> > > important.
> > 
> > I think I recall determining that reproducible builds were already
> > broken due to the way meson handles RPATH/RUNPATH.
> > 
> > I too frequently use the version string to make sure I am running the
> > same code I expect, and having a build-time stamp in there (for debug)
> > builds would be quite nice.
> > 
> > Restricting this to DEBUG builds might be quite nice, then release
> > builds from packagers just get a clean version.
> > 
> > Adding only for release builds also removes any worries of reproducible
> > builds from the equation anyway ;-)
> 
> Would adding a timestamp for dirty builds be more generic ? Presumably
> if the working tree is clean you don't need to differentiate between
> different builds with the same commti sha1, as they should all be the
> same :-)

I like his, the timestamp is only really useful for dirty builds, will 
send a v2.

> 
> > >> ---
> > >>  utils/gen-version.sh | 4 +++-
> > >>  1 file changed, 3 insertions(+), 1 deletion(-)
> > >>
> > >> diff --git a/utils/gen-version.sh b/utils/gen-version.sh
> > >> index 7f7872ceba7b038a..93bc97d6d8a8a24a 100755
> > >> --- a/utils/gen-version.sh
> > >> +++ b/utils/gen-version.sh
> > >> @@ -32,4 +32,6 @@ git diff-index --quiet HEAD || version="$version-dirty"
> > >>  # of the git SHA1 and remove the initial 'v'.
> > >>  version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 2-)
> > >>  
> > >> -echo "$version"
> > >> +buildtime=$(date --iso-8601=seconds --utc)
> > >> +
> > >> +echo "$version $buildtime"
> 
> -- 
> Regards,
> 
> Laurent Pinchart

Patch

diff --git a/utils/gen-version.sh b/utils/gen-version.sh
index 7f7872ceba7b038a..93bc97d6d8a8a24a 100755
--- a/utils/gen-version.sh
+++ b/utils/gen-version.sh
@@ -32,4 +32,6 @@  git diff-index --quiet HEAD || version="$version-dirty"
 # of the git SHA1 and remove the initial 'v'.
 version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 2-)
 
-echo "$version"
+buildtime=$(date --iso-8601=seconds --utc)
+
+echo "$version $buildtime"