[libcamera-devel,v3] libcamera: Add build time to version string for dirty builds

Message ID 20200805204703.2532732-1-niklas.soderlund@ragnatech.se
State Accepted
Commit f32261f2577ef951e0e69dceae6600478da7f798
Headers show
Series
  • [libcamera-devel,v3] libcamera: Add build time to version string for dirty builds
Related show

Commit Message

Niklas Söderlund Aug. 5, 2020, 8:47 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 has 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-05T22:42:18+02:00)

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
* Changes since v2
- Wrap timestmap between parentheses
- Print time in local timezone
- Fix spelling in commit message
---
 utils/gen-version.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham Aug. 6, 2020, 2:18 p.m. UTC | #1
Hi Niklas,

On 05/08/2020 21:47, 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 has 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-05T22:42:18+02:00)
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
> * Changes since v2
> - Wrap timestmap between parentheses
> - Print time in local timezone
> - Fix spelling in commit message
> ---
>  utils/gen-version.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/gen-version.sh b/utils/gen-version.sh
> index 7f7872ceba7b038a..b09ad495f86a7a58 100755
> --- a/utils/gen-version.sh
> +++ b/utils/gen-version.sh
> @@ -26,7 +26,7 @@ if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir")
>  then
>  	git update-index --refresh > /dev/null 2>&1
>  fi
> -git diff-index --quiet HEAD || version="$version-dirty"
> +git diff-index --quiet HEAD || version="$version-dirty ($(date --iso-8601=seconds))"
>  
>  # Replace first '-' with a '+' to denote build metadata, strip the 'g' in from
>  # of the git SHA1 and remove the initial 'v'.
>

Patch

diff --git a/utils/gen-version.sh b/utils/gen-version.sh
index 7f7872ceba7b038a..b09ad495f86a7a58 100755
--- a/utils/gen-version.sh
+++ b/utils/gen-version.sh
@@ -26,7 +26,7 @@  if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir")
 then
 	git update-index --refresh > /dev/null 2>&1
 fi
-git diff-index --quiet HEAD || version="$version-dirty"
+git diff-index --quiet HEAD || version="$version-dirty ($(date --iso-8601=seconds))"
 
 # Replace first '-' with a '+' to denote build metadata, strip the 'g' in from
 # of the git SHA1 and remove the initial 'v'.