new tarball, new version. This fixes a somewhat obscure issue where for example rpmforge adds apt repos, and also I assume

some apt rpm tools might do the same for yum repos. Now inxi will simply note the presence of each type, for apt and yum.

I didnt' do this feature for pacman and pisi, because I've never heard of that, but if necessary, I'll add it.

Now inxi will hopefully correctly note the presence of the various repos and list the files with the repo type correctly
noted for each type.

I also fixed a bug in the yum/rpm type repo detection, inxi failed to properly handle spaces around the = sign, which made
it falsely identify as enabled disabled repos, it tested for only ^enabled=1 whereas also ^enabled = 1 is a possible syntax.

This is now corrected.
This commit is contained in:
inxi-svn 2012-12-22 04:01:02 +00:00
parent 2642ac39c7
commit f2fbe65485

52
inxi
View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 1.8.24 #### version: 1.8.25
#### Date: December 6 2012 #### Date: December 21 2012
#### Patch Number: 00 #### Patch Number: 00
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
@ -191,7 +191,6 @@ LINE_MAX_IRC='105'
PS_COUNT=5 PS_COUNT=5
PS_THROTTLED='' PS_THROTTLED=''
REPO_DATA='' REPO_DATA=''
REPO_FILE_ID=''
### primary data array holders ## usage: 'A_<var>' ### primary data array holders ## usage: 'A_<var>'
A_ALSA_DATA='' A_ALSA_DATA=''
@ -6016,23 +6015,27 @@ get_raid_data()
get_repo_data() get_repo_data()
{ {
eval $LOGFS 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_type='unknown'
local apt_file='/etc/apt/sources.list' yum_repo_dir='/etc/yum.repos.d/' yum_conf='/etc/yum.conf' 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 pacman_conf='/etc/pacman.conf' pacman_repo_dir='/etc/pacman.d/' pisi_dir='/etc/pisi/'
# apt - debian, buntus # 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 if [[ -f $apt_file || -d $apt_file.d ]];then
REPO_DATA="$( grep -Esv '(^[[:space:]]*$|^[[:space:]]*#)' $apt_file $apt_file.d/*.list )" REPO_DATA="$( grep -Esv '(^[[:space:]]*$|^[[:space:]]*#)' $apt_file $apt_file.d/*.list | sed -r 's/^(.*)/apt sources:\1/' )"
REPO_FILE_ID='apt sources' fi
# yum - fedora, redhat, centos, etc # yum - fedora, redhat, centos, etc. Note that rpmforge also may create apt sources
elif [[ -d $yum_repo_dir || -f $yum_conf ]];then # in /etc/apt/sources.list.d/. Therefore rather than trying to assume what package manager is
# 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 # older redhats put their yum data in /etc/yum.conf
for repo_file in $( ls $yum_repo_dir*.repo $yum_conf 2>/dev/null ) for repo_file in $( ls $yum_repo_dir*.repo $yum_conf 2>/dev/null )
do do
repo_data_working="$( gawk -v repoFile=$repo_file ' repo_data_working="$( gawk -v repoFile=$repo_file '
# construct the string for the print function to work with, file name: data # construct the string for the print function to work with, file name: data
function print_line( fileName, repoId, repoUrl ){ function print_line( fileName, repoId, repoUrl ){
print fileName ":" repoId repoUrl print "yum repos:" fileName ":" repoId repoUrl
} }
BEGIN { BEGIN {
FS="\n" FS="\n"
@ -6057,17 +6060,18 @@ get_repo_data()
repoTitle = $1 " ~ " repoTitle = $1 " ~ "
} }
/^(mirrorlist|baseurl)/ { /^(mirrorlist|baseurl)/ {
sub( /(mirrorlist|baseurl)=/, "", $1 ) # strip out the field starter sub( /(mirrorlist|baseurl)[[:space:]]*=[[:space:]]*/, "", $1 ) # strip out the field starter
urlData = $1 urlData = $1
} }
/^enabled=/ { # note: enabled = 1. enabled = 0 means disabled
/^enabled[[:space:]]*=/ {
enabledStatus = $1 enabledStatus = $1
} }
# print out the line if all 3 values are found, otherwise if a new # 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 # repoTitle is hit above, it will print out the line there instead
{ {
if ( urlData != "" && enabledStatus != "" && repoTitle != "" ){ if ( urlData != "" && enabledStatus != "" && repoTitle != "" ){
if ( enabledStatus !~ /enabled=0/ ){ if ( enabledStatus !~ /enabled[[:space:]]*=[[:space:]]*0/ ){
print_line( repoFile, repoTitle, urlData ) print_line( repoFile, repoTitle, urlData )
} }
enabledStatus="" enabledStatus=""
@ -6094,7 +6098,7 @@ $repo_data_working"
repo_data_working='' repo_data_working=''
fi fi
done done
REPO_FILE_ID='yum repos' # pacman - archlinux, going to assume that pisi and arch/pacman don't have the above issue with apt/yum
# pisi - pardus # pisi - pardus
elif [[ -d $pisi_dir && -n $( type -p pisi ) ]];then elif [[ -d $pisi_dir && -n $( type -p pisi ) ]];then
REPO_DATA="$( pisi list-repo )" REPO_DATA="$( pisi list-repo )"
@ -6112,15 +6116,13 @@ $repo_data_working"
print $0 print $0
}' <<< $repo_line ) }' <<< $repo_line )
if [[ -n $( grep '://' <<< $repo_line ) ]];then if [[ -n $( grep '://' <<< $repo_line ) ]];then
repo_data_working="$repo_data_working:$repo_line\n" repo_data_working="pisi repos:$repo_data_working:$repo_line\n"
else else
repo_data_working="$repo_data_working$repo_line" repo_data_working="$repo_data_working$repo_line"
fi fi
done <<< "$REPO_DATA" done <<< "$REPO_DATA"
# echo and execute the line breaks inserted # echo and execute the line breaks inserted
REPO_DATA="$( echo -e $repo_data_working )" REPO_DATA="$( echo -e $repo_data_working )"
REPO_FILE_ID='pisi repo'
# pacman - archlinux
elif [[ -f $pacman_conf ]];then elif [[ -f $pacman_conf ]];then
# get list of mirror include files, trim white space off ends # get list of mirror include files, trim white space off ends
repo_data_working="$( gawk ' repo_data_working="$( gawk '
@ -6147,7 +6149,7 @@ $repo_data_working"
} }
/^[[:space:]]*Server/ { /^[[:space:]]*Server/ {
sub(/^[[:space:]]+|[[:space:]]+$/,"",$2) sub(/^[[:space:]]+|[[:space:]]+$/,"",$2)
print repoFile ":" $2 "\\n" print "pacman repo servers:" repoFile ":" $2 "\\n"
} }
' $repo_file )" ' $repo_file )"
else else
@ -6156,7 +6158,6 @@ $repo_data_working"
done done
# execute line breaks # execute line breaks
REPO_DATA="$( echo -e $repo_data_working2 )" REPO_DATA="$( echo -e $repo_data_working2 )"
REPO_FILE_ID='arch repo servers'
fi fi
eval $LOGFE eval $LOGFE
} }
@ -8558,7 +8559,7 @@ print_repo_data()
{ {
eval $LOGFS eval $LOGFS
local repo_count=0 repo_line='' file_name='' file_content='' file_name_holder='' local repo_count=0 repo_line='' file_name='' file_content='' file_name_holder=''
local repo_full='' b_print_next_line='false' local repo_full='' b_print_next_line='false' repo_type=''
get_repo_data get_repo_data
@ -8567,8 +8568,9 @@ print_repo_data()
while read repo_line while read repo_line
do do
(( repo_count++ )) (( repo_count++ ))
file_name=$( cut -d ':' -f 1 <<< $repo_line ) repo_type=$( cut -d ':' -f 1 <<< $repo_line )
file_content=$( cut -d ':' -f 2-6 <<< $repo_line ) file_name=$( cut -d ':' -f 2 <<< $repo_line )
file_content=$( cut -d ':' -f 3-7 <<< $repo_line )
# this will dump unwanted white space line starters. Some irc channels # this will dump unwanted white space line starters. Some irc channels
# use bots that show page title for urls, so need to break the url by adding # use bots that show page title for urls, so need to break the url by adding
# a white space. # a white space.
@ -8579,10 +8581,10 @@ print_repo_data()
fi fi
# check file name, if different, update the holder for print out # check file name, if different, update the holder for print out
if [[ $file_name != $file_name_holder ]];then if [[ $file_name != $file_name_holder ]];then
if [[ $REPO_FILE_ID != 'pisi repo' ]];then if [[ $repo_type != 'pisi repo' ]];then
repo_full="${C1}Active $REPO_FILE_ID in file:${C2} $file_name" repo_full="${C1}Active $repo_type in file:${C2} $file_name"
else else
repo_full="${C1}$REPO_FILE_ID:${C2} $file_name" repo_full="${C1}$repo_type:${C2} $file_name"
fi fi
file_name_holder=$file_name file_name_holder=$file_name
b_print_next_line='true' b_print_next_line='true'