[lttng-dev] [PATCH] Add bzr revno to the version if in a bzr repository

Alexandre Montplaisir alexmonthy at voxpopuli.im
Tue Jun 3 14:20:52 EDT 2014


Just to give some context, we had a problem with the Ubuntu PPA 
packages, where the version in version.h would not get set to anything, 
and the resulting binary wouldn't report a version number when doing 
lttng --version.

Turned out it's because Launchpad imports everything to bzr branches, 
which scrubs the .git directory, and builds the package from that. So 
the .git directory was not available when building. Which caused the 
empty version.h (it's easy to reproduce locally, just delete the .git 
directory then build).

I tested this patch, and it works well when building from the bzr 
branch. Nice work!

However, should we also handle the case where there is neither a .git or 
.bzr directory, and only use the version from configure.ac?


Cheers,
Alexandre



On 06/03/2014 01:40 PM, Raphaël Beamonte wrote:
> Signed-off-by: Raphaël Beamonte <raphael.beamonte at gmail.com>
> ---
>   include/Makefile.am | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/include/Makefile.am b/include/Makefile.am
> index 386c5ba..a677331 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -18,7 +18,13 @@ version.h:
>   		##
>   		git_branch="$$(git describe --all 2>/dev/null)"; \
>   		if [ -z "$${git_branch}" ]; then \
> -			git_version=""; \
> +			## If we are not in a git repository, we can try bzr
> +			bzr_version="$$(bzr log -S -l1 2>/dev/null | head -n1 | cut -d' ' -f2)"; \
> +			if [ -n "$${bzr_version}" ]; then \
> +				git_version="\" VERSION \"-bzr$${bzr_version}"; \
> +			else \
> +				git_version=""; \
> +			fi; \
>   		else \
>   			git_describe="$$(git describe)"; \
>   			if [ "$${git_branch}" == "$${git_describe}" ] || \




More information about the lttng-dev mailing list