From 2ba6243862b432996a50c8ec9f047064582c4e95 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 29 Jun 2020 10:33:30 +0200
Subject: [PATCH] CONFIG: refine handling of git information for debian builds

- When OpenFOAM is under git control and a 'debian/' directory exists,
  this could mean two things:

  1) Additional debian control has been added to OpenFOAM
  2) OpenFOAM has been imported into a debian project

For the case that OpenFOAM has been imported into a debian project,
using the git information would be highly misleading. There will be no
OpenFOAM SHA1 correspondence.

However, if additional debian control has been added to OpenFOAM the
SHA1 will be valid.

The ad hoc solution is to use an additional "openfoam.debian"
directory to flag the addition of debian controls into openfoam.

When a "debian/" directory exists without a "openfoam.debian", assume
that the OpenFOAM has been imported into debian and do not use the SHA1.
---
 wmake/scripts/wmake-build-info | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/wmake/scripts/wmake-build-info b/wmake/scripts/wmake-build-info
index b542aeb9dce..87e151b5440 100755
--- a/wmake/scripts/wmake-build-info
+++ b/wmake/scripts/wmake-build-info
@@ -29,10 +29,19 @@
 #     - debian : implicitly disables git queries
 #
 # Note
-#     When a 'debian/' directory exists, the '.git/' directory is most
-#     likely from debian and not from OpenFOAM (ie, useless here).
-#     This corresponds to an implicit '-no-git', which has no effect
-#     when building from pristine sources.
+#     There is a corner case when obtaining build information from git.
+#     It is possible that OpenFOAM has been imported into a debian form,
+#     in which case the '.git/' directory is most from debian and cannot
+#     be used to obtain an OpenFOAM sha1 value.
+#
+#     Ad hoc logic (slightly messy):
+#     1) Have an 'openfoam.debian/' directory.
+#        Assume that debian control has been added to OpenFOAM.
+#        Can use git to obtain build information.
+#     2) Have a 'debian/' directory only.
+#        Assume OpenFOAM has been added into a debian project.
+#        Treat as '-no-git', which which has no effect
+#        when building from pristine sources.
 #
 # SeeAlso
 #     META-INFO/README.md for other routines that also use META-INFO.
@@ -145,8 +154,10 @@ done
 [ -d "$META_INFO" ] || \
     die "No ${META_INFO##*/}/ directory for project"
 
-# Disable git queries for debian packaging (see notes above)
-if [ -d "$WM_PROJECT_DIR/debian" ]
+# Debian handling (see notes above)
+# - disable git queries if debian project and not internal "debianization"
+if [ -d "$WM_PROJECT_DIR/debian" ] \
+&& [ ! -e "$WM_PROJECT_DIR/openfoam.debian" ]
 then
     unset FOAM_GIT_DIR
 fi
-- 
GitLab