blob: efd33f93baade886d3187759ce52ccf679c6bc05 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#autoload
# Usage: _deb_packages expl... avail|installed|uninstalled
_deb_packages_updage_avail () {
if (( ! $+_deb_packages_cache_uninstalled )); then
_deb_packages_cache_avail=(
${(f)"$(apt-cache dumpavail | awk '/^Package:/ { print $2 }')"}
)
fi
cachevar=_deb_packages_cache_avail
}
_deb_packages_updage_installed () {
if (( ! $+_deb_packages_cache_installed )); then
_deb_packages_cache_installed=(
${${${(f)"$(dpkg --get-selections)"}:#*deinstall}%% *}
)
fi
cachevar=_deb_packages_cache_installed
}
_deb_packages_updage_uninstalled () {
_deb_packages_updage_avail
_deb_packages_updage_installed
if (( ! $+_deb_packages_cache_uninstalled )); then
_deb_packages_cache_uninstalled=(
${_deb_packages_cache_avail:#${(j:|:)~${_deb_packages_cache_installed:q}}}
)
fi
cachevar=_deb_packages_cache_uninstalled
}
_deb_packages () {
local command="$argv[$#]" expl cachevar
[[ "$command" = (installed|uninstalled|avail) ]] || {
_message "_deb_packages:unknown command: $command"
return
}
expl=("${(@)argv[1,-2]}")
_deb_packages_updage_$command
_tags packages && compadd "$expl[@]" - "${(e):-"\${(@)$cachevar}"}"
}
_deb_packages "$@"
|