Split rpm-related completions to contrib/rpm
This commit is contained in:
parent
477f3cbae9
commit
34d7032b12
1
CHANGES
1
CHANGES
@ -25,6 +25,7 @@ bash-completion (1.x)
|
|||||||
* Split apt_build completion to contrib/apt-build
|
* Split apt_build completion to contrib/apt-build
|
||||||
* Split aptitude-related completions to contrib/aptitude
|
* Split aptitude-related completions to contrib/aptitude
|
||||||
* Split apt-cache and apt-get completions to contrib/apt
|
* Split apt-cache and apt-get completions to contrib/apt
|
||||||
|
* Split rpm-related completions to contrib/rpm
|
||||||
|
|
||||||
[ Ville Skyttä ]
|
[ Ville Skyttä ]
|
||||||
* Split yum and yum-arch completion into contrib/yum.
|
* Split yum and yum-arch completion into contrib/yum.
|
||||||
|
@ -94,6 +94,7 @@ bashcomp_DATA = contrib/ant \
|
|||||||
contrib/ri \
|
contrib/ri \
|
||||||
contrib/rcs \
|
contrib/rcs \
|
||||||
contrib/rpcdebug \
|
contrib/rpcdebug \
|
||||||
|
contrib/rpm \
|
||||||
contrib/rpmcheck \
|
contrib/rpmcheck \
|
||||||
contrib/rrdtool \
|
contrib/rrdtool \
|
||||||
contrib/rsync \
|
contrib/rsync \
|
||||||
|
299
bash_completion
299
bash_completion
@ -1497,305 +1497,6 @@ _cvs()
|
|||||||
complete -F _cvs $default cvs
|
complete -F _cvs $default cvs
|
||||||
}
|
}
|
||||||
|
|
||||||
have rpm && {
|
|
||||||
# helper functions for rpm completion
|
|
||||||
#
|
|
||||||
_rpm_installed_packages()
|
|
||||||
{
|
|
||||||
local ver nodig="$1" nosig="$2"
|
|
||||||
|
|
||||||
if [ -r /var/log/rpmpkgs -a \
|
|
||||||
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
|
|
||||||
# using RHL 7.2 or later - this is quicker than querying the DB
|
|
||||||
COMPREPLY=( $( sed -ne \
|
|
||||||
's|^\('$cur'[^[:space:]]*\)-[^[:space:]-]\+-[^[:space:]-]\+\.rpm$|\1|p' \
|
|
||||||
/var/log/rpmpkgs ) )
|
|
||||||
else
|
|
||||||
_rpm_nodigsig
|
|
||||||
COMPREPLY=( $( rpm -qa $nodig $nosig --qf='%{NAME} ' "$cur*" ) )
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
_rpm_groups()
|
|
||||||
{
|
|
||||||
local IFS=$'\t'
|
|
||||||
# remove trailing backslash, or grep will complain
|
|
||||||
cur=${cur%"\\"}
|
|
||||||
COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
|
|
||||||
grep "^$cur" ) )
|
|
||||||
# backslash escape spaces and translate newlines to tabs
|
|
||||||
COMPREPLY=( $( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ) )
|
|
||||||
}
|
|
||||||
|
|
||||||
_rpm_nodigsig()
|
|
||||||
{
|
|
||||||
if [ -z "$nodig" -a -z "$nosig" ]; then
|
|
||||||
local rpmver
|
|
||||||
|
|
||||||
rpmver=$(rpm --version)
|
|
||||||
rpmver=${rpmver##* }
|
|
||||||
|
|
||||||
if [[ "$rpmver" > "4.0.4" ]]; then
|
|
||||||
nodig="--nodigest"
|
|
||||||
fi
|
|
||||||
if [[ "$rpmver" > "4.0.99" ]]; then
|
|
||||||
nosig="--nosignature"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# rpm(8) completion
|
|
||||||
#
|
|
||||||
_rpm()
|
|
||||||
{
|
|
||||||
local cur prev nodig nosig
|
|
||||||
|
|
||||||
COMPREPLY=()
|
|
||||||
cur=`_get_cword`
|
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
||||||
nodig=""
|
|
||||||
nosig=""
|
|
||||||
_rpm_nodigsig
|
|
||||||
|
|
||||||
if [ $COMP_CWORD -eq 1 ]; then
|
|
||||||
# first parameter on line
|
|
||||||
case "$cur" in
|
|
||||||
-b*)
|
|
||||||
COMPREPLY=( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs'\
|
|
||||||
-- $cur ) )
|
|
||||||
;;
|
|
||||||
-t*)
|
|
||||||
COMPREPLY=( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts'\
|
|
||||||
-- $cur ) )
|
|
||||||
;;
|
|
||||||
--*)
|
|
||||||
COMPREPLY=( $( compgen -W '--help --version --initdb \
|
|
||||||
--checksig --recompile --rebuild --resign --addsign \
|
|
||||||
--rebuilddb --showrc --setperms --setugids --tarbuild \
|
|
||||||
--eval --install --upgrade --query --freshen --erase \
|
|
||||||
--verify --querytags --rmsource --rmspec --clean \
|
|
||||||
--import' -- $cur ) )
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
COMPREPLY=( $( compgen -W '-b -e -E -F -i -q -t -U -V' \
|
|
||||||
-- $cur ) )
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$prev" in
|
|
||||||
--@(@(db|exclude)path|prefix|relocate|root))
|
|
||||||
_filedir -d
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
--eval|-E)
|
|
||||||
# get a list of macros
|
|
||||||
COMPREPLY=( $( rpm --showrc | sed -ne \
|
|
||||||
's/^-\?[0-9]\+[:=][[:space:]]\+\('${cur#%}'[^[:space:](]*\).*/\1/p' ) )
|
|
||||||
COMPREPLY=( "${COMPREPLY[@]/#/%}" )
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
--pipe)
|
|
||||||
COMPREPLY=( $( compgen -c -- $cur ) )
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
--rcfile)
|
|
||||||
_filedir
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
--specfile)
|
|
||||||
# complete on .spec files
|
|
||||||
_filedir spec
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
--whatprovides)
|
|
||||||
if [[ "$cur" == */* ]]; then
|
|
||||||
_filedir
|
|
||||||
else
|
|
||||||
# complete on capabilities
|
|
||||||
local IFS=$'\n'
|
|
||||||
COMPREPLY=( $( compgen -W "$( rpm -qa $nodig $nosig \
|
|
||||||
--queryformat='%{providename}\n' )" \
|
|
||||||
-- $cur ) )
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
--whatrequires)
|
|
||||||
if [[ "$cur" == */* ]]; then
|
|
||||||
_filedir
|
|
||||||
else
|
|
||||||
# complete on capabilities
|
|
||||||
local IFS=$'\n'
|
|
||||||
COMPREPLY=( $( compgen -W "$( rpm -qa $nodig $nosig \
|
|
||||||
--queryformat='%{requirename}\n' )" \
|
|
||||||
-- $cur ) )
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
--target)
|
|
||||||
COMPREPLY=( $( compgen -W "$( command rpm --showrc | sed -ne \
|
|
||||||
's/^\s*compatible\s\+build\s\+archs\s*:\s*\(.*\)/\1/ p' )" -- $cur ) )
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "${COMP_WORDS[1]}" in
|
|
||||||
-@([iFU]*|-install|-freshen|-upgrade))
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--percent --force --test \
|
|
||||||
--replacepkgs --replacefiles --root --excludedocs \
|
|
||||||
--includedocs --noscripts --rcfile --ignorearch \
|
|
||||||
--dbpath --prefix --ignoreos --nodeps --allfiles \
|
|
||||||
--ftpproxy --ftpport --justdb --httpproxy --httpport \
|
|
||||||
--noorder --relocate --badreloc --notriggers \
|
|
||||||
--excludepath --ignoresize --oldpackage --define \
|
|
||||||
--eval --pipe --queryformat --repackage --nosuggests \
|
|
||||||
--nodigest --nosignature' -- $cur ) )
|
|
||||||
else
|
|
||||||
_filedir 'rpm'
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
-@(e|-erase))
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--allmatches --noscripts \
|
|
||||||
--notriggers --nodeps --test --repackage' -- $cur ) )
|
|
||||||
else
|
|
||||||
_rpm_installed_packages "$nodig" "$nosig"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
-@(q*|-query))
|
|
||||||
# check whether we're doing file completion
|
|
||||||
if [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--scripts --root \
|
|
||||||
--rcfile --requires --ftpport --ftpproxy \
|
|
||||||
--httpproxy --httpport --provides --triggers \
|
|
||||||
--dump --changelog --dbpath \
|
|
||||||
--last --filesbypkg \
|
|
||||||
--info --list --state \
|
|
||||||
--docfiles --configfiles --queryformat \
|
|
||||||
--conflicts --obsoletes \
|
|
||||||
--nodigest --nosignature \
|
|
||||||
--suggests --enhances \
|
|
||||||
--triggerscripts' -- $cur ) )
|
|
||||||
else
|
|
||||||
_filedir
|
|
||||||
fi
|
|
||||||
elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
|
|
||||||
_rpm_groups
|
|
||||||
elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
|
|
||||||
# uninstalled package completion
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--scripts --root \
|
|
||||||
--rcfile --whatprovides --whatrequires \
|
|
||||||
--requires --triggeredby --ftpport --ftpproxy \
|
|
||||||
--httpproxy --httpport --provides --triggers \
|
|
||||||
--dump --changelog --dbpath --filesbypkg \
|
|
||||||
--define --eval --pipe --showrc --info --list \
|
|
||||||
--state --docfiles --configfiles --queryformat\
|
|
||||||
--conflicts --obsoletes --nodigest \
|
|
||||||
--nosignature' -- $cur ) )
|
|
||||||
else
|
|
||||||
_filedir 'rpm'
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# installed package completion
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--scripts --root \
|
|
||||||
--rcfile --whatprovides --whatrequires \
|
|
||||||
--requires --triggeredby --ftpport --ftpproxy \
|
|
||||||
--httpproxy --httpport --provides --triggers \
|
|
||||||
--dump --changelog --dbpath --specfile \
|
|
||||||
--querybynumber --last --filesbypkg --define \
|
|
||||||
--eval --pipe --showrc --info --list --state \
|
|
||||||
--docfiles --configfiles --queryformat \
|
|
||||||
--conflicts --obsoletes --pkgid --hdrid \
|
|
||||||
--fileid --tid --nodigest --nosignature \
|
|
||||||
--triggerscripts' -- $cur ) )
|
|
||||||
elif [ "${COMP_LINE#* -*([^ -])a}" == "$COMP_LINE" ]; then
|
|
||||||
_rpm_installed_packages "$nodig" "$nosig"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
-@(K*|-checksig))
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--nopgp --nogpg --nomd5 \
|
|
||||||
--nodigest --nosignature' -- $cur ) )
|
|
||||||
else
|
|
||||||
_filedir 'rpm'
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
-@([Vy]*|-verify))
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--root --rcfile --dbpath \
|
|
||||||
--nodeps --nogroup --nolinkto --nomode --nomtime \
|
|
||||||
--nordev --nouser --nofiles --noscripts --nomd5 \
|
|
||||||
--querytags --specfile --whatrequires --whatprovides \
|
|
||||||
--nodigest --nosignature' -- $cur ) )
|
|
||||||
# check whether we're doing file completion
|
|
||||||
elif [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
|
|
||||||
_filedir
|
|
||||||
elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
|
|
||||||
_rpm_groups
|
|
||||||
elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
|
|
||||||
_filedir 'rpm'
|
|
||||||
else
|
|
||||||
_rpm_installed_packages "$nodig" "$nosig"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
-[bt]*)
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--short-circuit --timecheck \
|
|
||||||
--clean --rmsource --rmspec --test --sign --buildroot \
|
|
||||||
--target --nobuild --nodeps --nodirtokens' -- $cur ) )
|
|
||||||
elif [[ ${COMP_WORDS[1]} == -b* ]]; then
|
|
||||||
_filedir 'spec'
|
|
||||||
else
|
|
||||||
_filedir '@(tgz|tar.@(gz|bz2|lzma))'
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--re@(build|compile))
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--nodeps --rmsource \
|
|
||||||
--rmspec --sign --nodirtokens --target' -- $cur ) )
|
|
||||||
else
|
|
||||||
_filedir '?(no)src.rpm'
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--tarbuild)
|
|
||||||
_filedir '@(tgz|tar.@(gz|bz2|lzma))'
|
|
||||||
;;
|
|
||||||
--@(re|add)sign)
|
|
||||||
_filedir 'rpm'
|
|
||||||
;;
|
|
||||||
--set@(perms|gids))
|
|
||||||
_rpm_installed_packages "$nodig" "$nosig"
|
|
||||||
;;
|
|
||||||
--@(clean|rms@(ource|pec)))
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--clean --rmsource \
|
|
||||||
--rmspec' -- $cur ) )
|
|
||||||
else
|
|
||||||
_filedir 'spec'
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--@(import|dbpath|root))
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W '--import --dbpath --root' \
|
|
||||||
-- $cur ) )
|
|
||||||
else
|
|
||||||
_filedir
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
complete -F _rpm $filenames rpm rpmbuild
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function provides simple user@host completion
|
# This function provides simple user@host completion
|
||||||
#
|
#
|
||||||
_user_at_host() {
|
_user_at_host() {
|
||||||
|
298
contrib/rpm
Normal file
298
contrib/rpm
Normal file
@ -0,0 +1,298 @@
|
|||||||
|
have rpm && {
|
||||||
|
# helper functions for rpm completion
|
||||||
|
#
|
||||||
|
_rpm_installed_packages()
|
||||||
|
{
|
||||||
|
local ver nodig="$1" nosig="$2"
|
||||||
|
|
||||||
|
if [ -r /var/log/rpmpkgs -a \
|
||||||
|
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
|
||||||
|
# using RHL 7.2 or later - this is quicker than querying the DB
|
||||||
|
COMPREPLY=( $( sed -ne \
|
||||||
|
's|^\('$cur'[^[:space:]]*\)-[^[:space:]-]\+-[^[:space:]-]\+\.rpm$|\1|p' \
|
||||||
|
/var/log/rpmpkgs ) )
|
||||||
|
else
|
||||||
|
_rpm_nodigsig
|
||||||
|
COMPREPLY=( $( rpm -qa $nodig $nosig --qf='%{NAME} ' "$cur*" ) )
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpm_groups()
|
||||||
|
{
|
||||||
|
local IFS=$'\t'
|
||||||
|
# remove trailing backslash, or grep will complain
|
||||||
|
cur=${cur%"\\"}
|
||||||
|
COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
|
||||||
|
grep "^$cur" ) )
|
||||||
|
# backslash escape spaces and translate newlines to tabs
|
||||||
|
COMPREPLY=( $( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ) )
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpm_nodigsig()
|
||||||
|
{
|
||||||
|
if [ -z "$nodig" -a -z "$nosig" ]; then
|
||||||
|
local rpmver
|
||||||
|
|
||||||
|
rpmver=$(rpm --version)
|
||||||
|
rpmver=${rpmver##* }
|
||||||
|
|
||||||
|
if [[ "$rpmver" > "4.0.4" ]]; then
|
||||||
|
nodig="--nodigest"
|
||||||
|
fi
|
||||||
|
if [[ "$rpmver" > "4.0.99" ]]; then
|
||||||
|
nosig="--nosignature"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# rpm(8) completion
|
||||||
|
#
|
||||||
|
_rpm()
|
||||||
|
{
|
||||||
|
local cur prev nodig nosig
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
cur=`_get_cword`
|
||||||
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
nodig=""
|
||||||
|
nosig=""
|
||||||
|
_rpm_nodigsig
|
||||||
|
|
||||||
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
|
# first parameter on line
|
||||||
|
case "$cur" in
|
||||||
|
-b*)
|
||||||
|
COMPREPLY=( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs'\
|
||||||
|
-- $cur ) )
|
||||||
|
;;
|
||||||
|
-t*)
|
||||||
|
COMPREPLY=( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts'\
|
||||||
|
-- $cur ) )
|
||||||
|
;;
|
||||||
|
--*)
|
||||||
|
COMPREPLY=( $( compgen -W '--help --version --initdb \
|
||||||
|
--checksig --recompile --rebuild --resign --addsign \
|
||||||
|
--rebuilddb --showrc --setperms --setugids --tarbuild \
|
||||||
|
--eval --install --upgrade --query --freshen --erase \
|
||||||
|
--verify --querytags --rmsource --rmspec --clean \
|
||||||
|
--import' -- $cur ) )
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=( $( compgen -W '-b -e -E -F -i -q -t -U -V' \
|
||||||
|
-- $cur ) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$prev" in
|
||||||
|
--@(@(db|exclude)path|prefix|relocate|root))
|
||||||
|
_filedir -d
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--eval|-E)
|
||||||
|
# get a list of macros
|
||||||
|
COMPREPLY=( $( rpm --showrc | sed -ne \
|
||||||
|
's/^-\?[0-9]\+[:=][[:space:]]\+\('${cur#%}'[^[:space:](]*\).*/\1/p' ) )
|
||||||
|
COMPREPLY=( "${COMPREPLY[@]/#/%}" )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--pipe)
|
||||||
|
COMPREPLY=( $( compgen -c -- $cur ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--rcfile)
|
||||||
|
_filedir
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--specfile)
|
||||||
|
# complete on .spec files
|
||||||
|
_filedir spec
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--whatprovides)
|
||||||
|
if [[ "$cur" == */* ]]; then
|
||||||
|
_filedir
|
||||||
|
else
|
||||||
|
# complete on capabilities
|
||||||
|
local IFS=$'\n'
|
||||||
|
COMPREPLY=( $( compgen -W "$( rpm -qa $nodig $nosig \
|
||||||
|
--queryformat='%{providename}\n' )" \
|
||||||
|
-- $cur ) )
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--whatrequires)
|
||||||
|
if [[ "$cur" == */* ]]; then
|
||||||
|
_filedir
|
||||||
|
else
|
||||||
|
# complete on capabilities
|
||||||
|
local IFS=$'\n'
|
||||||
|
COMPREPLY=( $( compgen -W "$( rpm -qa $nodig $nosig \
|
||||||
|
--queryformat='%{requirename}\n' )" \
|
||||||
|
-- $cur ) )
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--target)
|
||||||
|
COMPREPLY=( $( compgen -W "$( command rpm --showrc | sed -ne \
|
||||||
|
's/^\s*compatible\s\+build\s\+archs\s*:\s*\(.*\)/\1/ p' )" -- $cur ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "${COMP_WORDS[1]}" in
|
||||||
|
-@([iFU]*|-install|-freshen|-upgrade))
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--percent --force --test \
|
||||||
|
--replacepkgs --replacefiles --root --excludedocs \
|
||||||
|
--includedocs --noscripts --rcfile --ignorearch \
|
||||||
|
--dbpath --prefix --ignoreos --nodeps --allfiles \
|
||||||
|
--ftpproxy --ftpport --justdb --httpproxy --httpport \
|
||||||
|
--noorder --relocate --badreloc --notriggers \
|
||||||
|
--excludepath --ignoresize --oldpackage --define \
|
||||||
|
--eval --pipe --queryformat --repackage --nosuggests \
|
||||||
|
--nodigest --nosignature' -- $cur ) )
|
||||||
|
else
|
||||||
|
_filedir 'rpm'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-@(e|-erase))
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--allmatches --noscripts \
|
||||||
|
--notriggers --nodeps --test --repackage' -- $cur ) )
|
||||||
|
else
|
||||||
|
_rpm_installed_packages "$nodig" "$nosig"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-@(q*|-query))
|
||||||
|
# check whether we're doing file completion
|
||||||
|
if [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--scripts --root \
|
||||||
|
--rcfile --requires --ftpport --ftpproxy \
|
||||||
|
--httpproxy --httpport --provides --triggers \
|
||||||
|
--dump --changelog --dbpath \
|
||||||
|
--last --filesbypkg \
|
||||||
|
--info --list --state \
|
||||||
|
--docfiles --configfiles --queryformat \
|
||||||
|
--conflicts --obsoletes \
|
||||||
|
--nodigest --nosignature \
|
||||||
|
--suggests --enhances \
|
||||||
|
--triggerscripts' -- $cur ) )
|
||||||
|
else
|
||||||
|
_filedir
|
||||||
|
fi
|
||||||
|
elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
|
||||||
|
_rpm_groups
|
||||||
|
elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
|
||||||
|
# uninstalled package completion
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--scripts --root \
|
||||||
|
--rcfile --whatprovides --whatrequires \
|
||||||
|
--requires --triggeredby --ftpport --ftpproxy \
|
||||||
|
--httpproxy --httpport --provides --triggers \
|
||||||
|
--dump --changelog --dbpath --filesbypkg \
|
||||||
|
--define --eval --pipe --showrc --info --list \
|
||||||
|
--state --docfiles --configfiles --queryformat\
|
||||||
|
--conflicts --obsoletes --nodigest \
|
||||||
|
--nosignature' -- $cur ) )
|
||||||
|
else
|
||||||
|
_filedir 'rpm'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# installed package completion
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--scripts --root \
|
||||||
|
--rcfile --whatprovides --whatrequires \
|
||||||
|
--requires --triggeredby --ftpport --ftpproxy \
|
||||||
|
--httpproxy --httpport --provides --triggers \
|
||||||
|
--dump --changelog --dbpath --specfile \
|
||||||
|
--querybynumber --last --filesbypkg --define \
|
||||||
|
--eval --pipe --showrc --info --list --state \
|
||||||
|
--docfiles --configfiles --queryformat \
|
||||||
|
--conflicts --obsoletes --pkgid --hdrid \
|
||||||
|
--fileid --tid --nodigest --nosignature \
|
||||||
|
--triggerscripts' -- $cur ) )
|
||||||
|
elif [ "${COMP_LINE#* -*([^ -])a}" == "$COMP_LINE" ]; then
|
||||||
|
_rpm_installed_packages "$nodig" "$nosig"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-@(K*|-checksig))
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--nopgp --nogpg --nomd5 \
|
||||||
|
--nodigest --nosignature' -- $cur ) )
|
||||||
|
else
|
||||||
|
_filedir 'rpm'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-@([Vy]*|-verify))
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--root --rcfile --dbpath \
|
||||||
|
--nodeps --nogroup --nolinkto --nomode --nomtime \
|
||||||
|
--nordev --nouser --nofiles --noscripts --nomd5 \
|
||||||
|
--querytags --specfile --whatrequires --whatprovides \
|
||||||
|
--nodigest --nosignature' -- $cur ) )
|
||||||
|
# check whether we're doing file completion
|
||||||
|
elif [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
|
||||||
|
_filedir
|
||||||
|
elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
|
||||||
|
_rpm_groups
|
||||||
|
elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
|
||||||
|
_filedir 'rpm'
|
||||||
|
else
|
||||||
|
_rpm_installed_packages "$nodig" "$nosig"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-[bt]*)
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--short-circuit --timecheck \
|
||||||
|
--clean --rmsource --rmspec --test --sign --buildroot \
|
||||||
|
--target --nobuild --nodeps --nodirtokens' -- $cur ) )
|
||||||
|
elif [[ ${COMP_WORDS[1]} == -b* ]]; then
|
||||||
|
_filedir 'spec'
|
||||||
|
else
|
||||||
|
_filedir '@(tgz|tar.@(gz|bz2|lzma))'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
--re@(build|compile))
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--nodeps --rmsource \
|
||||||
|
--rmspec --sign --nodirtokens --target' -- $cur ) )
|
||||||
|
else
|
||||||
|
_filedir '?(no)src.rpm'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
--tarbuild)
|
||||||
|
_filedir '@(tgz|tar.@(gz|bz2|lzma))'
|
||||||
|
;;
|
||||||
|
--@(re|add)sign)
|
||||||
|
_filedir 'rpm'
|
||||||
|
;;
|
||||||
|
--set@(perms|gids))
|
||||||
|
_rpm_installed_packages "$nodig" "$nosig"
|
||||||
|
;;
|
||||||
|
--@(clean|rms@(ource|pec)))
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--clean --rmsource \
|
||||||
|
--rmspec' -- $cur ) )
|
||||||
|
else
|
||||||
|
_filedir 'spec'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
--@(import|dbpath|root))
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '--import --dbpath --root' \
|
||||||
|
-- $cur ) )
|
||||||
|
else
|
||||||
|
_filedir
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
complete -F _rpm $filenames rpm rpmbuild
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user