mirror of
https://github.com/smxi/inxi.git
synced 2024-11-17 00:31:19 +00:00
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:
parent
b8382ecb68
commit
54f23fb3e8
75
inxi
75
inxi
|
@ -3611,6 +3611,8 @@ get_distro_data()
|
||||||
# get the wild carded array of release/version /etc files if present
|
# get the wild carded array of release/version /etc files if present
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
cd /etc
|
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})
|
a_distro_glob=(*[-_]{release,version})
|
||||||
cd "$OLDPWD"
|
cd "$OLDPWD"
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
|
@ -3747,37 +3749,37 @@ get_lsb_os_release_data()
|
||||||
BEGIN {
|
BEGIN {
|
||||||
IGNORECASE=1
|
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
|
# note: adding the spacing directly to variable to make sure distro output is null if not found
|
||||||
/^DISTRIB_ID/ {
|
/^DISTRIB_ID/ {
|
||||||
gsub(/^ +| +$/, "", $NF)
|
|
||||||
# this is needed because grep for "arch" is too loose to be safe
|
# this is needed because grep for "arch" is too loose to be safe
|
||||||
if ( $NF == "arch" ) {
|
if ( $2 == "arch" ) {
|
||||||
distroId = "Arch Linux"
|
distroId = "Arch Linux"
|
||||||
}
|
}
|
||||||
else if ( $NF != "n/a" ) {
|
else if ( $2 != "n/a" ) {
|
||||||
distroId = $NF " "
|
distroId = $2 " "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/^DISTRIB_RELEASE/ {
|
/^DISTRIB_RELEASE/ {
|
||||||
gsub(/^ +| +$/, "", $NF)
|
if ( $2 != "n/a" ) {
|
||||||
if ( $NF != "n/a" ) {
|
distroRelease = $2 " "
|
||||||
distroRelease = $NF " "
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/^DISTRIB_CODENAME/ {
|
/^DISTRIB_CODENAME/ {
|
||||||
gsub(/^ +| +$/, "", $NF)
|
if ( $2 != "n/a" ) {
|
||||||
if ( $NF != "n/a" ) {
|
distroCodename = $2 " "
|
||||||
distroCodename = $NF " "
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# sometimes some distros cannot do their lsb-release files correctly, so here is
|
# sometimes some distros cannot do their lsb-release files correctly, so here is
|
||||||
# one last chance to get it right.
|
# one last chance to get it right.
|
||||||
/^DISTRIB_DESCRIPTION/ {
|
/^DISTRIB_DESCRIPTION/ {
|
||||||
gsub(/^ +| +$/, "", $0)
|
s if ( $2 != "n/a" ) {
|
||||||
if ( $NF != "n/a" ) {
|
distroDescription = $2
|
||||||
# slice out the part inside "", like: DISTRIB_DESCRIPTION="Arch Linux"
|
|
||||||
gsub(/DISTRIB_DESCRIPTION=|"/,"",$0)
|
|
||||||
distroDescription = $0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
|
@ -3797,21 +3799,24 @@ get_lsb_os_release_data()
|
||||||
lsb-app)
|
lsb-app)
|
||||||
# this is HORRIBLY slow, not using
|
# this is HORRIBLY slow, not using
|
||||||
if [[ -n $( type -p lsb_release ) ]];then
|
if [[ -n $( type -p lsb_release ) ]];then
|
||||||
distro=$( echo "$( lsb_release -irc )" | gawk '
|
distro=$( echo "$( lsb_release -irc )" | gawk -F ':' '
|
||||||
BEGIN {
|
BEGIN {
|
||||||
IGNORECASE=1
|
IGNORECASE=1
|
||||||
}
|
}
|
||||||
|
# clean out unwanted characters
|
||||||
|
{
|
||||||
|
gsub(/\"/,"", $0 )
|
||||||
|
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2 )
|
||||||
|
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $1 )
|
||||||
|
}
|
||||||
/^Distributor ID/ {
|
/^Distributor ID/ {
|
||||||
gsub(/^ +| +$/, "", $NF)
|
distroId = $2
|
||||||
distroId = $NF
|
|
||||||
}
|
}
|
||||||
/^Release/ {
|
/^Release/ {
|
||||||
gsub(/^ +| +$/, "", $NF)
|
distroRelease = $2
|
||||||
distroRelease = $NF
|
|
||||||
}
|
}
|
||||||
/^Codename/ {
|
/^Codename/ {
|
||||||
gsub(/^ +| +$/, "", $NF)
|
distroCodename = $2
|
||||||
distroCodename = $NF
|
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
print distroId " " distroRelease " (" distroCodename ")"
|
print distroId " " distroRelease " (" distroCodename ")"
|
||||||
|
@ -3829,27 +3834,29 @@ get_lsb_os_release_data()
|
||||||
versionId=""
|
versionId=""
|
||||||
distroName=""
|
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
|
# note: adding the spacing directly to variable to make sure distro output is null if not found
|
||||||
/^PRETTY_NAME/ {
|
/^PRETTY_NAME/ {
|
||||||
gsub(/^ +| +$|\"/, "", $NF)
|
if ( $2 != "n/a" ) {
|
||||||
if ( $NF != "n/a" ) {
|
prettyName = $2
|
||||||
prettyName = $NF
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/^NAME/ {
|
/^NAME/ {
|
||||||
gsub(/^ +| +$|\"/, "", $NF)
|
if ( $2 != "n/a" ) {
|
||||||
if ( $NF != "n/a" ) {
|
regularName = $2
|
||||||
regularName = $NF
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/^VERSION/ {
|
/^VERSION/ {
|
||||||
gsub(/^ +| +$|\"/, "", $NF)
|
if ( $2 != "n/a" && $1 == "VERSION" ) {
|
||||||
gsub(/^ +| +$/, "", $1)
|
versionName = $2
|
||||||
if ( $NF != "n/a" && $1 == "VERSION" ) {
|
|
||||||
versionName = $NF
|
|
||||||
}
|
}
|
||||||
else if ( $NF != "n/a" && $1 == "VERSION_ID" ) {
|
else if ( $2 != "n/a" && $1 == "VERSION_ID" ) {
|
||||||
versionId = $NF
|
versionId = $2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
|
|
Loading…
Reference in a new issue