zsh-workers
 help / color / mirror / code / Atom feed
* _values does not quote inserted matches
@ 2002-04-13 20:38 Borsenkow Andrej
  2002-04-13 23:26 ` Bart Schaefer
  0 siblings, 1 reply; 15+ messages in thread
From: Borsenkow Andrej @ 2002-04-13 20:38 UTC (permalink / raw)
  To: Zsh hackers list

Using current CVS:

{pts/3}% _foo() {
function> _values -s , test "a b" "c d"
function> }
{pts/3}% compdef _foo foo
{pts/3}% foo a b,
Completing test
a b  c d

note, that match inserted into command line is not quoted that makes it
impossible to complete more than one value.

-andrej



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: _values does not quote inserted matches
  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
  0 siblings, 2 replies; 15+ messages in thread
From: Bart Schaefer @ 2002-04-13 23:26 UTC (permalink / raw)
  To: Borsenkow Andrej, Zsh hackers list

On Apr 14, 12:38am, Borsenkow Andrej wrote:
} Subject: _values does not quote inserted matches
}
} note, that match inserted into command line is not quoted that makes it
} impossible to complete more than one value.

The problem is this stuff at lines 54-58 of _values:

      if [[ ${#noargs}+${#args}+${#opts} -ne 1 ]] && compvalues -s sep; then
        sep=( "-qQS" "$sep" )
      else
        sep=()
      fi

I don't know why the Q is included on line 55?  It seems to all work OK if
I take it out.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: _values does not quote inserted matches
  2002-04-13 23:26 ` Bart Schaefer
@ 2002-04-16  6:11   ` Borsenkow Andrej
  2002-04-16  7:54   ` Sven Wischnowsky
  1 sibling, 0 replies; 15+ messages in thread
From: Borsenkow Andrej @ 2002-04-16  6:11 UTC (permalink / raw)
  To: 'Zsh hackers list'

