1 |
commit: 518f11eedce64dc3aa0e494c50755b886ca44a40 |
2 |
Author: Vadim A. Misbakh-Soloviov <mva <AT> mva <DOT> name> |
3 |
AuthorDate: Sat Aug 30 10:17:27 2014 +0000 |
4 |
Commit: Vadim A. Misbakh-Soloviov <mva <AT> mva <DOT> name> |
5 |
CommitDate: Sat Aug 30 10:17:27 2014 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/zsh-completion.git;a=commit;h=518f11ee |
7 |
|
8 |
_gentoo_packages, _portage: reworked sets completion, added portage options |
9 |
|
10 |
Signed-off-by: Vadim A. Misbakh-Soloviov <mva <AT> mva.name> |
11 |
|
12 |
--- |
13 |
_gentoo_packages | 38 +++++++++++-------------- |
14 |
_portage | 86 ++++++++++++++++++++++++++++++++++++++++++++++---------- |
15 |
2 files changed, 87 insertions(+), 37 deletions(-) |
16 |
|
17 |
diff --git a/_gentoo_packages b/_gentoo_packages |
18 |
index e770181..9a747b7 100644 |
19 |
--- a/_gentoo_packages |
20 |
+++ b/_gentoo_packages |
21 |
@@ -133,15 +133,15 @@ _parsesetsconf() { |
22 |
fi |
23 |
} |
24 |
|
25 |
-_get_installed_sets() { |
26 |
+_gentoo_packages_update_installed_sets() { |
27 |
local sets; |
28 |
sets=($(</var/lib/portage/world_sets)); |
29 |
if [[ ((${#sets} > 0)) ]]; then |
30 |
- echo "${(o@)^sets}" |
31 |
+ _wanted installed_sets expl 'installed set' compadd "$@" "${(o@)^sets}" |
32 |
fi |
33 |
} |
34 |
|
35 |
-_get_available_sets() { |
36 |
+_gentoo_packages_update_available_sets() { |
37 |
trees=($(_portdir -o) /etc/portage /usr/share/portage/config) |
38 |
for PORTDIR in ${(@)trees}; do |
39 |
if [[ -d ${PORTDIR} ]]; then |
40 |
@@ -157,7 +157,7 @@ _get_available_sets() { |
41 |
fi |
42 |
done |
43 |
if [[ ((${#sets} > 0)) ]]; then |
44 |
- echo "@${(o@)^sets}" |
45 |
+ _wanted available_sets expl 'available set' compadd "$@" "@${(o@)^sets}" |
46 |
fi |
47 |
} |
48 |
|
49 |
@@ -201,9 +201,6 @@ _gentoo_packages_update_installed(){ |
50 |
installed_dir="/var/db/pkg" |
51 |
installed_portage=($installed_dir/*-*/*) |
52 |
|
53 |
- installed_sets=($(_get_installed_sets)) |
54 |
- _wanted installed_sets expl 'installed set' compadd "$@" "${(o@)^installed_sets}" |
55 |
- |
56 |
installed_pkgname=(${${installed_portage:t}%%-[0-9]*}) |
57 |
_wanted packages expl 'package' compadd "$@" ${installed_pkgname} |
58 |
|
59 |
@@ -224,22 +221,19 @@ _gentoo_packages_update_installed_versions(){ |
60 |
_gentoo_packages_update_available_pkgnames_only(){ |
61 |
local trees packages |
62 |
|
63 |
- trees=( $(_portdir) $(_portdir -o) ) |
64 |
+ trees=($(_portdir) $(_portdir -o)) |
65 |
|
66 |
- packages=( $trees/*-*/*(:t) ) |
67 |
+ packages=($trees/*-*/*(:t)) |
68 |
_wanted packages expl 'package' compadd - "${(@)packages}" |
69 |
} |
70 |
|
71 |
_gentoo_packages_update_available(){ |
72 |
local trees category packages pkg expl |
73 |
|
74 |
- trees=( $(_portdir) $(_portdir -o) ) |
75 |
- category=( $trees/*-*(/:t) ) |
76 |
- |
77 |
- available_sets=( $(_get_available_sets) ) |
78 |
- _wanted available_sets expl 'available sets' compadd "${@}" "${(@)available_sets}" |
79 |
+ trees=($(_portdir) $(_portdir -o)) |
80 |
+ category=($trees/*-*(/:t)) |
81 |
|
82 |
- packages=( $trees/*-*/*(:t) ) |
83 |
+ packages=($trees/*-*/*(:t)) |
84 |
_wanted packages expl 'package' compadd - "${(@)packages}" |
85 |
|
86 |
# Complete cat/pkg. _multi_parts is much to slow for such a large task, |
87 |
@@ -250,7 +244,7 @@ _gentoo_packages_update_available(){ |
88 |
_wanted cat_packages expl 'category/package' compadd -S '/' $category |
89 |
else |
90 |
compset -P '*/' |
91 |
- pkg=( $trees/$IPREFIX/*(:t) ) |
92 |
+ pkg=($trees/$IPREFIX/*(:t)) |
93 |
_wanted cat_packages expl 'category/package' compadd $pkg |
94 |
fi |
95 |
} |
96 |
@@ -261,14 +255,14 @@ _gentoo_packages_update_available_versions(){ |
97 |
PORTDIR=$(_portdir) |
98 |
PORTDIR_OVERLAY=$(_portdir -o); |
99 |
|
100 |
- trees=( $PORTDIR $=PORTDIR_OVERLAY ) |
101 |
- category=( $trees/*-*(/:t) ) |
102 |
+ trees=($PORTDIR $=PORTDIR_OVERLAY) |
103 |
+ category=($trees/*-*(/:t)) |
104 |
typeset -U category |
105 |
|
106 |
- if [[ $#PREFIX -ge 1 && -z $words[(r)(--inject|-i)] ]] ; then |
107 |
+ if [[ $#PREFIX -ge 1 && -z $words[(r)(--inject|-i)] ]] ; then |
108 |
overlay_ebuilds=($=PORTDIR_OVERLAY/*-*/${PREFIX%%-[0-9]#*}*/*.ebuild(:t:r) ) |
109 |
portage_ebuilds=($PORTDIR/metadata/cache/*-*/${PREFIX%%-[0-9]#*}*(:t)) |
110 |
- _wanted packages expl 'package' compadd $portage_ebuilds $overlay_ebuilds |
111 |
+ _wanted packages expl 'package' compadd $portage_ebuilds $overlay_ebuilds |
112 |
fi |
113 |
pkg=( $trees/${PREFIX%%/*}/*/*.ebuild(:t:r) ) |
114 |
_wanted cat_packages expl 'category/package' _sep_parts category / pkg |
115 |
@@ -294,11 +288,11 @@ _gentoo_packages () { |
116 |
if [[ -z "$update_policy" ]]; then |
117 |
zstyle ":completion:*:*:$service:*" cache-policy _gentoo_cache_policy |
118 |
fi |
119 |
- [[ "$command" == (installed(_versions|)|available(_versions|)|binary|category|(active_|)useflag|available_pkgnames_only) ]] || { |
120 |
+ [[ "$command" == (installed(_versions|_sets|)|available(_versions|_sets|_pkgnames_only|)|binary|category|(active_|)useflag) ]] || { |
121 |
_message "unknown command: $command" |
122 |
return |
123 |
} |
124 |
- [[ "$pkgset" == (installed(_versions|)|available(_versions|)|binary|category|(active_|)useflag|available_pkgnames_only) ]] || { |
125 |
+ [[ "$pkgset" == (installed(_versions|_sets|)|available(_versions|_sets|_pkgnames_only|)|binary|category|(active_|)useflag) ]] || { |
126 |
pkgset="$command" |
127 |
} |
128 |
expl=("${(@)argv[1,-2]}") |
129 |
|
130 |
diff --git a/_portage b/_portage |
131 |
index e241357..57fc0a5 100644 |
132 |
--- a/_portage |
133 |
+++ b/_portage |
134 |
@@ -60,21 +60,21 @@ _quickpkg () { |
135 |
# Stuff for emerge |
136 |
|
137 |
_emerge () { |
138 |
- local nopkg_opts all noask_opts bopts install_args common_args profiles |
139 |
+ local nopkg_opts all noask_opts bopts install_args common_args profiles |
140 |
|
141 |
noask_opts=(-p -a --pretend --ask --regen --info --search -s --searchdesc \ |
142 |
- -S --version -V --help -h --metadata) |
143 |
+ -S --version -V --help -h --metadata --check-news) |
144 |
|
145 |
nopkg_opts=(--resume --skipfirst -c --clean -h --help --depclean --info \ |
146 |
--metadata -P --prune --regen -s --search -S --searchdesc --sync -C \ |
147 |
- --unmerge -V --version -i --inject) |
148 |
+ --unmerge -V --version -i --inject --list-sets --deselect --check-news) |
149 |
|
150 |
bopts=($nopkg_opts -b --buildpkg -B --buildpkgonly -G --getbinpkgonly -g \ |
151 |
--getbinpkg -k --usepkg -K --usepkgonly --fetch-all-uri -f -F --fetchonly) |
152 |
|
153 |
all=($bopts -l --changelog --columns --deep -D --emptytree -e --newuse \ |
154 |
--noconfmem --nodeps -O --noreplace -n --oneshot -1 -o --onlydeps --tree -t \ |
155 |
- -u --update -U --upgradeonly) |
156 |
+ -u --update -U --upgradeonly --config) |
157 |
|
158 |
common_args=( |
159 |
"($noask_opts --sync)"{-p,--pretend}"[Simply display what would be done]" |
160 |
@@ -83,15 +83,73 @@ _emerge () { |
161 |
'(--quiet -q --verbose -v)'{-q,--quiet}'[General outcome is a reduced or condensed output]' |
162 |
'(--verbose -v --quiet -q)'{-v,--verbose}'[Tell emerge to run in verbose mode]' |
163 |
'--nospinner[Disables the spinner for the session]' |
164 |
- #'--deselect[--deselect=n Remove atom from world file]' |
165 |
- '--deselect=[Remove atom from world file]' |
166 |
+ '(: -)'{-h,--help}'[Displays help]' |
167 |
+ "(: -)--config[Run package specific actions needed to be executed after the emerge process has completed]:installed atom:_gentoo_packages installed" |
168 |
+ "(: -)--list-sets[Displays a list of available package sets]" |
169 |
+ "--color=[Color output]:yes/no:((y\:'yes' n\:'no'))" |
170 |
+ "--accept-properties=[Temporarily override the ACCEPT_PROPERTIES variable]" |
171 |
+ "--accept-restrict=[Temporarily override the ACCEPT_RESTRICT variable]" |
172 |
+ "($noask_opts)"{-A,--alert=}"[Add a terminal bell to all interactive prompts]:yes/no:((y\:'yes' n\:'no'))" |
173 |
+ "--ignore-default-opts[Ignore EMERGE_DEFAULT_OPTS]" |
174 |
+ "--moo[Have you mooed today?]" |
175 |
) |
176 |
install_args=( |
177 |
- "($bopts)"{-b,--buildpkg}"[Tells emerge to build binary packages]" |
178 |
+ '--deselect=[Remove atom from world file]:yes/no:((y\:'yes' n\:'no'))' |
179 |
+ "--alphabetical[Sort use/other flags output alphabetically despite of status]" |
180 |
+ "--ask-enter-invalid[When with --ask, interpret a single 'Enter' key press as invalid input]" |
181 |
+ "--autounmask[Automatically unmask packages and generate package.use]:yes/no:((y\:'yes' n\:'no'))" |
182 |
+ "--autounmask-unrestricted-atoms[Use >= for autounmask if possible]:yes/no:((y\:'yes' n\:'no'))" |
183 |
+ "--autounmask-keep-masks[Don't unmask hardmasks and unkeyworded (live)]:yes/no:((y\:'yes' n\:'no'))" |
184 |
+ "--autounmask-write[Automatically write autounmask changes (respect CONFIG_PROTECT)]:yes/no:((y\:'yes' n\:'no'))" |
185 |
+ "--backtrack=[Number of times to backtrack if dependency calculation fails]:number:(0 10 30)" |
186 |
+ "--binpkg-respect-use=[Ignore binary packages if their uses don't match current config]:yes/no:((y\:'yes' n\:'no'))" |
187 |
+ "--complete-graph=[Consider the deep dependencies of all packages from the world set]:yes/no:((y\:'yes' n\:'no'))" |
188 |
+ "--complete-graph-if-new-use=[--complete-graph if USE or IUSE will change for an installed package]:yes/no:((y\:'yes' n\:'no'))" |
189 |
+ "--complete-graph-if-new-ver=[--complete-graph if an installed package version will change]:yes/no:((y\:'yes' n\:'no'))" |
190 |
+ "--config-root=[Set PORTAGE_CONFIGROOT variable]:root path:_files -/" |
191 |
+ "--depclean-lib-check=[Check library link-level dependencies]:yes/no:((y\:'yes' n\:'no'))" |
192 |
+ "--digest[Prevent corruption from being noticed]" |
193 |
+ "--dynamic-deps=[Substitute the dependencies of installed packages with the dependencies of corresponding unbuilt ebuilds]:yes/no:((y\:'yes' n\:'no'))" |
194 |
+ "--fail-clean=[Clean up temporary files after a build failure]:yes/no:((y\:'yes' n\:'no'))" |
195 |
+ "--ignore-built-slot-operator-deps=[Ignore the slot/sub-slot dependencies for built pkg]:yes/no:((y\:'yes' n\:'no'))" |
196 |
+ "(: $nopkg_opts)"{-j,--jobs=}"[Number of packages to build simultaneously]:jobs:({1.."${#${$(</proc/cpuinfo)/^processor}}"})" |
197 |
+ "--keep-going[Continue as much as possible after an error]:yes/no:((y\:'yes' n\:'no'))" |
198 |
+ "--load-average[No new builds should be started if there are other builds running and the load average is at least VALUE]" |
199 |
+ "--misspell-suggestions[Enable or disable misspell suggestions]:yes/no:((y\:'yes' n\:'no'))" |
200 |
+ "--newrepo[Recompile a package if it is now being pulled from a different repository]" |
201 |
+ "--usepkg-exclude[Ignore matching binary packages]:installed atom:_gentoo_packages installed" |
202 |
+ "--rebuild-exclude[Do not rebuild matching packages on --rebuild]:installed atom:_gentoo_packages installed" |
203 |
+ "--rebuild-ignore[Do not rebuild packages that depend on matching packages on --rebuild]:installed atom:_gentoo_packages installed" |
204 |
+ "--package-moves[Perform package moves when necessary]:yes/no:((y\:'yes' n\:'no'))" |
205 |
+ "--pkg-format[Binary package format]:archive type:(tar rpm)" |
206 |
+ "--prefix=[Set EPREFIX env variable]:prefix path:_files -/" |
207 |
+ "--quiet-build=[Redirect all build output to logs]:yes/no:((y\:'yes' n\:'no'))" |
208 |
+ "--quiet-fail=[Suppresses display of the build log on stdout]:yes/no:((y\:'yes' n\:'no'))" |
209 |
+ "--quiet-repo-display[Suppress ::repository in output (and use numbers)]" |
210 |
+ "--quiet-unmerge-warn[Disable the warning message on --unmerge and friends]" |
211 |
+ "--rebuild-if-new-slot[Automatically rebuild or reinstall packages when dependencies can be satisfied by a newer slot]:yes/no:((y\:'yes' n\:'no'))" |
212 |
+ "--rebuild-if-new-rev[Rebuild packages when build-time dependencies are built from source, if the dependency is not already installed with the same version and revision]:yes/no:((y\:'yes' n\:'no'))" |
213 |
+ "--rebuild-if-new-ver[Rebuild packages when build-time dependencies are built from source, if the dependency is not already installed with the same version]:yes/no:((y\:'yes' n\:'no'))" |
214 |
+ "--rebuild-if-unbuilt[Rebuild packages when build-time dependencies are built from source]:yes/no:((y\:'yes' n\:'no'))" |
215 |
+ "--rebuilt-binaries[Replace installed packages with binary packages that have been rebuilt]:yes/no:((y\:'yes' n\:'no'))" |
216 |
+ "--rebuilt-binaries-timestamp[Only binaries older than TIMESTAMP will be considered by the rebuilt-binaries logic]:TIMESTAMP" |
217 |
+ "--reinstall[Alias for --changed-use (currently)]:reinstall opts:(changes-use)" |
218 |
+ "--reinstall-atoms[Treat matching packages as if they are not installed]:installed atoms:_gentoo_packages installed" |
219 |
+ "--root=[Set ROOT env variable]:prefix path:_files -/" |
220 |
+ "(: $nopkg_opts)"{-w,--select=}"[Add specified packages to the world set (inverse of --oneshot)]:yes/no:((y\:'yes' n\:'no'))" |
221 |
+ "--selective=[Use --selective=n if you want to forcefully disable --selective, regardless of options like --changed-use, --newuse, --noreplace, or --update]:yes/no:((y\:'yes' n\:'no'))" |
222 |
+ "--unordered-display[Produce more readable package tree with --tree]" |
223 |
+ "--use-ebuild-visibility[Use unbuilt ebuild metadata for visibility checks on built packages]:yes/no:((y\:'yes' n\:'no'))" |
224 |
+ "--useoldpkg-atoms[Prefer matching binary packages over newer unbuilt packages]:available atom:_gentoo_packages available" |
225 |
+ "($bopts)"{-b,--buildpkg=}"[Tells emerge to build binary packages]:(y n)" |
226 |
+ "($bopts)--buildpkg-exclude[Space separated list of package atoms for which no binary packages should be built]" |
227 |
+ "($bopts)--exclude[Space separated list of package names or slot atoms which should not be installed]" |
228 |
"($bopts)"{-B,--buildpkgonly}"[Tells emerge to only build binary packages]" |
229 |
"($nopkg_opts --emptytree -e -l --changelog --usepkgonly -K)"{-l,--changelog}"[This will show the ChangeLog]" |
230 |
"($nopkg_opts -t --tree)--columns[Displays versions in aligned format]" |
231 |
- "($nopkg_opts -D --deep)"{-D,--deep}"[Consider the entire dependency tree of packages]" |
232 |
+ "($nopkg_opts -D --deep --newuse -N --changed-use)"{-D,--deep}"[Consider the entire dependency tree of packages]" |
233 |
+ "($nopkg_opts -D --deep --newuse -N --changed-use)"{-N,--newuse}"[Include installed packages where any USE flags have changed since compilation.]" |
234 |
+ "($nopkg_opts -D --deep --newuse -N --changed-use)--changed-use[Include installed packages where enabled USE flags have changed since installation]" |
235 |
"($nopkg_opts -e -l --changelog --emptytree)"{-e,--emptytree}"[Only consider glibc as installed packages]" |
236 |
"($all --nospinner --pretend -p)"{-i,--inject}"[Portage thinks that this package is installed]" |
237 |
"($nopkg_opts $bopts)"{-f,--fetchonly}"[Just perform fetches for all packages]" |
238 |
@@ -108,9 +166,8 @@ _emerge () { |
239 |
"($nopkg_opts --upgradeonly -U)"{-U,--upgradeonly}"[Do not update packages to a lower version]" |
240 |
"($bopts)"{-k,--usepkg}"[Tells emerge to use binary packages if available]" |
241 |
"($bopts --changelog -l)"{-K,--usepkgonly}"[Tells emerge to use binary packages only]" |
242 |
- "($all)"{-c,--clean}"[Cleans the system by removing packages]" |
243 |
- '(: -)'{-h,--help}'[Displays help]:subject:(sync config system)' |
244 |
- "(: $all)--depclean[Clean all packages that have no reason for being installed]" |
245 |
+ "($all)--clean[Cleans the system by removing packages]" |
246 |
+ "(: $all)"{-c,--depclean}"[Clean all packages that have no reason for being installed (see man!!!)]" |
247 |
"(: $all $noask_opts --nospinner --quiet -q)--info[This is a list of information to include in bug reports]" |
248 |
"(: -)--metadata[Generate metadata]" |
249 |
"($nopkg_opts --usepkgonly -K)--newuse[Include installed packages which have changed USE flags]" |
250 |
@@ -119,6 +176,7 @@ _emerge () { |
251 |
"(: $all $noask_opts --verbose -v)"{-s,--search}"[Searches for matches]" |
252 |
"(: $all $noask_opts --verbose -v)"{-S,--searchdesc}"[Matches the seachdesc string against the description field]" |
253 |
"(: $all --pretend -p)--sync[Initiates a portage tree update]" |
254 |
+ "(: $all --pretend -p)--check-news[Scan all repositories for relevant unread GLEP 42 news items]" |
255 |
"($all)"{-C,--unmerge}"[Removes all matching packages]" |
256 |
'(: -)'{-V,--version}'[Display version info]' |
257 |
"(: $all[3,-1])--resume[Resumes the last merge operation]" |
258 |
@@ -139,6 +197,7 @@ _emerge () { |
259 |
_arguments -s \ |
260 |
"$common_args[@]" "$install_args[@]" \ |
261 |
"*:installed package:_gentoo_packages installed" \ |
262 |
+ "::installed sets:_gentoo_packages installed_sets" \ |
263 |
&& return 0 |
264 |
fi |
265 |
|
266 |
@@ -152,14 +211,10 @@ _emerge () { |
267 |
"$common_args[@]" "$install_args[@]" \ |
268 |
'*:binary package:_gentoo_packages binary' && return 0 |
269 |
|
270 |
- elif [[ $words[-3] == (--help|-h) ]] ; then |
271 |
- _message "No more arguments" && return 0 |
272 |
- |
273 |
else |
274 |
if compset -P '(\\|)(>=|<=|<|>|=)'; then |
275 |
_arguments \ |
276 |
"*:portage:_gentoo_packages available_versions" && return 0 |
277 |
- |
278 |
elif (( $words[(I)(--inject|-i)] )) ; then |
279 |
_arguments -s \ |
280 |
"$common_args[@]" "$install_args[@]" \ |
281 |
@@ -169,6 +224,7 @@ _emerge () { |
282 |
"$common_args[@]" "$install_args[@]" \ |
283 |
"($nopkg_opts)::portage: _values 'profile' \$profiles[@] " \ |
284 |
"($nopkg_opts)*:portage:_gentoo_packages available" \ |
285 |
+ "($nopkg_opts)::available sets:_gentoo_packages available_sets" \ |
286 |
&& return 0 |
287 |
fi |
288 |
fi |