1#compdef dpkg dpkg-deb dpkg-query dpkg-reconfigure 2 3local _dpkg_deb_actions _dpkg_common_actions _dpkg_actions _dpkg_options 4local _dpkg_options_recursive #_dpkg_actions_install _dpkg_actions_record_avail 5local _dpkg_deb_only_actions 6local _dpkg_deb_and_query_only_actions _dpkg_deb_and_query_only_options 7local _dpkg_query_actions 8local curcontext="$curcontext" context state line expl ret 9typeset -A opt_args 10 11_dpkg_deb_only_actions=( 12 '-D[debugging output]' 13 '(--new)--old[old archive format]' 14 '(--old)--new[new archive format]' 15 '--nocheck[suppress control file check]' 16 '-z+[compression level]:compression number:(1 2 3 4 5 6 7 8 9)' 17) 18 19_dpkg_deb_actions=( 20 '(--build -b)'{--build,-b}'[build archive]:directory:_files -/' 21 '(--contents -c)'{--contents,-c}'[list contents]:Debian package:_files -g "*.u#deb(-.)"' 22 '(--info -I)'{--info,-I}'[show info]:Debian package:_files -g "*.u#deb(-.)"' 23 '(--field -f)'{--field,-f}'[show fields]:Debian package:_files -g "*.u#deb(-.)"' 24 '(--control -e)'{--control,-e}'[extract control]:Debian package:_files -g "*.u#deb(-.)"' 25 '(--extract -x)'{--extract,-x}'[extract files]:Debian package:_files -g "*.u#deb(-.)"' 26 '(--vextract -X)'{--vextract,-X}'[extract and list files]:Debian package:_files -g "*.u#deb(-.)"' 27 '--fsys-tarfile[output fs tarfile]:Debian package:_files -g "*.u#deb(-.)"' 28) 29 30_dpkg_common_actions=( 31 '--help[show help]' 32 '--version[show version]' 33 '(--license --licence)'{--license,--licence}'[show licencing]' 34) 35 36_dpkg_actions=( 37 '(--install -i)'{--install,-i}'[install packages]:*:Debian packages:->install' 38 '--unpack[unpack package]:Debian package:_files -g "*.deb(-.)"' 39 '--configure[reconfigure specified packages]:*:package:->configure' 40 '(--remove -r)'{--remove,-r}'[remove package]:*:package:->remove' 41 '(--purge -P)'{--purge,-P}'[purge package]:*:package:->purge' 42 '--update-avail[update available]:package file:_files' 43 '--merge-avail[merge available]:package file:_files' 44 '(--record-avail -A)'{--record-avail,-A}'[record available]:*:package files:->record_avail' 45 '--forget-old-unavail[forget uninstalled unavailable]' 46 '--clear-avail[clear available]' 47 '(--audit -C)'{--audit,-C}'[check for broken pkgs]' 48 '--get-selections[get selections]:pattern:' 49 '--set-selections[set selections]' 50 '--yet-to-unpack[list uninstalled]' 51 '--print-architecture[print target architecture]' 52 '--print-installation-architecture' 53 '--compare-versions[compare version numbers]:*::expression:= ->compare_versions' 54) 55 56_dpkg_options=( 57 '--abort-after[abort after errors]:number of errors:' 58 '--root=[alternative root]:root:_files -/' 59 '--instdir=[change inst root but not data dir]:_files -/' 60 '(--selected-only -O)'{--selected-only,-O}'[skip unselected packages]' 61 '(--skip-same-version -E)'{--skip-same-version,-E}'[skip packages with same version as installed]' 62 '(--refuse-downgrade -G)'{--refuse-downgrade,-G}'[skip packages with earlier version than installed]' 63 '(--auto-deconfigure -B)'{--auto-deconfigure,-B}'[install can break other packages]' 64 '--largemem[optimize for >4Mb RAM]' 65 '--smallmem[optimize for <4Mb RAM]' 66 '--no-act[show potential actions but do not follow through]' 67 '-D+[debug options]:debug options:(h 1 2 3)' 68 '--debug=[debug options]:debug options:(help 1 2 3)' 69 '--ignore-depends=[ignore depends involving package]:package:_deb_packages avail' 70 --{force,refuse,no-force}'--[forcing options]:what:(all downgrade configure-any hold bad-path not-root overwrite overwrite-diverted bad-verify depends-version depends confnew confold confdef confmiss conflicts architecture overwrite-dir remove-reinstreq remove-essential help)' 71) 72 73_dpkg_options_recursive=( '(--recursive -R)'{--recursive,-R}'[recursive]' ) 74 75_dpkg_deb_and_query_only_actions=( 76 '(--show -W)'{--show,-W}'[show package info]:Debian package:_files -g \*.u\#deb\(-.\)' 77) 78 79_dpkg_deb_and_query_only_options=( 80 '--showformat=-[alternative format]:format: ' 81) 82 83_dpkg_query_actions=( 84 '(--status -s)'{--status,-s}'[display package status]:*:packages:->status' 85 '(--print-avail -p)'{--print-avail,-p}'[display available details]:packages:_deb_packages avail' 86 '(--listfiles, -L)'{--listfiles,-L}'[list owned files]:*:packages:->listfiles' 87 '(--list -l)'{--list,-l}'[list packages]:*:packages:->list' 88 '(--search -S)'{--search,-S}'[search for file owner]:*:pattern:->search' 89 '--admindir=[data directory]:directory:_files -/' 90) 91 92# not needed anymore? 93# _dpkg_actions_install=('(--install)-i[install]' '(-i)--install') 94# _dpkg_actions_record_avail=('(--record-avail)-A[record available]' '(-A)--record-avail') 95 96case "$service" in 97 dpkg) 98 _arguments -C -s \ 99 "$_dpkg_actions[@]" \ 100 "$_dpkg_deb_actions[@]" \ 101 "$_dpkg_common_actions[@]" \ 102 "$_dpkg_options[@]" \ 103 "$_dpkg_options_recursive[@]" \ 104 "$_dpkg_query_actions[@]" && return 0 105 ;; 106 107 dpkg-deb) 108 _arguments "$_dpkg_deb_actions[@]" \ 109 "$_dpkg_deb_only_actions[@]" \ 110 "$_dpkg_common_actions[@]" \ 111 "$_dpkg_deb_and_query_only_actions[@]" \ 112 "$_dpkg_deb_and_query_only_options[@]" && return 0 113 114 ;; 115 116 dpkg-query) 117 _arguments "$_dpkg_query_actions[@]" \ 118 "$_dpkg_common_actions[@]" \ 119 "$_dpkg_deb_and_query_only_actions[@]" \ 120 "$_dpkg_deb_and_query_only_options[@]" && return 0 121 ;; 122 dpkg-reconfigure) 123 _arguments -s -w \ 124 '(-f --frontend)'{-f,--frontend}'[select frontend to use]:frontend:(dialog readline noninteractive gnome kde editor web)' \ 125 '(-p --priority)'{-p,--priority}'[specify min priority of questions]:priority:(low medium high critical)' \ 126 '--default-priority[use default question priority]' \ 127 '(*)--all[reconfigure all installed packages using debconf]' \ 128 '(-u --unseen-only)'{-u,--unseen-only}'[only ask questions not yet seen are asked]' \ 129 '--force[reconfigure even packages in broken state]' \ 130 '(-)'{-h,--help}'[display help information]' \ 131 '*:package:_deb_packages installed' && return 0 132 ;; 133esac 134 135case "$state" in 136 install|record_avail) 137 _call_function ret _dpkg_$state && return ret 138# not needed anymore? 139# "${(@e):-\$_dpkg_actions_${state}}" \ 140 _arguments -C -A '-*' -s \ 141 "$_dpkg_options[@]" \ 142 \!${^_dpkg_actions%%:*} \ 143 - recur \ 144 "$_dpkg_options_recursive[@]" \ 145 '*:directory:_path_files -/' \ 146 - nonrecur \ 147 '*:Debian package:_path_files -g "*.deb(-.)"' 148 ;; 149 remove|status|listfiles) 150 _call_function ret _dpkg_$state && return ret 151 _arguments -C -A "-*" -s "$_dpkg_options[@]" \ 152 '*:package:_deb_packages installed' 153 ;; 154 purge) 155 _call_function ret _dpkg_$state && return ret 156 _arguments -C -A "-*" -s "$_dpkg_options[@]" \ 157 '*:package:_deb_packages xinstalled' 158 ;; 159 list) 160 _call_function ret _dpkg_$state && return ret 161 _arguments -C -A "-*" -s "$_dpkg_options[@]" \ 162 '*:packages:_deb_packages avail' 163 ;; 164 compare_versions) 165 _call_function ret _dpkg_$state && return ret 166 _arguments -C -A "-*" -s \ 167 '1:version A:' \ 168 '2:operator:(lt le eq ne ge gt lt-nl le-nl ge-nl gt-nl)' \ 169 '3:version B:' 170 ;; 171 configure) 172 _call_function ret _dpkg_$state && return ret 173 _arguments -C -A "-*" -s '--configure' \ 174 "$_dpkg_options[@]" \ 175 '(* -a --pending)'{-a,--pending}'[pending packages]' \ 176 '*:package:_deb_packages installed' 177 ;; 178 search) 179 _call_function ret _dpkg_$state && return ret 180 _files 181 ;; 182esac 183