<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18049">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">build: Refactor the earlier "basebranch" commit<br><br>Recap from earlier commit:  If you have a development branch for a<br>major project that will receive gerrit reviews it'll probably be<br>named something like "development/16/newproject" or a work branch<br>based on that "development" branch.  That will necessitate<br>setting "defaultbranch=development/16/newproject" in .gitreview.<br>The make_version script uses that variable to construct the<br>asterisk version however, which results in versions<br>like "GIT-development/16/newproject-ee582a8c7b" which is probably<br>not what you want.  It also constructs the URLs for downloading<br>external modules with that version, which will fail.<br><br>Fast-forward:<br><br>The earlier attempt at adding a "basebranch" variable to<br>.gitreview didn't work out too well in practice because changes<br>were made to .gitreview, which is a checked-in file.  So, if<br>you wanted to rebase your work branch on the base branch, rebase<br>would attempt to overwrite your .gitreview with the one from<br>the base branch and complain about a conflict.<br><br>This is a slighltly different approach that adds three methods to<br>determine the mainline branch:<br><br>1.  --- MAINLINE_BRANCH from the environment<br><br>If MAINLINE_BRANCH is already set in the environment, that will<br>be used.  This is primarily for the Jenkins jobs.<br><br>2.  --- .develvars<br><br>Instead of storing the basebranch in .gitreview, it can now be<br>stored in a non-checked-in ".develvars" file and keyed by the<br>current branch.  So, if you were working on a branch named<br>"new-feature-work" based on "development/16/new-feature" and wanted<br> to push to that branch in Gerrit but wanted to pull the external<br> modules for 16, you'd create the following .develvars file:<br><br>[branch "new-feature-work"]<br>    mainline-branch = 16<br><br>The .gitreview file would still look like:<br><br>[gerrit]<br>defaultbranch=development/16/new-feature<br><br>...which would cause any reviews pushed from "new-feature-work" to<br>go to the "development/16/new-feature" branch in Gerrit.<br><br>The key is that the .develvars file is NEVER checked in (it's been<br>added to .gitignore).<br><br>3.  --- Well Known Development Branch<br><br>If you're actually working in a branch named like<br>"development/<mainline_branch>/some-feature", the mainline branch<br>will be parsed from it.<br><br>4.  --- .gitreview<br><br>If none of the earlier conditions exist, the .gitreview<br>"defaultbranch" variable will be used just as before.<br><br>Change-Id: I1cdeeaa0944bba3f2e01d7a2039559d0c266f8c9<br>---<br>M .gitignore<br>M build_tools/make_version<br>M tests/CI/buildAsterisk.sh<br>M tests/CI/installAsterisk.sh<br>4 files changed, 45 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/49/18049/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/.gitignore b/.gitignore</span><br><span>index 0f31820..1ba75fa 100644</span><br><span>--- a/.gitignore</span><br><span>+++ b/.gitignore</span><br><span>@@ -37,4 +37,4 @@</span><br><span> out/</span><br><span> *.orig</span><br><span> tests/CI/output</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+.develvars</span><br><span>diff --git a/build_tools/make_version b/build_tools/make_version</span><br><span>index aefe6b1..9dca4bd 100755</span><br><span>--- a/build_tools/make_version</span><br><span>+++ b/build_tools/make_version</span><br><span>@@ -3,11 +3,13 @@</span><br><span> AWK=${AWK:-awk}</span><br><span> GIT=${GIT:-git}</span><br><span> GREP=${GREP:-grep}</span><br><span style="color: hsl(120, 100%, 40%);">+SED=${SED:-sed}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> </span><br><span> if [ -f ${1}/.version ]; then</span><br><span>     cat ${1}/.version</span><br><span> elif [ -d ${1}/.svn ]; then</span><br><span style="color: hsl(0, 100%, 40%);">-    PARTS=`LANG=C svn info ${1} | ${GREP} URL | ${AWK} '{print $2;}' | sed -e 's:^.*/svn/asterisk/::' | sed -e 's:/: :g'`</span><br><span style="color: hsl(120, 100%, 40%);">+    PARTS=`LANG=C svn info ${1} | ${GREP} URL | ${AWK} '{print $2;}' | ${SED} -e 's:^.*/svn/asterisk/::' | ${SED} -e 's:/: :g'`</span><br><span>     BRANCH=0</span><br><span>     TEAM=0</span><br><span>     TAG=0</span><br><span>@@ -93,16 +95,33 @@</span><br><span>         echo "UNKNOWN__and_probably_unsupported"</span><br><span>         exit 1</span><br><span>     fi</span><br><span style="color: hsl(0, 100%, 40%);">-     cd ${1}</span><br><span style="color: hsl(120, 100%, 40%);">+    cd ${1}</span><br><span> </span><br><span>     # If the first log commit messages indicates that this is checked into</span><br><span>     # subversion, we'll just use the SVN- form of the revision.</span><br><span>     MODIFIED=""</span><br><span style="color: hsl(0, 100%, 40%);">-    SVN_REV=`${GIT} log --pretty=full -1 | sed -n '/git-svn-id:/ s/.*\@\([^ ]*\) .*/\1/p'`</span><br><span style="color: hsl(120, 100%, 40%);">+    SVN_REV=`${GIT} log --pretty=full -1 | ${SED} -n '/git-svn-id:/ s/.*\@\([^ ]*\) .*/\1/p'`</span><br><span>     if [ -z "$SVN_REV" ]; then</span><br><span style="color: hsl(0, 100%, 40%);">-        MAINLINE_BRANCH=$(${GIT} config -f .gitreview --get gerrit.basebranch)</span><br><span style="color: hsl(0, 100%, 40%);">-        if [ "x${MAINLINE_BRANCH}" = "x" ] ; then</span><br><span style="color: hsl(0, 100%, 40%);">-            MAINLINE_BRANCH=$(${GIT} config -f .gitreview --get gerrit.defaultbranch)</span><br><span style="color: hsl(120, 100%, 40%);">+        # If MAINLINE_BRANCH is already set in the environment, use it.</span><br><span style="color: hsl(120, 100%, 40%);">+        if [ -z "${MAINLINE_BRANCH}" ] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+            # Try to retrieve MAINLINE_BRANCH from a local .develvars file first.</span><br><span style="color: hsl(120, 100%, 40%);">+            # .develvars is keyed by the branch name so we need to get that first.</span><br><span style="color: hsl(120, 100%, 40%);">+            BRANCH=$(${GIT} symbolic-ref --short HEAD)</span><br><span style="color: hsl(120, 100%, 40%);">+            if [ -f .develvars ] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+                MAINLINE_BRANCH=$(${GIT} config -f .develvars --get branch.${BRANCH}.mainline-branch)</span><br><span style="color: hsl(120, 100%, 40%);">+            fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+            # If we didn't find it, see if this is a well-known development branch.</span><br><span style="color: hsl(120, 100%, 40%);">+            # development/<mainline_branch>/<branchname> or</span><br><span style="color: hsl(120, 100%, 40%);">+            # devel/<mainline_branch>/<branchname></span><br><span style="color: hsl(120, 100%, 40%);">+            if [ "x${MAINLINE_BRANCH}" = "x" ] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+                MAINLINE_BRANCH=$(echo "${BRANCH}" | ${SED} -n -r -e "s@devel(opment)?/([0-9]+)/.+@\2@p")</span><br><span style="color: hsl(120, 100%, 40%);">+            fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+            # If we didn't find it, get it from .gitreview defaultbranch.</span><br><span style="color: hsl(120, 100%, 40%);">+            if [ "x${MAINLINE_BRANCH}" = "x" ] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+                MAINLINE_BRANCH=$(${GIT} config -f .gitreview --get gerrit.defaultbranch)</span><br><span style="color: hsl(120, 100%, 40%);">+            fi</span><br><span>         fi</span><br><span> </span><br><span>         VERSION=`${GIT} describe --long --always --tags --dirty=M 2> /dev/null`</span><br><span>@@ -116,7 +135,7 @@</span><br><span>         fi</span><br><span>         echo GIT-${MAINLINE_BRANCH}-${VERSION}</span><br><span>     else</span><br><span style="color: hsl(0, 100%, 40%);">-        PARTS=`LANG=C ${GIT} log --pretty=full | ${GREP} -F "git-svn-id:" | head -1 | ${AWK} '{print $2;}' | sed -e s:^.*/svn/$2/:: | sed -e 's:/: :g' | sed -e 's/@.*$//g'`</span><br><span style="color: hsl(120, 100%, 40%);">+        PARTS=`LANG=C ${GIT} log --pretty=full | ${GREP} -F "git-svn-id:" | head -1 | ${AWK} '{print $2;}' | ${SED} -e s:^.*/svn/$2/:: | ${SED} -e 's:/: :g' | ${SED} -e 's/@.*$//g'`</span><br><span>         BRANCH=0</span><br><span>         TEAM=0</span><br><span>         TAG=0</span><br><span>diff --git a/tests/CI/buildAsterisk.sh b/tests/CI/buildAsterisk.sh</span><br><span>index 52f762e..71cfcc6 100755</span><br><span>--- a/tests/CI/buildAsterisk.sh</span><br><span>+++ b/tests/CI/buildAsterisk.sh</span><br><span>@@ -17,6 +17,10 @@</span><br><span>  BRANCH_NAME=$(git config -f .gitreview --get gerrit.defaultbranch)</span><br><span> fi</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+if [[ "$BRANCH_NAME" =~ devel(opment)?/([0-9]+)/.+ ]] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+  export MAINLINE_BRANCH="${BASH_REMATCH[2]}"</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> gen_cats() {</span><br><span>  set +x</span><br><span>       action=$1</span><br><span>@@ -91,6 +95,11 @@</span><br><span> PKGCONFIG=`which pkg-config`</span><br><span> _libdir=`${CIDIR}/findLibdir.sh`</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+_version=$(./build_tools/make_version .)</span><br><span style="color: hsl(120, 100%, 40%);">+for var in BRANCH_NAME MAINLINE_BRANCH OUTPUT_DIR CACHE_DIR CCACHE_DISABLE CCACHE_DIR _libdir _version ; do</span><br><span style="color: hsl(120, 100%, 40%);">+ declare -p $var || :</span><br><span style="color: hsl(120, 100%, 40%);">+done</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> common_config_args="--prefix=/usr ${_libdir:+--libdir=${_libdir}} --sysconfdir=/etc --with-pjproject-bundled"</span><br><span> $PKGCONFIG 'jansson >= 2.11' || common_config_args+=" --with-jansson-bundled"</span><br><span> common_config_args+=" ${CACHE_DIR:+--with-sounds-cache=${CACHE_DIR}/sounds --with-externals-cache=${CACHE_DIR}/externals}"</span><br><span>diff --git a/tests/CI/installAsterisk.sh b/tests/CI/installAsterisk.sh</span><br><span>index 00866d1..da48bc2 100755</span><br><span>--- a/tests/CI/installAsterisk.sh</span><br><span>+++ b/tests/CI/installAsterisk.sh</span><br><span>@@ -10,8 +10,17 @@</span><br><span> if [ x"$DESTDIR" != x ] ; then</span><br><span>      mkdir -p "$DESTDIR"</span><br><span> fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+if [[ "$BRANCH_NAME" =~ devel(opment)?/([0-9]+)/.+ ]] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ export MAINLINE_BRANCH="${BASH_REMATCH[2]}"</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+_version=$(./build_tools/make_version .)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> destdir=${DESTDIR:+DESTDIR=$DESTDIR}</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+declare -p _version</span><br><span style="color: hsl(120, 100%, 40%);">+declare -p destdir</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> [ $UNINSTALL -gt 0 ] && ${MAKE} ${destdir} uninstall</span><br><span> [ $UNINSTALL_ALL -gt 0 ] && ${MAKE} ${destdir} uninstall-all</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18049">change 18049</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18049"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I1cdeeaa0944bba3f2e01d7a2039559d0c266f8c9 </div>
<div style="display:none"> Gerrit-Change-Number: 18049 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>