> On Apr 14, 12:38am, Borsenkow Andrej wrote:
> } Subject: _values does not quote inserted matches
> }
> } note, that match inserted into command line is not quoted that makes
it
> } impossible to complete more than one value.
> 
> The problem is this stuff at lines 54-58 of _values:
> 
>       if [[ ${#noargs}+${#args}+${#opts} -ne 1 ]] && compvalues -s
sep; then
>         sep=( "-qQS" "$sep" )
>       else
>         sep=()
>       fi
> 
> I don't know why the Q is included on line 55?  It seems to all work
OK if
> I take it out.
> 

I'd like to here Sven's comment on it. Sven, are we expected to pass
fully quoted strings to _values (in this case, where is it documented?)
or is _value expected to behave just like most other completion
functions, quoting inserted strings automatically?

-andrej


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: _values does not quote inserted matches
  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
  1 sibling, 1 reply; 15+ messages in thread
From: Sven Wischnowsky @ 2002-04-16  7:54 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Apr 14, 12:38am, Borsenkow Andrej wrote:
> } Subject: _values does not quote inserted matches
> }
> } note, that match inserted into command line is not quoted that makes it
> } impossible to complete more than one value.
> 
> The problem is this stuff at lines 54-58 of _values:
> 
>       if [[ ${#noargs}+${#args}+${#opts} -ne 1 ]] && compvalues -s sep; then
>         sep=( "-qQS" "$sep" )
>       else
>         sep=()
>       fi
> 
> I don't know why the Q is included on line 55?  It seems to all work OK if
> I take it out.

Same for me. And I couldn't find when we added this, so it's probably
very old, from a time when _values was less sophisticated about
separators with special characters or something.

So, let's try.


Bye
  Sven

Index: Completion/Base/Utility/_values
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_values,v
retrieving revision 1.7
diff -u -r1.7 _values
--- Completion/Base/Utility/_values	22 Jan 2002 10:22:48 -0000	1.7
+++ Completion/Base/Utility/_values	16 Apr 2002 07:54:35 -0000
@@ -51,7 +51,7 @@
     else
       compvalues -d descr
       if [[ ${#noargs}+${#args}+${#opts} -ne 1 ]] && compvalues -s sep; then
-        sep=( "-qQS" "$sep" )
+        sep=( "-qS" "$sep" )
       else
         sep=()
       fi

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: _values does not quote inserted matches
  2002-04-16  7:54   ` Sven Wischnowsky
@ 2002-04-16 10:08     ` Borsenkow Andrej
  2002-04-16 16:07       ` Bart Schaefer
  0 siblings, 1 reply; 15+ messages in thread
From: Borsenkow Andrej @ 2002-04-16 10:08 UTC (permalink / raw)
  To: 'Sven Wischnowsky', zsh-workers


> > I don't know why the Q is included on line 55?  It seems to all work
OK if
> > I take it out.
> 
> Same for me. And I couldn't find when we added this, so it's probably
> very old, from a time when _values was less sophisticated about
> separators with special characters or something.
> 
> So, let's try.
> 

Now, this does quote inserted string which is good. Unfortunately, it is
still confused by inserted quotes ... 

_urpmi_media() {
    local source media brace
    local -a all_sources suf
    local context state line
    typeset -A val_args
    while read source media brace; do
        [[ "$brace" != "{" ]] && continue
        all_sources=($all_sources[@] $source)
    done < /etc/urpmi/urpmi.cfg

    _values -s , 'urpmi media' $all_sources
}

bor@cooker% urpmi --media Contrib\ CD,
Completing urpmi media
Contrib CD        Installation CD

So far so good. But if I now hit ENTER and try complete again ...

bor@cooker% urpmi --media Contrib\ CD,
No matches for: `urpmi media'

Looks like _values get confused by quoting on command line?

-andrej


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: _values does not quote inserted matches
  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
  0 siblings, 2 replies; 15+ messages in thread
From: Bart Schaefer @ 2002-04-16 16:07 UTC (permalink / raw)
  To: Borsenkow Andrej, zsh-workers

On Apr 16,  2:08pm, Borsenkow Andrej wrote:
}
} Now, this does quote inserted string which is good. Unfortunately, it is
} still confused by inserted quotes ... 

I tried to reproduce this, but I don't have the version of _urpmi that
calls _urpmi_media ... which I didn't notice at first, and then I spent
an inordinate amount of time figuring out why I was getting

zsh% urpmi <TAB>
zsh% urpmi expl=''
expl=''
expl=''
expl=''

It turned out to be an extraneous `local expl' in the version of _urpmi
that I do have:

@@ -92,7 +92,7 @@
 	    done < /etc/urpmi/urpmi.cfg
 	;;
 	urpmi_rpms )
-	    local pkg foo expl
+	    local pkg foo
 	    local -a pkgs
 	    local -a synthesis
 	    synthesis=(/var/lib/urpmi/synthesis.*(N))

Andrej, please fix that when you're committing your other changes.

} bor@cooker% urpmi --media Contrib\ CD,
} No matches for: `urpmi media'
} 
} Looks like _values get confused by quoting on command line?

I finally did reproduce this with a simpler compdef, and looked at the
_complete_debug output.

The problem doesn't seem to be with _values, per se ... it's either in the
`compvalues' C function, or somewhere down below _describe.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 15+ messages in thread

* PATCH: Re: _values does not quote inserted matches
  2002-04-16 16:07       ` Bart Schaefer
@ 2002-04-17  7:26         ` Sven Wischnowsky
  2002-04-19  8:37         ` Borsenkow Andrej
  1 sibling, 0 replies; 15+ messages in thread
From: Sven Wischnowsky @ 2002-04-17  7:26 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> The problem doesn't seem to be with _values, per se ... it's either in the
> `compvalues' C function, or somewhere down below _describe.

Right. The former. And it's weird that I forgot it there, because it
did it for comparguments. Hm. Anyaway. The patch below copies the
appropriate piece of code from comparguments to compvalues.

I'll also apply this to 4.0.


Bye
  Sven

Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.76
diff -u -r1.76 computil.c
--- Src/Zle/computil.c	18 Feb 2002 14:36:02 -0000	1.76
+++ Src/Zle/computil.c	17 Apr 2002 07:25:12 -0000
@@ -2768,6 +2768,23 @@
     return NULL;
 }
 
+static Cvval
+cv_quote_get_val(Cvdef d, char *name)
+{
+    int ne;
+
+    /* remove quotes */
+    name = dupstring(name);
+    ne = noerrs;
+    noerrs = 2;
+    parse_subst_string(name);
+    noerrs = ne;
+    remnulargs(name);
+    untokenize(name);
+
+    return cv_get_val(d, name);
+}
+
 /* Handle a xor list. */
 
 static void
@@ -2820,7 +2837,7 @@
         do {
             sav = *++s;
             *s = '\0';
-            if ((r = cv_get_val(d, v))) {
+            if ((r = cv_quote_get_val(d, v))) {
                 *s = sav;
 
                 break;
@@ -2864,7 +2881,7 @@
             sav = *sap;
             *sap = '\0';
         }
-        if ((!(r = cv_get_val(d, s)) || r->type == CVV_NOARG) && skip)
+        if ((!(r = cv_quote_get_val(d, s)) || r->type == CVV_NOARG) && skip)
             ns = as;
 
         if (sap)
@@ -2886,7 +2903,7 @@
         } else
             *ap = sap = NULL;
 
-        r = cv_get_val(d, s);
+        r = cv_quote_get_val(d, s);
 
         if (sap)
             *sap = sav;

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: _values does not quote inserted matches
  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
  1 sibling, 1 reply; 15+ messages in thread
From: Borsenkow Andrej @ 2002-04-19  8:37 UTC (permalink / raw)
  To: 'Bart Schaefer', zsh-workers

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]

> It turned out to be an extraneous `local expl' in the version of
_urpmi
> that I do have:
> 
> @@ -92,7 +92,7 @@
>  	    done < /etc/urpmi/urpmi.cfg
>  	;;
>  	urpmi_rpms )
> -	    local pkg foo expl
> +	    local pkg foo
>  	    local -a pkgs
>  	    local -a synthesis
>  	    synthesis=(/var/lib/urpmi/synthesis.*(N))
> 
> Andrej, please fix that when you're committing your other changes.
> 

