1#compdef apt-get apt-cache apt-cdrom apt-config 2 3_apt () { 4 case "$service" in 5 apt-get) _apt-get "$@";; 6 apt-cache) _apt-cache "$@";; 7 apt-cdrom) _apt-cdrom "$@";; 8 apt-config) _apt-config "$@";; 9 *) _message "unknown command $service";; 10 esac 11} 12 13# usage: _apt_arguments funcname option-spec... -- rest-regex 14_apt_arguments () { 15 16 local funcname 17 funcname="$1" 18 shift 19 20 typeset -A canonicalize num_options 21 local short_hasarg short_bool short_intlevel short_configfile short_arbitem 22 local long_hasarg long_bool long_intlevel long_configfile long_arbitem 23 local short_release long_release 24 local comp_hasarg='' 25 local opt opts type 26 27 while [[ 0 -lt $# && $1 != -- ]]; do 28 opts="${1%%:*}" 29 type="${1#*:}" 30 31 case $type in 32 bool) num_options[$opts]=1;; 33 intlevel) num_options[$opts]=-1;; 34 configfile) num_options[$opts]=1;; 35 arbitem) num_options[$opts]=-1;; 36 release) num_options[$opts]=1;; 37 *) num_options[$opts]=1 38 comp_hasarg="${comp_hasarg}$opts) $type;;"$'\n' 39 type=hasarg;; 40 esac 41 42 for opt in ${(s:,:)=opts}; do 43 canonicalize[$opt]="$opts" 44 case $opt in 45 --*) eval "long_$type=(\$long_$type ${opt#--})";; 46 -?) eval "short_$type=(\$short_$type ${opt#-})";; 47 esac 48 done 49 shift 50 done 51 52 # skip -- 53 [[ 0 -lt $# ]] && shift 54 55 comp_hasarg="{case \$current_option in 56 ${comp_hasarg}esac}" 57 58 local short_seq false true bool bool_prefix intlevel word word1 nul qnul match 59 local comp_bool comp_intlevel comp_configfile comp_arbitem comp_long comp_opt 60 local comp_release comp_long_prefix comp_short 61 local regex_short regex_long regex_all regex_long_prefix 62 63 regex_all=( \( "$@" \) ) 64 65 short_seq="(${(j:|:)short_bool}|${(j:|:)short_intlevel})#" 66 67 false=(no false without off disable) 68 true=(yes true with on enable) 69 bool=($false $true) 70 71 bool_prefix=(--${^bool}-) 72 73 intlevel='[0-9]##' 74 75 word=$'[^\0]#\0' 76 word1=$'[^\0]##\0' 77 nul=$'\0' 78 qnul="\$'\\0'" 79 80 comp_bool="($bool)" 81 comp_intlevel= 82 comp_configfile='_files' 83 comp_arbitem= 84 comp_release='_apt_releases' 85 86 comp_short=\ 87'{if [[ $PREFIX = -'"$short_seq"' ]]; then 88 _apt_consume_short ${PREFIX[2,-1]} 89 tmp1=(${(M)${(s:,:)${(kj:,:)num_options[(R)*~0]}}:#-?}) 90 tmp2=(${PREFIX}${^tmp1#-}) 91 _describe -o option tmp1 tmp2 92elif [[ -z "$PREFIX" ]]; then 93 tmp1=(${(M)${(s:,:)${(kj:,:)num_options[(R)*~0]}}:#-?}) 94 _describe -o option tmp1 95fi}' 96 97 comp_long=\ 98'tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#--*}#--}}" 99tmp2=(--${(M)^long_bool:#$~tmp1} --${(M)^long_intlevel:#$~tmp1}) 100tmp3=(--${(M)^long_hasarg:#$~tmp1} --${(M)^long_configfile:#$~tmp1} --${(M)^long_arbitem:#$~tmp1} --${(M)^long_release:#$~tmp1}) 101_describe -o option tmp2 -- tmp3 -S= -- bool_prefix -S ""' 102 103 comp_long_prefix=\ 104'{tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#--*}#--}}" 105tmp2=($_ra_left${(M)^long_bool:#$~tmp1} $_ra_left${(M)^long_intlevel:#$~tmp1}) 106tmp3=($_ra_left${(M)^long_hasarg:#$~tmp1} $_ra_left${(M)^long_configfile:#$~tmp1} $_ra_left${(M)^long_arbitem:#$~tmp1} $_ra_left${(M)^long_release:#$~tmp1}) 107tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#-?}#-}}" 108tmp2=("$tmp2[@]" $_ra_left${(M)^short_bool:#$~tmp1} $_ra_left${(M)^short_intlevel:#$~tmp1}) 109tmp3=("$tmp3[@]" $_ra_left${(M)^short_hasarg:#$~tmp1} $_ra_left${(M)^short_configfile:#$~tmp1} $_ra_left${(M)^short_arbitem:#$~tmp1} $_ra_left${(M)^short_release:#$~tmp1}) 110_describe -o option tmp2 -- tmp3 -S=}' 111 112 comp_opt='{{ ! zstyle -T ":completion:${curcontext}:options" prefix-needed || [[ "$PREFIX" = -* ]] }'" && { $comp_short; $comp_long }}" 113 comp_short="{$comp_short}" 114 comp_long="{$comp_long}" 115 116 regex_short=() 117 regex_long=() 118 regex_long_prefix=() 119 120 if (( $#short_hasarg )); then 121 regex_short=("$regex_short[@]" 122 /"$short_seq(${(j:|:)short_hasarg})(=|)"/ 123 -'_apt_consume_short ${match[1]%=}; current_option=${canonicalize[-${${match[1]%=}[-1]}]}' 124 \( /"$word1"/ ":options:option:$comp_hasarg" \| /"$nul"/ /"$word"/ ":options:option:$comp_hasarg" \) \| 125 ) 126 regex_long_prefix=("$regex_long_prefix[@]" 127 /"(${(j:|:)short_hasarg})$nul"/ 128 -'_apt_consume_short ${match[1][-2]}; current_option=${canonicalize[-${${match[1]%'$qnul'}[-1]}]}' 129 /"$word"/ ":options:option:$comp_hasarg" \| 130 /"(${(j:|:)short_hasarg})="/ 131 -'_apt_consume_short ${match[1][-2]}; current_option=${canonicalize[-${${match[1]%=}[-1]}]}' 132 \( /"$word1"/ ":options:option:$comp_hasarg" \| /"$nul"/ /"$word"/ ":options:option:$comp_hasarg" \) \| 133 ) 134 fi 135 136 if (( $#short_bool )); then 137 regex_short=("$regex_short[@]" 138 /"$short_seq(${(j:|:)short_bool})($nul(${(j:|:)bool})|(${(j:|:)bool})|)$nul"/ 139 -'_apt_consume_short ${match[1]%%('$qnul'('${(j:|:)bool}')|('${(j:|:)bool}')|)'$qnul'}' \| 140 /"$short_seq(${(j:|:)short_bool})="/ 141 -'_apt_consume_short ${match[1]%=}' 142 \( /"$word1"/ ":names:boolean value:$comp_bool" \| /"$nul"/ /"$word"/ ":names:boolean value:$comp_bool" \) \| 143 ) 144 regex_long_prefix=("$regex_long_prefix[@]" 145 /"(${(j:|:)short_bool})="/ 146 -'_apt_consume_short ${match[1][-2]}' 147 \( /"$word1"/ ":names:boolean value:$comp_bool" \| /"$nul"/ /"$word"/ ":names:boolean value:$comp_bool" \) \| 148 /"(${(j:|:)short_bool})$nul"/ 149 -'_apt_consume_short ${match[1][-2]}' 150 /"((${(j:|:)bool})$nul|)"/ ":names:boolean value:$comp_bool" \| 151 ) 152 fi 153 154 if (( $#short_intlevel )); then 155 regex_short=("$regex_short[@]" 156 /"$short_seq(${(j:|:)short_intlevel})($nul$intlevel|$intlevel|)$nul"/ 157 -'_apt_consume_short ${match[1]%%'"($qnul$intlevel|$intlevel|)$qnul"'}' \| 158 /"$short_seq(${(j:|:)short_intlevel})="/ 159 -'_apt_consume_short ${match[1]%=}' 160 \( /"$word1"/ ":options:option:$comp_intlevel" \| /"$nul"/ /"$word"/ ":options:option:$comp_intlevel" \) \| 161 ) 162 regex_long_prefix=("$regex_long_prefix[@]" 163 /"(${(j:|:)short_intlevel})="/ 164 -'_apt_consume_short ${match[1][-2]}' 165 \( /"$word1"/ ":options:option:$comp_intlevel" \| /"$nul"/ /"$word"/ ":options:option:$comp_intlevel" \) \| 166 /"(${(j:|:)short_intlevel})$nul"/ 167 -'_apt_consume_short ${match[1][-2]}' 168 /"($intlevel$nul|)"/ ":options:option:$comp_intlevel" \| 169 ) 170 fi 171 172 if (( $#short_configfile )); then 173 regex_short=("$regex_short[@]" 174 /"$short_seq(${(j:|:)short_configfile})(=|)"/ 175 -'_apt_consume_short ${match[1]%=}' 176 \( /"$word1"/ ":files:config file:$comp_configfile" \| /"$nul"/ /"$word"/ ":files:config file:$comp_configfile" \) \| 177 ) 178 regex_long_prefix=("$regex_long_prefix[@]" 179 /"(${(j:|:)short_configfile})$nul"/ 180 -'_apt_consume_short ${match[1][-2]}' 181 /"$word"/ ":files:config file:$comp_configfile" \| 182 /"(${(j:|:)short_configfile})="/ 183 -'_apt_consume_short ${match[1][-2]}' 184 \( /"$word1"/ ":files:config file:$comp_configfile" \| /"$nul"/ /"$word"/ ":files:config file:$comp_configfile" \) \| 185 ) 186 fi 187 188 if (( $#short_arbitem )); then 189 regex_short=("$regex_short[@]" 190 /"$short_seq(${(j:|:)short_arbitem})(=|)"/ 191 -'_apt_consume_short ${match[1]%=}' 192 \( /"$word1"/ ":options:option:$comp_arbitem" \| /"$nul"/ /"$word"/ ":options:option:$comp_arbitem" \) \| 193 ) 194 regex_long_prefix=("$regex_long_prefix[@]" 195 /"(${(j:|:)short_arbitem})$nul"/ 196 -'_apt_consume_short ${match[1][-2]}' 197 /"$word"/ ":options:option:$comp_arbitem" \| 198 /"(${(j:|:)short_arbitem})="/ 199 -'_apt_consume_short ${match[1][-2]}' 200 \( /"$word1"/ ":options:option:$comp_arbitem" \| /"$nul"/ /"$word"/ ":options:option:$comp_arbitem" \) \| 201 ) 202 fi 203 204 if (( $#short_release )); then 205 regex_short=("$regex_short[@]" 206 /"$short_seq(${(j:|:)short_release})(=|)"/ 207 -'_apt_consume_short ${match[1]%=}' 208 \( /"$word1"/ ":releases:release name:$comp_release" \| /"$nul"/ /"$word"/ ":release name:release:$comp_release" \) \| 209 ) 210 regex_long_prefix=("$regex_long_prefix[@]" 211 /"(${(j:|:)short_release})$nul"/ 212 -'_apt_consume_short ${match[1][-2]}' 213 /"$word"/ ":releases:release name:$comp_release" \| 214 /"(${(j:|:)short_release})="/ 215 -'_apt_consume_short ${match[1][-2]}' 216 \( /"$word1"/ ":releases:release name:$comp_release" \| /"$nul"/ /"$word"/ ":releases:release name:$comp_release" \) \| 217 ) 218 fi 219 220 if (( $#long_hasarg )); then 221 regex_long=("$regex_long[@]" 222 /"(${(j:|:)long_hasarg})$nul"/ 223 -'_apt_consume_long ${match[1]%'$qnul'}; current_option=${canonicalize[--${match[1]%'$qnul'}]}' 224 /"$word"/ ":options:option:$comp_hasarg" \| 225 /"(${(j:|:)long_hasarg})="/ 226 -'_apt_consume_long ${match[1]%=}; current_option=${canonicalize[--${match[1]%=}]}' 227 \( /"$word1"/ ":options:option:$comp_hasarg" \| /"$nul"/ /"$word"/ ":options:option:$comp_hasarg" \) \| 228 ) 229 regex_long_prefix=("$regex_long_prefix[@]" 230 /"(${(j:|:)long_hasarg})$nul"/ 231 -'_apt_consume_long ${match[1]%'$qnul'}; current_option=${canonicalize[--${match[1]%'$qnul'}]}' 232 /"$word"/ ":options:option:$comp_hasarg" \| 233 /"(${(j:|:)long_hasarg})="/ 234 -'_apt_consume_long ${match[1]%=}; current_option=${canonicalize[--${match[1]%=}]}' 235 \( /"$word1"/ ":options:option:$comp_hasarg" \| /"$nul"/ /"$word"/ ":options:option:$comp_hasarg" \) \| 236 ) 237 fi 238 239 if (( $#long_bool )); then 240 regex_long=("$regex_long[@]" 241 /"(${(j:|:)long_bool})="/ 242 -'_apt_consume_long ${match[1]%=}' 243 \( /"$word1"/ ":names:boolean value:$comp_bool" \| /"$nul"/ /"$word"/ ":names:boolean value:$comp_bool" \) \| 244 /"(${(j:|:)long_bool})$nul"/ 245 -'_apt_consume_long ${match[1]%'$qnul'}' 246 /"((${(j:|:)bool})$nul|)"/ ":names:boolean value:$comp_bool" \| 247 ) 248 regex_long_prefix=("$regex_long_prefix[@]" 249 /"(${(j:|:)long_bool})="/ 250 -'_apt_consume_long ${match[1]%=}' 251 \( /"$word1"/ ":names:boolean value:$comp_bool" \| /"$nul"/ /"$word"/ ":names:boolean value:$comp_bool" \) \| 252 /"(${(j:|:)long_bool})$nul"/ 253 -'_apt_consume_long ${match[1]%'$qnul'}' 254 /"((${(j:|:)bool})$nul|)"/ ":names:boolean value:$comp_bool" \| 255 ) 256 fi 257 258 if (( $#long_intlevel )); then 259 regex_long=("$regex_long[@]" 260 /"(${(j:|:)long_intlevel})="/ 261 -'_apt_consume_long ${match[1]%=}' 262 \( /"$word1"/ ":options:option:$comp_intlevel" \| /"$nul"/ /"$word"/ ":options:option:$comp_intlevel" \) \| 263 /"(${(j:|:)long_intlevel})$nul"/ 264 -'_apt_consume_long ${match[1]%'$qnul'}' 265 /"($intlevel$nul|)"/ ":options:option:$comp_intlevel" \| 266 ) 267 regex_long_prefix=("$regex_long_prefix[@]" 268 /"(${(j:|:)long_intlevel})="/ 269 -'_apt_consume_long ${match[1]%=}' 270 \( /"$word1"/ ":options:option:$comp_intlevel" \| /"$nul"/ /"$word"/ ":options:option:$comp_intlevel" \) \| 271 /"(${(j:|:)long_intlevel})$nul"/ 272 -'_apt_consume_long ${match[1]%'$qnul'}' 273 /"($intlevel$nul|)"/ ":options:option:$comp_intlevel" \| 274 ) 275 fi 276 277 if (( $#long_configfile )); then 278 regex_long=("$regex_long[@]" 279 /"(${(j:|:)long_configfile})$nul"/ 280 -'_apt_consume_long ${match[1]%'$qnul'}' 281 /"$word"/ ":files:config file:$comp_configfile" \| 282 /"(${(j:|:)long_configfile})="/ 283 -'_apt_consume_long ${match[1]%=}' 284 \( /"$word1"/ ":files:config file:$comp_configfile" \| /"$nul"/ /"$word"/ ":files:config file:$comp_configfile" \) \| 285 ) 286 regex_long_prefix=("$regex_long_prefix[@]" 287 /"(${(j:|:)long_configfile})$nul"/ 288 -'_apt_consume_long ${match[1]%'$qnul'}' 289 /"$word"/ ":files:config file:$comp_configfile" \| 290 /"(${(j:|:)long_configfile})="/ 291 -'_apt_consume_long ${match[1]%=}' 292 \( /"$word1"/ ":files:config file:$comp_configfile" \| /"$nul"/ /"$word"/ ":files:config file:$comp_configfile" \) \| 293 ) 294 fi 295 296 if (( $#long_arbitem )); then 297 regex_long=("$regex_long[@]" 298 /"(${(j:|:)long_arbitem})$nul"/ 299 -'_apt_consume_long ${match[1]%'$qnul'}' 300 /"$word"/ ":options:option:$comp_arbitem" \| 301 /"(${(j:|:)long_arbitem})="/ 302 -'_apt_consume_long ${match[1]%=}' 303 \( /"$word1"/ ":options:option:$comp_arbitem" \| /"$nul"/ /"$word"/ ":options:option:$comp_arbitem" \) \| 304 ) 305 regex_long_prefix=("$regex_long_prefix[@]" 306 /"(${(j:|:)long_arbitem})$nul"/ 307 -'_apt_consume_long ${match[1]%'$qnul'}' 308 /"$word"/ ":options:option:$comp_arbitem" \| 309 /"(${(j:|:)long_arbitem})="/ 310 -'_apt_consume_long ${match[1]%=}' 311 \( /"$word1"/ ":options:option:$comp_arbitem" \| /"$nul"/ /"$word"/ ":options:option:$comp_arbitem" \) \| 312 ) 313 fi 314 315 if (( $#long_release )); then 316 regex_long=("$regex_long[@]" 317 /"(${(j:|:)long_release})$nul"/ 318 -'_apt_consume_long ${match[1]%'$qnul'}' 319 /"$word"/ ":releases:release name:$comp_release" \| 320 /"(${(j:|:)long_release})="/ 321 -'_apt_consume_long ${match[1]%=}' 322 \( /"$word1"/ ":releases:release name:$comp_release" \| /"$nul"/ /"$word"/ ":releases:release name:$comp_release" \) \| 323 ) 324 regex_long_prefix=("$regex_long_prefix[@]" 325 /"(${(j:|:)long_release})$nul"/ 326 -'_apt_consume_long ${match[1]%'$qnul'}' 327 /"$word"/ ":releases:release name:$comp_release" \| 328 /"(${(j:|:)long_release})="/ 329 -'_apt_consume_long ${match[1]%=}' 330 \( /"$word1"/ ":releases:release name:$comp_release" \| /"$nul"/ /"$word"/ ":releases:release name:$comp_release" \) \| 331 ) 332 fi 333 334 regex_all=( 335 /"$word"/ 336 \( /--/+ \( "$regex_long[@]" 337 /"(${(j:|:)bool})-"/+ 338 \( "$regex_long_prefix[@]" 339 /"[]"/ ":options:option:$comp_long_prefix" \) \) \| 340 /-/+ \( "$regex_short[@]" /"[]"/ \) \| 341 /"[]"/ ":options:option:$comp_opt" \) \# 342 "$regex_all[@]" 343 ) 344 345 _regex_arguments "${funcname}_sm" "$regex_all[@]" 346 347 eval "$funcname () { 348 typeset -A canonicalize num_options 349 canonicalize=(${(kv)canonicalize}) 350 num_options=(${(kv)num_options}) 351 352 local short_hasarg short_bool short_intlevel short_configfile short_arbitem 353 local long_hasarg long_bool long_intlevel long_configfile long_arbitem 354 local short_release long_release 355 local bool_prefix 356 short_hasarg=($short_hasarg) 357 short_bool=($short_bool) 358 short_intlevel=($short_intlevel) 359 short_configfile=($short_configfile) 360 short_arbitem=($short_arbitem) 361 short_release=($short_release) 362 long_hasarg=($long_hasarg) 363 long_bool=($long_bool) 364 long_intlevel=($long_intlevel) 365 long_configfile=($long_configfile) 366 long_arbitem=($long_arbitem) 367 long_release=($long_release) 368 bool_prefix=($bool_prefix) 369 370 local current_option tmp1 tmp2 tmp3 371 372 ${funcname}_sm 373 }" 374} 375 376_apt_consume_short () { 377 local short opt 378 for short in ${(s::)1}; do 379 opt="$canonicalize[-$short]" 380 (( 0 < num_options[$opt] && num_options[$opt]-- )) 381 done 382 return 0 383} 384 385_apt_consume_long () { 386 local long opt 387 opt="$canonicalize[--$1]" 388 (( 0 < num_options[$opt] && num_options[$opt]-- )) 389 return 0 390} 391 392_apt-get () { 393 _apt_arguments _apt-get_sm \ 394 -h,--help:bool \ 395 -v,--version:bool \ 396 -q,--quiet,--silent:intlevel \ 397 -d,--download-only:bool \ 398 -b,--compile,--build:bool \ 399 -s,--simulate,--just-print,--dry-run,--recon,--no-act:bool \ 400 -y,--yes,--assume-yes:bool \ 401 -f,--fix-broken:bool \ 402 -u,--show-upgraded:bool \ 403 -V,--verbose-versions:bool \ 404 -m,--ignore-missing,--fix-missing:bool \ 405 --no-download:bool \ 406 --no-install-recommends:bool \ 407 --ignore-hold:bool \ 408 --no-upgrade:bool \ 409 --force-yes:bool \ 410 --print-uris:bool \ 411 --purge:bool \ 412 --list-cleanup:bool \ 413 --reinstall:bool \ 414 -c,--config-file:configfile \ 415 -o,--option:arbitem \ 416 -t,--target-release,--default-release:release \ 417 --trivial-only:bool \ 418 --no-remove:bool \ 419 --only-source:bool \ 420 --diff-only:bool \ 421 --tar-only:bool \ 422 --arch-only:bool \ 423 --allow-unauthenticated:bool \ 424 -- \ 425 /$'update\0'/ \| \ 426 /$'upgrade\0'/ \| \ 427 \( \ 428 /$'install\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \ 429 /$'[^\0/]#/'/ /$'[^\0/]#\0'/ ':release name::_apt_releases' \) \| \ 430 /$'remove\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ 431 /$'purge\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ 432 /$'dist-upgrade\0'/ \| \ 433 /$'dselect-upgrade\0'/ \| \ 434 /$'clean\0'/ \| \ 435 /$'autoclean\0'/ \| \ 436 /$'changelog\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 437 /$'check\0'/ \| \ 438 /$'source\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 439 /$'build-dep\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 440 /$'autoremove\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ 441 /$'help\0/' \| \ 442 /$'markauto\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ 443 /$'unmarkauto\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ 444 /"[]"/ ':argument-1::compadd "$expl_action[@]" update upgrade install remove purge dist-upgrade dselect-upgrade clean autoclean changelog check source build-dep autoremove help markauto unmarkauto' 445 446 _apt-get () { 447 local expl_action expl_packages 448 _description actions expl_action 'action' 449 _description packages expl_packages 'package' 450 451 _apt-get_sm 452 } 453 454 _apt-get "$@" 455} 456 457_apt-cache () { 458 _apt_arguments _apt-cache_sm \ 459 -h,--help:bool \ 460 -v,--version:bool \ 461 -p,--pkg-cache:'_files "$expl_pkg_cache[@]"' \ 462 -s,--src-cache:'_files "$expl_src_cache[@]"' \ 463 -q,--quiet:intlevel \ 464 -i,--important:bool \ 465 -f,--full:bool \ 466 -g,--generate:bool \ 467 -n,--names-only:bool \ 468 --all-names:bool \ 469 -a,--all-versions:bool \ 470 --recurse:bool \ 471 -c,--config-file:configfile \ 472 -o,--option:arbitem \ 473 --installed:bool \ 474 -- \ 475 /$'help\0'/ \| \ 476 /$'add\0'/ /$'[^\0]#\0'/ ':files:index files:_files "$expl[@]"' \# \| \ 477 /$'gencaches\0'/ \| \ 478 /$'showpkg\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 479 /$'showsrc\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 480 /$'stats\0'/ \| \ 481 /$'dump\0'/ \| \ 482 /$'dumpavail\0'/ \| \ 483 /$'unmet\0'/ \| \ 484 /$'search\0'/ /$'[^\0]#\0'/ ':strings:pattern:' \| \ 485 /$'show\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 486 /$'depends\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 487 /$'rdepends\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 488 /$'pkgnames\0'/ /$'[^\0]#\0'/ ':strings:prefix:' \| \ 489 /$'dotty\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 490 /$'xvcg\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 491 /$'policy\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 492 /$'madison\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ 493 /"[]"/ ':argument-1::compadd "$expl_action[@]" help add gencaches showpkg showsrc stats dump dumpavail unmet search show depends rdepends pkgnames dotty policy xvcg madison' 494 495 _apt-cache () { 496 local expl_action expl_packages expl_pkg_cache expl_src_cache 497 _description actions expl_action 'action' 498 _description packages expl_packages 'package' 499 _description files expl_pkg_cache 'package cache' 500 _description files expl_src_cache 'source cache' 501 502 _apt-cache_sm 503 } 504 505 _apt-cache "$@" 506} 507 508_apt-cdrom () { 509 _apt_arguments _apt-cdrom_sm \ 510 -h,--help:bool \ 511 -v,--version:bool \ 512 -d,--cdrom:'_files "$expl_mount_point[@]" -/' \ 513 -r,--rename:bool \ 514 -m,--no-mount:bool \ 515 -f,--fast:bool \ 516 -n,--just-print,--recon,--no-act:bool \ 517 -a,--thorough:bool \ 518 -c,--config-file:configfile \ 519 -o,--option:arbitem \ 520 -- \ 521 /$'add\0'/ \| \ 522 /$'ident\0'/ \| \ 523 /"[]"/ ':argument-1::compadd "$expl_action[@]" add ident' 524 525 _apt-cdrom () { 526 local expl_action expl_mount_point 527 _description actions expl_action 'action' 528 _description files expl_mount_point 'mount point' 529 530 _apt-cdrom_sm 531 } 532 533 _apt-cdrom "$@" 534} 535 536_apt-config () { 537 _apt_arguments _apt-config \ 538 -h,--help:bool \ 539 -v,--version:bool \ 540 -c,--config-file:configfile \ 541 -o,--option:arbitem \ 542 -- \ 543 /$'shell\0'/ \ 544 \( \ 545 /$'[^\0]#\0'/ ':parameters:shell variable to assign:_parameters' \ 546 /$'[^\0]#\0'/ ':values:configuration key:compadd "$expl[@]" - ${${(f)"$(apt-config dump 2>&1)"}% *}' \ 547 \) \# \| \ 548 /$'dump\0'/ \| \ 549 /"[]"/ ':argument-1:action:compadd "$expl[@]" shell dump' 550 551 _apt-config "$@" 552} 553 554_apt_releases_update () { 555 if ( [[ ${+_apt_releases} -eq 0 ]] || 556 _cache_invalid APT_releases ) && ! _retrieve_cache APT_releases; 557 then 558 _apt_releases=( 559${${${${(M)${(f)"$(apt-cache policy)"}:#*release*}#*a=}%%,*}:#now} 560 ) 561 typeset -U _apt_releases 562 _store_cache APT_releases _apt_releases 563 fi 564} 565 566_apt_releases () { 567 local update_policy 568 569 zstyle -s ":completion:*:*:$service:*" cache-policy update_policy 570 if [[ -z "$update_policy" ]]; then 571 zstyle ":completion:*:*:$service:*" cache-policy _apt_caching_policy 572 fi 573 574 _apt_releases_update 575 576 _tags apt-releases && compadd -a _apt_releases 577} 578 579_apt_caching_policy () { 580 local -a oldp 581 582 oldp=( "$1"(mw+1) ) 583 (( $#oldp )) && return 0 584 585 [[ /var/cache/apt/pkgcache.bin -nt "$1" || 586 /var/lib/dpkg/available -nt "$1" ]] 587} 588 589_apt "$@" 590