-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Sail version check to Makefile
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
|
||
req_major="0" | ||
req_minor="17" | ||
req_patch="1" | ||
|
||
function check { | ||
local version=$(sail -v | cut -d ' ' -f 2); | ||
|
||
if [ "$?" -ne 0 ]; then | ||
echo "Could not find Sail version: 'sail -v' command failed" | ||
exit 1 | ||
fi | ||
|
||
local message="Sail version must be at least ${req_major}.${req_minor}.${req_patch}, got ${version}" | ||
|
||
local major=$(echo $version | cut -d '.' -f 1); | ||
local minor=$(echo $version | cut -d '.' -f 2); | ||
local patch=$(echo $version | cut -d '.' -f 3); | ||
|
||
# Sail version string may be two digits without a patch version, | ||
# in which case we treat it as zero. | ||
if [ -z "$patch" ]; then | ||
patch="0" | ||
fi | ||
|
||
if [ "$major" -lt "$req_major" ]; then | ||
echo "${message}" | ||
exit 1 | ||
elif [ "$major" -gt "$req_major" ]; then | ||
exit 0 | ||
fi | ||
|
||
if [ "$minor" -lt "$req_minor" ]; then | ||
echo "${message}" | ||
exit 1 | ||
elif [ "$minor" -gt "$req_minor" ]; then | ||
exit 0 | ||
fi | ||
|
||
if [ "$patch" -lt "$req_patch" ]; then | ||
echo "${message}" | ||
exit 1 | ||
fi | ||
|
||
exit 0 | ||
} | ||
|
||
check |