Add os and system to the list of known release files.

* The arch release file will name the distro as "Arch Linux".
* Added a function to remove single and double quotes from strings.
* When parsing the `os-release` file, unquote the parsed strings.
This commit is contained in:
Pedro Algarvio 2013-02-23 02:49:14 +00:00
parent 42760d3d51
commit 3e655094e8

View file

@ -368,6 +368,14 @@ __parse_version_string() {
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: __unquote_string
# DESCRIPTION: Strip single or double quotes from the provided string.
#-------------------------------------------------------------------------------
__unquote_string() {
echo $@ | sed "s/^\([\"']\)\(.*\)\1\$/\2/g"
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: __sort_release_files
# DESCRIPTION: Custom sort function. Alphabetical or numerical sort is not
@ -375,8 +383,8 @@ __parse_version_string() {
#-------------------------------------------------------------------------------
__sort_release_files() {
KNOWN_RELEASE_FILES=$(echo "(arch|centos|debian|ubuntu|fedora|redhat|suse|\
mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|lsb)\
(-|_)(release|version)" | sed -r 's:[[:space:]]::g')
mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|lsb|system|\
os)(-|_)(release|version)" | sed -r 's:[[:space:]]::g')
primary_release_files=""
secondary_release_files=""
# Sort know VS un-known files first
@ -449,7 +457,7 @@ __gather_linux_system_info() {
[ "${rv}x" = "x" ] && continue # There's no version information. Continue to next rsource
v=$(__parse_version_string "$rv")
case $(echo ${n} | tr '[:upper:]' '[:lower:]') in
redhat )
redhat )
if [ ".$(egrep 'CentOS' /etc/${rsource})" != . ]; then
n="CentOS"
elif [ ".$(egrep 'Red Hat Enterprise Linux' /etc/${rsource})" != . ]; then
@ -458,7 +466,7 @@ __gather_linux_system_info() {
n="<R>ed <H>at <L>inux"
fi
;;
arch ) n="Arch" ;;
arch ) n="Arch Linux" ;;
centos ) n="CentOS" ;;
debian ) n="Debian" ;;
ubuntu ) n="Ubuntu" ;;
@ -480,7 +488,7 @@ __gather_linux_system_info() {
done < /etc/${rsource}
;;
os )
n=$(grep '^NAME=' /etc/os-release | sed -e 's/^NAME=\(.*\)$/\1/g')
n=$(__unquote_string $(grep '^NAME=' /etc/os-release | sed -e 's/^NAME=\(.*\)$/\1/g'))
;;
* ) n="${n}" ;
esac