Cleanup _portmaster
[zfbsd.git] / _portmaster
blobe9780d89af56f846b81225da00698a5d0ab89dad
1 #compdef portmaster
3 _portmaster_pkgs() {
4   compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(/:t)
7 _portmaster_ports() {
8   local ret=1 _fbsd_ports _fbsd_cat
9    _fbsd_cat=(${PORTSDIR:-/usr/ports}/[a-z]*(/:t))
10    if [[ $PREFIX != */* ]] ; then
11      _wanted cat_packages expl 'category/ports' compadd -S '/' $_fbsd_cat
12    else
13      compset -P '*/'
14      _fbsd_ports=(${PORTSDIR:-/usr/ports}/$IPREFIX/*(/:t))
15      _wanted cat_packages expl 'category/ports' compadd $_fbsd_ports
16    fi
17   return ret
20 _portmaster_pkgs_and_ports() {
21   local ret=1
22   _portmaster_pkgs && ret=0
23   _portmaster_ports && ret=0
25   return ret
28 _portmaster() {
29   local specific_args common_args expunge_args standalone_args kid
30   standalone_args=(
31   '--clean-distfiles[delete distfiles not associated with an installed ports: interactive]'
32   '--clean-distfiles-all[delete distfiles not associated with an installed ports]'
33   '--check-depends[cross-check and update dependency information for all ports]'
34   '--check-port-dbdir[check for stale entries in /var/db/ports]'
35   '-l[list all installed ports by category]'
36   '-L[list all installed ports by category, and search for updates]'
37   {'(-help)-h','(-h)--help'}'[display help message]:'
38     '--version[display the version only]:'
39     )
40     specific_args=(
41     '(-s -r -o)-e[expunge port using pkg_delete, and remove all distfiles]:name of port:_portmaster_pkgs'
42     '(-e -r -o)-s[clean out stale ports that used to be depended on]'
43     '(-e -s -o)-r[rebuild the specified port, and all ports that depend on it]:name/glob of port:_portmaster_pkgs'
44     '(-e -s -r)-o[replace the installed port with a port from a different origin]:new port dir:_portmaster_ports'
45     )
46     expunge_args=(
47     '(-b)-B[prevents creation of the backup package for the installed port]'
48     '(-d)-D[no cleaning of distfiles]'
49     '(-D)-d[always clean distfiles]'
50     )
51     common_args=(
52     "(-G)--force-config[run 'make config' for all ports]" 
53     "-C[prevents 'make clean' from being run before building]"
54     '-H[hide details of the port build and install in a log file]'
55     "-K[prevents 'make clean' from being run after building]"
56     '(-B)-b[create and keep a backup package of an installed port]'
57     '-g[create a package of the new port]'
58     '-n[run through configure, but do not make or install any ports]'
59     '-t[recurse dependencies thoroughly, using all-depends-list]'
60     '-v[verbose output]'
61     '-w[save old shared libraries before deinstall]'
62     '-u[unattended mode]'
63     '(-i)-f[always rebuild ports]'
64     '(-f)-i[interactive update mode]'
65     '-m[any arguments to supply to make]:arguments for make:'
66     '-x[avoid building or updating ports that match this pattern]:glob pattern to exclude from building:'
67     '-p[specify the full path to a port directory]:a port directory:'
68     '--show-work[show what dependent ports are, and are not installed]'
69     '-R[restart an update, skipping ports already up to date]' 
70     '-a[check all ports, update as necessary]'
71     '-F[fetch distfiles only]'
72     $expunge_args
73     $specific_args
74     )
75     if (( CURRENT == 2 ));then
76       _arguments -s \
77       $standalone_args \
78       $common_args \
79       '*:Packages and Ports:_portmaster_pkgs_and_ports'
80     else 
81       case "$words[2]" in
82         --clean-distfiles|--clean-distfiles-all|--check-depends|--check-port-dbdir|--version|-help|-h)
83         return 0
84         ;;
85         *)
86         if (( $words[(I)-(e|r)] ));then
87           _arguments -s \
88           '*:Packages:_portmaster_pkgs'
89         elif (( kid=$words[(I)-o] ));then
90           if (( CURRENT == $kid + 1 ));then
91             _arguments -s \
92             '*:Ports replacing:_portmaster_ports'
93           elif (( CURRENT == $kid + 2 )); then
94             _arguments -s \
95             '*:Package to replace:_portmaster_pkgs'
96           else 
97             return 0
98           fi
99         elif (( $words[(I)-s] ));then
100           return 0
101         else
102           _arguments -s \
103           $common_args \
104           '*:Packages and Ports:_portmaster_pkgs_and_ports'
105         fi
106         ;;
107       esac
108     fi
109   }
111   _portmaster "$@"