2011-09-25 17:26:04 +00:00
|
|
|
#compdef port
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Description
|
|
|
|
# -----------
|
|
|
|
#
|
|
|
|
# Completion script for MacPorts (http://www.macports.org).
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Authors
|
|
|
|
# -------
|
|
|
|
#
|
|
|
|
# * Matt Cable <wozz@wookie.net>
|
|
|
|
# * Sorin Ionescu <sorin.ionescu@gmail.com>
|
2013-03-20 07:22:38 +00:00
|
|
|
# * Aljaž Srebrnič <a2piratesoft@gmail.com>
|
2011-09-25 17:26:04 +00:00
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2013-03-20 07:22:38 +00:00
|
|
|
_port() {
|
|
|
|
# Variables for _argument
|
|
|
|
typeset -A opt_args
|
|
|
|
local context state state_descr line
|
2011-09-25 17:26:04 +00:00
|
|
|
|
2014-02-19 09:46:53 +00:00
|
|
|
local -a upgrade_options revupgrade_options select_options \
|
2014-02-19 09:46:10 +00:00
|
|
|
actions pseudo_common pseudo_advanced port_prefix
|
2011-09-25 17:26:04 +00:00
|
|
|
|
2013-03-20 07:22:38 +00:00
|
|
|
port_prefix=$(which port | sed 's|/bin/port||')
|
2011-09-25 17:26:04 +00:00
|
|
|
|
2014-02-19 07:55:29 +00:00
|
|
|
actions=( activate archive archivefetch build cat cd
|
|
|
|
checksum clean configure contents deactivate dependents deps
|
|
|
|
destroot dir distcheck distfiles dmg dpkg echo edit exit
|
|
|
|
extract fetch file gohome help info install installed lint list
|
|
|
|
livecheck load location log logfile mdmg mirror mpkg notes
|
|
|
|
outdated patch pkg platform portpkg provides quit rdependents
|
|
|
|
rdeps rev-upgrade rpm search select selfupdate setrequested space
|
|
|
|
srpm submit sync test unarchive uninstall unload unsetrequested
|
|
|
|
upgrade url usage variants version work )
|
2012-06-10 00:39:41 +00:00
|
|
|
|
2013-03-20 07:22:38 +00:00
|
|
|
pseudo_common=(all current active inactive actinact installed uninstalled outdated
|
|
|
|
obsolete requested unrequested leaves)
|
|
|
|
|
|
|
|
pseudo_advanced=('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:')
|
|
|
|
|
|
|
|
select_options=(
|
|
|
|
'--list:List available versions for the group'
|
|
|
|
'--set:Select the given version for the group'
|
2013-03-31 21:29:55 +00:00
|
|
|
'--show:Show which version is currently selected for the group (default if none given)'
|
2013-03-20 07:22:38 +00:00
|
|
|
)
|
|
|
|
|
2013-04-02 19:56:07 +00:00
|
|
|
revupgrade_options=('--id-loadcmd-check:Run more checks against a special loadcommand in Mach-O binaries')
|
|
|
|
|
2014-02-19 09:46:53 +00:00
|
|
|
upgrade_options=(
|
|
|
|
'--force\:Ignore\ circumstances\ that\ would\ normally\ cause\ ports\ to\ be\ skipped\ \(e.g.\ not\ outdated\).' \
|
|
|
|
'--enforce-variants\:If\ the\ installed\ variants\ do\ not\ match\ those\ requested,\ upgrade\ even\ if\ the\ port\ is\ not\ outdated.' \
|
|
|
|
'--no-replace\:Do\ not\ replace\ one\ port\ with\ another\ according\ to\ the\ replaced_by\ field.' \
|
|
|
|
)
|
|
|
|
|
2013-03-31 21:29:55 +00:00
|
|
|
local cache_policy
|
|
|
|
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
|
|
|
|
if [[ -z "$cache_policy" ]]; then
|
|
|
|
zstyle ":completion:${curcontext}:" cache-policy _port_caching_policy
|
|
|
|
fi
|
|
|
|
|
2013-03-20 07:22:38 +00:00
|
|
|
_arguments -s -C \
|
2014-02-19 07:52:04 +00:00
|
|
|
'-v[Verbose mode (generate verbose messages)]' \
|
|
|
|
'-d[Debug mode (generate debugging messages, implies -v)]' \
|
|
|
|
'-q[Quiet mode (suppress messages)]' \
|
|
|
|
"-n[Don't upgrade dependencies (affects upgrade and install)]" \
|
|
|
|
"-R[Also upgrade dependents (only affects upgrade) - note that this does not upgrade dependents' dependencies]" \
|
|
|
|
'-u[Uninstall non-active ports when upgrading and uninstalling]' \
|
|
|
|
'-f[Force mode (ignore state file)]' \
|
|
|
|
'-o[Honor state files even if the Portfile has been modified since (called -o because it used to mean "older")]' \
|
|
|
|
'-s[Source-only mode (build and install from source, do not attempt to fetch binary archives)]' \
|
|
|
|
'-b[Binary-only mode (build and install from binary archives, ignore source, abort if no archive available)]' \
|
|
|
|
'-c[Autoclean mode (execute clean after install)]' \
|
|
|
|
"-k[Keep mode (don't autoclean after install)]" \
|
|
|
|
'-D[Specify portdir]' \
|
2013-03-20 07:22:38 +00:00
|
|
|
'-F[Read and process the file of commands specified by the argument.]' \
|
|
|
|
'-p[Despite any errors encountered, proceed to process multiple ports and commands.]' \
|
|
|
|
'-y[Perform a dry run.]' \
|
2014-02-19 07:52:04 +00:00
|
|
|
'-t[Enable trace mode debug facilities on platforms that support it (Mac OS X).]' \
|
2013-03-20 07:22:38 +00:00
|
|
|
"1:Port actions:($actions)" \
|
2013-04-02 19:41:40 +00:00
|
|
|
'*:extra:->extra' \
|
2013-03-20 07:22:38 +00:00
|
|
|
&& return 0
|
2013-04-02 19:41:40 +00:00
|
|
|
|
|
|
|
case "$state" in
|
|
|
|
extra)
|
|
|
|
_port_dispatch
|
|
|
|
;;
|
|
|
|
esac
|
2013-03-31 21:29:55 +00:00
|
|
|
}
|
2013-03-20 07:22:38 +00:00
|
|
|
|
2013-03-31 21:29:55 +00:00
|
|
|
_port_dispatch() {
|
|
|
|
case "$words[2]" in
|
|
|
|
provides)
|
|
|
|
_files
|
|
|
|
;;
|
|
|
|
search)
|
|
|
|
_message 'pattern'
|
|
|
|
;;
|
|
|
|
help)
|
|
|
|
_describe -t actions 'Port actions' actions
|
|
|
|
;;
|
|
|
|
select)
|
|
|
|
_call_function - _port_select
|
|
|
|
;;
|
|
|
|
contents|deactivate|setrequested|space|uninstall|unsetrequested)
|
|
|
|
# Cache the list of installed ports.
|
|
|
|
if ( [[ ${+_port_installed_packages} -eq 0 ]] || _cache_invalid PORT_INSTALLED_PACKAGES ) &&
|
|
|
|
! _retrieve_cache PORT_INSTALLED_PACKAGES;
|
|
|
|
then
|
2014-02-19 07:52:04 +00:00
|
|
|
_port_installed_packages=( $(_call_program path-all "port echo installed | cut -d ' ' -f 1") )
|
2013-03-31 21:29:55 +00:00
|
|
|
_store_cache PORT_INSTALLED_PACKAGES _port_installed_packages
|
|
|
|
fi
|
|
|
|
_alternative \
|
|
|
|
"ports:Installed ports:($_port_installed_packages)" \
|
|
|
|
"pseudo-common:Common Pseudo-portnames:($pseudo_common)" \
|
|
|
|
"pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)"
|
|
|
|
;;
|
|
|
|
upgrade)
|
2014-02-19 09:46:53 +00:00
|
|
|
# No good reason to actually cache outdated ports list
|
2013-03-31 21:29:55 +00:00
|
|
|
local outdated_packages
|
2014-02-19 09:46:53 +00:00
|
|
|
outdated_packages=( $(_call_program path-outdated "port echo outdated | cut -d ' ' -f 1") )
|
|
|
|
_alternative -- \
|
|
|
|
"upgrade-options:Upgrade options:(($upgrade_options))" \
|
|
|
|
"ports:Outdated ports:($outdated_packages)" \
|
|
|
|
"pseudo-common:Common Pseudo-portnames:($pseudo_common)" \
|
|
|
|
"pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)"
|
2013-03-31 21:29:55 +00:00
|
|
|
;;
|
2013-04-02 19:56:07 +00:00
|
|
|
rev-upgrade)
|
|
|
|
if (( CURRENT == 3 )); then
|
|
|
|
_describe 'Rev-upgrade options' revupgrade_options
|
|
|
|
fi
|
|
|
|
;;
|
2013-03-31 21:29:55 +00:00
|
|
|
*)
|
|
|
|
# Cache the list of all ports.
|
|
|
|
if ( [[ ${+_port_available_packages} -eq 0 ]] || _cache_invalid PORT_AVAILABLE_PACKAGES ) &&
|
|
|
|
! _retrieve_cache PORT_AVAILABLE_PACKAGES;
|
|
|
|
then
|
|
|
|
_port_available_packages=( $(_call_program path-all "port echo all") )
|
|
|
|
_store_cache PORT_AVAILABLE_PACKAGES _port_available_packages
|
|
|
|
fi
|
|
|
|
_alternative \
|
|
|
|
"ports:Available ports:($_port_available_packages)" \
|
|
|
|
"pseudo-common:Common Pseudo-portnames:($pseudo_common)" \
|
|
|
|
"pseudo-advanced:Advanced Pseudo-portnames:($pseudo_advanced)"
|
2013-03-20 07:22:38 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2013-03-24 21:26:32 +00:00
|
|
|
_port_select() {
|
|
|
|
if (( CURRENT == 3 )); then
|
|
|
|
_describe 'Port select options' select_options
|
|
|
|
elif (( CURRENT == 4 )); then
|
|
|
|
local select_group
|
|
|
|
select_group=()
|
|
|
|
for f in $port_prefix/etc/select/*; do
|
|
|
|
select_group+=$(basename $f)
|
|
|
|
done
|
|
|
|
_describe "Port select groups" select_group
|
|
|
|
elif [[ $CURRENT -eq 5 && $words[3] == '--set' ]]; then
|
|
|
|
local select_variants
|
|
|
|
select_variants=("${(f)$(port select --list $words[4] | sed -e '1 d' -e 's/^[ \t]*//' -e 's/ (active)$//')}")
|
|
|
|
_describe "Port select group $words[4] variants" select_variants
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-03-24 21:31:08 +00:00
|
|
|
_port_caching_policy() {
|
|
|
|
local reg_time comp_time
|
|
|
|
reg_time=$(stat -c '%Z' $port_prefix/var/macports/registry/registry.db)
|
|
|
|
comp_time=$(stat -c '%Z' $1)
|
|
|
|
return $(( reg_time < comp_time ))
|
|
|
|
}
|
|
|
|
|
2013-03-20 07:22:38 +00:00
|
|
|
_port "$@"
|