+awk_vercmp='
+ function max(a, b) { return a > b ? a : b }
+ function vercmp(v1, v2, i, a, b) {
+ v1 = max(split(v1, a, /[-_.:]/), split(v2, b, /[-_.:]/))
+ for (i = 1; i <= v1; i++)
+ if (v2 = a[i] - b[i])
+ break
+ return v2
+ }
+'
+function vercmpgt() {
+ awk "$awk_vercmp"'
+ BEGIN {
+ exit !(vercmp(ARGV[1], ARGV[2]) > 0)
+ }
+' "$@"
+}
+
#---------------------------------------------------------------------
## Find all spells that need to be updated (for any reason).
## Checks the version caches and compares them to the installed one.
@@ -153,7 +171,7 @@ function find_updates() {
local tmp_queue=$1
local recheck_queue=$2
- awk -v i=$VERSION_STATUS -v verbose=$VERBOSE_QUEUING '
+ awk -v i=$VERSION_STATUS -v verbose=$VERBOSE_QUEUING "$awk_vercmp"'
# decide what to print - just the spell or also the reason
function needs_update( reasons, diff) {
if (verbose == "on") {
@@ -166,7 +184,7 @@ function find_updates() {
reasons = reasons " Security update."
}
}
- if ($2 != factor[2]) {
+ if (vercmp($2, factor[2]) < 0) {
reasons = reasons " New version (" factor[2] ")."
}
if ($3 < factor[3] ) {
@@ -250,7 +268,7 @@ function does_spell_need_update_slow() {
message="$message Security update."
fi
fi
- if [[ $VERSION != $curr_version ]]; then
+ if vercmpgt $VERSION $curr_version; then
message="$message New version ($VERSION)."
fi
if (( "${PATCHLEVEL:-0}" > "$curr_patchlevel" )); then
[SM-Commit] GIT changes to master sorcery by Ismael Luceno (ec486fc52b559dfb41e94437fb5fb8d2389d2382),
Ismael Luceno, 01/04/2015