mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 08:57:57 +00:00
branch one, first attempt to add suse zypp repo support, also a bug fix for intel vm cpu data
This commit is contained in:
parent
c9bdd0a982
commit
a75460b94e
169
inxi
169
inxi
|
@ -2,7 +2,7 @@
|
|||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### Version: 1.9.8
|
||||
#### Date: June 14 2013
|
||||
#### Date: June 15 2013
|
||||
#### Patch Number: 01-b1
|
||||
########################################################################
|
||||
#### SPECIAL THANKS
|
||||
|
@ -3603,6 +3603,7 @@ get_cpu_ht_multicore_smp_data()
|
|||
num_of_processors = 0
|
||||
num_of_cpus = 0
|
||||
cpu_core_count = 0
|
||||
siblings = 0
|
||||
core_id[0]
|
||||
processor_id[0]
|
||||
cpu_id[0]
|
||||
|
@ -3613,14 +3614,13 @@ get_cpu_ht_multicore_smp_data()
|
|||
nr = 0
|
||||
bArm = "false"
|
||||
bXeon = "false"
|
||||
siblings = ""
|
||||
}
|
||||
# hack to handle xeons which can have buggy /proc/cpuinfo files
|
||||
/^model name/ && ( $0 ~ /Xeon/ ) {
|
||||
bXeon = "true"
|
||||
}
|
||||
# only do this once since sibling count does not change
|
||||
/^siblings/ && ( bXeon == "true" ) && ( siblings == "" ) {
|
||||
/^siblings/ && ( bXeon == "true" ) && ( siblings == 0 ) {
|
||||
gsub(/[^0-9]/,"",$NF)
|
||||
if ( $NF != "" ) {
|
||||
siblings = $NF
|
||||
|
@ -3693,7 +3693,7 @@ get_cpu_ht_multicore_smp_data()
|
|||
num_of_cores++
|
||||
}
|
||||
# xeon may show wrong core / physical id count, if it does, fix it
|
||||
if ( num_of_cores == 1 && bXeon == "true" && siblings != "" && siblings > 1 ) {
|
||||
if ( num_of_cores == 1 && bXeon == "true" && siblings > 1 ) {
|
||||
num_of_cores = siblings/2
|
||||
}
|
||||
# final check, override the num of cores value if it clearly is wrong
|
||||
|
@ -3701,6 +3701,11 @@ get_cpu_ht_multicore_smp_data()
|
|||
if ( ( num_of_cores == 1 ) && ( cpu_core_count * num_of_cpus > 1 ) ) {
|
||||
num_of_cores = cpu_core_count * num_of_cpus
|
||||
}
|
||||
# last check, seeing some intel cpus and vms with intel cpus that do not show any
|
||||
# core id data at all, or siblings.
|
||||
if ( num_of_cores == 0 && num_of_processors > 0 ) {
|
||||
num_of_cores = num_of_processors
|
||||
}
|
||||
|
||||
####################################################################
|
||||
# algorithm
|
||||
|
@ -3708,12 +3713,12 @@ get_cpu_ht_multicore_smp_data()
|
|||
# if > 1 processor && processor id (physical id) != core id then Multi-Core Processors (MCP)
|
||||
# if > 1 processor && processor ids (physical id) > 1 then Multiple Processors (SMP)
|
||||
# if = 1 processor then single core/processor Uni-Processor (UP)
|
||||
if ( num_of_processors > 1 || ( bXeon == "true" && siblings != "" ) ) {
|
||||
if ( num_of_processors > 1 || ( bXeon == "true" && siblings > 0 ) ) {
|
||||
# non-multicore HT
|
||||
if ( num_of_processors == (num_of_cores * 2) ) {
|
||||
type = type "HT-"
|
||||
}
|
||||
else if ( bXeon == "true" && siblings != "" && siblings > 1 ) {
|
||||
else if ( bXeon == "true" && siblings > 1 ) {
|
||||
type = type "HT-" # num_of_processors num_of_cores num_of_cpus
|
||||
}
|
||||
# non-HT multi-core or HT multi-core
|
||||
|
@ -5075,7 +5080,7 @@ get_hdd_data_basic()
|
|||
# size += $3
|
||||
# }
|
||||
# special case from this data: 8 0 156290904 sda
|
||||
# note: vm has 252/253 known starter, grsec has 202
|
||||
# note: vm has 252/253/254 known starter, grsec has 202
|
||||
$1 ~ /^(3|8|22|33|202|252|253|254)$/ && $NF ~ /[hsv]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) {
|
||||
size += $3
|
||||
}
|
||||
|
@ -7274,10 +7279,11 @@ get_raid_component_data_bsd()
|
|||
get_repo_data()
|
||||
{
|
||||
eval $LOGFS
|
||||
local repo_file='' repo_data_working='' repo_data_working2='' repo_line=''
|
||||
local repo_file='' repo_data_working='' repo_data_working2='' repo_line='' repo_files=''
|
||||
local repo_name=''
|
||||
local apt_file='/etc/apt/sources.list' yum_repo_dir='/etc/yum.repos.d/' yum_conf='/etc/yum.conf'
|
||||
local pacman_conf='/etc/pacman.conf' pacman_repo_dir='/etc/pacman.d/' pisi_dir='/etc/pisi/'
|
||||
local freebsd_conf='/etc/portsnap.conf'
|
||||
local zypp_repo_dir='/etc/zypp/repos.d' freebsd_conf='/etc/portsnap.conf'
|
||||
|
||||
# apt - debian, buntus, also sometimes some yum/rpm repos may create apt repos here as well
|
||||
if [[ -f $apt_file || -d $apt_file.d ]];then
|
||||
|
@ -7288,76 +7294,85 @@ get_repo_data()
|
|||
# actually running, inxi will merely note the existence of each repo type for apt/yum.
|
||||
# Also, in rpm, you can install apt-rpm for the apt-get command, so it's not good to check for
|
||||
# only the commands in terms of selecting which repos to show.
|
||||
if [[ -d $yum_repo_dir || -f $yum_conf ]];then
|
||||
# older redhats put their yum data in /etc/yum.conf
|
||||
for repo_file in $( ls $yum_repo_dir*.repo $yum_conf 2>/dev/null )
|
||||
do
|
||||
repo_data_working="$( gawk -v repoFile=$repo_file '
|
||||
# construct the string for the print function to work with, file name: data
|
||||
function print_line( fileName, repoId, repoUrl ){
|
||||
print "yum repos:" fileName ":" repoId repoUrl
|
||||
}
|
||||
BEGIN {
|
||||
FS="\n"
|
||||
IGNORECASE=1
|
||||
enabledStatus=""
|
||||
repoTitle=""
|
||||
urlData=""
|
||||
}
|
||||
# this is a hack, assuming that each item has these fields listed, we collect the 3
|
||||
# items one by one, then when the url/enabled fields are set, we print it out and
|
||||
# reset the data. Not elegant but it works. Note that if enabled was not present
|
||||
# we assume it is enabled then, and print the line, reset the variables. This will
|
||||
# miss the last item, so it is printed if found in END
|
||||
/^\[.+\]/ {
|
||||
if ( urlData != "" && repoTitle != "" ){
|
||||
print_line( repoFile, repoTitle, urlData )
|
||||
enabledStatus=""
|
||||
urlData=""
|
||||
repoTitle=""
|
||||
if [[ -d $yum_repo_dir || -f $yum_conf || -d $zypp_repo_dir ]];then
|
||||
if [[ -d $yum_repo_dir || -f $yum_conf ]];then
|
||||
# older redhats put their yum data in /etc/yum.conf
|
||||
repo_files=$( ls $yum_repo_dir*.repo $yum_conf 2>/dev/null )
|
||||
repo_name='yum'
|
||||
elif [[ -d $zypp_repo_dir ]];then
|
||||
repo_files=$( ls $zypp_repo_dir 2>/dev/null )
|
||||
repo_name='zypp'
|
||||
fi
|
||||
if [[ -n $repo_files ]];then
|
||||
for repo_file in $repo_files
|
||||
do
|
||||
repo_data_working="$( gawk -v repoFile=$repo_file '
|
||||
# construct the string for the print function to work with, file name: data
|
||||
function print_line( fileName, repoId, repoUrl ){
|
||||
print "'$repo_name':" fileName ":" repoId repoUrl
|
||||
}
|
||||
gsub( /\[|\]/, "", $1 ) # strip out the brackets
|
||||
repoTitle = $1 " ~ "
|
||||
}
|
||||
/^(mirrorlist|baseurl)/ {
|
||||
sub( /(mirrorlist|baseurl)[[:space:]]*=[[:space:]]*/, "", $1 ) # strip out the field starter
|
||||
urlData = $1
|
||||
}
|
||||
# note: enabled = 1. enabled = 0 means disabled
|
||||
/^enabled[[:space:]]*=/ {
|
||||
enabledStatus = $1
|
||||
}
|
||||
# print out the line if all 3 values are found, otherwise if a new
|
||||
# repoTitle is hit above, it will print out the line there instead
|
||||
{
|
||||
if ( urlData != "" && enabledStatus != "" && repoTitle != "" ){
|
||||
if ( enabledStatus !~ /enabled[[:space:]]*=[[:space:]]*0/ ){
|
||||
BEGIN {
|
||||
FS="\n"
|
||||
IGNORECASE=1
|
||||
enabledStatus=""
|
||||
repoTitle=""
|
||||
urlData=""
|
||||
}
|
||||
# this is a hack, assuming that each item has these fields listed, we collect the 3
|
||||
# items one by one, then when the url/enabled fields are set, we print it out and
|
||||
# reset the data. Not elegant but it works. Note that if enabled was not present
|
||||
# we assume it is enabled then, and print the line, reset the variables. This will
|
||||
# miss the last item, so it is printed if found in END
|
||||
/^\[.+\]/ {
|
||||
if ( urlData != "" && repoTitle != "" ){
|
||||
print_line( repoFile, repoTitle, urlData )
|
||||
enabledStatus=""
|
||||
urlData=""
|
||||
repoTitle=""
|
||||
}
|
||||
gsub( /\[|\]/, "", $1 ) # strip out the brackets
|
||||
repoTitle = $1 " ~ "
|
||||
}
|
||||
/^(mirrorlist|baseurl)/ {
|
||||
sub( /(mirrorlist|baseurl)[[:space:]]*=[[:space:]]*/, "", $1 ) # strip out the field starter
|
||||
urlData = $1
|
||||
}
|
||||
# note: enabled = 1. enabled = 0 means disabled
|
||||
/^enabled[[:space:]]*=/ {
|
||||
enabledStatus = $1
|
||||
}
|
||||
# print out the line if all 3 values are found, otherwise if a new
|
||||
# repoTitle is hit above, it will print out the line there instead
|
||||
{
|
||||
if ( urlData != "" && enabledStatus != "" && repoTitle != "" ){
|
||||
if ( enabledStatus !~ /enabled[[:space:]]*=[[:space:]]*0/ ){
|
||||
print_line( repoFile, repoTitle, urlData )
|
||||
}
|
||||
enabledStatus=""
|
||||
urlData=""
|
||||
repoTitle=""
|
||||
}
|
||||
}
|
||||
END {
|
||||
# print the last one if there is data for it
|
||||
if ( urlData != "" && repoTitle != "" ){
|
||||
print_line( repoFile, repoTitle, urlData )
|
||||
}
|
||||
enabledStatus=""
|
||||
urlData=""
|
||||
repoTitle=""
|
||||
}
|
||||
}
|
||||
END {
|
||||
# print the last one if there is data for it
|
||||
if ( urlData != "" && repoTitle != "" ){
|
||||
print_line( repoFile, repoTitle, urlData )
|
||||
}
|
||||
}
|
||||
' $repo_file )"
|
||||
|
||||
# then load the global for each file as it gets filled
|
||||
if [[ -n $repo_data_working ]];then
|
||||
if [[ -z $REPO_DATA ]];then
|
||||
REPO_DATA="$repo_data_working"
|
||||
else
|
||||
REPO_DATA="$REPO_DATA
|
||||
' $repo_file )"
|
||||
|
||||
# then load the global for each file as it gets filled
|
||||
if [[ -n $repo_data_working ]];then
|
||||
if [[ -z $REPO_DATA ]];then
|
||||
REPO_DATA="$repo_data_working"
|
||||
else
|
||||
REPO_DATA="$REPO_DATA
|
||||
$repo_data_working"
|
||||
fi
|
||||
repo_data_working=''
|
||||
fi
|
||||
repo_data_working=''
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
# pacman - archlinux, going to assume that pisi and arch/pacman don't have the above issue with apt/yum
|
||||
# pisi - pardus
|
||||
elif [[ -d $pisi_dir && -n $( type -p pisi ) ]];then
|
||||
|
@ -9112,6 +9127,7 @@ print_hard_disk_data()
|
|||
local hdd_capacity="${a_hdd_basic_working[0]}"
|
||||
local hdd_used=${a_hdd_basic_working[1]}
|
||||
local bsd_unsupported='Hard drive data not yet supported for BSD systems.'
|
||||
local hdd_name_temp=''
|
||||
|
||||
if [[ $B_SHOW_BASIC_DISK == 'true' || $B_SHOW_DISK == 'true' ]];then
|
||||
## note: the output part of this should be in the print hdd data function, not here
|
||||
|
@ -9151,7 +9167,12 @@ print_hard_disk_data()
|
|||
fi
|
||||
dev_data="${C1}id$SEP3${C2} /dev/${a_hdd_working[0]} "
|
||||
fi
|
||||
hdd_name="${C1}model$SEP3${C2} ${a_hdd_working[2]}"
|
||||
if [[ -n ${a_hdd_working[2]} ]];then
|
||||
hdd_name_temp=${a_hdd_working[2]}
|
||||
else
|
||||
hdd_name_temp='N/A'
|
||||
fi
|
||||
hdd_name="${C1}model$SEP3${C2} $hdd_name_temp"
|
||||
hdd_string="$usb_data$dev_data$hdd_name$size_data$hdd_serial$hdd_temp_data"
|
||||
hdd_model="${hdd_model}${C1}$(($i+1)):${C2} $hdd_string "
|
||||
# printing line one, then new lines according to $divisor setting, and after, if leftovers, print that line.
|
||||
|
|
Loading…
Reference in a new issue