Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nurlan
eepm
Commits
5f23ec17
Commit
5f23ec17
authored
Jul 18, 2022
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
distr_info: big OS detection rewrite (based on /etc/os-release)
parent
daa3254a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
95 deletions
+58
-95
distr_info
bin/distr_info
+58
-95
No files found.
bin/distr_info
View file @
5f23ec17
...
...
@@ -6,7 +6,7 @@
# You can set ROOTDIR to root system dir
#ROOTDIR=
PROGVERSION
=
"2022071
3
"
PROGVERSION
=
"2022071
8
"
# TODO: check /etc/system-release
...
...
@@ -240,7 +240,7 @@ normalize_name()
;;
*
)
#echo "${1// /}"
echo
"
$1
"
|
sed
-e
"s/ //g"
firstupper
"
$1
"
|
sed
-e
"s/ //g"
-e
's|(.*||'
;;
esac
}
...
...
@@ -253,7 +253,7 @@ DISTRIB_ID=""
DISTRIB_RELEASE
=
""
DISTRIB_CODENAME
=
""
#
Next default
by /etc/os-release
#
Default detection
by /etc/os-release
# https://www.freedesktop.org/software/systemd/man/os-release.html
if
distro os-release
;
then
# shellcheck disable=SC1090
...
...
@@ -266,7 +266,8 @@ if distro os-release ; then
#PRETTY_NAME
VENDOR_ID
=
"
$ID
"
DISTRIB_FULL_RELEASE
=
$DISTRIB_RELEASE
DISTRIB_RELEASE
=
$(
echo
$DISTRIB_RELEASE
|
sed
-e
"s/
\.
[0-9]
$/
/g"
)
DISTRIB_RELEASE
=
$(
echo
"
$DISTRIB_RELEASE
"
|
sed
-e
"s/
\.
[0-9]
$/
/g"
)
elif
distro lsb-release
;
then
DISTRIB_ID
=
$(
cat
$DISTROFILE
| get_var DISTRIB_ID
)
DISTRIB_RELEASE
=
$(
cat
$DISTROFILE
| get_var DISTRIB_RELEASE
)
...
...
@@ -274,10 +275,56 @@ elif distro lsb-release ; then
PRETTY_NAME
=
$(
cat
$DISTROFILE
| get_var DISTRIB_DESCRIPTION
)
fi
# TODO:
#if [ -n "$DISTRIB_ID" ] ; then
# # don't check obsoleted ways
# ;
case
"
$VENDOR_ID
"
in
"alt"
|
"altlinux"
)
case
"
$DISTRIB_ID
"
in
"ALTServer"
|
"ALTSPWorkstation"
|
"Sisyphus"
)
;;
*
)
DISTRIB_ID
=
"ALTLinux"
;;
esac
;;
"astra"
)
DISTRIB_RELEASE
=
"
$VERSION_CODENAME
"
;;
esac
case
"
$DISTRIB_ID
"
in
"ALTLinux"
)
echo
"
$VERSION
"
|
grep
-q
"c9f.* branch"
&&
DISTRIB_RELEASE
=
"c9"
# FIXME: fast hack for fallback: 10 -> p10 for /etc/os-release
if
echo
"
$DISTRIB_RELEASE
"
|
grep
-q
"^[0-9]"
&&
echo
"
$DISTRIB_RELEASE
"
|
grep
-q
-v
"[0-9][0-9][0-9]"
;
then
DISTRIB_RELEASE
=
"
$(
echo
p
$DISTRIB_RELEASE
|
sed
-e
's|\..*||'
)
"
fi
;;
# "ALTServer")
# DISTRIB_RELEASE=$(echo $DISTRIB_RELEASE | sed -e "s/\..*//g")
# ;;
"ALTSPWorkstation"
)
DISTRIB_ID
=
"ALTLinux"
case
"
$DISTRIB_FULL_RELEASE
"
in
8.0|8.1
)
;;
8.
*
)
DISTRIB_RELEASE
=
"c9"
;;
esac
# DISTRIB_RELEASE=$(echo $DISTRIB_RELEASE | sed -e "s/\..*//g")
;;
"Sisyphus"
)
DISTRIB_ID
=
"ALTLinux"
DISTRIB_RELEASE
=
"Sisyphus"
;;
esac
[
-n
"
$DISTRIB_ID
"
]
&&
return
# check via obsoleted ways
# ALT Linux based
if
distro altlinux-release
;
then
DISTRIB_ID
=
"ALTLinux"
...
...
@@ -325,30 +372,10 @@ elif distro gentoo-release ; then
DISTRIB_RELEASE
=
$(
basename
$MAKEPROFILE
)
echo
$DISTRIB_RELEASE
|
grep
-q
"[0-9]"
||
DISTRIB_RELEASE
=
$(
basename
"
$(
dirname
$MAKEPROFILE
)
"
)
#"
elif
[
"
$DISTRIB_ID
"
=
"ALTServer"
]
;
then
DISTRIB_RELEASE
=
$(
echo
$DISTRIB_RELEASE
|
sed
-e
"s/
\.
.*//g"
)
elif
[
"
$DISTRIB_ID
"
=
"ALTSPWorkstation"
]
;
then
DISTRIB_ID
=
"ALTLinux"
case
"
$DISTRIB_RELEASE
"
in
8.0|8.1
)
;;
8.
*
)
DISTRIB_RELEASE
=
"c9"
;;
esac
DISTRIB_RELEASE
=
$(
echo
$DISTRIB_RELEASE
|
sed
-e
"s/
\.
.*//g"
)
elif
distro slackware-version
;
then
DISTRIB_ID
=
"Slackware"
DISTRIB_RELEASE
=
"
$(
grep
-Eo
'[0-9]+\.[0-9]+'
$DISTROFILE
)
"
elif
distro os-release
&&
hascommand apk
;
then
# shellcheck disable=SC1090
.
$ROOTDIR
/etc/os-release
DISTRIB_ID
=
"
$(
firstupper
"
$ID
"
)
"
DISTRIB_RELEASE
=
"
$VERSION_ID
"
elif
distro os-release
&&
hascommand tce-ab
;
then
# shellcheck disable=SC1090
.
$ROOTDIR
/etc/os-release
...
...
@@ -376,76 +403,12 @@ elif distro openwrt_release ; then
.
$DISTROFILE
DISTRIB_RELEASE
=
$(
cat
$ROOTDIR
/etc/openwrt_version
)
# for Ubuntu use standard LSB info
elif
[
"
$DISTRIB_ID
"
=
"Ubuntu"
]
&&
[
-n
"
$DISTRIB_RELEASE
"
]
;
then
# use LSB version
true
elif
distro astra_version
;
then
# use OS release
DISTRIB_ID
=
"
$(
echo
"
$DISTRIB_ID
"
|
sed
-e
's|(.*||'
)
"
DISTRIB_RELEASE
=
"
$VERSION_CODENAME
"
true
# Debian based
elif
distro debian_version
;
then
DISTRIB_ID
=
"Debian"
DISTRIB_RELEASE
=
$(
cat
$DISTROFILE
|
sed
-e
"s/
\.
.*//g"
)
# Mandriva based
elif
distro pclinuxos-release
;
then
DISTRIB_ID
=
"PCLinux"
if
has
"2007"
;
then
DISTRIB_RELEASE
=
"2007"
elif
has
"2008"
;
then
DISTRIB_RELEASE
=
"2008"
elif
has
"2010"
;
then
DISTRIB_RELEASE
=
"2010"
fi
elif
distro mandriva-release
||
distro mandrake-release
;
then
DISTRIB_ID
=
"Mandriva"
if
has 2005
;
then
DISTRIB_RELEASE
=
"2005"
elif
has 2006
;
then
DISTRIB_RELEASE
=
"2006"
elif
has 2007
;
then
DISTRIB_RELEASE
=
"2007"
elif
has 2008
;
then
DISTRIB_RELEASE
=
"2008"
elif
has 2009.0
;
then
DISTRIB_RELEASE
=
"2009.0"
elif
has 2009.1
;
then
DISTRIB_RELEASE
=
"2009.1"
else
# use /etc/lsb-release info by default
if
has ROSA
;
then
DISTRIB_ID
=
"ROSA"
fi
fi
# Fedora based
elif
distro MCBC-release
;
then
DISTRIB_ID
=
"MCBC"
if
has 3.0
;
then
DISTRIB_RELEASE
=
"3.0"
elif
has 3.1
;
then
DISTRIB_RELEASE
=
"3.1"
fi
# TODO: drop in favour of /etc/os-release
elif
distro redhat-release
&&
[
-z
"
$PRETTY_NAME
"
]
;
then
# FIXME if need
# actually in the original RHEL: Red Hat Enterprise Linux .. release N
DISTRIB_ID
=
"RHEL"
if
has CentOS
;
then
DISTRIB_ID
=
"CentOS"
elif
has Scientific
;
then
DISTRIB_ID
=
"Scientific"
elif
has GosLinux
;
then
DISTRIB_ID
=
"GosLinux"
fi
if
has Beryllium
;
then
DISTRIB_ID
=
"Scientific"
DISTRIB_RELEASE
=
"4.1"
elif
has
"release 4"
;
then
DISTRIB_RELEASE
=
"4"
elif
has
"release 5"
;
then
DISTRIB_RELEASE
=
"5"
elif
has
"release 6"
;
then
DISTRIB_RELEASE
=
"6"
elif
has
"release 7"
;
then
DISTRIB_RELEASE
=
"7"
elif
has
"release 8"
;
then
DISTRIB_RELEASE
=
"8"
fi
# SUSE based
elif
distro SuSe-release
||
distro SuSE-release
;
then
DISTRIB_ID
=
"SUSE"
...
...
@@ -487,14 +450,14 @@ elif [ "$(uname -o 2>/dev/null)" = "Cygwin" ] ; then
DISTRIB_RELEASE
=
"all"
fi
}
fill_distr_info
[
-n
"
$DISTRIB_ID
"
]
||
DISTRIB_ID
=
"Generic"
if
[
-z
"
$PRETTY_NAME
"
]
;
then
PRETTY_NAME
=
"
$DISTRIB_ID
$DISTRIB_RELEASE
"
fi
}
fill_distr_info
get_uname
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment