2011-11-01 22:14:45 +02:00
|
|
|
# This function is required by _dpkg and _dpkg-reconfigure -*- shell-script -*-
|
2011-10-12 00:19:50 +03:00
|
|
|
|
|
|
|
_have grep-status && {
|
2009-06-05 21:39:46 +02:00
|
|
|
_comp_dpkg_installed_packages()
|
|
|
|
{
|
2009-10-04 19:42:50 +02:00
|
|
|
grep-status -P -e "^$1" -a -FStatus 'install ok installed' -n -s Package
|
2009-06-05 21:39:46 +02:00
|
|
|
}
|
|
|
|
} || {
|
|
|
|
_comp_dpkg_installed_packages()
|
2011-11-05 11:38:25 +01:00
|
|
|
{
|
|
|
|
command grep -A 1 "Package: $1" /var/lib/dpkg/status | \
|
|
|
|
command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
|
|
|
|
half-configured" \
|
|
|
|
-Ee "^Essential: yes" | \
|
|
|
|
command grep "Package: $1" | cut -d\ -f2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_have grep-status && {
|
|
|
|
_comp_dpkg_purgeable_packages()
|
|
|
|
{
|
2011-11-06 21:04:48 +01:00
|
|
|
grep-status -P -e "^$1" -a -FStatus 'install ok installed' -o -FStatus 'deinstall ok config-files' -n -s Package
|
2011-11-05 11:38:25 +01:00
|
|
|
}
|
|
|
|
} || {
|
|
|
|
_comp_dpkg_purgeable_packages()
|
2009-06-05 21:39:46 +02:00
|
|
|
{
|
2009-12-15 23:48:10 +02:00
|
|
|
command grep -A 1 "Package: $1" /var/lib/dpkg/status | \
|
|
|
|
command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
|
2009-10-04 19:42:50 +02:00
|
|
|
half-configured|config-files" \
|
|
|
|
-Ee "^Essential: yes" | \
|
2009-12-15 23:48:10 +02:00
|
|
|
command grep "Package: $1" | cut -d\ -f2
|
2009-06-05 21:39:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Debian dpkg(8) completion
|
|
|
|
#
|
|
|
|
_dpkg()
|
|
|
|
{
|
2011-05-01 22:18:40 +03:00
|
|
|
local cur prev words cword split
|
|
|
|
_init_completion -s || return
|
2009-06-05 21:39:46 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
_expand || return 0
|
2009-06-05 21:39:46 +02:00
|
|
|
|
2011-04-20 16:49:57 +03:00
|
|
|
local i=$cword
|
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
# find the last option flag
|
|
|
|
if [[ $cur != -* ]]; then
|
2011-02-10 23:55:16 +02:00
|
|
|
while [[ $prev != -* && $i -ne 1 ]]; do
|
2009-10-04 19:42:50 +02:00
|
|
|
i=$((i-1))
|
2011-04-20 16:49:57 +03:00
|
|
|
prev=${words[i-1]}
|
2009-10-04 19:42:50 +02:00
|
|
|
done
|
|
|
|
fi
|
2009-06-05 21:39:46 +02:00
|
|
|
|
2009-12-30 00:39:59 +01:00
|
|
|
case $prev in
|
2009-11-22 11:43:26 +01:00
|
|
|
-c|-i|-A|-I|-f|-e|-x|-X|-W|--install|--unpack|--record-avail| \
|
|
|
|
--contents|--info|--fsys-tarfile|--field|--control|--extract| \
|
|
|
|
--show)
|
2009-10-04 19:42:50 +02:00
|
|
|
_filedir '?(u)deb'
|
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-b|--build)
|
2009-10-04 19:42:50 +02:00
|
|
|
_filedir -d
|
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-s|-p|-l|--status|--print-avail|--list)
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( apt-cache pkgnames "$cur" 2>/dev/null ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-S|--search)
|
2009-10-04 19:42:50 +02:00
|
|
|
_filedir
|
|
|
|
return 0
|
|
|
|
;;
|
2011-11-05 11:38:25 +01:00
|
|
|
-r|--remove)
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2011-11-05 11:38:25 +01:00
|
|
|
-L|-P|--listfiles|--purge)
|
|
|
|
COMPREPLY=( $( _comp_dpkg_purgeable_packages "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2009-10-04 19:42:50 +02:00
|
|
|
esac
|
2009-06-05 21:39:46 +02:00
|
|
|
|
2011-05-02 11:41:52 +03:00
|
|
|
$split && return
|
2009-06-05 21:39:46 +02:00
|
|
|
|
2011-05-02 11:41:52 +03:00
|
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
2011-04-04 22:14:39 +03:00
|
|
|
} &&
|
2011-11-01 20:23:53 +01:00
|
|
|
complete -F _dpkg dpkg dpkg-deb dpkg-query
|
2009-06-05 21:39:46 +02:00
|
|
|
|
|
|
|
# Debian GNU dpkg-reconfigure(8) completion
|
|
|
|
#
|
|
|
|
_dpkg_reconfigure()
|
|
|
|
{
|
2011-04-20 16:49:57 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2009-06-05 21:39:46 +02:00
|
|
|
|
2011-04-20 16:49:57 +03:00
|
|
|
local opt
|
2009-06-05 21:39:46 +02:00
|
|
|
|
2009-12-30 00:39:59 +01:00
|
|
|
case $prev in
|
2009-11-22 11:43:26 +01:00
|
|
|
-f|--frontend)
|
2009-12-21 00:09:02 +02:00
|
|
|
opt=( $( printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/* ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
opt=( ${opt[@]##*/} )
|
|
|
|
opt=( ${opt[@]%.pm} )
|
|
|
|
COMPREPLY=( $( compgen -W '${opt[@]}' -- "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-p|--priority)
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -W 'low medium high critical' -- "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2009-06-05 21:39:46 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
if [[ "$cur" == -* ]]; then
|
2010-02-09 11:09:04 +01:00
|
|
|
COMPREPLY=( $(compgen -W '--frontend --priority --all --unseen-only \
|
|
|
|
--help --showold --force --terse' -- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
else
|
|
|
|
COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
|
|
|
|
fi
|
2009-06-05 21:39:46 +02:00
|
|
|
} &&
|
2009-10-22 12:04:29 +03:00
|
|
|
complete -F _dpkg_reconfigure -o default dpkg-reconfigure
|
2009-06-05 21:39:46 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|