mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-16 09:40:21 +00:00
Include a version parsing function which ignores revisions.
This commit is contained in:
parent
ce7c286452
commit
b919d276ac
1 changed files with 23 additions and 9 deletions
|
@ -179,6 +179,25 @@ __gather_os_info() {
|
|||
__gather_os_info
|
||||
|
||||
|
||||
#--- FUNCTION ----------------------------------------------------------------
|
||||
# NAME: __parse_version_string
|
||||
# DESCRIPTION: Parse version strings ignoring the revision.
|
||||
# MAJOR.MINOR.REVISION becomes MAJOR.MINOR
|
||||
#-------------------------------------------------------------------------------
|
||||
__parse_version_string() {
|
||||
VERSION_STRING="$1"
|
||||
PARSED_VERSION=$(
|
||||
echo $VERSION_STRING |
|
||||
sed -e 's/^/#/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#.*$//'
|
||||
)
|
||||
echo $PARSED_VERSION
|
||||
}
|
||||
|
||||
|
||||
#--- FUNCTION ----------------------------------------------------------------
|
||||
# NAME: __gather_linux_system_info
|
||||
# DESCRIPTION: Discover Linux system information
|
||||
|
@ -189,7 +208,7 @@ __gather_linux_system_info() {
|
|||
|
||||
if [ -f /etc/lsb-release ]; then
|
||||
DISTRO_NAME=$(grep DISTRIB_ID /etc/lsb-release | sed -e 's/.*=//')
|
||||
DISTRO_VERSION=$(grep DISTRIB_RELEASE /etc/lsb-release | sed -e 's/.*=//')
|
||||
DISTRO_VERSION=$(__parse_version_string $(grep DISTRIB_RELEASE /etc/lsb-release | sed -e 's/.*=//'))
|
||||
fi
|
||||
|
||||
if [ "x$DISTRO_NAME" != "x" -a "x$DISTRO_VERSION" != "x" ]; then
|
||||
|
@ -206,14 +225,9 @@ __gather_linux_system_info() {
|
|||
[ ! -f "/etc/${rsource}" ] && continue
|
||||
|
||||
n=$(echo ${rsource} | sed -e 's/[_-]release$//' -e 's/[_-]version$//')
|
||||
v=$(
|
||||
(grep VERSION /etc/${rsource}; cat /etc/${rsource}) | grep '[0-9]' | sed -e 'q' |\
|
||||
sed -e 's/^/#/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#.*$//'
|
||||
)
|
||||
v=$(__parse_version_string $(
|
||||
(grep VERSION /etc/${rsource}; cat /etc/${rsource}) | grep '[0-9]' | sed -e 'q'
|
||||
))
|
||||
case $(echo ${n} | tr '[:upper:]' '[:lower:]') in
|
||||
redhat )
|
||||
if [ ".$(egrep '(Red Hat Enterprise Linux|CentOS)' /etc/${rsource})" != . ]; then
|
||||
|
|
Loading…
Add table
Reference in a new issue