From: Borsenkow Andrej <Andrej.Borsenkow@mow.siemens.ru>
To: zsh-workers@sunsite.dk
Subject: PATCH: _urpmi update
Date: Mon, 6 May 2002 11:04:04 +0400 [thread overview]
Message-ID: <6134254DE87BD411908B00A0C99B044F02E89A34@mowd019a.mow.siemens.ru> (raw)
In-Reply-To: <20020423094513.GA20267@logica.com>
[-- Attachment #1: Type: text/plain, Size: 527 bytes --]
>
> Looking over the rest it looks fine. The one thing I see that I would
> do differently is to have a single tags loop in _urpmi_rpms instead
> of the three consecutive _wanted calls. It also adds source and
> binary rpms separately which means that directories get added twice.
> I think it'd be better to add them together - a user can always
> separate them with a file-patterns style.
>
Right. This also changes indentation (sorry, Sven, I just have 'set
sw=4' in .vimrc as I happen to like it the most :-)
-andrej
[-- Attachment #2: zsh-urpmi.diff --]
[-- Type: application/octet-stream, Size: 10271 bytes --]
Index: Completion/Mandrake/Command/_urpmi
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Mandrake/Command/_urpmi,v
retrieving revision 1.5
diff -u -r1.5 _urpmi
--- Completion/Mandrake/Command/_urpmi 16 Jan 2002 16:29:52 -0000 1.5
+++ Completion/Mandrake/Command/_urpmi 6 May 2002 07:00:20 -0000
@@ -1,118 +1,170 @@
-#compdef urpmi urpmi.addmedia urpmi.removemedia urpmi.update
+#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
+ 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
}
+_urpmi_media() {
+ local source media brace expl
+ local -a all_sources
+
+ [[ -f /etc/urpmi/urpmi.cfg ]] || return 1
+
+ while read source media brace; do
+ [[ "$brace" != "{" ]] && continue
+ all_sources=("$all_sources[@]" $source)
+ done < /etc/urpmi/urpmi.cfg
+
+ _values -s , 'urpmi media' "$all_sources[@]"
+}
+
+_urpmi_rpms() {
+ local pkg ret=1 expl
+
+ _tags rpms files
+
+ while _tags; do
+ if _requested rpms expl 'urpmi RPMs'; 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
+ fi
+
+ _requested files expl '(S)RPM files' \
+ _files -g '*.(#i)rpm' && ret=0
+ done
+
+ return $ret
+}
+
+_urpmi_media_url() {
+ local expl ret=1
+
+ if compset -P file:// || compset -P removable://; then
+ _files "$@" -W / -/ && ret=0
+ elif [[ -prefix '(ftp|http)://' ]]; then
+ _urls "$@" && ret=0
+ else
+ _wanted mediatype expl 'type of media' \
+ compadd "$@" -- file:// http:// ftp:// removable:// && ret=0
+ fi
+
+ return $ret
+}
+
+_urpme_package() {
+ local -a _rpms
+ _rpms=( $(_call_program packages rpm -qa 2>/dev/null) )
+ compadd "$@" -a -- _rpms
+}
+
_urpmi() {
- local expl state curcontext="$curcontext" line ret=1
- typeset -A opt_args
+ local state context line ret=1
+ typeset -A opt_args
- case "$service" in
- urpmi.addmedia )
- _arguments -C -A '-*' \
- "(--wget)--curl[use curl to retrieve distant files]" \
- "(:)--distrib[automatically create all media from an installation medium]:media URL:->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:->media_url" \
- "(--distrib): :(with)" \
- "(--distrib):relative path to hdlist file: " \
- && ret=0
- ;;
- urpmi.removemedia )
- _arguments -C -A '-*' \
- "(:)-a[select all media]" \
- "(-a)"{,\*}": :->urpmi_media" \
- && ret=0
- ;;
- urpmi.update )
- _arguments -C -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" \
- && ret=0
- ;;
- urpmi )
- _arguments -C -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)--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)-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" \
- && ret=0
- ;;
- esac
-
- case "$state" in
- media_url )
- if compset -P file:// || compset -P removable://; then
- _files -W / -/ && ret=0
- elif [[ -prefix '(ftp|http)://' ]]; then
- _urls && ret=0
- else
- _wanted urpmi_media_type expl 'type of media' \
- compadd -- file:// http:// ftp:// removable:// && ret=0
- fi
- ;;
- urpmi_media )
- local source media brace ret=1
- while read source media brace; do
- [[ "$brace" != "{" ]] && continue
- _wanted urpmi_media expl 'available media' \
- compadd -- "$source"
- ret=0
- done < /etc/urpmi/urpmi.cfg
- ;;
- urpmi_rpms )
- local pkg foo expl
- local -a pkgs
- local -a synthesis
- synthesis=(/var/lib/urpmi/synthesis.*(N))
- (( $#synthesis > 0 )) && {
- 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
- }
- (( $#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
+ case "$service" in
+ urpme )
+ _arguments -A '-*' \
+ "--auto[do not ask any question]" \
+ "-a[find all matches]" \
+ ": :_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: " \
+ && ret=0
+ ;;
+ urpmi.removemedia )
+ _arguments -A '-*' \
+ "(:)-a[select all media]" \
+ "(-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" \
+ && 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 --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" \
+ && 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 depndencies]" \
+ "(--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: " \
+ && ret=0
+ ;;
+ esac
- return $ret
+ return $ret
}
local update_policy
next prev parent reply other threads:[~2002-05-06 7:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-13 20:38 _values does not quote inserted matches Borsenkow Andrej
2002-04-13 23:26 ` Bart Schaefer
2002-04-16 6:11 ` Borsenkow Andrej
2002-04-16 7:54 ` Sven Wischnowsky
2002-04-16 10:08 ` Borsenkow Andrej
2002-04-16 16:07 ` Bart Schaefer
2002-04-17 7:26 ` PATCH: " Sven Wischnowsky
2002-04-19 8:37 ` Borsenkow Andrej
2002-04-19 16:54 ` Bart Schaefer
2002-04-23 9:45 ` Oliver Kiddle
2002-04-24 7:37 ` Sven Wischnowsky
2002-05-06 7:04 ` Borsenkow Andrej [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-01-13 10:27 PATCH: _urpmi update Borsenkow Andrej
2002-01-14 10:04 ` Chmouel Boudjnah
2002-01-14 10:23 ` Borsenkow Andrej
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6134254DE87BD411908B00A0C99B044F02E89A34@mowd019a.mow.siemens.ru \
--to=andrej.borsenkow@mow.siemens.ru \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).