Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 58198
Collapse All | Expand All

(-)_portage-20040204 (-18 / +79 lines)
Lines 115-122 Link Here
115
    elif (( CURRENT > 2 ));then
115
    elif (( CURRENT > 2 ));then
116
        case "$words[2]" in
116
        case "$words[2]" in
117
	    unmerge|-C)
117
	    unmerge|-C)
118
		_arguments -s \
118
	 	  if compset -P '(\\|)[><][=]'; then
119
		    '*:installed pkgname with versions:_portage_unmerge' "$common_args[@]" && return 0
119
			_arguments -s \
120
		    	'*:installed pkgname with versions:_portage_unmerge_vers' "$common_args[@]" && return 0
121
		  elif compset -P '(\\|)[<=>]'; then
122
			_arguments -s \
123
		    	'*:installed pkgname with versions:_portage_unmerge_vers' "$common_args[@]" && return 0
124
		  else 
125
			_arguments -s \
126
		    	'*:installed pkgname:_portage_unmerge' "$common_args[@]" && return 0
127
		  fi
120
		;;
128
		;;
121
	    clean|-c)
129
	    clean|-c)
122
	    	_arguments -s \
130
	    	_arguments -s \
Lines 126-132 Link Here
126
		_arguments -s \
134
		_arguments -s \
127
		    '*:use package only:_portage_tbz2list' "$common_args[@]" && return 0
135
		    '*:use package only:_portage_tbz2list' "$common_args[@]" && return 0
128
		;;
136
		;;
129
	    depclean|help|-h|info|regen|sync|rsync|--searchdesc|-S|search|-s|inject|-j|prune|-P)
137
	    depclean|help|-h|info|regen|sync|rsync|--searchdesc|-S|search|-s|prune|-P)
138
		;;
139
	    --resume|--skipfirst)
140
	    	_arguments -s \
141
		 '--skipfirst[Removes the first package in the resume list]' \
142
		    "$common_args[@]"  && return 0
130
		;;
143
		;;
131
	    *)
144
	    *)
132
		_arguments -s \
145
		_arguments -s \
Lines 141-164 Link Here
141
        state=''
154
        state=''
142
        case "$lstate" in
155
        case "$lstate" in
143
	    actions)
156
	    actions)
157
		if compset -P '(\\|)[><][=]'; then
144
		_alternative \
158
		_alternative \
145
		    ':emerge actions:_actions' \
159
			'*:portage:_ebuild_cache'
146
		    '*:portage:_portage_pkglist'
160
161
		elif compset -P '(\\|)[<=>]'; then
162
		_alternative \
163
			'*:portage:_ebuild_cache'
164
				
165
		else 
166
		_alternative \
167
		':emerge actions:_actions' \
168
		     '*:portage:_portage_pkglist'
169
		fi
170
147
		;;
171
		;;
148
	    install_portage)
172
	    install_portage)
173
		if compset -P '(\\|)[><][=]'; then
149
		_alternative \
174
		_alternative \
150
		    '*:portage:_portage_pkglist'
175
			'*:portage:_ebuild_cache'
176
		elif compset -P '(\\|)[<=>]'; then
177
		_alternative \
178
			'*:portage:_ebuild_cache'
179
		else
180
		_alternative \
181
		     '*:portage:_portage_pkglist'
182
		fi
151
		;;
183
		;;
152
        esac
184
        esac
153
    done
185
    done
154
}
186
}
155
187
156
#Function to show only installed packages "cat/name-ver"
188
#Function to show only installed packages   -- pkgname (no category or version #)
157
_portage_unmerge(){
189
_portage_unmerge(){
158
    installed_portage=(/var/db/pkg/*-*/*)
190
    installed_portage=(/var/db/pkg/*-*/*)
159
    installed_dir=/var/db/pkg/
191
    installed_pkgname=${(M)${${installed_portage##*/}%%-[0-9]*}}
160
    installed_pkg=${installed_portage//$installed_dir/}
192
    _tags -s installed_pkgname && { compadd "$@" ${(kv)=installed_pkgname} }
161
    _tags -s installed_pkg && { compadd "$@" -k installed_pkg || compadd "$@" ${(kv)=installed_pkg} }
193
    _path_files -/ -W "/var/db/pkg/"
194
}
195
196
#Function to show only installed packages -- cat/name-ver
197
_portage_unmerge_vers(){
198
    installed_portage=(/var/db/pkg/*-*/*)
199
    installed_pkgname=${(M)${${installed_portage##*/}}}
200
    _tags -s installed_pkgname && {  compadd "$@" ${(kv)=installed_pkgname} }
201
    _path_files -/ -W "/var/db/pkg/"
162
}
202
}
163
203
164
#Functions to show "cat/name", classes and dependencies
204
#Functions to show "cat/name", classes and dependencies
Lines 188-196 Link Here
188
    #[[ -n "${portdir_overlay}" ]] && _path_files -/ -W "${portdir_overlay}"
228
    #[[ -n "${portdir_overlay}" ]] && _path_files -/ -W "${portdir_overlay}"
189
    _path_files -g \*.ebuild
229
    _path_files -g \*.ebuild
190
}
230
}
231
#Function for matching all ebuilds  pkg-ver (slow if asking for all packages)
232
_ebuild_cache(){
233
    if _cache_invalid portage_ebuilds || ! _retrieve_cache portage_ebuilds; then
234
235
    overlay_ebuilds=($portdir_overlay/*-*/*/*)
236
    overlay_list=${${(M)${overlay_ebuilds##*/}#*ebuild}%%.ebuild}
237
    metadata_ebuilds=($portdir/metadata/cache/*-*/*)
238
    metadata_list=${(M)${${metadata_ebuilds##*/}}}
239
240
	 _store_cache portage_ebuilds metadata_list overlay_list
241
    fi
242
    _tags -s metadata_list && {compadd "$@" ${(kv)=metadata_list} } 
243
    _tags -s overlay_list && {compadd "$@" ${(kv)=overlay_list} }
244
}
245
246
local update_policy
247
zstyle -s ":completion:*:*:emerge:*" cache-policy update_policy
248
if [[ -z "$update_policy" ]]; then
249
  zstyle ":completion:*:*:emerge:*" cache-policy _ebuilds_caching_policy
250
fi
251
252
_ebuilds_caching_policy () {
253
  # rebuild if cache is more than a week old
254
  oldp=( "$1"(mw+1) )
255
  (( $#oldp )) && return 0
256
}
191
257
192
common_args=(
258
common_args=(
193
    {'(-p)--pretend','(--pretend)-p'}'[simply  display  what would be done]'
259
    {'(-p -a --ask)--pretend','(--pretend -a --ask)-p'}'[simply  display  what would be done]'
260
    {'(-p -a --pretend)--ask','(--pretend -p --ask)-a'}'[ask what would be done]'
194
    {'(-d)--debug','(--debug)-d'}'[Tells emerge to run the emerge command in debug mode]'
261
    {'(-d)--debug','(--debug)-d'}'[Tells emerge to run the emerge command in debug mode]'
195
)
262
)
196
install_args=(
263
install_args=(
Lines 212-227 Link Here
212
    {'(--usepkg --changelog -l)-k','(-k --changelog -l)--usepkg'}'[Tells emerge to use binary packages if available]'
279
    {'(--usepkg --changelog -l)-k','(-k --changelog -l)--usepkg'}'[Tells emerge to use binary packages if available]'
213
    {'(--usepkgonly --changelog -l)-K','(-K --changelog -l)--usepkgonly'}'[Tells emerge to use binary packages only]'
280
    {'(--usepkgonly --changelog -l)-K','(-K --changelog -l)--usepkgonly'}'[Tells emerge to use binary packages only]'
214
    {'(--verbose)-v','(-v)--verbose'}'[Tell emerge to run in verbose mode]'
281
    {'(--verbose)-v','(-v)--verbose'}'[Tell emerge to run in verbose mode]'
215
    '(-p --pretend)--columns[Displays versions in aligned format]'
282
    '(-p --pretend -a --ask)--columns[Displays versions in aligned format]'
216
    '--resume[Resumes the last merge operation]'
283
    '--resume[Resumes the last merge operation]'
217
    '--skipfirst[Removes the first package in the resume list]'
218
)
284
)
219
285
220
_options() {
221
    _arguments -s \
222
	"$unmerge_args[@]" "$common_args[@]" "$install_args[@]"
223
}
224
225
_actions() {
286
_actions() {
226
    _values "emerge actions" \
287
    _values "emerge actions" \
227
	'sync[Initiates a portage tree update]' \
288
	'sync[Initiates a portage tree update]' \

Return to bug 58198