Here is updated version. It relies on recent _values fixes. The
completion is correct for Mandrake 8.2. If you say O.K it will go in
both head and 4.0.

I'd like to use common with _rpm cache and functions to get list of
installed RPMs, but _rpm is one large function and I am reluctant to
split it (I remember somebody was against it, but forgot reasons).

-andrej


[-- Attachment #2: _urpmi --]
[-- Type: application/octet-stream, Size: 6065 bytes --]

#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
}
    
_urpmi_media() {
    local source media brace expl
    local -a all_sources

    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
    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

    _wanted urpmi_files expl 'RPM files to install' \
	_files "$@" -g '*.(#i)rpm' && ret=0

    _wanted urpmi_source_files expl 'source RPM files to install' \
	_files "$@" -g '*.(#i)src.rpm' && ret=0

    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 urpmi_media_type 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 state context line ret=1
    typeset -A opt_args

    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
}

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 "$@"

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: _values does not quote inserted matches
  2002-04-19  8:37         ` Borsenkow Andrej
@ 2002-04-19 16:54           ` Bart Schaefer
  2002-04-23  9:45             ` Oliver Kiddle
  0 siblings, 1 reply; 15+ messages in thread
From: Bart Schaefer @ 2002-04-19 16:54 UTC (permalink / raw)
  To: zsh-workers

On Apr 19, 12:37pm, Borsenkow Andrej wrote:
}
} Here is updated version. It relies on recent _values fixes. The
} completion is correct for Mandrake 8.2. If you say O.K it will go in
} both head and 4.0.

Somebody other than me (Peter?  Oliver?  Sven?) should give the OK.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: _values does not quote inserted matches
  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               ` PATCH: _urpmi update Borsenkow Andrej
  0 siblings, 2 replies; 15+ messages in thread
From: Oliver Kiddle @ 2002-04-23  9:45 UTC (permalink / raw)
  To: zsh-workers

Andrej wrote:
> 
> Here is updated version. It relies on recent _values fixes. The
> completion is correct for Mandrake 8.2. If you say O.K it will go in
> both head and 4.0.

Are the recent _values fixes going on the 4.0 branch then? I'd say that
was questionable without first checking through _values calls for
quoted strings. Presumably _urpmi can be adjusted for the old _values
fairly easily so if Andrej is happy that it works on each branch, it
gets my okay.

> I'd like to use common with _rpm cache and functions to get list of
> installed RPMs, but _rpm is one large function and I am reluctant to
> split it (I remember somebody was against it, but forgot reasons).

I can't think of any reason why not. It is very similar to the Debian
situation where we have an _deb_packages used by both _dpkg and _apt.
Maybe the reasons against splitting _rpm before was based on rpm being
the only command to complete rpm packages.

Bart wrote:
> Somebody other than me (Peter?  Oliver?  Sven?) should give the OK.

Well I haven't been able to test the _values calling part as it gets
its arguments by parsing urpmi.cfg which I don't have.

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.

Oliver
-- 

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: _values does not quote inserted matches
  2002-04-23  9:45             ` Oliver Kiddle
@ 2002-04-24  7:37               ` Sven Wischnowsky
  2002-05-06  7:04               ` PATCH: _urpmi update Borsenkow Andrej
  1 sibling, 0 replies; 15+ messages in thread
From: Sven Wischnowsky @ 2002-04-24  7:37 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> Andrej wrote:
> > 
> > Here is updated version. It relies on recent _values fixes. The
> > completion is correct for Mandrake 8.2. If you say O.K it will go in
> > both head and 4.0.
> 
> Are the recent _values fixes going on the 4.0 branch then? I'd say that
> was questionable without first checking through _values calls for
> quoted strings. Presumably _urpmi can be adjusted for the old _values
> fairly easily so if Andrej is happy that it works on each branch, it
> gets my okay.

Well, the C-code changes (16998) have been applied to 4.0. If that's
everything this patch relies upon, it's probably ok. No doubt Andrej
has made or will make sure.

> > I'd like to use common with _rpm cache and functions to get list of
> > installed RPMs, but _rpm is one large function and I am reluctant to
> > split it (I remember somebody was against it, but forgot reasons).
> 
> I can't think of any reason why not. It is very similar to the Debian
> situation where we have an _deb_packages used by both _dpkg and _apt.
> Maybe the reasons against splitting _rpm before was based on rpm being
> the only command to complete rpm packages.

I think we only were against splitting it up so that we have one
function file per sub-command. Factoring out the completion of RPM
names is alright, I think.

> Bart wrote:
> > Somebody other than me (Peter?  Oliver?  Sven?) should give the OK.
> 
> Well I haven't been able to test the _values calling part as it gets
> its arguments by parsing urpmi.cfg which I don't have.
> 
> 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. My only other comment is that the indentation style is
completely different from our normal one in the completion functions.


Bye
  Sven

-- 
Sven Wischnowsky                          wischnow@berkom.de


^ permalink raw reply	[flat|nested] 15+ messages in thread

* PATCH: _urpmi update
  2002-04-23  9:45             ` Oliver Kiddle
  2002-04-24  7:37               ` Sven Wischnowsky
@ 2002-05-06  7:04               ` Borsenkow Andrej
  1 sibling, 0 replies; 15+ messages in thread
