Commit a751f52d authored by Vitaly Lipatov's avatar Vitaly Lipatov

distr_info: use more strong normalize distro versions

parent 332de905
......@@ -262,6 +262,25 @@ normalize_name()
esac
}
# 1.2.3.4.5 -> 1
normalize_version1()
{
echo "$1" | sed -e "s|\..*||"
}
# 1.2.3.4.5 -> 1.2
normalize_version2()
{
echo "$1" | sed -e "s|^\([^.][^.]*\.[^.][^.]*\)\..*|\1|"
}
# 1.2.3.4.5 -> 1.2.3
normalize_version3()
{
echo "$1" | sed -e "s|^\([^.][^.]*\.[^.][^.]*\.[^.][^.]*\)\..*|\1|"
}
fill_distr_info()
{
# Default values
......@@ -276,27 +295,30 @@ if distro os-release ; then
# shellcheck disable=SC1090
. $DISTROFILE
DISTRIB_ID="$(normalize_name "$NAME")"
# DISTRIB_ID="$(firstupper "$ID")"
DISTRIB_RELEASE_ORIG="$VERSION_ID"
DISTRIB_RELEASE="$VERSION_ID"
[ -n "$DISTRIB_RELEASE" ] || DISTRIB_RELEASE="CUR"
# set by os-release:
#PRETTY_NAME
VENDOR_ID="$ID"
DISTRIB_FULL_RELEASE=$DISTRIB_RELEASE
DISTRIB_RELEASE=$(echo "$DISTRIB_RELEASE" | sed -e "s/\.[0-9]$//g")
DISTRIB_CODENAME="$VERSION_CODENAME"
elif distro lsb-release ; then
DISTRIB_ID=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRIB_RELEASE=$(cat $DISTROFILE | get_var DISTRIB_RELEASE)
DISTRIB_RELEASE_ORIG="$DISTRIB_RELEASE"
DISTRIB_CODENAME=$(cat $DISTROFILE | get_var DISTRIB_CODENAME)
PRETTY_NAME=$(cat $DISTROFILE | get_var DISTRIB_DESCRIPTION)
fi
DISTRIB_RELEASE=$(normalize_version2 "$DISTRIB_RELEASE")
case "$VENDOR_ID" in
"alt"|"altlinux")
DISTRIB_RELEASE=$(echo "$DISTRIB_RELEASE" | sed -e "s/\.[0-9].*//g")
# 2.4.5.99 -> 2
DISTRIB_RELEASE=$(normalize_version1 "$DISTRIB_RELEASE_ORIG")
case "$DISTRIB_ID" in
"ALTServer"|"ALTSPWorkstation"|"Sisyphus")
;;
......@@ -306,7 +328,9 @@ case "$VENDOR_ID" in
esac
;;
"astra")
DISTRIB_RELEASE="$VERSION_CODENAME"
DISTRIB_RELEASE=$(normalize_version3 "$DISTRIB_RELEASE_ORIG" | sed -e 's|_.*||')
#[ "$DISTRIB_RELEASE" = "1.17" ] && DISTRIB_RELEASE="$VERSION_ID"
#DISTRIB_RELEASE="$VERSION_CODENAME"
;;
esac
......@@ -326,8 +350,14 @@ case "$DISTRIB_ID" in
case "$DISTRIB_FULL_RELEASE" in
8.0|8.1)
;;
8.2|8.3)
DISTRIB_RELEASE="c9f1"
;;
8.4)
DISTRIB_RELEASE="c9f2"
;;
8.*)
DISTRIB_RELEASE="c9"
DISTRIB_RELEASE="c9f3"
;;
esac
# DISTRIB_RELEASE=$(echo $DISTRIB_RELEASE | sed -e "s/\..*//g")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment