blob: c91226582f37f42885fc8169270d4e3c568a66a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
# bash completion for urpmi and friends
# Copyright (c) 2002-2006 Guillaume Rousse <guillomovitch@mandriva.com>
# $Id: urpmi.bash-completion 266536 2010-02-26 21:07:37Z guillomovitch $
common_options="-q --quiet -v --verbose --debug -h --help --urpmi-root --wait-lock"
# utility functions
_urpmi_get_medias()
{
medias=( $( urpmq --list-media $1 2>/dev/null \
| sed -e 's/(/\\(/g' -e 's/)/\\)/g' -e 's/ /\\ /g' ) )
}
_urpmi_medias()
{
local medias IFS=$'\t\n'
# get medias list
_urpmi_get_medias all
# return matching ones
COMPREPLY=( $( compgen -W '${medias[@]}' -- $cur ) )
}
_urpmi_aliases()
{
# return list of available aliases
COMPREPLY=( $( awk -F: '{print $1}' /etc/urpmi/parallel.cfg 2>/dev/null \
| grep "^${cur//\\\\/}" ) )
}
_urpmi_packages()
{
local options
# find media selection options
for (( i=1; i < COMP_CWORD; i++ )); do
case "${COMP_WORDS[i]}" in
--@\(excludemedia|media\))
options="$options ${COMP_WORDS[i]} ${COMP_WORDS[i+1]}"
i=$(($i+1))
;;
--update)
options="$options ${COMP_WORDS[i]}"
;;
esac
done
COMPREPLY=( $( compgen -W "$(urpmq $options --list | grep ^$cur )" -- ) )
}
# urpmi completion
#
_urpmi()
{
local cur prev options
COMPREPLY=()
cur=`_get_cword`
prev=`_get_pword`
case "$prev" in
--media)
_urpmi_medias
return 0
;;
--excludemedia)
_urpmi_medias
return 0
;;
--sortmedia)
_urpmi_medias
return 0
;;
--searchmedia)
_urpmi_medias
return 0
;;
--parallel)
_urpmi_aliases
return 0
;;
--root|--urpmi-root)
_filedir -d
return 0
;;
esac
if [[ "$cur" == -* ]]; then
# return list of available options
options="$common_options -a -p -P -y --update --media --excludemedia \
--sortmedia --synthesis --auto --auto-select --no-uninstall \
--split-level --split-length --fuzzy --buildrequires --install-src \
--clean --noclean --parallel --wget --prozilla --curl --limit-rate \
--proxy --proxy-user --bug --no-verify-rpm --no-install --test \
--excludepath --excludedocs --searchmedia --ignoresize \
--ignorearch --strict-arch --wget-options --curl-options \
--prozilla-options --rsync-options --resume --retry --skip \
--prefer --nolock --more-choices --downgrade"
# add dangereous option for everything else as rurpmi
if [[ ${COMP_WORDS[0]} != *rurpmi ]]; then
options="$options --root --use-distrib --env --auto-orphans \
--replacepkgs --justdb --allow-nodeps --allow-force \
--no-suggests --force --noscripts --auto-update --keep \
--nokeep --replacefiles --verify-rpm"
for (( i=1; i < COMP_CWORD; i++ )); do
case ${COMP_WORDS[i]} in
----auto-update)
options="$options --no-md5sum \
--force-key"
;;
esac
done
fi
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
else
if [[ ${COMP_WORDS[0]} == *rurpmi ]]; then
# return available packages only
_urpmi_packages
else
# return available packages (unless clearly a file)
# and rpm files
if [[ "$cur" != */* ]]; then
_urpmi_packages
fi
_filedir '@(rpm|spec)'
fi
fi
}
complete -F _urpmi $filenames urpmi gurpmi rurpmi
# urpmq completion
#
_urpmq()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
--media)
_urpmi_medias
return 0
;;
--excludemedia)
_urpmi_medias
return 0
;;
--sortmedia)
_urpmi_medias
return 0
;;
--parallel)
_urpmi_nodes
return 0
;;
--list-media)
COMPREPLY=( $( compgen -W 'all update active' -- $cur))
return 0
;;
esac
if [[ "$cur" == -* ]]; then
# return list of available options
COMPREPLY=( $( compgen -W "$common_options -d -u -m -a -c -y -s -i -g \
-p -r -f -l --update --media --excludemedia --sortmedia \
--synthesis --auto-select --auto-orphans --not-available \
--no-suggests --fuzzy \
--keep --nokeep --list --list-url --list-media --list-nodes \
--list-aliases --src --sources --provides --requires --obsoletes \
--suggests --summary --sourcerpm --force --parallel --wget --curl \
--prozilla --changelog --conflicts --proxy --proxy-user --env \
--dump-config --whatprovides --whatrequires \
--whatrequires-recursive --skip --prefer --use-distrib \
--searchmedia --ignorearch" -- $cur))
else
# return rpm files (can't list available packages anymore)
_filedir rpm
fi
}
complete -F _urpmq urpmq
# urpme completion
#
_urpme()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
if [[ "$cur" == -* ]]; then
# return list of available options
COMPREPLY=( $( compgen -W "$common_options -a --auto --test \
--auto-orphans --parallel --justdb --noscripts" -- $cur ) )
else
# return list of available packages
_xfunc rpm _rpm_installed_packages
fi
}
complete -F _urpme urpme
# urpmf completion
#
_urpmf()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
--media)
_urpmi_medias
return 0
;;
--excludemedia)
_urpmi_medias
return 0
;;
--sortmedia)
_urpmi_medias
return 0
;;
esac
if [[ "$cur" == -* ]]; then
# return list of available options
COMPREPLY=( $( compgen -W "$common_options -i -f -e -a -o -m --update \
--media --excludemedia --sortmedia --synthesis --use-distrib \
--uniq --name --group --license --size --epoch --summary \
--description --sourcerpm --packager--buildhost --url --provides \
--requires --suggests --files --conflicts --obsoletes --env" \
-- $cur ) )
else
# return available files
_filedir
fi
}
complete -F _urpmf urpmf
# urpmi.update completion
#
_urpmi_update()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
if [[ "$cur" == -* ]]; then
# return list of available options
COMPREPLY=( $( compgen -W "$common_options -a -f --wget --prozilla \
--curl --limit-rate --proxy --proxy-user --update --ignore \
--no-ignore --no-md5sum --force-key --norebuild" -- $cur))
else
# return list of available media
_urpmi_medias
fi
}
complete -F _urpmi_update urpmi.update
# urpmi.addmedia completion
#
_urpmi_addmedia()
{
local cur i args
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
if [[ "$cur" == -* ]]; then
# return list of available options
COMPREPLY=( $( compgen -W "$common_options -f --wget --curl --prozilla \
--limit-rate --proxy --proxy-user --update --raw \
--probe-synthesis --probe-hdlist --probe-rpms --no-probe --distrib \
--env --version --arch --virtual --norebuild --nopubkey" -- $cur ) )
else
# count number of mandatory args given sofar
args=$COMP_CWORD
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == -* ]]; then
args=$(($args-1))
fi
done
case $args in
1)
# return list of available media
_urpmi_medias
;;
2)
# return list of available protocols
COMPREPLY=( $( compgen -W 'file:// http:// \
ftp:// removable:// ssh:// \
rsync://' -- $cur ) )
;;
3)
# return word "with"
COMPREPLY=( 'with' )
;;
esac
fi
}
complete -F _urpmi_addmedia urpmi.addmedia
# urpmi.removemedia completion
#
_urpmi_removemedia()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
if [[ "$cur" == -* ]]; then
# if word begins with a dash, return list of available options
COMPREPLY=( $( compgen -W "$common_options -a -y" -- $cur ) )
else
# elsewhere, return list of available media
_urpmi_medias
fi
}
complete -F _urpmi_removemedia urpmi.removemedia
|