[Asterisk-code-review] Makefile: Avoid git-make user conflict (asterisk[18])
Kevin Harwell
asteriskteam at digium.com
Wed Jul 13 18:36:00 CDT 2022
Kevin Harwell has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/18808 )
Change subject: Makefile: Avoid git-make user conflict
......................................................................
Makefile: Avoid git-make user conflict
make_version now silently checks if the required git commands will
fail. If they do, then return UNKNOWN__git_check_fail to
distinguish this failure from other UNKNOWN__ version failures
Makefile checks for this value on install and exits out with
instructions
ASTERISK-30029
Change-Id: If8f10cac8f509c08981120f17555762342020221
---
M Makefile
M build_tools/make_version
2 files changed, 28 insertions(+), 1 deletion(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved; Approved for Submit
diff --git a/Makefile b/Makefile
index 8c9498c..f435ac9 100644
--- a/Makefile
+++ b/Makefile
@@ -327,6 +327,9 @@
SUBMAKE:=$(MAKE) --quiet --no-print-directory
endif
+mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
+mkfile_dir := $(dir $(mkfile_path))
+
# $(MAKE) is printed in several places, and we want it to be a
# fixed size string. Define a variable whose name has also the
# same size, so we can easily align text.
@@ -693,7 +696,17 @@
@exit 1
endif
-install: badshell bininstall datafiles
+versioncheck:
+ifeq ($(ASTERISKVERSION),UNKNOWN__git_check_fail)
+ @echo "Asterisk Version is unknown due to a git error. If you are running make"
+ @echo "as a different user than the project owner, this can be resolved by"
+ @echo "running the following command as the user currently executing make: "$$USER
+ @echo "git config --global --add safe.directory "$(mkfile_dir:/=)
+ @exit 1
+endif
+
+
+install: badshell versioncheck bininstall datafiles
@if [ -x /usr/sbin/asterisk-post-install ]; then \
/usr/sbin/asterisk-post-install "$(DESTDIR)" . ; \
fi
@@ -878,6 +891,12 @@
endif
ifeq ($(ASTERISKVERSION),UNKNOWN__and_probably_unsupported)
@echo "Asterisk Version is unknown, not configuring Doxygen PROJECT_NUMBER."
+else ifeq ($(ASTERISKVERSION),UNKNOWN__git_check_fail)
+ @echo "Asterisk Version is unknown due to a git error. If you are running make"
+ @echo "as a different user than the project owner, this can be resolved by"
+ @echo "running the following command as the user currently executing make: "$$USER
+ @echo "git config --global --add safe.directory "$(mkfile_dir:/=)
+ @echo "not configuring Doxygen PROJECT_NUMBER."
else
@echo "PROJECT_NUMBER = $(ASTERISKVERSION)" >> doc/Doxyfile
endif
@@ -968,6 +987,7 @@
@$(MAKE) clean
@[ -f "$(DESTDIR)$(ASTDBDIR)/astdb.sqlite3" ] || [ ! -f "$(DESTDIR)$(ASTDBDIR)/astdb" ] || [ ! -f menuselect.makeopts ] || grep -q MENUSELECT_UTILS=.*astdb2sqlite3 menuselect.makeopts || (sed -i.orig -e's/MENUSELECT_UTILS=\(.*\)/MENUSELECT_UTILS=\1 astdb2sqlite3/' menuselect.makeopts && echo "Updating menuselect.makeopts to include astdb2sqlite3" && echo "Original version backed up to menuselect.makeopts.orig")
+
$(SUBDIRS_UNINSTALL):
+ at DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTDATADIR="$(ASTDATADIR)" $(SUBMAKE) -C $(@:-uninstall=) uninstall
diff --git a/build_tools/make_version b/build_tools/make_version
index 9dca4bd..58395ca 100755
--- a/build_tools/make_version
+++ b/build_tools/make_version
@@ -95,6 +95,13 @@
echo "UNKNOWN__and_probably_unsupported"
exit 1
fi
+
+ GITCHECK=$(${GIT} describe --always 2>/dev/null || echo gitfail 2>/dev/null)
+ if [ "x${GITCHECK}" = "xgitfail" ]; then
+ echo "UNKNOWN__git_check_fail"
+ exit 1
+ fi
+
cd ${1}
# If the first log commit messages indicates that this is checked into
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18808
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: If8f10cac8f509c08981120f17555762342020221
Gerrit-Change-Number: 18808
Gerrit-PatchSet: 2
Gerrit-Owner: Michael Bradeen <mbradeen at sangoma.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220713/8e7e823f/attachment.html>
More information about the asterisk-code-review
mailing list