openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [openoffice] branch AOO42X updated: Allow for source repo builds to include repo revision number, as stored when the tarball/zipfile was created.
Date Thu, 03 Oct 2019 17:08:04 GMT
This is an automated email from the ASF dual-hosted git repository.

jim pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git


The following commit(s) were added to refs/heads/AOO42X by this push:
     new a7eb43e  Allow for source repo builds to include repo revision number, as stored
when the tarball/zipfile was created.
a7eb43e is described below

commit a7eb43eed7f3f420620f44556505ba42be2d378c
Author: Jim Jagielski <jimjag@gmail.com>
AuthorDate: Thu Oct 3 12:57:05 2019 -0400

    Allow for source repo builds to include repo revision number, as stored when the tarball/zipfile
was created.
    
    (cherry picked from commit 27a447d8e738b70f74ab05606693d7139127efc4)
---
 main/instsetoo_native/util/makefile.mk  |  1 +
 main/solenv/bin/modules/RepoRevision.pm | 44 ++++++++++++++++++++++++---------
 2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/main/instsetoo_native/util/makefile.mk b/main/instsetoo_native/util/makefile.mk
index c228a85..e03c437 100644
--- a/main/instsetoo_native/util/makefile.mk
+++ b/main/instsetoo_native/util/makefile.mk
@@ -163,6 +163,7 @@ VERBOSESWITCH+=-log
 SRC_RELEASE_OUT_DIR=$(shell cd $(OUT) && pwd)$/AOO_SRC_Release
 
 aoo_srcrelease: $(SOLARENV)$/bin$/srcrelease.xml
+	$(PERL) -I$(SOLARENV)/bin/modules -e "use RepoRevision; print RepoRevision::DetectRevisionId(\"$(SRC_ROOT)\")"
> $(SOLARENV)$/inc$/reporevision.lst
 	@-$(MKDIR) $(OUT)$/AOO_SRC_Release
 	$(ANT) -f $(SOLARENV)$/bin$/srcrelease.xml -q -Dbasedir=$(SOURCE_ROOT_DIR) -Dout.dir=$(SRC_RELEASE_OUT_DIR)
 
diff --git a/main/solenv/bin/modules/RepoRevision.pm b/main/solenv/bin/modules/RepoRevision.pm
index db04180..580e0cf 100644
--- a/main/solenv/bin/modules/RepoRevision.pm
+++ b/main/solenv/bin/modules/RepoRevision.pm
@@ -23,11 +23,29 @@
 
 package RepoRevision;
 
-#old SVN code unchanged
-sub DetectRevisionIdFromSVN ($)
+sub DetectRevisionIdFromFile ($)
 {
 	my $path = shift;
+	my $id = undef;
+
+	open( my $fh, '<', $path ) || return undef;
+	$id = <$fh>;
+	close $fh;
+	return $id;
+}
+
+sub DetectRevisionIdFromGit ($)
+{
+	my $path = shift;
+	my $id = undef;
+
+	$id = `git log -1 --pretty=format:%h --abbrev=10`;
+	return $id;
+}
 
+sub DetectRevisionIdFromSVN ($)
+{
+	my $path = shift;
 	my $id = undef;
 
 	open my $proc, "cd $path && svn info 2>\&1 |";
@@ -36,8 +54,7 @@ sub DetectRevisionIdFromSVN ($)
 		if (/svn: E155007:/ || /svn: '.' is not a working copy/)
 		{
 			# Not in an SVN repository.
-			$id = DetectRevisionIdFromGit($path);
-			last;
+			return undef;
 		}
 		else
 		{
@@ -49,7 +66,6 @@ sub DetectRevisionIdFromSVN ($)
 		}
 	}
 	close $proc;
-
 	return $id;
 }
 
@@ -57,20 +73,24 @@ sub DetectRevisionIdFromSVN ($)
 sub DetectRevisionId ($)
 {
 	my $path = shift;
-
 	my $id = undef;
-	#test if path points to a git repository. if true return is 0 else positive number.
-	my $isNotGit= `[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1`;
-	if ($isNotGit)
+
+	my $NotGit = `cd $path && git rev-parse --git-dir > /dev/null 2>&1`;
+	if (!$NotGit || -d ".git" || -d "$path/.git")
 	{
-		$id = DetectRevisionIdFromSVN ($path);
+		$id = DetectRevisionIdFromGit ($path);
 	}
 	else
 	{
-		#returns directly the hash of the current checkout.
-		$id = `git log -1 --pretty=format:%h --abbrev=10`;
+		$id = DetectRevisionIdFromSVN ($path);
 	}
 
+	if (!$id)
+	{
+		#NOTE: Magic cookie file 'reporevision.lst' created by aoo_srcrelease
+		$id = DetectRevisionIdFromFile ("$ENV{'SOLARENV'}/inc/reporevision.lst");
+		if (!$id) { $id = "unknown-rev" };
+	}
 	return $id;
 }
 


Mime
View raw message