diff options
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Mandrake/Command/_urpmi | 345 |
1 files changed, 239 insertions, 106 deletions
diff --git a/Completion/Mandrake/Command/_urpmi b/Completion/Mandrake/Command/_urpmi index f831fbab3..031f10f07 100644 --- a/Completion/Mandrake/Command/_urpmi +++ b/Completion/Mandrake/Command/_urpmi @@ -1,46 +1,41 @@ -#compdef urpme urpmi urpmi.addmedia urpmi.removemedia urpmi.update urpmq - -_urpmi_cache_policy() { - local -a synthesis - local i - synthesis=(/var/lib/urpmi/synthesis.*) - for i in $synthesis; do - [[ -e "$1" && -e "$i" && "$1" -nt "$i" ]] && return 1 - done - return 0 -} - +#compdef urpme urpmi urpmi.addmedia urpmi.removemedia urpmi.update urpmq urpmf parsehdlist + _urpmi_media() { - local source media brace expl - local -a all_sources + local ret=1 signle=0 + local -a all_sources opts - [[ -f /etc/urpmi/urpmi.cfg ]] || return 1 + if [[ $1 = -s ]]; then + single=1 + shift + fi - while read source media brace; do - [[ "$brace" != "{" ]] && continue - all_sources=("$all_sources[@]" $source) - done < /etc/urpmi/urpmi.cfg + # TODO should we probe for active media only? + all_sources=( ${(f)"$(urpmq --list-media 2> /dev/null)"} ) + + if (( single )); then + compadd "$expl[@]" -a all_sources && ret=0 + else + _values -s , 'urpmi media' "$all_sources[@]" && ret=0 + fi - _values -s , 'urpmi media' "$all_sources[@]" + return $ret } _urpmi_rpms() { - local pkg ret=1 expl + local ret=1 expl _tags rpms files while _tags; do if _requested rpms expl 'urpmi RPM'; then - local -a synthesis pkgs - synthesis=(/var/lib/urpmi/synthesis.*(N)) - if [[ $#synthesis -gt 0 ]]; then - if _cache_invalid _urpmi_rpms || ! _retrieve_cache _urpmi_rpms; then - pkgs=($(zcat $synthesis | \ - grep @info@ | cut -d @ -f 3 | sed -e 's/\.[^.]*$//')) - _store_cache _urpmi_rpms pkgs - fi - compadd "$expl[@]" -a pkgs && ret=0 - fi + local -a pkgs + pkgs=( $(urpmq --list 2> /dev/null \ + ${(k)opt_args[--media]:-${opt_args[--searchmedia]:+--media}} \ + ${(v)opt_args[--media]}${opt_args[--searchmedia]:+${opt_args[--media]:+,}${opt_args[--searchmedia]}} \ + ${(k)opt_args[--excludemedia]} ${(v)opt_args[--excludemedia]} + ) + ) + compadd "$expl[@]" -a pkgs && ret=0 fi _requested files expl '(S)RPM file' \ @@ -52,6 +47,7 @@ _urpmi_rpms() { return ret } +# TODO add completion of remote directory for SSH, rsync, ftp _urpmi_media_url() { local expl ret=1 @@ -60,8 +56,13 @@ _urpmi_media_url() { elif [[ -prefix '(ftp|http)://' ]]; then _urls "$@" && ret=0 else - _wanted mediatype expl 'type of media' \ - compadd "$@" -- file:// http:// ftp:// removable:// && ret=0 + if (( ${+opt_args[--virtual]} )); then + _wanted mediatype expl 'type of media' \ + compadd -S "" "$@" -- file:// && ret=0 + else + _wanted mediatype expl 'type of media' \ + compadd -S "" "$@" -- ssh:// rsync:// file:// http:// ftp:// removable:// && ret=0 + fi fi return $ret @@ -70,112 +71,244 @@ _urpmi_media_url() { _urpme_package() { local -a _rpms _rpms=( $(_call_program packages rpm -qa 2>/dev/null) ) - compadd "$@" -a -- _rpms + compadd "$@" -a _rpms +} + +_urpmi_parallel_alias() { + # placeholder as I do not actually have parallel system to test + return 1 } _urpmi() { - local state context line ret=1 - typeset -A opt_args + local state context line ret=1 help="--help -h" + + local -a opts_help opts_net opts_verbose opts_inst_rem opts_search opts_media + + opts_help=( + "($help : -)"{--help,-h}"[print usage information]" + ) + + opts_net=( + "($help --wget)--curl[use curl to retrieve distant files]" + "($help)--limit-rate[limit the download speed (b/s)]:download speed in b/s: " + "($help)--proxy:proxy host:_hosts" + "($help)--proxy-user:proxy user:_users" + "($help --curl)--wget[use wget to retrieve distant files]" + ) + + opts_verbose=( + "(--help -h -v)-q[quiet mode]" + "(--help -h -q)-v[verbose mode]" + ) + opts_inst_rem=( + "($help)--auto[automatically select a package in choices]" + "($help)--force[force invocation even if some packages do not exist]" + "($help)--parallel[distributed urpmi across machines of alias]:urpmi alias name:_urpmi_parallel_alias" + "($help)--root[use another root for rpm installation]:root diretory:_files -/" + "($help)--test[test only, do not modify system]" + "($help)-a[select all matches on command line]" + ) + + opts_search=( + "($help --fuzzy -z)"{--fuzzy,-y}"[return all matches even if exact match exists]" + "($help -p -P)-p[allow search in provides to find package]" + "($help -p -P)-P[do not search in provides to find package]" + ) + + opts_media=( + "($help)--excludemedia[do not use the given media]:urpmi media: _urpmi_media" + "($help --update --use-distrib)--media[use only the media listed by comma]:urpmi media: _urpmi_media" + "($help)--searchmedia[use only the given media to search requested (or updated) packages]:urpmi media: _urpmi_media -s" + "($help)--sortmedia[sort media according to substrings separated by comma]:urpmi media: _urpmi_media" + "($help)--synthesis[use the given synthesis instead of urpmi db]:synthesis file:_url" + "($help --media --use-distrib)--update[use only update media]" + "($help --media --update)--use-distrib[configure urpmi on the fly from a distrib tree]:installation media:_urpmi_media_url" + ) case "$service" in urpme ) _arguments -A '-*' \ + $opts_help \ + $opts_inst_rem \ "--auto[do not ask any question]" \ - "-a[find all matches]" \ + "-v[verbose]" \ ": :_urpme_package" ;; urpmi.addmedia ) _arguments -A '-*' \ - "(--wget)--curl[use curl to retrieve distant files]" \ - "(:)--distrib[automatically create all media from an installation medium]:media URL:_urpmi_media_url" \ - "--update[mark as update media]" \ - "(--curl)--wget[use wget to retrieve distant files]" \ - "-c[clean headers cache directory]" \ - "-f[force generation of hdlist files]" \ - "-h[try to find and use synthesis or hdlist file]" \ - "(--distrib):name of media: " \ - "(--distrib):media URL:_urpmi_media_url" \ - "(--distrib): :(with)" \ - "(--distrib):relative path to hdlist file" \ + $opts_help \ + $opts_net \ + $opts_verbose \ + "($help)--arch[use specified architecture]:Mandrake architecture: " \ + "($help :)--distrib[automatically create all media from an installation medium]:media URL:_urpmi_media_url" \ + "($help)--from[use specified url for list of mirrors]:mirror URL:_url" \ + "($help)--no-md5sum[disable MD5SUM file checking]" \ + "($help --probe-hdlist --probe-synthesis)--no-probe[do not try to find any synthesis or hdlist file]" \ + "($help --no-probe --probe-synthesis)--probe-hdlist[try to find and use hdlist file]" \ + "($help --no-probe --probe-hdlist)--probe-synthesis[try to find and use synthesis file]" \ + "($help)--update[mark as update media]" \ + "($help)--version[use specified distribution version]:Mandrake version: " \ + "($help)--virtual[create virtual media wich are always up-to-date]" \ + "($help)-c[clean headers cache directory]" \ + "($help)-f[force generation of hdlist files]" \ + "($help --distrib):name of media: " \ + "($help --distrib):media URL:_urpmi_media_url" \ + "($help --distrib): :(with)" \ + "($help --distrib):relative path to hdlist file" \ && ret=0 ;; urpmi.removemedia ) _arguments -A '-*' \ - "(:)-a[select all media]" \ - "(-a)"{,\*}": :_urpmi_media" \ + $opts_help \ + $opts_verbose \ + "($help : -)"{--help,-h}"[print usage information]" \ + "($help :)-a[select all media]" \ + "($help)-c[clean headers cache directory]" \ + "($help)-y[fuzzy mathing on media names]" \ + "(-a)"{,\*}": : _urpmi_media" \ && ret=0 ;; urpmi.update ) _arguments -A '-*' \ - "(--wget)--curl[use curl to retrieve distant files]" \ - "(--curl)--wget[use wget to retrieve distant files]" \ - "(:)-a[select all non-removable media]" \ - "-c[clean /var/cache/urpmi/headers on exit]" \ - "-d[force complete computation of depslist.ordered file]" \ - "*-f[force generation of hdlist files]" \ - "(-a)"{,\*}": :_urpmi_media" \ + $opts_help \ + $opts_net \ + $opts_verbose \ + "($help : -)"{--help,-h}"[print usage information]" \ + "($help)--force-key[force update of gpg key]" \ + "($help : -a)--update[update only update media]" \ + "($help --update :)-a[select all non-removable media]" \ + "($help)-c[clean /var/cache/urpmi/headers on exit]" \ + "($help)*-f[force generation of hdlist files]" \ + "($help -a)"{,\*}": : _urpmi_media" \ && ret=0 ;; urpmi ) _arguments -A '-*' \ - "(: -)--help[print usage information]" \ - "(--help)--allow-medium-change[allow change of removable media]" \ - "(--help)--auto[do not ask any questions]" \ - "(--help)--auto-select[select the packages to update]" \ - "(--help -X)--best-output[automatically select text or X interface]" \ - "(--help)--complete[use parsehdlist server to complete selection]" \ - "(--help --wget)--curl[use curl to retrieve distant files]" \ - "(--help)--force[proceed even when some packages do not exist]" \ - "(--help --fuzzy -z)"{--fuzzy,-y}"[return all matches even if exact match exists]" \ - "(--help)--media[use only the media listed by comma]: :_urpmi_media" \ - "(--help)--noclean[do not clean RPM cache]" \ - "(--help --src -s)"{--src,-s}"[next package is source package]" \ - "(--help)--update[use only update media]" \ - "(--help --verify-rpm)--no-verify-rpm[do not verify rpm signature before installation]" \ - "(--help --no-verify-rpm)--verify-rpm[verify rpm signature before installation]" \ - "(--help --curl)--wget[use wget to retrieve distant files]" \ - "(--help)-a[select all packages matching command line]" \ - "(--help -m -M)-m[choose minimum closure of requires (default)]" \ - "(--help -m -M)-M[choose maximum closure of requires]" \ - "(--help)-P[do not search in provides]" \ - "(--help -q -v)-q[be quiet]" \ - "(--help -q -v)-v[verbose mode]" \ - "(--help --best-output)-X[use X interface]" \ - "(--help)"{,\*}": :_urpmi_rpms" \ + $opts_help \ + $opts_net \ + $opts_verbose \ + $opts_inst_rem \ + $opts_search \ + $opts_media \ + "($help : -)"{--help,-h}"[print usage information]" \ + "($help)--allow-force[allow asking user to install packages without dependencies checking and integrity]" \ + "($help)--allow-nodeps[allow asking user to install packages without dependencies checking]" \ + "($help)--auto-select[utomatically select packages to upgrade the system]" \ + "($help --env)--bug[output a bug report in given directory]:directory for bug report:_files -/" \ + "($help -X)--best-output[automatically select text or X interface]" \ + "($help --noclean)--clean[remove rpm from cache before anything else]" \ + "($help --clean)--noclean[keep rpm not used in cache]" \ + "($help --bug)--env[use specific environment (typically result of --bug)]:directory for bug report:_files -/" \ + "($help)--excludedocs[exclude docs files]: " \ + "($help)--excludepath[exclude path separated by comma]:path: " \ + "($help)--install-src[install only source package (no binaries)]" \ + "($help)--keep[keep existing packages if possible]" \ + "($help)--more-choices[propose more choices than the default]" \ + "($help --no-resume)--resume[resume transfer of partially-downloaded files]" \ + "($help --resume)--no-resume[do not resume transfer of partially-downloaded files]" \ + "($help)--root[use another root for rpm installation]:root diretory:_files -/" \ + "($help)--skip[packages which installation should be skipped]:packages: " \ + "($help)--split-length[small transaction length]:transaction length: " \ + "($help)--split-level[split in small transaction]:transaction size: " \ + "($help --src -s)"{--src,-s}"[next package is source package]" \ + "($help)--strict-arch[upgrade only packages with the same architecture]" \ + "($help)--no-uninstall[never ask to uninstall a package, abort the installation]" \ + "($help --verify-rpm)--no-verify-rpm[do not verify rpm signature before installation]" \ + "($help --no-verify-rpm)--verify-rpm[verify rpm signature before installation]" \ + "($help)-a[select all packages matching command line]" \ + "($help -m -M)-m[choose minimum closure of requires (default)]" \ + "($help -m -M)-M[choose maximum closure of requires]" \ + "($help --best-output)-X[use X interface]" \ + "($help)"{,\*}": :_urpmi_rpms" \ && ret=0 ;; urpmq ) _arguments -A '-*' \ - "(--help -h)--auto-select[automatically select packages for upgrading the system]" \ - "(--help -h)--force[ignore non-existent packages]" \ - "(--help -h --fuzzy -z)"{--fuzzy,-y}"[return all matches even if exact match exists]" \ - "(--help -h)--headers[extract headers for package listed from urpmi db to stdout]" \ - "(--help -h)--media[use only the media listed by comma]: :_urpmi_media" \ - "(--help -h)--sources[show full path to package file]" \ - "(--help -h --src -s)"{--src,-s}"[next package is source package]" \ - "(--help -h)--update[use only update media]" \ - "(--help -h -c -p -P)-c[choose complete method for resolving requires closure]" \ - "(--help -h)-d[show package dependencies]" \ - "(--help -h)-f[print version, release and arch with name]" \ - "(--help -h)-g[print groups too with name]" \ - "(--help -h -c -p -P)-p[allow search in provides to find package]" \ - "(--help -h -c -p -P)-P[do not search in provides to find package]" \ - "(--help -h)-r[print version and release too with name]" \ - "(--help -h)-u[remove package if a better version is already installed]" \ - "(--help -h)-v[verbose mode]" \ - "(--help -h)*:urpmi package name" \ + $opts_help \ + $opts_media \ + $opts_search \ + "($help)--auto-select[automatically select packages for upgrading the system]" \ + "($help)--force[ignore non-existent packages]" \ + "($help)--headers[extract headers for package listed from urpmi db to stdout]" \ + "($help : -list --list-media --list-url --list-nodes --list-aliases)--list[list available packages]" \ + "($help : -list --list-media --list-url --list-nodes --list-aliases)--list-media[list available media]" \ + "($help : -list --list-media --list-url --list-nodes --list-aliases)--list-url[list available url]" \ + "($help : -list --list-media --list-url --list-nodes --list-aliases)--list-nodes[list available nodes]" \ + "($help : -list --list-media --list-url --list-nodes --list-aliases)--list-aliases[list available aliases]" \ + "($help)--sources[show full path to package file]" \ + "($help --src -s)"{--src,-s}"[next package is source package]" \ + "($help)--summary[print RPM summary]" \ + "($help)-c[complete output with package to be removed]" \ + "($help)-d[extend query to package dependencies]" \ + "($help)-f[print version, release and arch with name]" \ + "($help)-g[print groups too with name]" \ + "($help)-i[print useful information in human readable form]" \ + "($help)-l[list files in package]" \ + "($help)-r[print version and release too with name]" \ + "($help)-R[reverse search to what requires package]" \ + "($help)-u[remove package if a better version is already installed]" \ + "($help -list --list-media --list-url --list-nodes --list-aliases)*:urpmi package name":_urpmi_rpms \ && ret=0 ;; + urpmf ) + # TODO this is not complete, some operators are missing + _arguments -A '-*' \ + $opts_help \ + $opts_media \ + "($help --name --group --size --epoch --summary --description --sourcerpm --packager --buildhost --url --provides --requires --files --conflicts --obsoletes)--all[print all tags]" \ + "($help --all --name)--buildhost[print tag buildhost: build host]" \ + "($help --all --name)--conflicts[print tag conflicts: all conflicts]" \ + "($help --all --name)--description[print tag description: description]" \ + "($help --all --name)--epoch[print tag epoch: epoch]" \ + "($help --all --name)--files[print tag files: all files]" \ + "($help --all --name)--group[print tag group: group]" \ + "($help --all --group --size --epoch --summary --description --sourcerpm --packager --buildhost --url --provides --requires --files --conflicts --obsoletes)--name[print only package names]" \ + "($help --all --name)--obsoletes[print tag obsoletes: all obsoletes]" \ + "($help --verbose)--quiet[do not print tag name]" \ + "($help --all --name)--packager[print tag packager: packager]" \ + "($help --all --name)--provides[print tag provides: all provides]" \ + "($help --all --name)--requires[print tag requires: all requires]" \ + "($help --all --name)--size[print tag size: size]" \ + "($help --all --name)--sourcerpm[print tag sourcerpm: source rpm]" \ + "($help --all --name)--summary[print tag summary: summary]" \ + "($help)--uniq[do not print identical lines]" \ + "($help --all --name)--url[print tag url: url]" \ + "($help --quiet)--verbose[verbose mode]" \ + "($help)*-a[binary AND operator]" \ + "($help)-i[ignore case distinctions in every pattern]" \ + "($help)-f[print version, release and arch with name]" \ + "($help)-e[include perl code directly as perl -e]:perl code: " \ + "($help)*-o[binary OR operator]" \ + && ret=0 + ;; + parsehdlist ) + # TODO this is not complete, some operators are missing + _arguments -A '-*' \ + $opts_help \ + "($help --interactive --quiet --name --group --size --epoch --summary --description --sourcerpm --packager --buildhost --url --provides --requires --files --conflicts --obsoletes)--all[print all tags]" \ + "($help --all --interactive --name)--buildhost[print tag buildhost: build host]" \ + "($help --all --interactive --name)--conflicts[print tag conflicts: all conflicts]" \ + "($help --all --interactive --name)--description[print tag description: description]" \ + "($help --all --interactive --name)--epoch[print tag epoch: epoch]" \ + "($help --all --interactive --name)--files[print tag files: all files]" \ + "($help --all --interactive --name)--group[print tag group: group]" \ + "($help --all --interactive --group --size --epoch --summary --description --sourcerpm --packager --buildhost --url --provides --requires --files --conflicts --obsoletes)--name[print only package names]" \ + "($help --all --interactive --name)--obsoletes[print tag obsoletes: all obsoletes]" \ + "($help --interactive)--quiet[do not print tag name]" \ + "($help --all --interactive --name)--packager[print tag packager: packager]" \ + "($help --all --interactive --name)--provides[print tag provides: all provides]" \ + "($help --all --interactive --name)--requires[print tag requires: all requires]" \ + "($help --all --interactive --name)--size[print tag size: size]" \ + "($help --all --interactive --name)--sourcerpm[print tag sourcerpm: source rpm]" \ + "($help --all --interactive --name)--summary[print tag summary: summary]" \ + "($help)--uniq[do not print identical lines]" \ + "($help --all --interactive --name)--url[print tag url: url]" \ + "*:hdlist files:_files -g '*.cz'" \ + && ret=0 + ;; esac return $ret } -local update_policy - -zstyle -s ":completion:*:*:urpmi:*" cache-policy update_policy -if [[ -z "$update_policy" ]]; then - zstyle ":completion:*:*:urpmi:*" cache-policy _urpmi_cache_policy -fi - _urpmi "$@" |