1 |
commit: ba66a09a2469e12799995a24b5f59aa718df8f38 |
2 |
Author: =?UTF-8?q?Felix=20Neum=C3=A4rker?= <xdch47 <AT> posteo <DOT> de> |
3 |
AuthorDate: Wed Feb 20 20:18:05 2019 +0000 |
4 |
Commit: Vadim Misbakh-Soloviov <mva <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 19 17:51:33 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/zsh-completion.git/commit/?id=ba66a09a |
7 |
|
8 |
Merge Pull Request #18 (squashed) |
9 |
|
10 |
[PATCH 1/6] _gentoo_repos: split functions into 2 files |
11 |
[PATCH 2/6] _portage: improve completion for ebuild and emaint |
12 |
[PATCH 3/6] _eselect: rewrite for more generic completion |
13 |
[PATCH 4/6] add EPREFIX support |
14 |
[PATCH 5/6] _eselect: multi_parts timezone completion |
15 |
[PATCH 6/6] _eselect: set/enable filter for lists > 10 |
16 |
|
17 |
Signed-off-by: Vadim A. Misbakh-Soloviov <git <AT> mva.name> |
18 |
|
19 |
src/_eselect | 363 +++++++++++++++++++++++++++---------------------- |
20 |
src/_gentoo_packages | 28 ++-- |
21 |
src/_gentoo_repos | 64 ++------- |
22 |
src/_gentoo_repos_conf | 55 ++++++++ |
23 |
src/_gentoolkit | 4 +- |
24 |
src/_portage | 145 ++++++++++++++++---- |
25 |
src/_portage_utils | 4 +- |
26 |
7 files changed, 396 insertions(+), 267 deletions(-) |
27 |
|
28 |
diff --git a/src/_eselect b/src/_eselect |
29 |
index 46b8477..77b9fd6 100644 |
30 |
--- a/src/_eselect |
31 |
+++ b/src/_eselect |
32 |
@@ -1,199 +1,232 @@ |
33 |
-#compdef eselect |
34 |
- |
35 |
-common_values=( |
36 |
- "help[Display help text]" |
37 |
- "usage[Display usage information]" |
38 |
- "version[Display version information]" |
39 |
-) |
40 |
- |
41 |
-_eselect_env () { |
42 |
- if (( $words[(I)(update)] )); then |
43 |
- _values "update options" \ |
44 |
- "makelinks[force updating of links]" \ |
45 |
- "noldconfig[Do not alter the ld.so cache or configuration]" && return 0 |
46 |
+#compdef eselect kernel-config profile-config rc-config |
47 |
+ |
48 |
+_eselect_parse_generic() { |
49 |
+ local -a mod_std mod_extra |
50 |
+ local -a eselect_args |
51 |
+ local mod_cur eselect_descr |
52 |
+ local mod descr etype |
53 |
+ |
54 |
+ eselect_args=($@) |
55 |
+ if [[ $1 == "modules" ]] ; then |
56 |
+ eselect_args=($1 usage) |
57 |
fi |
58 |
- _values "env options" $common_values \ |
59 |
- 'update[Collect environment variables from all scripts in /etc/env.d/]' && return 0 |
60 |
-} |
61 |
+ mod_cur="mod_extra" |
62 |
+ eselect_descr="$(LANG=C COLUMNS=100 eselect --colour=no ${eselect_args[@]} 2> /dev/null)" |
63 |
+ |
64 |
+ while IFS="" read -r helpdesc ; do |
65 |
+ case "$helpdesc" in |
66 |
+ ("Built-in modules:"|"Standard actions:")) |
67 |
+ mod_cur="mod_std" |
68 |
+ ;; |
69 |
+ ("Extra modules:"|"Extra actions:")) |
70 |
+ mod_cur="mod_extra" |
71 |
+ ;; |
72 |
+ esac |
73 |
+ |
74 |
+ if [[ "$helpdesc" =~ '^ [A-Za-z]' ]] ; then |
75 |
+ echo "$helpdesc" | read mod descr |
76 |
+ descr="$(echo "$descr" | sed -r -e 's/.*\s\s\s+//')" |
77 |
+ set -A $mod_cur ${(P)mod_cur} ${mod}:${(q)descr} |
78 |
+ fi |
79 |
+ done <<< "$eselect_descr" |
80 |
|
81 |
-_eselect_binutils () { |
82 |
- local binutilslist |
83 |
- if (( $words[(I)(set)] )); then |
84 |
- binutilslist=(${(f)"$(eselect --brief --color=no binutils list)"}) |
85 |
- _values "available binutils version" $binutilslist[@] && return 0 |
86 |
+ if [[ -z "${eselect_args[@]}" ]] ; then |
87 |
+ etype="modules" |
88 |
+ else |
89 |
+ etype="actions" |
90 |
fi |
91 |
- _values "binutils options" $common_values \ |
92 |
- "list[List all installed version of binutils]" \ |
93 |
- "show[Print the currently active binutils version]" \ |
94 |
- "set[Activate one of the installed binutils]" && return 0 |
95 |
-} |
96 |
|
97 |
-_eselect_kernel () { |
98 |
- local kernellist |
99 |
- if (( $words[(I)(set)] )); then |
100 |
- kernellist=(${(f)"$(eselect --brief --color=no kernel list)"}) |
101 |
- _values "available kernel version" $kernellist[@] && return 0 |
102 |
+ if [[ -z "${mod_extra}" && -z "${mod_std}" ]] ; then |
103 |
+ _nothing |
104 |
+ else |
105 |
+ _describe -t eselect_extra -V "eselect extra $etype" mod_extra |
106 |
+ _describe -t eselect_standard -V "eselect standard $etype" mod_std |
107 |
fi |
108 |
- _values "kernel options" $common_values \ |
109 |
- "list[List available kernel symlink targets]" \ |
110 |
- "show[Show the current kernel symlink]" \ |
111 |
- "set[Set a new kernel symlink target]" && return 0 |
112 |
} |
113 |
|
114 |
-_eselect_ctags () { |
115 |
- local ctagslist |
116 |
- if (( $words[(I)(set)] )); then |
117 |
- ctagslist=(${(f)"$(eselect --brief --color=no ctags list)"}) |
118 |
- _values "available ctags version" $ctagslist[@] && return 0 |
119 |
+_eselect_parse_action_list() { |
120 |
+ local eselect_list |
121 |
+ local idx descr |
122 |
+ local arr_items_selected=$2 |
123 |
+ local arr_items_unselected=$3 |
124 |
+ |
125 |
+ eselect_list="$(LANG=C COLUMNS=100 eselect --colour=no $1 list 2> /dev/null)" |
126 |
+ while IFS="" read -r ele ; do |
127 |
+ echo "$ele" | read idx descr |
128 |
+ idx=${idx#*\[} |
129 |
+ idx=${idx%\]*} |
130 |
+ if [[ "$idx" =~ '^[0-9]+$' ]]; then |
131 |
+ local stripped_descr="${descr% *\**}" |
132 |
+ if [[ "${stripped_descr}" != "${descr}" ]] ; then |
133 |
+ set -A $arr_items_selected ${(P)arr_items_selected} "$idx:${(q)descr}" |
134 |
+ else |
135 |
+ set -A $arr_items_unselected ${(P)arr_items_unselected} "$idx:${(q)descr}" |
136 |
+ fi |
137 |
+ fi |
138 |
+ done <<< "$eselect_list" |
139 |
+} |
140 |
+ |
141 |
+_eselect_module_action() { |
142 |
+ if (( $+functions[_eselect_${1}_action] )) ; then |
143 |
+ _eselect_${1}_action |
144 |
+ else |
145 |
+ _eselect_parse_generic ${1} |
146 |
fi |
147 |
- _values "ctags options" $common_values \ |
148 |
- "list[List available ctags symlink targets]" \ |
149 |
- "show[Show the current target of the ctags symlink]" \ |
150 |
- "update[Automatically update the ctags symlink]" \ |
151 |
- "set[Set a new ctags symlink target]" && return 0 |
152 |
} |
153 |
|
154 |
-_eselect_profile () { |
155 |
- local profilelist |
156 |
- if (( $words[(I)(set)] )); then |
157 |
- profilelist=(${${(f)"$(eselect --brief --color=no profile list)"}/:/\\:}) |
158 |
- _values -w "available profiles" $profilelist[@] \ |
159 |
- "--force[Forcibly set the symlink]" && return 0 |
160 |
+_eselect_complete_action() { |
161 |
+ local actionname=$(_eselect_get_module) |
162 |
+ if (( $+functions[_eselect_complete_${actionname}_action] )) ; then |
163 |
+ _eselect_complete_${actionname}_action |
164 |
+ else |
165 |
+ _eselect_complete_action_generic ${actionname} |
166 |
fi |
167 |
- _values "profile options" $common_values \ |
168 |
- "list[List available profile symlink targets]" \ |
169 |
- "show[Show the current make.profile symlink]" \ |
170 |
- "set[Set a new profile symlink target]" && return 0 |
171 |
} |
172 |
|
173 |
-_eselect_fontconfig () { |
174 |
- local fclistenabled fclistdisabled |
175 |
- if (( $words[(I)(enable)] )); then |
176 |
- fclistdisabled=(${${${${(M)${(f)"$(eselect --color=no fontconfig list)"}## *}#*\*}// \**/}//( \[*\] | \[*\] )/}) |
177 |
- _values -w ".conf to enable" $fclistdisabled[@] && return 0 |
178 |
- elif (( $words[(I)(disable)] )); then |
179 |
- fclistenabled=(${${${(M)${(M)${(f)"$(eselect --color=no fontconfig list)"}## *}#*\*}// \**/}//( \[*\] | \[*\] )/}) |
180 |
- _values -w ".conf to disable" $fclistenabled[@] && return 0 |
181 |
+_eselect_get_module() { |
182 |
+ if [[ $service == "eselect" ]] ; then |
183 |
+ echo $line[1] |
184 |
+ else |
185 |
+ echo ${service%-config} |
186 |
fi |
187 |
- _values "fontconfig options" $common_values \ |
188 |
- "list[List available fontconfig .conf files]" \ |
189 |
- "disable[Disable specified fontconfig .conf file(s)]" \ |
190 |
- "enable[Enable specified fontconfig .conf file(s)]" && return 0 |
191 |
} |
192 |
|
193 |
-_eselect_opengl () { |
194 |
- local opengllist |
195 |
- if (( $words[(I)(set)] )); then |
196 |
- opengllist=(${(f)"$(eselect --brief --color=no opengl list)"}) |
197 |
- _values -w "opengl implementations and options" $opengllist[@] \ |
198 |
- "--use-old[If an implementation is already set, use that one instead]" \ |
199 |
- "--prefix[Set the source prefix]:path:_files -/" \ |
200 |
- "--dst-prefix[Set the destination prefix]:path:_files -/" \ |
201 |
- "--ignore-missing[Ignore missing files when setting a new implementation]" && return 0 |
202 |
+_eselect_action_index() { |
203 |
+ if [[ $service == "eselect" ]] ; then |
204 |
+ echo 2 |
205 |
+ else |
206 |
+ echo 1 |
207 |
fi |
208 |
- _values "opengl options" $common_values \ |
209 |
- "list[List the available OpenGL implementations]" \ |
210 |
- "set[Select the OpenGL implementation]" \ |
211 |
- "show[Print the current OpenGL implementation]" && return 0 |
212 |
+} |
213 |
+_eselect_get_action () { |
214 |
+ echo ${line[$(_eselect_action_index)]} |
215 |
+} |
216 |
+ |
217 |
+_eselect_action() { |
218 |
+ _eselect_module_action $(_eselect_get_module) |
219 |
+} |
220 |
+ |
221 |
+_eselect_module() { |
222 |
+ _eselect_parse_generic |
223 |
} |
224 |
|
225 |
-_eselect_vi () { |
226 |
- local vilist |
227 |
- if (( $words[(I)(set)] )); then |
228 |
- vilist=(${(f)"$(eselect --brief --color=no vi list)"}) |
229 |
- _values -w "vi implementation" $vilist[@] && return 0 |
230 |
- elif (( $words[(I)(update)] )); then |
231 |
- _values -w "option" "--if-unset[Do not override existing implementation]" && return 0 |
232 |
+_eselect_complete_action_generic() { |
233 |
+ local -a sel_items |
234 |
+ local -a unsel_items |
235 |
+ |
236 |
+ if (( $NORMARG + $(_eselect_action_index) == $CURRENT )) ; then |
237 |
+ case "$(_eselect_get_action)" in |
238 |
+ ("set"|"enable")) |
239 |
+ _eselect_parse_action_list $1 sel_items unsel_items |
240 |
+ if (( $#unsel_items + $#sel_items > 0 )) ; then |
241 |
+ _describe -t eselect_sel -V 'eselect items' unsel_items |
242 |
+ if (( $#unsel_items + $#sel_items < 10 )) ; then |
243 |
+ _describe -t eselect_unsel -V 'eselect already selected items' sel_items |
244 |
+ fi |
245 |
+ return 0 |
246 |
+ fi |
247 |
+ ;; |
248 |
+ ("remove"|"disable")) |
249 |
+ _eselect_parse_action_list $1 sel_items unsel_items |
250 |
+ if [[ -n "${sel_items[@]}" ]] ; then |
251 |
+ _describe -V 'eselect items' sel_items |
252 |
+ return 0 |
253 |
+ fi |
254 |
+ ;; |
255 |
+ esac |
256 |
fi |
257 |
- _values "vi options" $common_values \ |
258 |
- "list[List available vi implementations]" \ |
259 |
- "set[Set a new vi implementation provider]" \ |
260 |
- "show[Show the current vi implementation]" \ |
261 |
- "update[Automatically update the vi provider]" |
262 |
+ |
263 |
+ _nothing |
264 |
} |
265 |
|
266 |
-_eselect_news() { |
267 |
- |
268 |
- ## TODO: Normal numeric sorting. |
269 |
- ## I've spent many time on trying to rewrite this |
270 |
- ## function to normally sort (to DO NOT sort, actually) items, |
271 |
- ## but it growing bigger and bigger and going to be too complicated. |
272 |
- ## So, I (mva) either need to help to make it in the "right way". |
273 |
- ## Or, maybe, to completely rewrite this compdef. |
274 |
- |
275 |
- local -a newslist; |
276 |
- if ((CURRENT == 3)); then |
277 |
- _values 'news options' $stdopts[@] \ |
278 |
- 'list[List news items]' \ |
279 |
- 'count[Display number of news items]' \ |
280 |
- 'purge[Purge read news]' \ |
281 |
- 'read[Read news items]' \ |
282 |
- 'unread[Mark read news items as unread again]' && return 0 |
283 |
- elif ((CURRENT == 4)); then |
284 |
- if (( $words[(I)(count)] )); then |
285 |
- _values -w 'news' 'new[Count only new news items]' 'all[Count all news items]' && return 0 |
286 |
- fi |
287 |
+# custom completions: |
288 |
+(( $+functions[_eselect_complete_news_action] )) || _eselect_complete_news_action() { |
289 |
+ local -a items |
290 |
|
291 |
- newslist=(${${${${${${${(M)${(f)"$(eselect --color=no news list)"}## *}// \**/}/ \[/}/\] ##/\[}/%/]}/ \[/ (}/\] /) }) |
292 |
+ case "$(_eselect_get_action)" in |
293 |
+ ("read"|"unread")) |
294 |
+ local -a extra_items=('all:Read all news items') |
295 |
+ if [[ $(_eselect_get_action) == "read" ]] ; then |
296 |
+ extra_items=('new:Read unread news items (default)' "${extra_items[@]}") |
297 |
+ fi |
298 |
+ _eselect_parse_action_list news items items |
299 |
|
300 |
- if (( $words[(I)(read)] )); then |
301 |
- newslist+=( "new[Read unread news items (default)]" "all[Read all news items]" "--mbox[Output in mbox format]" "--quiet[Suppress output, only change status]" "--raw[Output in raw format]" ) |
302 |
- fi; |
303 |
+ items=(${(q)extra_items[@]} ${(Oa)items}) |
304 |
+ if [[ -n "${items[@]}" ]] ; then |
305 |
+ _describe -V 'eselect items' items |
306 |
+ return 0 |
307 |
+ fi |
308 |
+ ;; |
309 |
+ esac |
310 |
|
311 |
- if (( $words[(I)(unread)] )); then |
312 |
- newslist+=( "all[Unread all news items]" ) |
313 |
- fi |
314 |
+ _nothing |
315 |
+} |
316 |
|
317 |
- _values -w 'news' $newslist[@] && return 0 |
318 |
+(( $+functions[_eselect_complete_kernel_action] )) || _eselect_complete_kernel_action() { |
319 |
+ local -a items |
320 |
+ |
321 |
+ if (( $NORMARG + $(_eselect_action_index) == $CURRENT )) ; then |
322 |
+ case "$(_eselect_get_action)" in |
323 |
+ "set") |
324 |
+ for k in ${(@f)$(eselect --colour=no --brief kernel list)} ; do |
325 |
+ items+=${k#linux-} |
326 |
+ done |
327 |
+ local -a expl=(-P linux-) |
328 |
+ compadd -V 'eselect kernel' -P linux- ${items[@]} |
329 |
+ return 0 |
330 |
+ ;; |
331 |
+ esac |
332 |
fi |
333 |
+ |
334 |
+ _nothing |
335 |
} |
336 |
|
337 |
-_eselect () { |
338 |
- local globopts modnames modopts |
339 |
- |
340 |
- globopts=( |
341 |
- "--brief[Make output shorter]" |
342 |
- "--colour=no[Disable coloured output]" |
343 |
- "--color=no[Disable coloured output]" |
344 |
- ) |
345 |
- modnames=(${${${(M)${(f)"$(eselect --brief --color=no modules list)"}## *}// */}// /}) |
346 |
- |
347 |
- if ((CURRENT == 2)); then |
348 |
- _arguments -s \ |
349 |
- "$globopts[@]" \ |
350 |
- "*:portage:_values 'eselect modules' \$modnames[@]" && return 0 |
351 |
- elif ((CURRENT == 3)); then |
352 |
- if [[ $words[2] == --colour=no || $words[2] == --color=no ]]; then |
353 |
- _arguments -s \ |
354 |
- "*:portage:_values 'eselect modules' \$modnames[@]" && return 0 |
355 |
- elif (( $modnames[(I)$words[2]] )); then |
356 |
- if [[ "$words[2]" == (env|binutils|kernel|ctags|profile|fontconfig|opengl|vi|news) ]]; then |
357 |
- _eselect_$words[2] "$@" |
358 |
- else |
359 |
- modopts=(${${${(M)${(f)"$(eselect --brief --color=no $words[2] usage)"}## *}// */}// /}) |
360 |
- _arguments -s \ |
361 |
- "*:portage:_values 'eselect $words[2] options' \$modopts[@]" && return 0 |
362 |
- fi |
363 |
- fi |
364 |
- elif ((CURRENT >= 4)); then |
365 |
- if (( $words[(I)(--color=no|--colour=no)] )); then |
366 |
- if (( $modnames[(I)$words[3]] )); then |
367 |
- if [[ "$words[3]" == (env|binutils|kernel|ctags|profile|fontconfig|opengl|vi|news) ]]; then |
368 |
- _eselect_$words[3] "$@" |
369 |
- else |
370 |
- modopts=(${${${${(M)${(f)"$(eselect --brief --color=no $words[3] usage)"}## *}// */}// /}// *}) |
371 |
- _arguments -s \ |
372 |
- "*:portage:_values 'eselect $words[3] options' \$modopts[@]" && return 0 |
373 |
- fi |
374 |
- fi |
375 |
- else |
376 |
- if (( $modnames[(I)$words[2]] )); then |
377 |
- (( $+functions[_eselect_$words[2]] )) && _eselect_$words[2] "$@" |
378 |
- fi |
379 |
- fi |
380 |
+(( $+functions[_eselect_complete_profile_action] )) || _eselect_complete_profile_action() { |
381 |
+ if (( $NORMARG + $(_eselect_action_index) == $CURRENT )) ; then |
382 |
+ case "$(_eselect_get_action)" in |
383 |
+ "set") |
384 |
+ _values 'eselect profiles' $(eselect --colour=no --brief profile list) |
385 |
+ return 0 |
386 |
+ ;; |
387 |
+ esac |
388 |
fi |
389 |
+ |
390 |
+ _nothing |
391 |
+} |
392 |
+ |
393 |
+(( $+functions[_eselect_complete_timezone_action] )) || _eselect_complete_timezone_action() { |
394 |
+ if (( $NORMARG + $(_eselect_action_index) == $CURRENT )) ; then |
395 |
+ case "$(_eselect_get_action)" in |
396 |
+ "set") |
397 |
+ _multi_parts / "($(eselect --colour=no --brief timezone list))" |
398 |
+ return 0 |
399 |
+ ;; |
400 |
+ esac |
401 |
+ fi |
402 |
+ |
403 |
+ _nothing |
404 |
+} |
405 |
+ |
406 |
+eselect_comp() { |
407 |
+ integer NORMARG |
408 |
+ |
409 |
+ case "$service" in |
410 |
+ eselect) |
411 |
+ _arguments -A '-*' -n \ |
412 |
+ '--brief[Make output shorter]' \ |
413 |
+ '(--colour --color)'--colo{,u}r='[Enable or disable colour output]:colour:(yes no)' \ |
414 |
+ '1:eselect_module:_eselect_module' \ |
415 |
+ '2:eselect_action:_eselect_action' \ |
416 |
+ '*:eselect_complete_action:_eselect_complete_action' |
417 |
+ ;; |
418 |
+ *-config) |
419 |
+ _arguments -n \ |
420 |
+ "1:action:_eselect_action" \ |
421 |
+ '*:eselect_complete_action:_eselect_complete_action' |
422 |
+ ;; |
423 |
+ esac |
424 |
} |
425 |
|
426 |
-_eselect "$@" |
427 |
+eselect_comp "$@" |
428 |
|
429 |
# vim: set et sw=2 ts=2 ft=zsh: |
430 |
|
431 |
diff --git a/src/_gentoo_packages b/src/_gentoo_packages |
432 |
index 37539c8..c2d9d36 100644 |
433 |
--- a/src/_gentoo_packages |
434 |
+++ b/src/_gentoo_packages |
435 |
@@ -58,7 +58,7 @@ _parsesetsconf() { |
436 |
|
437 |
_gentoo_packages_update_installed_sets() { |
438 |
local sets |
439 |
- sets=($(</var/lib/portage/world_sets)) |
440 |
+ sets=($(<${EPREFIX}/var/lib/portage/world_sets)) |
441 |
if [[ ((${#sets} > 0)) ]]; then |
442 |
_wanted installed_sets expl 'installed set' compadd "$@" "${(o@)^sets}" |
443 |
fi |
444 |
@@ -67,7 +67,7 @@ _gentoo_packages_update_installed_sets() { |
445 |
_gentoo_packages_update_available_sets() { |
446 |
local dirs dir sets_dir set sets sets_path sets_files |
447 |
|
448 |
- dirs=($(_gentoo_repos -o) /etc/portage /usr/share/portage/config) |
449 |
+ dirs=($(_gentoo_repos -o) ${EPREFIX}/etc/portage ${EPREFIX}/usr/share/portage/config) |
450 |
|
451 |
for dir in ${(@)dirs}; do |
452 |
if [[ -d ${dir} ]]; then |
453 |
@@ -104,10 +104,10 @@ _gentoo_packages_update_useflag(){ |
454 |
_gentoo_packages_update_active_useflag(){ |
455 |
local flags USE |
456 |
var=USE |
457 |
- [[ -z ${(P)var} && -r /etc/portage/make.conf ]] && |
458 |
- local $var="$(. /etc/portage/make.conf 2>/dev/null; echo ${(P)var})" |
459 |
- [[ -z ${(P)var} && -r /etc/make.conf ]] && |
460 |
- local $var="$(. /etc/make.conf 2>/dev/null; echo ${(P)var})" |
461 |
+ [[ -z ${(P)var} && -r ${EPREFIX}/etc/portage/make.conf ]] && |
462 |
+ local $var="$(. ${EPREFIX}/etc/portage/make.conf 2>/dev/null; echo ${(P)var})" |
463 |
+ [[ -z ${(P)var} && -r ${EPREFIX}/etc/make.conf ]] && |
464 |
+ local $var="$(. ${EPREFIX}/etc/make.conf 2>/dev/null; echo ${(P)var})" |
465 |
flags=(${${${=USE}%-*}%\\*}) |
466 |
compadd $flags |
467 |
} |
468 |
@@ -122,7 +122,7 @@ _gentoo_packages_update_category(){ |
469 |
|
470 |
_gentoo_packages_update_installed(){ |
471 |
local installed_dir installed_portage installed_pkgname installed_list |
472 |
- installed_dir="/var/db/pkg" |
473 |
+ installed_dir="${EPREFIX}/var/db/pkg" |
474 |
installed_portage=($installed_dir/*-*/*) |
475 |
|
476 |
installed_pkgname=(${${installed_portage:t}%%-[0-9]*}) |
477 |
@@ -135,7 +135,7 @@ _gentoo_packages_update_installed(){ |
478 |
_gentoo_packages_update_installed_versions(){ |
479 |
local installed_list installed_portage |
480 |
|
481 |
- installed_portage=(/var/db/pkg/*-*/*) |
482 |
+ installed_portage=(${EPREFIX}/var/db/pkg/*-*/*) |
483 |
_wanted packages expl 'package' compadd "$@" ${installed_portage:t} |
484 |
|
485 |
installed_list=(${installed_portage##*/pkg/}) |
486 |
@@ -196,12 +196,12 @@ _gentoo_packages_update_available_versions(){ |
487 |
_gentoo_packages_update_binary() { |
488 |
local PKGDIR |
489 |
|
490 |
- [[ -z $PKGDIR && -r /etc/portage/make.conf ]] && |
491 |
- PKGDIR="$(. /etc/portage/make.conf 2>/dev/null; echo $PKGDIR)" |
492 |
- [[ -z $PKGDIR && -r /etc/make.conf ]] && |
493 |
- PKGDIR="$(. /etc/make.conf 2>/dev/null; echo $PKGDIR)" |
494 |
- [[ -z $PKGDIR && -r /usr/share/portage/config/make.globals ]] && |
495 |
- PKGDIR="$(. /usr/share/portage/config/make.globals 2>/dev/null; echo $PKGDIR)" |
496 |
+ [[ -z $PKGDIR && -r ${EPREFIX}/etc/portage/make.conf ]] && |
497 |
+ PKGDIR="$(. ${EPREFIX}/etc/portage/make.conf 2>/dev/null; echo $PKGDIR)" |
498 |
+ [[ -z $PKGDIR && -r ${EPREFIX}/etc/make.conf ]] && |
499 |
+ PKGDIR="$(. ${EPREFIX}/etc/make.conf 2>/dev/null; echo $PKGDIR)" |
500 |
+ [[ -z $PKGDIR && -r ${EPREFIX}/usr/share/portage/config/make.globals ]] && |
501 |
+ PKGDIR="$(. ${EPREFIX}/usr/share/portage/config/make.globals 2>/dev/null; echo $PKGDIR)" |
502 |
|
503 |
# this doesn't take care of ${PORTAGE_BINHOST}. If Gentoo official |
504 |
# binary mirror will be available we should rewrite it accordingly. |
505 |
|
506 |
diff --git a/src/_gentoo_repos b/src/_gentoo_repos |
507 |
index 85f3936..e5acf36 100644 |
508 |
--- a/src/_gentoo_repos |
509 |
+++ b/src/_gentoo_repos |
510 |
@@ -11,22 +11,22 @@ _gentoo_repos() { |
511 |
overlay_paths=(); |
512 |
result=(); |
513 |
|
514 |
- if [[ -e /usr/share/portage/config/repos.conf || -e /etc/portage/repos.conf ]]; then |
515 |
- main_repo=$(_repos_conf DEFAULT main-repo) |
516 |
- main_repo_path=$(_repos_conf ${main_repo} location) |
517 |
+ if [[ -e ${EPREFIX}/usr/share/portage/config/repos.conf || -e ${EPREFIX}/etc/portage/repos.conf ]]; then |
518 |
+ main_repo=$(_gentoo_repos_conf DEFAULT main-repo) |
519 |
+ main_repo_path=$(_gentoo_repos_conf ${main_repo} location) |
520 |
|
521 |
- for overlay in $(_repos_conf -l); do |
522 |
- overlay_paths+=($(_repos_conf ${overlay} location)) |
523 |
+ for overlay in $(_gentoo_repos_conf -l); do |
524 |
+ overlay_paths+=($(_gentoo_repos_conf ${overlay} location)) |
525 |
done |
526 |
|
527 |
- source /etc/make.conf 2>/dev/null |
528 |
- source /etc/portage/make.conf 2>/dev/null |
529 |
+ source ${EPREFIX}/etc/make.conf 2>/dev/null |
530 |
+ source ${EPREFIX}/etc/portage/make.conf 2>/dev/null |
531 |
|
532 |
overlay_paths+=(${(@)PORTDIR_OVERLAY}) |
533 |
else |
534 |
- source /usr/share/portage/config/make.globals 2>/dev/null |
535 |
- source /etc/make.conf 2>/dev/null |
536 |
- source /etc/portage/make.conf 2>/dev/null |
537 |
+ source ${EPREFIX}/usr/share/portage/config/make.globals 2>/dev/null |
538 |
+ source ${EPREFIX}/etc/make.conf 2>/dev/null |
539 |
+ source ${EPREFIX}/etc/portage/make.conf 2>/dev/null |
540 |
|
541 |
main_repo_path="${PORTDIR}" |
542 |
overlay_paths=(${(@)PORTDIR_OVERLAY}) |
543 |
@@ -43,50 +43,6 @@ _gentoo_repos() { |
544 |
echo ${(u)result} |
545 |
} |
546 |
|
547 |
-_repos_conf() { |
548 |
- local v file insection section arr secname |
549 |
- |
550 |
- secname=(); |
551 |
- |
552 |
- for file in /usr/share/portage/config/repos.conf \ |
553 |
- /etc/portage/repos.conf \ |
554 |
- /etc/portage/repos.conf/*.conf; do |
555 |
- |
556 |
- [[ -f ${file} ]] || continue |
557 |
- insection=0 |
558 |
- declare -A arr |
559 |
- IFS='= ' |
560 |
- |
561 |
- while read -r name value; do |
562 |
- [[ -z ${name} || ${name} == '#'* ]] && continue |
563 |
- |
564 |
- if [[ (${name} == '['*']') && (-z ${value}) ]]; then |
565 |
- value=${name//(\]|\[)} |
566 |
- name="section" |
567 |
- fi |
568 |
- arr[${name}]=${value} |
569 |
- |
570 |
- if [[ ${insection} == 1 && ${name} == "section" ]]; then |
571 |
- break |
572 |
- elif [[ ${name} == "section" ]]; then |
573 |
- [[ ${value} == ${1} ]] && insection=1 |
574 |
- secname+=(${value}) |
575 |
- elif [[ ${insection} == 1 ]]; then |
576 |
- if [[ ${name} == ${2} ]]; then |
577 |
- v=${value} |
578 |
- fi |
579 |
- fi |
580 |
- continue |
581 |
- done < ${file} |
582 |
- done |
583 |
- |
584 |
- if [[ ${1} == "-l" ]]; then |
585 |
- echo "${(@u)secname}" |
586 |
- else |
587 |
- echo "${v}" |
588 |
- fi |
589 |
-} |
590 |
- |
591 |
_gentoo_repos "$@" |
592 |
|
593 |
# vim: set et sw=2 ts=2 ft=zsh: |
594 |
|
595 |
diff --git a/src/_gentoo_repos_conf b/src/_gentoo_repos_conf |
596 |
new file mode 100644 |
597 |
index 0000000..3dad709 |
598 |
--- /dev/null |
599 |
+++ b/src/_gentoo_repos_conf |
600 |
@@ -0,0 +1,55 @@ |
601 |
+#autoload |
602 |
+ |
603 |
+# Usage: |
604 |
+# _gentoo_repos_conf -l -> returns the list of all repos names |
605 |
+# _gentoo_repos_conf REPO ATTRIBUTE -> returns the VALUE associated |
606 |
+# with the ATTRIBUTE of the REPO |
607 |
+ |
608 |
+_gentoo_repos_conf() { |
609 |
+ local v file insection section arr secname |
610 |
+ |
611 |
+ secname=(); |
612 |
+ |
613 |
+ |
614 |
+ for file in ${EPREFIX}/usr/share/portage/config/repos.conf \ |
615 |
+ ${EPREFIX}/etc/portage/repos.conf \ |
616 |
+ ${EPREFIX}/etc/portage/repos.conf/*.conf; do |
617 |
+ |
618 |
+ [[ -f ${file} ]] || continue |
619 |
+ insection=0 |
620 |
+ declare -A arr |
621 |
+ IFS='= ' |
622 |
+ |
623 |
+ while read -r name value; do |
624 |
+ [[ -z ${name} || ${name} == '#'* ]] && continue |
625 |
+ |
626 |
+ if [[ (${name} == '['*']') && (-z ${value}) ]]; then |
627 |
+ value=${name//(\]|\[)} |
628 |
+ name="section" |
629 |
+ fi |
630 |
+ arr[${name}]=${value} |
631 |
+ |
632 |
+ if [[ ${insection} == 1 && ${name} == "section" ]]; then |
633 |
+ break |
634 |
+ elif [[ ${name} == "section" ]]; then |
635 |
+ [[ ${value} == ${1} ]] && insection=1 |
636 |
+ secname+=(${value}) |
637 |
+ elif [[ ${insection} == 1 ]]; then |
638 |
+ if [[ ${name} == ${2} ]]; then |
639 |
+ v=${value} |
640 |
+ fi |
641 |
+ fi |
642 |
+ continue |
643 |
+ done < ${file} |
644 |
+ done |
645 |
+ |
646 |
+ if [[ ${1} == "-l" ]]; then |
647 |
+ echo "${(@u)secname}" |
648 |
+ else |
649 |
+ echo "${v}" |
650 |
+ fi |
651 |
+} |
652 |
+ |
653 |
+_gentoo_repos_conf "$@" |
654 |
+ |
655 |
+# vim: set et sw=2 ts=2 ft=zsh: |
656 |
|
657 |
diff --git a/src/_gentoolkit b/src/_gentoolkit |
658 |
index fdad29f..ce5ada4 100644 |
659 |
--- a/src/_gentoolkit |
660 |
+++ b/src/_gentoolkit |
661 |
@@ -204,7 +204,7 @@ _equery () { |
662 |
{size,s}'[print size of files contained in package]' |
663 |
{uses,u}'[display USE flags for package]' |
664 |
{which,w}'[print full path to ebuild for package]' |
665 |
- {has,a}'[list all packages matching ENVIRONMENT data stored in /var/db/pkg]' |
666 |
+ {has,a}'[list all installed packages where specified KEY matches the specified VALUE]' |
667 |
{keywords,y}'[display keywords for specified PKG]' |
668 |
{meta,m}'[display metadata about PKG]' |
669 |
) |
670 |
@@ -357,7 +357,7 @@ _glsa_id () { |
671 |
# will be low. May be we should display only the X previous GLSA, |
672 |
# or GLSA ids of the X last month. |
673 |
# |
674 |
- # start to look at /usr/lib/gentoolkit/pym/glsa.py if GLSA_DIR is still |
675 |
+ # start to look at ${EPREFIX}/usr/lib/gentoolkit/pym/glsa.py if GLSA_DIR is still |
676 |
# PORTDIR + "metadata/glsa/" |
677 |
# and then get the list (it's only xml files in GLSA_DIR, easy!) |
678 |
|
679 |
|
680 |
diff --git a/src/_portage b/src/_portage |
681 |
index 1c43ac4..8700829 100644 |
682 |
--- a/src/_portage |
683 |
+++ b/src/_portage |
684 |
@@ -1,33 +1,51 @@ |
685 |
#compdef emerge ebuild quickpkg emaint env-update etc-update portageq repoman |
686 |
|
687 |
_ebuild () { |
688 |
- if (( CURRENT == 2 )); then |
689 |
- _files -g \*.ebuild |
690 |
- elif (( CURRENT > 2 )); then |
691 |
- _values "ebuild command" \ |
692 |
- 'clean[Cleans the temporary build directory]' \ |
693 |
- 'help[Show help]' \ |
694 |
- 'setup[Run all package specific setup actions and exotic system checks.]' \ |
695 |
- 'fetch[Fetch all necessary files]' \ |
696 |
- 'digest[Creates a digest file for the package]' \ |
697 |
- 'unpack[Extracts the sources to a subdirectory in the build directory]' \ |
698 |
- 'prepare[Prepares the extracted sources by running the src_prepare()]' \ |
699 |
- 'configure[Configures the extracted sources by running the src_configure()]' \ |
700 |
- 'compile[Compiles the extracted sources by running the src_compile()]' \ |
701 |
- 'test[Runs package-specific test cases to verify that everything was built properly]' \ |
702 |
- 'preinst[Run specific actions that need to be done before installation]' \ |
703 |
- 'install[Installs the package to the temporary install directory]' \ |
704 |
- 'postinst[Run specific actions that need to be done after installation]' \ |
705 |
- 'qmerge[Installs the package de the filesystem]' \ |
706 |
- 'merge[perform the following actions: fetch, unpack, compile, install and qmerge.]' \ |
707 |
- 'unmerge[Remove the installed files of the packages]' \ |
708 |
- 'prerm[Run specific actions that need to be executed before unmerge]' \ |
709 |
- 'postrm[Run specific actions that need to be executed after unmerge]' \ |
710 |
- 'config[Run specific actions needed to be executed after the emerge process has completed.]' \ |
711 |
- 'package[This command is a lot like the merge command, but create a .tbz2 package]' \ |
712 |
- 'manifest[Updates the manifest file for the package.]' \ |
713 |
- 'rpm[Builds a RedHat RPM package]' |
714 |
- fi |
715 |
+ local state |
716 |
+ local expl=(-Vx) |
717 |
+ local optional_args=( |
718 |
+ '--skip-manifest[skip all manifest checks]' |
719 |
+ '--debug[run bash with the -x option]' |
720 |
+ '--color=[enable or disable color output]:yes/no:((y\:yes n\:no))' |
721 |
+ '--ignore-default-opts[ignore $EBUILD_DEFAULT_OPTS]' |
722 |
+ '--force[forces regeneration all associated distfiles if used with digest or or manifest command]' |
723 |
+ ) |
724 |
+ |
725 |
+ _arguments -O expl -C $optional_args "1:ebuild file:_files -g \*.ebuild" "*:ebuild command:->ebuild_cmd" |
726 |
+ |
727 |
+ case $state in |
728 |
+ (ebuild_cmd) |
729 |
+ |
730 |
+ local ebuild_cmds=( |
731 |
+ 'clean[Cleans the temporary build directory]' |
732 |
+ 'help[Show help]' |
733 |
+ 'setup[Run all package specific setup actions and exotic system checks]' |
734 |
+ 'fetch[Fetch all necessary files]' |
735 |
+ 'digest[Creates a digest file for the package]' |
736 |
+ 'unpack[Extracts the sources to a subdirectory in the build directory]' |
737 |
+ 'prepare[Prepares the extracted sources by running the src_prepare()]' |
738 |
+ 'configure[Configures the extracted sources by running the src_configure()]' |
739 |
+ 'compile[Compiles the extracted sources by running the src_compile()]' |
740 |
+ 'test[Runs package-specific test cases to verify that everything was built properly]' |
741 |
+ 'preinst[Run specific actions that need to be done before installation]' |
742 |
+ 'install[Installs the package to the temporary install directory]' |
743 |
+ 'postinst[Run specific actions that need to be done after installation]' |
744 |
+ 'qmerge[Installs the package de the filesystem]' |
745 |
+ 'merge[perform the following actions: fetch, unpack, compile, install and qmerge]' |
746 |
+ 'unmerge[Remove the installed files of the packages]' |
747 |
+ 'prerm[Run specific actions that need to be executed before unmerge]' |
748 |
+ 'postrm[Run specific actions that need to be executed after unmerge]' |
749 |
+ 'config[Run specific actions needed to be executed after the emerge process has completed]' |
750 |
+ 'package[This command is a lot like the merge command, but create a .tbz2 package]' |
751 |
+ 'manifest[Updates the manifest file for the package]' |
752 |
+ 'rpm[Builds a RedHat RPM package]' |
753 |
+ ) |
754 |
+ |
755 |
+ local curcontext="ebuild_cmd" |
756 |
+ zstyle -t ":completion:${curcontext}:values:values" sort || zstyle ":completion:${curcontext}:values:values" sort false |
757 |
+ _values -w "ebuild command" "$ebuild_cmds[@]" |
758 |
+ ;; |
759 |
+ esac |
760 |
} |
761 |
|
762 |
_quickpkg () { |
763 |
@@ -186,6 +204,8 @@ _emerge () { |
764 |
"(: $all[3,-1])--resume[Resumes the last merge operation]" |
765 |
"(: $all[3,-1])--skipfirst[Removes the first package in the resume list]" |
766 |
"($all)--keep-going[Continue merge even if a package fails to build]" |
767 |
+ "--with-bdeps=[pull in build time dependencies that are not strictly required]:yes/no:((y\:'yes' n\:'no'))" |
768 |
+ "--with-test-deps=[pull in dependencies that are conditional on the \"testUSE flag]:yes/no:((y\:'yes' n\:'no'))" |
769 |
) |
770 |
|
771 |
profiles=( |
772 |
@@ -235,11 +255,76 @@ _emerge () { |
773 |
} |
774 |
|
775 |
_emaint () { |
776 |
- _arguments -s \ |
777 |
+ local state |
778 |
+ local chk_opt fix_opt pretend_opt clean_opt purge_opt log_extra_opt repo_opt |
779 |
+ local sync_opt sync_extra_opt standalone_opt exclusive_cmd_opt repos |
780 |
+ local allcmd logcmd synccmd mergecmd fixcmds |
781 |
+ chk_opt=(-c --check) |
782 |
+ fix_opt=(-f --fix) |
783 |
+ pretend_opt=(-p --pretend) |
784 |
+ clean_opt=(-C --clean) |
785 |
+ purge_opt=(-P --purge) |
786 |
+ log_extra_opt=(-t --time) |
787 |
+ repo_opt=(-r --repo) |
788 |
+ sync_opt=(-a --auto -A --allrepos) |
789 |
+ sync_extra_opt=(--sync-submodule $repo_opt) |
790 |
+ |
791 |
+ standalone_opt=(-h --help --version) |
792 |
+ exclusive_cmd_opt=($chk_opt $fix_opt $sync_opt $purge_opt $pretend_opt $standalone_opt) |
793 |
+ repos=$(_gentoo_repos_conf -l) |
794 |
+ |
795 |
+ _arguments -C \ |
796 |
"(: -)"{-h,--help}'[show help message and exit]' \ |
797 |
+ "($sync_extra_opt $log_extra_opt $exclusive_cmd_opt $clean_opt)"{-f,--fix}"[Fix any problems that may exist]" \ |
798 |
"(: -)"--version"[show program's version number and exit]" \ |
799 |
- '(-c --check -f --fix)'{-c,--check}"[Check for any problems that may exist]:emaint:((all\:'check all' world\:'check only world file'))" \ |
800 |
- '(-c --check -f --fix)'{-f,--fix}"[Fix any problems that may exist]:emaint:((all\:'check all' world\:'check only world file'))" |
801 |
+ "($sync_extra_opt $exclusive_cmd_opt)"{-c,--check}"[check for any problems that may exist]" \ |
802 |
+ "($fix_opt $purge_opt $sync_opt $sync_extra_opt $standalone_opt -t --time)"{-t,--time}"[(cleanlogs only)changes the minimum age NUM (in days) of the logs to be listed or deleted]" \ |
803 |
+ "($sync_extra_opt $exclusive_cmd_opt)"{-p,--pretend}"[output logs that would be deleted (cleanlogs only)]" \ |
804 |
+ "($fix_opt $sync_opt $sync_extra_opt $purge_opt)"{-C,--clean}"[cleans the logs from \$PORT_LOGDIR (cleanlogs only)]" \ |
805 |
+ "($log_extra_opt $sync_extra_opt $exclusive_cmd_opt $clean_opt)"{-P,--purge}"[removes the list of previously failed merges (merges only)]" \ |
806 |
+ "($repo_opt $log_extra_opt $exclusive_cmd_opt $clean_opt)"{-a,--auto}"[sync repositories which have their auto-sync setting set (sync module only)]" \ |
807 |
+ "($chk_opt $fix_opt $purge_opt $pretend_opt $log_extra_opt $clean_opt $standalone_opt)*"{-r,--repo}"=[Sync the specified repo]:gentoo repo:($repos)" \ |
808 |
+ "($repo_opt $log_extra_opt $exclusive_cmd_opt $clean_opt)"{-A,--allrepos}"[Sync all repos that have a sync-url defined (sync module only)]" \ |
809 |
+ "($chk_opt $fix_opt $purge_opt $pretend_opt $log_extra_opt $clean_opt $standalone_opt)*--sync-submodule=[restrict sync to the specified submodule (sync module only)]:portage submodule:(glsa news profiles)" \ |
810 |
+ "1:emaint commands:->emaint_cmd" |
811 |
+ |
812 |
+ case $state in |
813 |
+ (emaint_cmd) |
814 |
+ local descr="emaint commands" |
815 |
+ |
816 |
+ local cmd=( |
817 |
+ 'all:perform all supported commands that accept the specified option' |
818 |
+ 'logs:clean out old logs from the $PORT_LOGDIR' |
819 |
+ 'sync:perform sync actions on specified repositories' |
820 |
+ 'merges:scan for failed package merges and attempt to fix those failed packages' |
821 |
+ 'binhost:generate a metadata index for binary packages located in $PKGDIR' |
822 |
+ 'cleanconfmem:discard no longer installed config tracker entries' |
823 |
+ 'cleanresume:discard merge lists saved for the emerge --resume action' |
824 |
+ 'movebin:perform package move updates for binary packages located in $PKGDIR' |
825 |
+ 'moveinst:perform package move updates for installed packages' |
826 |
+ 'world:fix problems in the world file' |
827 |
+ ) |
828 |
+ |
829 |
+ local -a remove |
830 |
+ if (( $words[(I)(-f|--fix)] )); then |
831 |
+ remove=(${cmd[(r)logs:*]} ${cmd[(r)sync:*}) |
832 |
+ elif (( $words[(I)(-c|--check)] )); then |
833 |
+ remove=(${cmd[(r)sync:*]}) |
834 |
+ elif (( $words[(I)(-p|--pretend|-C|--clean|-t|--time)] )); then |
835 |
+ cmd=(${cmd[(r)logs:*]}) |
836 |
+ elif (( $words[(I)(-a|--auto|-A|--allrepos|-r=*|--repo=*|-r|--repo|--sync-submodule|--sync-submodule=*)] )); then |
837 |
+ cmd=(${cmd[(r)sync:*]}) |
838 |
+ elif (( $words[(I)(--purge|-P)] )); then |
839 |
+ cmd=(${cmd[(r)merges:*]}) |
840 |
+ else |
841 |
+ remove=(${cmd[(r)sync:*]}) |
842 |
+ fi |
843 |
+ |
844 |
+ cmd=(${cmd:|remove}) |
845 |
+ _describe $descr cmd |
846 |
+ |
847 |
+ ;; |
848 |
+ esac |
849 |
} |
850 |
|
851 |
_env-update () { |
852 |
|
853 |
diff --git a/src/_portage_utils b/src/_portage_utils |
854 |
index 4c41e16..9077f30 100644 |
855 |
--- a/src/_portage_utils |
856 |
+++ b/src/_portage_utils |
857 |
@@ -98,7 +98,7 @@ case $service in |
858 |
{'(--repo)-R','(-R)--repo'}'[Display installed packages with repository]' \ |
859 |
{'(--umap)-U','(-U)--umap'}'[Display installed packages with flags used]' \ |
860 |
{'(--columns)-c','(-c)--columns'}'[Display column view]' \ |
861 |
- '--show-debug[Show /usr/lib/debug files]' \ |
862 |
+ '--show-debug[Show debug files]' \ |
863 |
{'(--exact)-e','(-e)--exact'}'[Exact match (only CAT/PN or PN without PV)]' \ |
864 |
{'(--all)-a','(-a)--all'}'[Show every installed package]' \ |
865 |
{'(--dir)-d','(-d)--dir'}'[Only show directories]' \ |
866 |
@@ -115,7 +115,7 @@ case $service in |
867 |
{'(--unlist)-u','(-u)--unlist'}'[Show unmerge history]' \ |
868 |
{'(--sync)-s','(-s)--sync'}'[Show sync history]' \ |
869 |
{'(--current)-c','(-c)--current'}'[Show current emerging packages]' \ |
870 |
- {'(--logfile)-f','(-f)--logfile'}'[Read emerge logfile instead of /var/log/emerge.log]:log:_files' \ |
871 |
+ {'(--logfile)-f','(-f)--logfile'}'[Read emerge logfile instead of $EMERGE_LOG_DIR/emerge.log]:log:_files' \ |
872 |
'*:packages:_gentoo_packages available' |
873 |
;; |
874 |
qsearch) |