aboutsummaryrefslogtreecommitdiff
path: root/release/Makefile.inc1
diff options
context:
space:
mode:
authorGlen Barber <gjb@FreeBSD.org>2020-07-16 20:34:26 +0000
committerGlen Barber <gjb@FreeBSD.org>2020-07-16 20:34:26 +0000
commit29b282f31d7388dfd9806fd1a0df8c37784482d8 (patch)
tree5468bf71e60dad060020474b6a4be5a1223fa4c8 /release/Makefile.inc1
parente2c0e292e8a7ca00ba99bcfccc9e637f45c3e8b1 (diff)
downloadsrc-29b282f31d7388dfd9806fd1a0df8c37784482d8.tar.gz
src-29b282f31d7388dfd9806fd1a0df8c37784482d8.zip
Makefile.inc1:
- New file. Adds logic to search for the git binary, as well as determining the branch and revision, used in various places. Makefile: - Remove searching for the svn{,lite} binary. Makefile.ec2: - Reduce duplicated code, removing searching for the svn{,lite} binary, in addition to EC2_SVN{BRANCH,REV}. - Rename EC2_SVN* with GIT* for consistency. Makefile.mirrors: - Remove the SRCBRANCH declaration, replaced with the exported GITBRANCH variable. - Update _SNAP_SUFFIX from SVNREVISION to GITREV, and remove the leading 'r' from it, since it will break git hashes. - Remove yet another instance of duplicated code to search for the svn{,version}lite binary. Sponsored by: Rubicon Communications, LLC (netgate.com)
Notes
Notes: svn path=/projects/release-git/; revision=363258
Diffstat (limited to 'release/Makefile.inc1')
-rw-r--r--release/Makefile.inc125
1 files changed, 25 insertions, 0 deletions
diff --git a/release/Makefile.inc1 b/release/Makefile.inc1
new file mode 100644
index 000000000000..c8426f2cba31
--- /dev/null
+++ b/release/Makefile.inc1
@@ -0,0 +1,25 @@
+#
+# $FreeBSD$
+#
+
+# Figure out where the git binary is.
+.if !defined(GIT_CMD) || empty(GIT_CMD)
+. for _P in /usr/bin /usr/local/bin
+. if exists(${_P}/git)
+GIT_CMD= ${_P}/git
+. endif
+. endfor
+. export GIT_CMD
+.else
+. error "Git binary not found. Set GIT_CMD appropriately."
+.endif
+
+# Set the git branch and hash to export where needed.
+.if !defined(GITBRANCH) || empty(GITBRANCH)
+GITBRANCH!= ${GIT_CMD} rev-parse --abbrev-ref HEAD 2>/dev/null | sed -e 's/\^\///'
+.export GITBRANCH
+.endif
+.if !defined(GITREV) || empty(GITREV)
+GITREV!= ${GIT_CMD} rev-parse --verify --short HEAD 2>/dev/null || true
+.export GITREV
+.endif