Fix parsing of Lustre version generated by "lctl get_param version"
before release 2.7. The old code generated a valid version number
even for older releases, except in the case where the "build:" line
did not start with a numeric value, since that line was incorrectly
being parsed instead of the "lustre:" line due to "$ver" not being
double-quoted properly, so "$ver" was being treated as a single
line and "head -n 1" was doing nothing. This was offset by sed
dropping everything before the _last_ ":" instead of before the
_first_ ":", and then using the "build: " line.
Test-Parameters: trivial
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Ifd7dc95aaf0d6edf3558e18b85a78bea861248d0
Reviewed-on: https://review.whamcloud.com/28793
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
# output: prints version string to stdout in (up to 4) dotted-decimal values
lustre_build_version() {
local facet=${1:-client}
- local ver
-
local ver=$(do_facet $facet "$LCTL get_param -n version 2>/dev/null ||
$LCTL lustre_build_version 2>/dev/null ||
$LCTL --version 2>/dev/null | cut -d' ' -f2")
- local lver=$(egrep -i "lustre: |version: " <<<$ver | head -n 1)
+ local lver=$(egrep -i "lustre: |version: " <<<"$ver" | head -n 1)
[ -n "$lver" ] && ver="$lver"
- sed -e 's/.*: //' -e 's/^v//' -e 's/-.*//' -e 's/_/./g' <<<$ver |
+ sed -e 's/[^:]*: //' -e 's/^v//' -e 's/[ -].*//' -e 's/_/./g' <<<$ver |
cut -d. -f1-4
}