cleaning up detections, removing explicit package manager tests and instead simply show the presence of the repos.

this is mainly to cleanly handle cases where either apt or rpm systems may be running the other package manager.
This commit is contained in:
inxi-svn 2012-12-22 03:54:43 +00:00
parent a768fc0669
commit be56b3af55

53
inxi
View file

@ -3,7 +3,7 @@
#### Script Name: inxi #### Script Name: inxi
#### version: 1.8.24 #### version: 1.8.24
#### Date: December 6 2012 #### Date: December 6 2012
#### Patch Number: 05-b1 #### Patch Number: 06-b1
######################################################################## ########################################################################
#### 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=''
@ -6020,25 +6019,15 @@ get_repo_data()
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/'
## note: a fringe case was discovered where repo files were in /etc/apt/sources.list.d for yum # apt - debian, buntus, also sometimes some yum/rpm repos may create apt repos here as well
# so handling more explicitly the actual repo file id. Note that apt-get can be run in rpm distros
# using apt-rpm package
if [[ -n $( type -p apt-get ) ]];then
repo_type='apt'
elif [[ -n $( type -p yum ) ]];then
repo_type='yum'
elif [[ -n $( type -p pisi ) ]];then
repo_type='pisi'
elif [[ -n $( type -p pacman ) ]];then
repo_type='pacman'
fi
# apt - debian, buntus
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="$repo_type sources"
fi fi
# yum - fedora, redhat, centos, etc. Note that rpmforge for some odd reason places its yum repos # yum - fedora, redhat, centos, etc. Note that rpmforge also may create apt sources
# in /etc/apt/sources.list.d/ # 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 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 )
@ -6046,7 +6035,7 @@ get_repo_data()
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"
@ -6109,10 +6098,9 @@ $repo_data_working"
repo_data_working='' repo_data_working=''
fi fi
done done
REPO_FILE_ID="$repo_type repos" # pacman - archlinux, going to assume that pisi and arch/pacman don't have the above issue with apt/yum
# pacman - archlinux, going to assume that pisi and arch/pacman don't have the above issue
# pisi - pardus # pisi - pardus
elif [[ -d $pisi_dir && $repo_type == 'pisi' ]];then elif [[ -d $pisi_dir && -n $( type -p pisi ) ]];then
REPO_DATA="$( pisi list-repo )" REPO_DATA="$( pisi list-repo )"
# now we need to create the structure: repo info: repo path # now we need to create the structure: repo info: repo path
# we do that by looping through the lines of the output and then # we do that by looping through the lines of the output and then
@ -6128,14 +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="$repo_type repos"
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 '
@ -6162,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
@ -6171,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="$repo_type repo servers"
fi fi
eval $LOGFE eval $LOGFE
} }
@ -8573,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
@ -8582,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.
@ -8594,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'