mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
16437: changes for new urpi in cooker
This commit is contained in:
parent
5659f442c0
commit
2cc2628cd1
2 changed files with 118 additions and 100 deletions
|
@ -1,3 +1,8 @@
|
|||
2002-01-13 Andrej Borsenkow <bor@zsh.org>
|
||||
|
||||
* 16437: Completion/Mandrake/Command/_urpmi: adapt
|
||||
to new urpmi version in cooker
|
||||
|
||||
2002-01-10 Sven Wischnowsky <wischnow@zsh.org>
|
||||
|
||||
* 16426: Completion/Unix/Command/_man,
|
||||
|
|
|
@ -1,82 +1,91 @@
|
|||
#compdef urpmi urpmi.addmedia urpmi.removemedia urpmi.update
|
||||
local state context line
|
||||
typeset -A opt_args
|
||||
|
||||
_urpmi_cache_policy() {
|
||||
[[ -e "$1" && -e /var/lib/urpmi/depslist.ordered && \
|
||||
"$1" -nt /var/lib/urpmi/depslist.ordered ]] && return 1
|
||||
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
|
||||
}
|
||||
|
||||
case "$service" in
|
||||
_urpmi() {
|
||||
local state context line ret=1
|
||||
typeset -A opt_args
|
||||
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
|
||||
|
||||
case "$service" in
|
||||
urpmi.addmedia )
|
||||
_arguments -A '-*' \
|
||||
"(--wget)--curl[use curl to retrieve distant files]" \
|
||||
"--distrib[automatically create all media from an installation medium]" \
|
||||
"--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]" \
|
||||
":name of media: " \
|
||||
":media URL:->media_url" \
|
||||
": :(with)" \
|
||||
":relative path to hdlist file: " \
|
||||
&& return 0
|
||||
&& ret=0
|
||||
;;
|
||||
urpmi.removemedia )
|
||||
_arguments -A '-*' \
|
||||
"(:)-a[select all media]" \
|
||||
"(-a)"{,\*}": :->urpmi_media" \
|
||||
&& return 0
|
||||
&& 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]" \
|
||||
"*-f[force rebuild of hdlist or base files (if repeated)]" \
|
||||
"-d[force complete computation of depslist.ordered file]" \
|
||||
"*-f[force generation of hdlist files]" \
|
||||
"(-a)"{,\*}": :->urpmi_media" \
|
||||
&& return 0
|
||||
&& ret=0
|
||||
;;
|
||||
urpmi )
|
||||
_arguments -A '-*' \
|
||||
"(: -)--help[print usage information]" \
|
||||
"(--help)--update[use only update media]" \
|
||||
"(--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)--force[preceed even when some packages do not exist]" \
|
||||
"(--help)--best-output[automatically select text or X interface]" \
|
||||
"(--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)--update[use only update media]" \
|
||||
"(--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)-c[choose complete method for resolving requires]" \
|
||||
"(--help)-p[allow 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" \
|
||||
&& return 0
|
||||
&& ret=0
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
case "$state" in
|
||||
case "$state" in
|
||||
media_url )
|
||||
if compset -P file://; then
|
||||
_files -W / -/ && return 0
|
||||
elif compset -P 'removable_cdrom(|_?)://'; then
|
||||
_files -/ && return 0
|
||||
elif compset -P removable_; then
|
||||
local -a devices
|
||||
locale dev foo
|
||||
while read dev foo; do
|
||||
[[ "$dev" != none ]] && devices=($devices ${dev#/dev/})
|
||||
done < /etc/fstab
|
||||
if [[ "$(rpm -q urpmi)" == urpmi-1.* ]]; then
|
||||
_wanted urpmi_device expl 'device for removable media' \
|
||||
compadd -s _ -S "" -a devices && return 0
|
||||
else
|
||||
_wanted urpmi_device expl 'device for removable media' \
|
||||
compadd -s :// -S "" -a devices && return 0
|
||||
fi
|
||||
if compset -P file:// || compset -P removable://; then
|
||||
_files -W / -/ && ret=0
|
||||
elif [[ -prefix '(ftp|http)://' ]]; then
|
||||
_urls && return 0
|
||||
_urls && ret=0
|
||||
else
|
||||
_wanted urpmi_media_type expl 'type of media' \
|
||||
compadd -- file:// http:// ftp:// removable_
|
||||
compadd -- file:// http:// ftp:// removable:// && ret=0
|
||||
fi
|
||||
;;
|
||||
urpmi_media )
|
||||
|
@ -87,25 +96,29 @@ case "$state" in
|
|||
compadd -- "$source"
|
||||
ret=0
|
||||
done < /etc/urpmi/urpmi.cfg
|
||||
return "$ret"
|
||||
;;
|
||||
urpmi_rpms )
|
||||
local pkg foo expl
|
||||
local -a pkgs
|
||||
if [[ -r /var/lib/urpmi/depslist.ordered ]]; then
|
||||
local -a synthesis
|
||||
synthesis=(/var/lib/urpmi/synthesis.*(N))
|
||||
(( $#synthesis > 0 )) && {
|
||||
if _cache_invalid _urpmi_rpms || ! _retrieve_cache _urpmi_rpms; then
|
||||
while read pkg foo; do
|
||||
[[ "$pkg" == (#b)(*)-[^-]##-[^-]## ]] && {
|
||||
pkgs[$#pkgs+1]=("$match[1]")
|
||||
}
|
||||
done < /var/lib/urpmi/depslist.ordered
|
||||
pkgs=($(zcat $synthesis | \
|
||||
grep @info@ | cut -d @ -f 3 | sed -e 's/\.[^.]*$//'))
|
||||
_store_cache _urpmi_rpms pkgs
|
||||
fi
|
||||
_wanted urpmi_rpms expl 'RPM to install' \
|
||||
compadd -a pkgs && return 0
|
||||
fi
|
||||
}
|
||||
(( $#pkgs > 0 )) && \
|
||||
_wanted urpmi_rpms expl 'urpmi RPMs to install' \
|
||||
compadd -a pkgs && ret=0
|
||||
(( $EUID == 0 )) && \
|
||||
_wanted urpmi_files expl 'RPM files to install' \
|
||||
_files -g '*.(#i)rpm' && ret=0
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
return 1
|
||||
return $ret
|
||||
}
|
||||
|
||||
_urpmi "$@"
|
||||
|
|
Loading…
Reference in a new issue