Browse Source

Fixed two bugs related to version handling in install and update code. (#10162)

* Try to update local tags during build to ensure consistent version.

By default, `git` does not update the list of tags for a repository
after it is first cloned unless you explicitly tell it to do so.

Because we use the most recent tag as the first part of our version
number, this can lead to strange ancient-looking version numbers that
are actually far more recent (for example, `v1.11.1-2915-g6106dd7`,
which is actually from v1.21.1 sources), potentially causing confusion
with respect to support.

This adds code to `netdata-installer.sh` to try to update the local repo
with the remote tags to ensure that we actually have sane version
numbers.

* Use 5 digits for commit count in version number comparison.

The original code in `netdata-updater.sh` includes a hard-coded
assumption that a version number will never have more than 3 digits for
the commit count. This is of course wrong in a handful of cases, which
will then get stuck on the older version because of the effects of digit
counts on comparisons.

This updates from our current 999 commit limit to a limit of 99999
commits, which is a reasonable expectation that we should never get
_that_ far.
Austin S. Hemmelgarn 4 years ago
parent
commit
b873b655ce
2 changed files with 13 additions and 1 deletions
  1. 12 0
      netdata-installer.sh
  2. 1 1
      packaging/installer/netdata-updater.sh

+ 12 - 0
netdata-installer.sh

@@ -919,6 +919,18 @@ if [ -x "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" ]; then
   "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" classic
 fi
 
+# -----------------------------------------------------------------------------
+# By default, `git` does not update local tags based on remotes. Because
+# we use the most recent tag as part of our version determination in
+# our build, this can lead to strange versions that look ancient but are
+# actually really recent. To avoid this, try and fetch tags if we're
+# working in a git checkout.
+if [ -d ./.git ] ; then
+  echo >&2
+  progress "Updating tags in git to ensure a consistent version number"
+  run git fetch <remote> 'refs/tags/*:refs/tags/*' || true
+fi
+
 # -----------------------------------------------------------------------------
 echo >&2
 progress "Run autotools to configure the build environment"

+ 1 - 1
packaging/installer/netdata-updater.sh

@@ -133,7 +133,7 @@ parse_version() {
   fi
 
   read -r -a pp <<< "$(echo "${v}" | tr '.' ' ')"
-  printf "%03d%03d%03d%03d" "${pp[0]}" "${pp[1]}" "${pp[2]}" "${b}"
+  printf "%03d%03d%03d%05d" "${pp[0]}" "${pp[1]}" "${pp[2]}" "${b}"
 }
 
 get_latest_version() {