--- toast 2005/09/17 06:28:18 1.408 +++ toast 2005/09/19 04:47:38 1.409 @@ -2202,15 +2202,28 @@ $url = cleanurl($url); } + my(@links) = $url; for(1..3) { - if(lookslikepkgurl($url)) + $url = $links[$#links]; + @links = sort cmpab grep(lookslikepkgurl($_), @links); + my(@result); + for(@links) { - (undef, $version) = guessnv($url) unless defined($version); - return [$name, $version, undef, $url]; + my($v) = $version; + (undef, $v) = guessnv($_) unless defined($v); + push(@result, [$name, $v, undef, $_]) } + if(scalar(@result) == 1) + { + eval + { + @result = findnewerpkg(@{$result[0]}) + } + } + return @result if @result; - my(@links) = linksfromurl($url); + @links = linksfromurl($url); my(@urls) = grep(lookslikepkgurl($_, $name, $version), @links); my($ext); for $ext (qw[.tar.bz2 .tar.gz .tgz .zip .deb .rpm]) @@ -2220,30 +2233,25 @@ my(@namematches) = grep { my($n) = guessnv($_); $n eq $name } @matches; @matches = @namematches if @namematches; - my($matchver) = $version; - if(!defined($matchver)) + if(defined($version)) { - my(@versions) = map { my(undef, $v) = guessnv($_); $v } @matches; - @versions = grep(defined($_), @versions); - if(@versions) - { - @versions = reverse sort cmpab @versions; - $matchver = $versions[0]; - @matches = grep - { - my(undef, $v) = guessnv($_); - defined($v) && $v eq $matchver; - } @matches; - } + my(@vermatches) = + grep { my(undef, $v) = guessnv($_); $v eq $version } @matches; + @matches = @vermatches if @vermatches; } - # TODO: return an ordered list of candidates, not just the best match - return ([$name, $matchver, undef, $matches[0]]) if @matches; + @matches = sort cmpab @matches; + @result = (); + for(@matches) + { + my($undef, $v) = guessnv($_); + push(@result, [$name, $v, undef, $_]); + } + return @result if @result; } @links = grep(/^\Q$url\E/, @links); last unless @links; - $url = pop(@links); } error("can't find URLs for " . pkgname($name, $version) . " at $url"); @@ -4510,7 +4518,7 @@ error unless defined($name); error if defined($build); - my(@pkgs) = isadded($name, $version) + my(@pkgs) = @urls || isadded($name, $version) ? findnewerpkg($name, $version, @urls) : findnewpkg($name, $version); @@ -6257,6 +6265,18 @@ =over 4 +=item s<B<toast find> I<PACKAGE> ...> + +Locate some of the URLs from which a package could be downloaded. +This command does not write to the disk at all. The output format is +similar to that of B<toast status>, but all information comes from the +network rather than the on-disk package database. If a given package +has not been added and no URLs were specified on the command line, +B<toast find> looks for an exact name match on freshmeat.net; otherwise +it attempts to list the directory or directories to which the package's +URL(s) belong. If an explicit version number is given, only that version +is listed; otherwise all versions are listed from oldest to newest. + =item S<B<toast add> I<PACKAGE> ...> Adds new packages to the repository by storing URLs. Use this command to @@ -6724,10 +6744,9 @@ =item S<B<--autofind> | B<--noautofind>> When B<autofind> is enabled, B<toast add> and other commands will -automatically look up package URLs on freshmeat.net when none have -been added previously or given explicitly. If no version number is -given either, the latest version listed on freshmeat.net will be used. -Default: enabled. +automatically look up package URLs as if by B<toast find> when none +have been added previously or given explicitly. If no version number +is given either, the latest version found will be used. Default: enabled. =item S<B<--autochange> | B<--noautochange>> @@ -7127,7 +7146,6 @@ - "toast edit" leaves things in an odd state if you hang up on it - "toast rename" is more case-sensitive than it ought to be - "toast get" prevents wget from truncating output if transfer restarts - - "toast find" is undocumented and shows only best match for new pkgs - "toast env" doesn't set PYTHONPATH Wish list: @@ -7155,6 +7173,7 @@ - have autofind/upgrade prompt for version (?) - optionally have toast add imply change, then make get+build smarter - toast status/env should allow multiple read-only storedirs/armdirs + - autofind should try other sites if freshmeat.net has no listing - fold archives by URL and/or hash? - zsh completions!