code cleanup on os-release/lsb-release, shouldn't make any difference for users, but there's a new tarball if you want to update the package.

This commit is contained in:
inxi-svn 2012-12-20 20:07:17 +00:00
parent b8382ecb68
commit 54f23fb3e8

75
inxi
View file

@ -3611,6 +3611,8 @@ get_distro_data()
# get the wild carded array of release/version /etc files if present
shopt -s nullglob
cd /etc
# note: always exceptions, so wild card after release/version: /etc/lsb-release-crunchbang
# wait to handle since crunchbang file is one of the few in the world that uses this method
a_distro_glob=(*[-_]{release,version})
cd "$OLDPWD"
shopt -u nullglob
@ -3747,37 +3749,37 @@ get_lsb_os_release_data()
BEGIN {
IGNORECASE=1
}
# clean out unwanted characters
{
gsub(/\"/,"", $0 )
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2 )
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $1 )
}
# note: adding the spacing directly to variable to make sure distro output is null if not found
/^DISTRIB_ID/ {
gsub(/^ +| +$/, "", $NF)
# this is needed because grep for "arch" is too loose to be safe
if ( $NF == "arch" ) {
if ( $2 == "arch" ) {
distroId = "Arch Linux"
}
else if ( $NF != "n/a" ) {
distroId = $NF " "
else if ( $2 != "n/a" ) {
distroId = $2 " "
}
}
/^DISTRIB_RELEASE/ {
gsub(/^ +| +$/, "", $NF)
if ( $NF != "n/a" ) {
distroRelease = $NF " "
if ( $2 != "n/a" ) {
distroRelease = $2 " "
}
}
/^DISTRIB_CODENAME/ {
gsub(/^ +| +$/, "", $NF)
if ( $NF != "n/a" ) {
distroCodename = $NF " "
if ( $2 != "n/a" ) {
distroCodename = $2 " "
}
}
# sometimes some distros cannot do their lsb-release files correctly, so here is
# one last chance to get it right.
/^DISTRIB_DESCRIPTION/ {
gsub(/^ +| +$/, "", $0)
if ( $NF != "n/a" ) {
# slice out the part inside "", like: DISTRIB_DESCRIPTION="Arch Linux"
gsub(/DISTRIB_DESCRIPTION=|"/,"",$0)
distroDescription = $0
s if ( $2 != "n/a" ) {
distroDescription = $2
}
}
END {
@ -3797,21 +3799,24 @@ get_lsb_os_release_data()
lsb-app)
# this is HORRIBLY slow, not using
if [[ -n $( type -p lsb_release ) ]];then
distro=$( echo "$( lsb_release -irc )" | gawk '
distro=$( echo "$( lsb_release -irc )" | gawk -F ':' '
BEGIN {
IGNORECASE=1
}
# clean out unwanted characters
{
gsub(/\"/,"", $0 )
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2 )
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $1 )
}
/^Distributor ID/ {
gsub(/^ +| +$/, "", $NF)
distroId = $NF
distroId = $2
}
/^Release/ {
gsub(/^ +| +$/, "", $NF)
distroRelease = $NF
distroRelease = $2
}
/^Codename/ {
gsub(/^ +| +$/, "", $NF)
distroCodename = $NF
distroCodename = $2
}
END {
print distroId " " distroRelease " (" distroCodename ")"
@ -3829,27 +3834,29 @@ get_lsb_os_release_data()
versionId=""
distroName=""
}
# clean out unwanted characters
{
gsub(/\"/,"", $0 )
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2 )
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $1 )
}
# note: adding the spacing directly to variable to make sure distro output is null if not found
/^PRETTY_NAME/ {
gsub(/^ +| +$|\"/, "", $NF)
if ( $NF != "n/a" ) {
prettyName = $NF
if ( $2 != "n/a" ) {
prettyName = $2
}
}
/^NAME/ {
gsub(/^ +| +$|\"/, "", $NF)
if ( $NF != "n/a" ) {
regularName = $NF
if ( $2 != "n/a" ) {
regularName = $2
}
}
/^VERSION/ {
gsub(/^ +| +$|\"/, "", $NF)
gsub(/^ +| +$/, "", $1)
if ( $NF != "n/a" && $1 == "VERSION" ) {
versionName = $NF
if ( $2 != "n/a" && $1 == "VERSION" ) {
versionName = $2
}
else if ( $NF != "n/a" && $1 == "VERSION_ID" ) {
versionId = $NF
else if ( $2 != "n/a" && $1 == "VERSION_ID" ) {
versionId = $2
}
}
END {