Fix cache handling, it must work as the original implementation
This commit is contained in:
parent
f344c2ca77
commit
b302f21ed9
72
src/_port
72
src/_port
|
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
# global variable
|
# global variable
|
||||||
#_port_available_packages
|
#_port_available_packages
|
||||||
|
#_port_installed_packages
|
||||||
|
|
||||||
_port() {
|
_port() {
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
|
|
@ -89,6 +90,9 @@ _port() {
|
||||||
'help' 'diagnose' 'migrate' 'outdated' 'platform' 'provides' 'reclaim' 'restore'
|
'help' 'diagnose' 'migrate' 'outdated' 'platform' 'provides' 'reclaim' 'restore'
|
||||||
'rev-upgrade' 'search' 'select' 'selfupdate' 'snapshot' 'sync' 'usage'
|
'rev-upgrade' 'search' 'select' 'selfupdate' 'snapshot' 'sync' 'usage'
|
||||||
)
|
)
|
||||||
|
local -a show_installed_package_commands=(
|
||||||
|
contents deactivate setrequested space unsetrequested uninstall
|
||||||
|
)
|
||||||
|
|
||||||
local -a options=()
|
local -a options=()
|
||||||
case $subcmd in
|
case $subcmd in
|
||||||
|
|
@ -301,13 +305,35 @@ _port() {
|
||||||
$options[@] \
|
$options[@] \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
else
|
else
|
||||||
_port_update_cache
|
local -a pseudo_port_names=(
|
||||||
|
all current active inactive actinact installed uninstalled outdated
|
||||||
|
obsolete requested unrequested leaves rleaves
|
||||||
|
)
|
||||||
|
|
||||||
|
local -a selectors=(
|
||||||
|
'variants:' 'variant:' 'description:' 'depends:'
|
||||||
|
'depends_lib:' 'depends_run:' 'depends_build:' 'depends_fetch:' 'depends_extract:'
|
||||||
|
'portdir:' 'homepage:' 'epoch:' 'platforms:' 'platform:' 'name:' 'long_description:'
|
||||||
|
'maintainers:' 'maintainer:' 'categories:' 'category:' 'version:' 'revision:' 'license:'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (( $show_installed_package_commands[(Ie)$subcmd] )); then
|
||||||
|
_port_update_cache "installed"
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
$options[@] \
|
$options[@] \
|
||||||
'1: :_port_names' \
|
'1: :_port_installed_ports' \
|
||||||
'*: :_port_options' \
|
'*: :_port_options' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
|
else
|
||||||
|
_port_update_cache "all"
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
$options[@] \
|
||||||
|
'1: :_port_available_ports' \
|
||||||
|
'*: :_port_options' \
|
||||||
|
&& ret=0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
@ -407,22 +433,18 @@ _port_options() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
(( $+functions[_port_names] )) ||
|
(( $+functions[_port_available_ports] )) ||
|
||||||
_port_names() {
|
_port_available_ports() {
|
||||||
local -a pseudo_port_names=(
|
|
||||||
all current active inactive actinact installed uninstalled outdated
|
|
||||||
obsolete requested unrequested leaves rleaves
|
|
||||||
)
|
|
||||||
|
|
||||||
local -a selectors=(
|
|
||||||
'variants:' 'variant:' 'description:' 'depends:'
|
|
||||||
'depends_lib:' 'depends_run:' 'depends_build:' 'depends_fetch:' 'depends_extract:'
|
|
||||||
'portdir:' 'homepage:' 'epoch:' 'platforms:' 'platform:' 'name:' 'long_description:'
|
|
||||||
'maintainers:' 'maintainer:' 'categories:' 'category:' 'version:' 'revision:' 'license:'
|
|
||||||
)
|
|
||||||
|
|
||||||
_alternative \
|
_alternative \
|
||||||
"ports:Available ports:($_port_available_packages)" \
|
'ports:Available ports:($_port_available_packages)' \
|
||||||
|
'pseudo-common:Common Pseudo-portnames:($pseudo_port_names)' \
|
||||||
|
'selectors:Pseudo portname selectors:($selectors)'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_port_installed_ports] )) ||
|
||||||
|
_port_installed_ports() {
|
||||||
|
_alternative \
|
||||||
|
"ports:Installed ports:($_port_installed_packages)" \
|
||||||
"pseudo-common:Common Pseudo-portnames:($pseudo_port_names)" \
|
"pseudo-common:Common Pseudo-portnames:($pseudo_port_names)" \
|
||||||
"selectors:Pseudo portname selectors:($selectors)"
|
"selectors:Pseudo portname selectors:($selectors)"
|
||||||
}
|
}
|
||||||
|
|
@ -448,6 +470,10 @@ _port_caching_policy() {
|
||||||
|
|
||||||
(( $+functions[_port_update_cache] )) ||
|
(( $+functions[_port_update_cache] )) ||
|
||||||
_port_update_cache() {
|
_port_update_cache() {
|
||||||
|
local cache_type=$1
|
||||||
|
|
||||||
|
case "$cache_type" in
|
||||||
|
(all)
|
||||||
# Cache the list of all ports.
|
# Cache the list of all ports.
|
||||||
if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) &&
|
if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) &&
|
||||||
! _retrieve_cache PORT_AVAILABLE_PACKAGES;
|
! _retrieve_cache PORT_AVAILABLE_PACKAGES;
|
||||||
|
|
@ -455,6 +481,16 @@ _port_update_cache() {
|
||||||
_port_available_packages=( $(_call_program path-all "port -q echo all") )
|
_port_available_packages=( $(_call_program path-all "port -q echo all") )
|
||||||
_store_cache PORT_AVAILABLE_PACKAGES _port_available_packages
|
_store_cache PORT_AVAILABLE_PACKAGES _port_available_packages
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
(installed)
|
||||||
|
if ( [[ ${+_port_installed_packages} -eq 0 ]] || _cache_invalid PORT_INSTALLED_PACKAGES ) &&
|
||||||
|
! _retrieve_cache PORT_INSTALLED_PACKAGES;
|
||||||
|
then
|
||||||
|
_port_installed_packages=( $(_call_program path-all "port -q echo installed") )
|
||||||
|
_store_cache PORT_INSTALLED_PACKAGES _port_installed_packages
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
(( $+functions[_port_select_groups] )) ||
|
(( $+functions[_port_select_groups] )) ||
|
||||||
|
|
@ -489,8 +525,10 @@ _port_variants() {
|
||||||
local name=$1
|
local name=$1
|
||||||
if (( $+commands[perl] )); then
|
if (( $+commands[perl] )); then
|
||||||
local -a variants=($(port variants $name | perl -wln -e 'm{^(?:\s+|\[\+\])([^:]+):} and print $1'))
|
local -a variants=($(port variants $name | perl -wln -e 'm{^(?:\s+|\[\+\])([^:]+):} and print $1'))
|
||||||
|
if [[ ${#variants} != 0 ]]; then
|
||||||
_values 'variant' $variants
|
_values 'variant' $variants
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
(( $+functions[_port_units] )) ||
|
(( $+functions[_port_units] )) ||
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue