Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 71957 | Differences between
and this patch

Collapse All | Expand All

(-)_portage (-88 / +8 lines)
Lines 114-132 Link Here
114
_quickpkg () {
114
_quickpkg () {
115
	if compset -P '(\\|)(>=|<=|<|>|=)'; then
115
	if compset -P '(\\|)(>=|<=|<|>|=)'; then
116
	_arguments -s \
116
	_arguments -s \
117
    	    '*:installed package:_portage_unmerge_vers'
117
    	    '*:installed package:_gentoo_packages installed_versions'
118
	  elif compset -P '(\\|)[/]'; then
118
	  elif compset -P '(\\|)[/]'; then
119
		_path_files -W / -/
119
		_path_files -W / -/
120
	  else
120
	  else
121
    		_arguments \
121
    		_arguments \
122
		    '*:installed package:_portage_unmerge'
122
		    '*:installed package:_gentoo_packages installed'
123
	  fi
123
	  fi
124
}
124
}
125
125
126
# Stuff for emerge
126
# Stuff for emerge
127
127
128
_emerge () {
128
_emerge () {
129
    local state
130
    local nopkg_opts all noask_opts bopts install_args common_args profiles
129
    local nopkg_opts all noask_opts bopts install_args common_args profiles
131
130
132
  noask_opts=(-p -a --pretend --ask --regen --info --search -s --searchdesc \
131
  noask_opts=(-p -a --pretend --ask --regen --info --search -s --searchdesc \
Lines 194-227 Link Here
194
    'system[All packages in the system profile]'
193
    'system[All packages in the system profile]'
195
  )
194
  )
196
195
197
  #Reading informations from make.conf
198
199
  local trees portage_pkglist category var
200
201
  for var in PORTDIR PORTDIR_OVERLAY PKGDIR ; do
202
    local env_var=\$${var}
203
204
    [[ -z ${(e)env_var} && -r /etc/make.conf ]] && local $var="`. /etc/make.conf 2>/dev/null;
205
	echo ${(e)env_var}`"
206
    [[ -z ${(e)env_var} && -r /etc/make.globals ]] && local $var="`. /etc/make.globals 2>/dev/null;
207
	echo ${(e)env_var}`"
208
  done
209
210
  trees=( $PORTDIR $=PORTDIR_OVERLAY )
211
  portage_pkglist=( $trees/*-*/*(:t) )
212
  category=( $trees/*-*(/:t) )
213
  typeset -U category
214
215
196
216
  # Dispatch
197
  # Dispatch
217
  if (( $words[(I)(--(unmerge|clean|prune)|-[[:alpha:]]#(C|c|P)[[:alpha:]]#)] )) ; then
198
  if (( $words[(I)(--(unmerge|clean|prune)|-[[:alpha:]]#(C|c|P)[[:alpha:]]#)] )) ; then
218
	if compset -P '(\\|)(>=|<=|<|>|=)'; then
199
	if compset -P '(\\|)(>=|<=|<|>|=)'; then
219
	    _arguments -s \
200
	    _arguments -s \
220
		'*:installed package:_portage_unmerge_vers' && return 0
201
		'*:installed package:_gentoo_packages installed_versions' && return 0
221
	else
202
	else
222
	    _arguments -s \
203
	    _arguments -s \
223
		"$common_args[@]" "$install_args[@]" \
204
		"$common_args[@]" "$install_args[@]" \
224
		"*:installed package:_portage_unmerge" && return 0
205
		"*:installed package:_gentoo_packages installed" && return 0
225
	fi
206
	fi
226
207
227
  elif (( $words[(I)(world|system)] )) ; then
208
  elif (( $words[(I)(world|system)] )) ; then
Lines 232-238 Link Here
232
  elif (( $words[(I)(--usepkgonly|-[[:alnum:]]#K[[:alnum:]]#)] )) ; then
213
  elif (( $words[(I)(--usepkgonly|-[[:alnum:]]#K[[:alnum:]]#)] )) ; then
233
    _arguments -s \
214
    _arguments -s \
234
	"$common_args[@]" "$install_args[@]" \
215
	"$common_args[@]" "$install_args[@]" \
235
	'*:binary package:_portage_tbz2list' && return 0
216
	'*:binary package:_gentoo_packages binary' && return 0
236
217
237
  elif [[ $words[-3] == (--help|-h) ]] ; then
218
  elif [[ $words[-3] == (--help|-h) ]] ; then
238
      _message "No more arguments" && return 0
219
      _message "No more arguments" && return 0
Lines 240-321 Link Here
240
  else
221
  else
241
	if compset -P '(\\|)(>=|<=|<|>|=)'; then
222
	if compset -P '(\\|)(>=|<=|<|>|=)'; then
242
	    _arguments \
223
	    _arguments \
243
		"*:portage:_portage_pkglist_vers" && return 0
224
		"*:portage:_gentoo_packages available_versions" && return 0
244
225
245
	elif (( $words[(I)(--inject|-i)] )) ; then
226
	elif (( $words[(I)(--inject|-i)] )) ; then
246
	    _arguments -s \
227
	    _arguments -s \
247
		"$common_args[@]" "$install_args[@]" \
228
		"$common_args[@]" "$install_args[@]" \
248
		"*:portage:_portage_pkglist_vers" && return 0
229
		"*:portage:_gentoo_packages available_versions" && return 0
249
	else
230
	else
250
	    _arguments -s \
231
	    _arguments -s \
251
		"$common_args[@]" "$install_args[@]" \
232
		"$common_args[@]" "$install_args[@]" \
252
		"($nopkg_opts)::portage: _values 'profile' \$profiles[@] " \
233
		"($nopkg_opts)::portage: _values 'profile' \$profiles[@] " \
253
		"($nopkg_opts)*:portage:_portage_pkglist" && return 0
234
		"($nopkg_opts)*:portage:_gentoo_packages available" && return 0
254
	fi
235
	fi
255
  fi
236
  fi
256
}
237
}
257
238
258
#Function to show only installed packages   -- pkgname (no category or version #)
259
_portage_unmerge(){
260
    local installed_pkgname installed_list installed_portage
261
    installed_portage=(/var/db/pkg/*-*/*)
262
263
    installed_pkgname=( ${${installed_portage:t}%%-[0-9]*} )
264
    _tags installed_pkgname && compadd "$@" ${installed_pkgname}
265
266
    installed_list=( ${${installed_portage#*/pkg/}%%-[0-9]*} )
267
    _wanted packages expl 'category/package' _multi_parts "$@" / installed_list
268
}
269
270
#Function to show only installed packages -- cat/name-ver
271
_portage_unmerge_vers(){
272
    local installed_list installed_portage
273
    installed_portage=(/var/db/pkg/*-*/*)
274
    _tags installed_pkgname && compadd "$@" ${installed_portage:t}
275
276
    # most other cat/pkg don't work with _files, so I changed this one too.
277
    installed_list=( ${installed_portage##*/pkg/} )
278
    _wanted packages expl 'category/package' _multi_parts "$@" / installed_list
279
}
280
281
#Function to show tbz2 files available
282
_portage_tbz2list() {
283
    # this doesn't take care of ${PORTAGE_BINHOST}. If Gentoo official
284
    # binary mirror will be available we should rewrite it accordingly.
285
    _path_files -g \*.tbz2 -W "${PKGDIR}/All"
286
}
287
288
#Function to show all available portage names
289
_portage_pkglist(){
290
    local pkg
291
    _tags portage_pkglist && compadd "$@" $portage_pkglist
292
293
    # Complete cat/pkg. _multi_parts is much to slow for such a large task,
294
    # _sep_parts removes the dash from gnome-<tab>, and _path_files wants to
295
    # complete cat/pkg/files (if "files" is ignored with -F, miscfiles, etc...
296
    # don't get completed).
297
    if [[ $PREFIX != */* ]] ; then
298
	_wanted packages expl 'category/package' compadd -S '/' $category
299
    else
300
	compset -P '*/'
301
	pkg=( $trees/$IPREFIX/*(:t) )
302
	_wanted packages expl 'category/package' compadd $pkg
303
    fi
304
}
305
306
#Function to show all package versions
307
_portage_pkglist_vers(){
308
    local portage_ebuilds overlay_ebuilds pkg
309
310
    if [[  $#PREFIX -ge 1  &&  -z $words[(r)(--inject|-i)]  ]] ; then
311
	overlay_ebuilds=(${=PORTDIR_OVERLAY}/*-*/${PREFIX%%-[0-9]#*}*/*.ebuild(:t:r) )
312
	portage_ebuilds=($PORTDIR/metadata/cache/*-*/${PREFIX%%-[0-9]#*}*(:t))
313
	_tags portage_pkglist && compadd "$@" $portage_ebuilds $overlay_ebuilds
314
    fi
315
316
    pkg=( $trees/${PREFIX%%/*}/*/*.ebuild(:t:r) )
317
    _wanted packages expl 'category/package' _sep_parts category / pkg
318
}
319
239
320
240
321
local gentoo_runlevels
241
local gentoo_runlevels

Return to bug 71957