I want to write a shell/bash script that can verify that all my build tools are matching certain version requirements and return pass/failed.
Example:
I use cmake, make and gcc.
$ cmake --version
cmake version 3.13.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ make --version
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ gcc --version
gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
In the first case, i would like to get a pass/failed whether the system matches those version numbers exactly, in the 2nd case, i would like to get a pass/failed whether the system provides minimally those versions number or newer (=greater, with respect to 1.2.2 is newer than 1.1.3).
So what i want to achieve is to:
- step 1: identify the 3 numbers point separated version number (also allow constructs like 123.22.1)
- step 2: split this string into 3 sections, major, minor, bugfix.
Afther that i can compare those string values against my expectation and return with a result.
Is there a simple solution with tools like awk or similar?