From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1269 invoked from network); 13 Jan 2002 10:28:14 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 13 Jan 2002 10:28:14 -0000 Received: (qmail 8247 invoked by alias); 13 Jan 2002 10:28:05 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16437 Received: (qmail 8236 invoked from network); 13 Jan 2002 10:28:05 -0000 From: Borsenkow Andrej To: Zsh hackers list Subject: PATCH: _urpmi update Content-Type: multipart/mixed; boundary="=-azonXygaTp85c3XaaSoc" X-Mailer: Evolution/1.0 (Preview Release) Date: 13 Jan 2002 13:27:52 +0300 Message-Id: <1010917673.4328.0.camel@localhost.localdomain> Mime-Version: 1.0 --=-azonXygaTp85c3XaaSoc Content-Type: text/plain Content-Transfer-Encoding: 7bit It seems that urpmi rewrite has stabilized so this syncs completion with current version. I stopped attempts to support several urpmi versions because it has been changing too rapidly and we do not have this completion in any released mandrake version as yet. Chmouel, if it looks O.K. please add to cooker? Should I add it to 4.0 as well? -andrej --=-azonXygaTp85c3XaaSoc Content-Disposition: attachment; filename=_urpmi.diff Content-Transfer-Encoding: quoted-printable Content-Type: text/x-diff; charset=KOI8-R Index: Completion/Mandrake/Command/_urpmi =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Completion/Mandrake/Command/_urpmi,v retrieving revision 1.2 diff -u -r1.2 _urpmi --- Completion/Mandrake/Command/_urpmi 2001/11/16 11:42:05 1.2 +++ Completion/Mandrake/Command/_urpmi 2002/01/13 10:23:12 @@ -1,111 +1,124 @@ #compdef urpmi urpmi.addmedia urpmi.removemedia urpmi.update -local state context line -typeset -A opt_args =20 _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=3D(/var/lib/urpmi/synthesis.*) + for i in $synthesis; do + [[ -e "$1" && -e "$i" && "$1" -nt "$i" ]] && return 1 + done return 0 } =20 -case "$service" in - urpmi.addmedia ) - _arguments -A '-*' \ - "--update[mark as update media]" \ - ":name of media: " \ - ":media URL:->media_url" \ - ": :(with)" \ - ":relative path to hdlist file: " \ - && return 0 - ;; - urpmi.removemedia ) - _arguments -A '-*' \ - "(:)-a[select all media]" \ - "(-a)"{,\*}": :->urpmi_media" \ - && return 0 - ;; - urpmi.update ) - _arguments -A '-*' \ - "(:)-a[select all non-removable media]" \ - "-c[clean /var/cache/urpmi/headers on exit]" \ - "*-f[force rebuild of hdlist or base files (if repeated)]" \ - "(-a)"{,\*}": :->urpmi_media" \ - && return 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)-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)"{,\*}": :->urpmi_rpms" \ - && return 0 - ;; -esac - -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" !=3D none ]] && devices=3D($devices ${dev#/dev/}) - done < /etc/fstab - if [[ "$(rpm -q urpmi)" =3D=3D urpmi-1.* ]]; then - _wanted urpmi_device expl 'device for removable media' \ - compadd -s _ -S "" -a devices && return 0 +_urpmi() { + local state context line ret=3D1 + 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: " \ + && ret=3D0 + ;; + urpmi.removemedia ) + _arguments -A '-*' \ + "(:)-a[select all media]" \ + "(-a)"{,\*}": :->urpmi_media" \ + && ret=3D0 + ;; + 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=3D0 + ;; + 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)--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=3D0 + ;; + esac + + case "$state" in + media_url ) + if compset -P file:// || compset -P removable://; then + _files -W / -/ && ret=3D0 + elif [[ -prefix '(ftp|http)://' ]]; then + _urls && ret=3D0 else - _wanted urpmi_device expl 'device for removable media' \ - compadd -s :// -S "" -a devices && return 0 + _wanted urpmi_media_type expl 'type of media' \ + compadd -- file:// http:// ftp:// removable:// && ret=3D0 fi - elif [[ -prefix '(ftp|http)://' ]]; then - _urls && return 0 - else - _wanted urpmi_media_type expl 'type of media' \ - compadd -- file:// http:// ftp:// removable_ - fi - ;; - urpmi_media ) - local source media brace ret=3D1 - while read source media brace; do - [[ "$brace" !=3D "{" ]] && continue - _wanted urpmi_media expl 'available media' \ - compadd -- "$source" - ret=3D0 - done < /etc/urpmi/urpmi.cfg - return "$ret" - ;; - urpmi_rpms ) - local pkg foo expl - local -a pkgs - if [[ -r /var/lib/urpmi/depslist.ordered ]]; then - if _cache_invalid _urpmi_rpms || ! _retrieve_cache _urpmi_rpms; = then - while read pkg foo; do - [[ "$pkg" =3D=3D (#b)(*)-[^-]##-[^-]## ]] && { - pkgs[$#pkgs+1]=3D("$match[1]") - } - done < /var/lib/urpmi/depslist.ordered - _store_cache _urpmi_rpms pkgs - fi - _wanted urpmi_rpms expl 'RPM to install' \ - compadd -a pkgs && return 0 - fi - ;; -esac + ;; + urpmi_media ) + local source media brace ret=3D1 + while read source media brace; do + [[ "$brace" !=3D "{" ]] && continue + _wanted urpmi_media expl 'available media' \ + compadd -- "$source" + ret=3D0 + done < /etc/urpmi/urpmi.cfg + ;; + urpmi_rpms ) + local pkg foo expl + local -a pkgs + local -a synthesis + synthesis=3D(/var/lib/urpmi/synthesis.*(N)) + (( $#synthesis > 0 )) && { + if _cache_invalid _urpmi_rpms || ! _retrieve_cache _urpmi_rpms; then + pkgs=3D($(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=3D0 + (( $EUID =3D=3D 0 )) && \ + _wanted urpmi_files expl 'RPM files to install' \ + _files -g '*.(#i)rpm' && ret=3D0 + ;; + esac =20 -return 1 + return $ret +} =20 +_urpmi "$@" --=-azonXygaTp85c3XaaSoc--