From: Borsenkow Andrej @ 2002-05-06  7:04 UTC (permalink / raw)
  To: zsh-workers

[-- 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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: PATCH: _urpmi update
  2002-01-14 10:04 ` Chmouel Boudjnah
@ 2002-01-14 10:23   ` Borsenkow Andrej
  0 siblings, 0 replies; 15+ messages in thread
From: Borsenkow Andrej @ 2002-01-14 10:23 UTC (permalink / raw)
  To: 'Chmouel Boudjnah'; +Cc: 'Zsh hackers list'

[-- Attachment #1: Type: text/plain, Size: 475 bytes --]

> Borsenkow Andrej <Andrej.Borsenkow@mow.siemens.ru> writes:
> 
> > 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?
> 
> yup look ok...

small fix (mostly for urpmi.addmedia --distrib)

-andrej


[-- Attachment #2: _urpmi.diff --]
[-- Type: application/octet-stream, Size: 1809 bytes --]

Index: Completion/Mandrake/Command/_urpmi
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Mandrake/Command/_urpmi,v
retrieving revision 1.3
diff -u -r1.3 _urpmi
--- Completion/Mandrake/Command/_urpmi	2002/01/13 13:11:18	1.3
+++ Completion/Mandrake/Command/_urpmi	2002/01/14 10:23:07
@@ -13,27 +13,21 @@
 _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]" \
+		"(:)--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]" \
-		":name of media: " \
-		":media URL:->media_url" \
-		": :(with)" \
-		":relative path to hdlist file: " \
+		"(--distrib):name of media: " \
+		"(--distrib):media URL:->media_url" \
+		"(--distrib): :(with)" \
+		"(--distrib):relative path to hdlist file: " \
 	     && ret=0
 	;;
 	urpmi.removemedia )
@@ -120,5 +114,12 @@
 
     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 "$@"

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: PATCH: _urpmi update
  2002-01-13 10:27 Borsenkow Andrej
@ 2002-01-14 10:04 ` Chmouel Boudjnah
  2002-01-14 10:23   ` Borsenkow Andrej
  0 siblings, 1 reply; 15+ messages in thread
From: Chmouel Boudjnah @ 2002-01-14 10:04 UTC (permalink / raw)
  To: Borsenkow Andrej; +Cc: Zsh hackers list

Borsenkow Andrej <Andrej.Borsenkow@mow.siemens.ru> writes:

> 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?

yup look ok...


^ permalink raw reply	[flat|nested] 15+ messages in thread

* PATCH: _urpmi update
@ 2002-01-13 10:27 Borsenkow Andrej
  2002-01-14 10:04 ` Chmouel Boudjnah
  0 siblings, 1 reply; 15+ messages in thread
From: Borsenkow Andrej @ 2002-01-13 10:27 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

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


[-- Attachment #2: _urpmi.diff --]
[-- Type: text/x-diff, Size: 7970 bytes --]

Index: Completion/Mandrake/Command/_urpmi
===================================================================
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
 
 _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.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" != 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
+_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: " \
+	     && 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)--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_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=0
 	    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=1
-	while read source media brace; do
-	    [[ "$brace" != "{" ]] && continue
-	    _wanted urpmi_media expl 'available media' \
-		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
-	    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
-		_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=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
 
-return 1
+    return $ret
+}
 
+_urpmi "$@"

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2002-05-06  7:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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               ` PATCH: _urpmi update Borsenkow Andrej
  -- strict thread matches above, loose matches on Subject: below --
2002-01-13 10:27 Borsenkow Andrej
2002-01-14 10:04 ` Chmouel Boudjnah
2002-01-14 10:23   ` Borsenkow Andrej

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).