@cryptotaxi247 / netdata-1 / commits / b873b655c

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 committed Nov 6, 2020 at 07:07 UTC b873b655ce2adb75cac07decfb8e2687e8fa8c6c
2 files changed +13 -1
netdata-installer.sh
+12
@@ -919,6 +919,18 @@ if [ -x "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" ]; then
919 "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" classic
920 fi
921
922 +# -----------------------------------------------------------------------------
923 +# By default, `git` does not update local tags based on remotes. Because
924 +# we use the most recent tag as part of our version determination in
925 +# our build, this can lead to strange versions that look ancient but are
926 +# actually really recent. To avoid this, try and fetch tags if we're
927 +# working in a git checkout.
928 +if [ -d ./.git ] ; then
929 + echo >&2
930 + progress "Updating tags in git to ensure a consistent version number"
931 + run git fetch <remote> 'refs/tags/*:refs/tags/*' || true
932 +fi
933 +
934 # -----------------------------------------------------------------------------
935 echo >&2
936 progress "Run autotools to configure the build environment"
packaging/installer/netdata-updater.sh
+1 -1
@@ -133,7 +133,7 @@ parse_version() {
133 fi
134
135 read -r -a pp <<< "$(echo "${v}" | tr '.' ' ')"
136 - printf "%03d%03d%03d%03d" "${pp[0]}" "${pp[1]}" "${pp[2]}" "${b}"
136 + printf "%03d%03d%03d%05d" "${pp[0]}" "${pp[1]}" "${pp[2]}" "${b}"
137 }
138
139 get_latest_version() {