[Asterisk-code-review] Makefile: Avoid git-make user conflict (asterisk[16])
Michael Bradeen
asteriskteam at digium.com
Wed Jun 1 21:04:09 CDT 2022
Michael Bradeen has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18605 )
Change subject: Makefile: Avoid git-make user conflict
......................................................................
Makefile: Avoid git-make user conflict
Makefile will now check to see if the running user id matches
the uid of the running directory. If matched, then the existing
method of using git to determine ASTERISKVERSION is maintained
with the addition of echoing this to a new .versionlabel. If the
users do not match, then Makefile will look in .versionlabel.
The intent is that a 'make' followed by a 'sudo make install' will
work, with the first make setting .versionlabel and the second then
using it. This avoids calling git which will fail due to the user
mismatch.
build_tools/list_valid_installed_externals now exclusively uses
.versionlabel which will have been set on the preceeding make
.gitignore updated to include .versionlabel
ASTERISK-30029
Change-Id: If8f10cac8f509c08981120f17555762342020221
---
M .gitignore
M Makefile
M build_tools/list_valid_installed_externals
3 files changed, 17 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/05/18605/1
diff --git a/.gitignore b/.gitignore
index 1ba75fa..2c84000 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,3 +38,4 @@
*.orig
tests/CI/output
.develvars
+.versionlabel
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 858aaa3..f2e7657 100644
--- a/Makefile
+++ b/Makefile
@@ -248,10 +248,17 @@
_ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
endif
+_MAKINGUID:= $(shell id -u)
+_GITUD:= $(shell stat -c '%u' .)
+
ifeq ($(GREP),)
else ifeq ($(GREP),:)
else
- ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) GIT=$(GIT) build_tools/make_version .)
+ ifeq ($(_MAKINGUID),$(_GITUD))
+ ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) GIT=$(GIT) build_tools/make_version .)
+ else
+ ASTERISKVERSION:=$(shell cat .versionlabel)
+ endif
endif
ifneq ($(AWK),)
ifneq ($(wildcard .version),)
@@ -374,7 +381,7 @@
+@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
+@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
-$(SUBDIRS): makeopts .lastclean main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h
+$(SUBDIRS): makeopts .lastclean .versionlabel main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h
ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
main: third-party
@@ -400,7 +407,7 @@
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
-main/version.c: FORCE menuselect.makeopts .lastclean
+main/version.c: FORCE menuselect.makeopts .lastclean .versionlabel
@build_tools/make_version_c > $@.tmp
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
@@ -410,6 +417,9 @@
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
+.versionlabel: menuselect.makeopts .lastclean
+ @echo $(ASTERISKVERSION) > .versionlabel
+
# build.h must depend on .lastclean, or parallel make may wipe it out after it's
# been created.
include/asterisk/build.h: .lastclean
@@ -433,6 +443,7 @@
rm -f doxygen.log
rm -rf latex
rm -f rest-api-templates/*.pyc
+ rm -f .versionlabel
@$(MAKE) -C menuselect clean
cp -f .cleancount .lastclean
@@ -968,6 +979,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/list_valid_installed_externals b/build_tools/list_valid_installed_externals
index 862447a..e6f03d7 100755
--- a/build_tools/list_valid_installed_externals
+++ b/build_tools/list_valid_installed_externals
@@ -38,7 +38,7 @@
exit 1
fi
-version=$(${ASTTOPDIR}/build_tools/make_version ${ASTTOPDIR})
+version=$(cat ${ASTTOPDIR}/.versionlabel)
if [[ ! ${version} =~ ^(GIT-)?([^.-]+)[.-].* ]] ; then
echo "${module_name}: Couldn't parse version ${version}"
exit 1
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18605
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: If8f10cac8f509c08981120f17555762342020221
Gerrit-Change-Number: 18605
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Bradeen <mbradeen at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220601/24388e65/attachment-0001.html>
More information about the asterisk-code-review
mailing list