autotools: propagate git version info to distribution tarball

Store the git describe output in the distribution tarball (make dist)
and ensure that this version is always used for builds from this
tarball. This will prevent the useless "Git Rev Unknown from unknown"
output in tar-based builds.

It will also prevent git from being invoked in tarball builds.

Remove the git branch name since the commit ID (and git tag) in the git
describe output is sufficient to identify the source tree. (In SVN, a
revision ID had to be paired with a branch name to identify the source
tree, in git this is no longer the case.)

Change-Id: Iffe142b6efd81e857802eb604d6310cfd301d207
Reviewed-on: https://code.wireshark.org/review/18415
Reviewed-by: João Valverde <j@v6e.pt>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
This commit is contained in:
Peter Wu 2016-10-31 23:16:00 +01:00 committed by Dario Lombardo
parent 4863d813e9
commit 9490f5e98d
2 changed files with 25 additions and 8 deletions

View File

@ -1202,3 +1202,7 @@ endif
# Update AUTHORS file with entries from git shortlog
gen-authors:
cd $(top_srcdir) && $(PERL) tools/generate_authors.pl AUTHORS.src > AUTHORS
dist-hook:
printf "git_description=%s\n" "$$(git -C $(top_srcdir) describe)" \
> $(top_distdir)/version.conf

View File

@ -130,17 +130,16 @@ sub read_repo_info {
my $is_git_repo = 0;
my $git_cdir;
# Make sure git is available.
if (!`$git_executable --version`) {
print STDERR "Git unavailable. Git revision will be missing from version string.\n";
return;
}
if ($version_pref{"pkg_enable"} > 0) {
$package_format = $version_pref{"pkg_format"};
}
if (-e "$srcdir/.git" && ! -d "$srcdir/.git/svn") {
# For tarball releases, do not invoke git at all and instead rely on
# versioning information that was provided at tarball creation time.
if ($version_pref{"git_description"}) {
$info_source = "version.conf file";
} elsif (-e "$srcdir/.git" && ! -d "$srcdir/.git/svn") {
$info_source = "Command line (git)";
$version_pref{"git_client"} = 1;
$is_git_repo = 1;
@ -154,6 +153,12 @@ sub read_repo_info {
$is_git_repo = 1;
}
# Make sure git is available.
if ($is_git_repo && !`$git_executable --version`) {
print STDERR "Git unavailable. Git revision will be missing from version string.\n";
return;
}
# Check whether to include VCS version information in version.h
if ($is_git_repo) {
chomp($git_cdir = qx{git --git-dir="$srcdir/.git" rev-parse --git-common-dir 2> $devnull});
@ -186,7 +191,12 @@ sub read_repo_info {
# Refs: git ls-remote code.wireshark.org:wireshark
# ea19c7f952ce9fc53fe4c223f1d9d6797346258b (r48972, changed version to 1.11.0)
if ($version_pref{"git_client"}) {
if ($version_pref{"git_description"}) {
$git_description = $version_pref{"git_description"};
$do_hack = 0;
# Assume format like v2.3.0rc0-1342-g7bdcf75
$commit_id = ($git_description =~ /([0-9a-f]+)$/)[0];
} elsif ($version_pref{"git_client"}) {
eval {
use warnings "all";
no warnings "all";
@ -606,7 +616,10 @@ sub new_version_h
}
if ($git_description) {
return "#define VCSVERSION \"$git_description from $repo_branch\"\n";
# Do not bother adding the git branch, the git describe output
# normally contains the base tag and commit ID which is more
# than sufficient to determine the actual source tree.
return "#define VCSVERSION \"$git_description\"\n";
}
if ($last_change && $num_commits) {