New version, new tarball. Maintainer: this is only for bsd darwin (aka osx, it's an

experiment, just to get it running, so you can all ignore this release.

Added in darwin cpu, init, distro version support, and updated inxi to support
darwin/osx without exiting. 

No linux changes.
This commit is contained in:
inxi-svn 2014-05-01 20:34:08 +00:00
parent caf624abc7
commit d5604c821e
2 changed files with 120 additions and 23 deletions

125
inxi
View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### Version: 2.1.25 #### Version: 2.1.26
#### Date: 2014-05-01 #### Date: 2014-05-01
#### Patch Number: 00 #### Patch Number: 00
######################################################################## ########################################################################
@ -614,7 +614,7 @@ DISTROS_OS_RELEASE_GOOD="arch-release SuSE-release"
# Note that \<ltd\> bans only words, not parts of strings; in \<corp\> you can't use punctuation characters like . or , # Note that \<ltd\> bans only words, not parts of strings; in \<corp\> you can't use punctuation characters like . or ,
# we're saving about 10+% of the total script exec time by hand building the ban lists here, using hard quotes. # we're saving about 10+% of the total script exec time by hand building the ban lists here, using hard quotes.
BAN_LIST_NORMAL='chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|incorporation|industrial|international|nee|revision|semiconductor|software|technologies|technology|ltd\.|\<ltd\>|inc\.|\<inc\>|intl\.|co\.|\<co\>|corp\.|\<corp\>|\(tm\)|\(r\)|®|\(rev ..\)' BAN_LIST_NORMAL='chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|incorporation|industrial|international|nee|revision|semiconductor|software|technologies|technology|ltd\.|\<ltd\>|inc\.|\<inc\>|intl\.|co\.|\<co\>|corp\.|\<corp\>|\(tm\)|\(r\)|®|\(rev ..\)'
BAN_LIST_CPU='@|cpu deca|dual core|dual-core|tri core|tri-core|quad core|quad-core|ennea|genuine|hepta|hexa|multi|octa|penta|processor|single|triple|[0-9\.]+ *[MmGg][Hh][Zz]' BAN_LIST_CPU='@||cpu |cpu deca|dual core|dual-core|tri core|tri-core|quad core|quad-core|ennea|genuine|hepta|hexa|multi|octa|penta|processor|single|triple|[0-9\.]+ *[MmGg][Hh][Zz]'
SENSORS_GPU_SEARCH='intel|radeon|nouveau' SENSORS_GPU_SEARCH='intel|radeon|nouveau'
@ -799,10 +799,12 @@ initialize_data()
# GNU/kfreebsd will by definition have GNU tools like sed/grep # GNU/kfreebsd will by definition have GNU tools like sed/grep
if [[ -z ${BSD_VERSION/*kfreebsd*/} ]];then if [[ -z ${BSD_VERSION/*kfreebsd*/} ]];then
BSD_TYPE='debian-bsd' # debian gnu bsd BSD_TYPE='debian-bsd' # debian gnu bsd
elif [[ -z ${BSD_VERSION/*darwin*/} ]];then
BSD_TYPE='darwin-bsd' # debian gnu bsd
else else
BSD_TYPE='bsd' # all other bsds if [[ -z ${BSD_VERSION/*darwin*/} ]];then
BSD_TYPE='darwin-bsd' # debian gnu bsd
else
BSD_TYPE='bsd' # all other bsds
fi
SED_I="-i ''" SED_I="-i ''"
SED_RX='-E' SED_RX='-E'
ESC=$(echo | tr '\n' '\033') ESC=$(echo | tr '\n' '\033')
@ -1047,7 +1049,7 @@ check_required_apps()
if [[ -z $BSD_TYPE ]];then if [[ -z $BSD_TYPE ]];then
depends="$depends lspci" depends="$depends lspci"
elif [[ $BSD_TYPE == 'bsd' ]];then elif [[ $BSD_TYPE == 'bsd' || $BSD_TYPE == 'darwin-bsd' ]];then
depends="$depends sysctl" depends="$depends sysctl"
# debian-bsd has lspci but you must be root to run it # debian-bsd has lspci but you must be root to run it
elif [[ $BSD_TYPE == 'debian-bsd' ]];then elif [[ $BSD_TYPE == 'debian-bsd' ]];then
@ -1894,7 +1896,7 @@ check_recommends_user_output()
echo "Python version: $python_version" echo "Python version: $python_version"
echo $Line echo $Line
echo "Test One: Required System Directories." echo "Test One: Required System Directories (Linux Only)."
print_lines_basic "0" "" "If one of these system directories is missing, $SCRIPT_NAME cannot operate:" print_lines_basic "0" "" "If one of these system directories is missing, $SCRIPT_NAME cannot operate:"
echo echo
check_recommends_items 'required-dirs' check_recommends_items 'required-dirs'
@ -3620,7 +3622,7 @@ get_audio_alsa_data()
get_cpu_core_count() get_cpu_core_count()
{ {
eval $LOGFS eval $LOGFS
local cpu_physical_count='' cpu_core_count='' cpu_type='' cpu_alpha_count='' local cpu_physical_count='' cpu_core_count='' cpu_type='' cpu_alpha_count='' cores_per_cpu=''
if [[ $B_CPUINFO_FILE == 'true' ]]; then if [[ $B_CPUINFO_FILE == 'true' ]]; then
# load the A_CPU_TYPE_PCNT_CCNT core data array # load the A_CPU_TYPE_PCNT_CCNT core data array
get_cpu_ht_multicore_smp_data get_cpu_ht_multicore_smp_data
@ -3642,19 +3644,38 @@ get_cpu_core_count()
if [[ $BSD_VERSION == 'openbsd' ]];then if [[ $BSD_VERSION == 'openbsd' ]];then
gawk_fs='=' gawk_fs='='
fi fi
cpu_core_count=$( gawk -F "$gawk_fs" ' cpu_core_count=$( gawk -F "$gawk_fs" -v bsdType=$BSD_TYPE '
# note: on openbsd can also be hw.ncpufound so exit after first # note: on openbsd can also be hw.ncpufound so exit after first
/^hw.ncpu/ { BEGIN {
print $NF coreCount=""
exit }
/^hw.ncpu$/ {
coreCount=$NF
# incredibly, they actually change field separators on some systems.
FS = ":"
}
/^machdep.cpu.core_count/ {
coreCount=$NF
}
END {
print coreCount
}' <<< "$Sysctl_a_Data" ) }' <<< "$Sysctl_a_Data" )
cores_per_cpu=$( gawk -F "$gawk_fs" '
/^machdep.cpu.cores_per_package/ {
print $NF
}' <<< "$Sysctl_a_Data" )
if [[ -n $( grep -E '^[0-9]+$' <<< "$cpu_core_count" ) ]];then if [[ -n $( grep -E '^[0-9]+$' <<< "$cpu_core_count" ) ]];then
cpu_alpha_count=$( get_cpu_core_count_alpha "$cpu_core_count" ) cpu_alpha_count=$( get_cpu_core_count_alpha "$cpu_core_count" )
if [[ $cpu_core_count -gt 1 ]];then if [[ $cpu_core_count -gt 1 ]];then
cpu_type='SMP' cpu_type='SMP'
fi fi
fi fi
cpu_physical_count=1 if [[ -n $cores_per_cpu ]];then
cpu_physical_count=$(( $cpu_core_count / $cores_per_cpu ))
else
cpu_physical_count=1
fi
A_CPU_CORE_DATA=( "$cpu_physical_count" "$cpu_alpha_count" "$cpu_type" "$cpu_core_count" ) A_CPU_CORE_DATA=( "$cpu_physical_count" "$cpu_alpha_count" "$cpu_type" "$cpu_core_count" )
fi fi
a_temp=${A_CPU_CORE_DATA[@]} a_temp=${A_CPU_CORE_DATA[@]}
@ -3844,7 +3865,8 @@ get_cpu_data_bsd()
local bsd_cpu_flags=$( get_cpu_flags_bsd ) local bsd_cpu_flags=$( get_cpu_flags_bsd )
local gawk_fs=': ' local gawk_fs=': '
if [[ $BSD_VERSION == 'openbsd' ]];then # note, in darwin, they switch fs from = to : ... sigh
if [[ $BSD_VERSION == 'openbsd' || $BSD_VERSION == 'darwin-bsd' ]];then
gawk_fs='=' gawk_fs='='
fi fi
# avoid setting this for systems where you have no read/execute permissions # avoid setting this for systems where you have no read/execute permissions
@ -3852,7 +3874,7 @@ get_cpu_data_bsd()
if [[ -n $Sysctl_a_Data || -n $bsd_cpu_flags ]];then if [[ -n $Sysctl_a_Data || -n $bsd_cpu_flags ]];then
IFS=$'\n' IFS=$'\n'
A_CPU_DATA=( $( A_CPU_DATA=( $(
gawk -F "$gawk_fs" -v cpuFlags="$bsd_cpu_flags" ' gawk -F "$gawk_fs" -v bsdType=$BSD_TYPE -v cpuFlags="$bsd_cpu_flags" '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
cpuModel="" cpuModel=""
@ -3860,8 +3882,9 @@ get_cpu_data_bsd()
cpuCache="" cpuCache=""
cpuBogomips="" cpuBogomips=""
cpuVendor="" cpuVendor=""
bMach="false"
} }
/^hw.model/ { ( bsdType != "darwin-bsd" ) && /^hw.model/ {
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF ) gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
gsub(/'"$BAN_LIST_CPU"'/, "", $NF ) gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
sub(//,"",$NF) sub(//,"",$NF)
@ -3873,12 +3896,36 @@ get_cpu_data_bsd()
exit exit
} }
} }
/^hw.(clock|cpuspeed)/ { /^hw.(clock|cpufrequency)$/ {
cpuClock=$NF cpuClock=$NF
if ( cpuModel != "" ) { if ( cpuModel != "" ) {
exit exit
} }
} }
/^machdep/ {
FS=":"
}
/^hw.cpufrequency/ {
cpuClock = $NF / 1000000
}
/^hw.l2cachesize/ {
cpuCache=$NF/1000
cpuCache=cpuCache " kB"
}
/^machdep.cpu.vendor/ {
cpuVendor=$NF
}
/^machdep.cpu.brand_string/ {
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
sub(//,"",$NF)
sub(/[a-z]+-core/, "", $NF )
gsub(/^ +| +$|\"/, "", $NF)
gsub(/ [ \t]+/, " ", $NF)
sub(/[[:space:]]*@.*/,"",$NF)
cpuModel=$NF
}
END { END {
print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor
print "N/A" print "N/A"
@ -3894,9 +3941,13 @@ get_cpu_flags_bsd()
eval $LOGFS eval $LOGFS
local cpu_flags='' local cpu_flags=''
local gawk_fs=':'
if [[ $BSD_VERSION == 'openbsd' ]];then
gawk_fs='='
fi
if [[ -n $Dmesg_Boot_Data ]];then if [[ -n $Dmesg_Boot_Data ]];then
cpu_flags=$( gawk -F '=' ' cpu_flags=$( gawk -F "=" '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
cpuFlags="" cpuFlags=""
@ -3916,6 +3967,17 @@ get_cpu_flags_bsd()
print cpuFlags print cpuFlags
exit exit
}' <<< "$Dmesg_Boot_Data" ) }' <<< "$Dmesg_Boot_Data" )
elif [[ -n $Sysctl_a_Data ]];then
cpu_flags=$( gawk -F "$gawk_fs" '
BEGIN {
IGNORECASE=1
cpuFlags=""
}
/^machdep.cpu.features/ {
cpuFlags=tolower($NF)
print cpuFlags
exit
}' <<< "$Sysctl_a_Data" )
fi fi
echo $cpu_flags echo $cpu_flags
log_function_data "$cpu_flags" log_function_data "$cpu_flags"
@ -4505,7 +4567,16 @@ get_distro_data()
# may need modification if archbsd / debian can be id'ed with /etc files # may need modification if archbsd / debian can be id'ed with /etc files
if [[ -n $BSD_TYPE ]];then if [[ -n $BSD_TYPE ]];then
distro=$( uname -sr ) if [[ $BSD_TYPE != 'darwin-bsd' ]];then
distro=$( uname -sr )
else
if [[ -f /System/Library/CoreServices/SystemVersion.plist ]];then
distro=$( grep -A1 -E '(ProductName|ProductVersion)' /System/Library/CoreServices/SystemVersion.plist | grep '<string>' | sed -E 's/<[\/]?string>//g' )
distro=$( echo $distro )
else
distro='Mac OS X'
fi
fi
echo "$distro" echo "$distro"
log_function_data "distro: $distro" log_function_data "distro: $distro"
eval $LOGFE eval $LOGFE
@ -5825,6 +5896,10 @@ get_init_data()
init_type='Epoch' init_type='Epoch'
# epoch version == Epoch Init System 1.0.1 "Sage" # epoch version == Epoch Init System 1.0.1 "Sage"
init_version=$( get_program_version 'epoch' '^Epoch' '4' ) init_version=$( get_program_version 'epoch' '^Epoch' '4' )
elif type -p launchctl &>/dev/null;then
init_type='Launchctl'
# epoch version == Epoch Init System 1.0.1 "Sage"
# init_version=$( get_program_version 'Launchctl' '^Launchctl' '4' )
# missing data: # missing data:
# http://smarden.org/runit/sv.8.html # http://smarden.org/runit/sv.8.html
elif [[ -e /sbin/runit-init || -e /etc/runit || -n $( type -p sv ) ]];then elif [[ -e /sbin/runit-init || -e /etc/runit || -n $( type -p sv ) ]];then
@ -9610,7 +9685,7 @@ print_cpu_data()
# bmip_data="${a_cpu_working[4]}" # bmip_data="${a_cpu_working[4]}"
# fi # fi
# bogomips are a linux thing, but my guess is over time bsds will use them somewhere anyway # bogomips are a linux thing, but my guess is over time bsds will use them somewhere anyway
if [[ $BSD_TYPE == 'bsd' && -z $bmip_data ]];then if [[ -n $BSD_TYPE && -z $bmip_data ]];then
bmip_data='' bmip_data=''
else else
bmip_data="${C1}bmips$SEP3${C2} $bmip_data " bmip_data="${C1}bmips$SEP3${C2} $bmip_data "
@ -9619,10 +9694,14 @@ print_cpu_data()
## note: this handles how intel reports L2, total instead of per core like AMD does ## note: this handles how intel reports L2, total instead of per core like AMD does
# note that we need to multiply by number of actual cpus here to get true cache size # note that we need to multiply by number of actual cpus here to get true cache size
if [[ -n ${a_cpu_working[2]} ]];then if [[ -n ${a_cpu_working[2]} ]];then
if [[ $cpu_vendor != 'intel' ]];then if [[ -z $BSD_TYPE ]];then
cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$(( $cpu_core_count * $cpu_physical_count ))" ) if [[ $cpu_vendor != 'intel' ]];then
cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$(( $cpu_core_count * $cpu_physical_count ))" )
else
cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_physical_count" )
fi
else else
cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_physical_count" ) cpu_cache=${a_cpu_working[2]}
fi fi
else else
cpu_cache='N/A' cpu_cache='N/A'

View file

@ -1,3 +1,21 @@
=====================================================================================
Version: 2.1.26
Patch Version: 00
Script Date: 2014-05-01
-----------------------------------
Changes:
-----------------------------------
New version, new tarball. Maintainer: this is only for bsd darwin (aka osx, it's an
experiment, just to get it running, so you can all ignore this release.
Added in darwin cpu, init, distro version support, and updated inxi to support
darwin/osx without exiting.
No linux changes.
-----------------------------------
-- Harald Hope - Thu, 01 May 2014 13:32:21 -0700
===================================================================================== =====================================================================================
Version: 2.1.25 Version: 2.1.25
Patch Version: 00 Patch Version: 00