Skip Menu |

This queue is for tickets about the CPAN CPAN distribution.

Report information
The Basics
Id: 32525
Status: resolved
Priority: 0/
Queue: CPAN

People
Owner: Nobody in particular
Requestors: imacat [...] mail.imacat.idv.tw
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.9205
Fixed in: (no value)



Subject: Show Updated Packages by their Main Modules
Dear Andreas J. König, Hi. This is imacat from Taiwan. I found that when I issue an "r" command, the CPAN shell returns the first modules of the updated packages it found, but not the main modules of the package: imacat@rinse ~ % echo r | /opt/perl/5.8.8/bin/cpan 2>&1 | grep MakeMaker ExtUtils::Command::MM 0.05 6.42 M/MS/MSCHWERN/ExtUtils-MakeMaker-6.42.tar.gz imacat@rinse ~ % It would be more useful if it can return the main modules of the updated packages, for example, imacat@rinse ~ % echo r | /opt/perl/5.8.8/bin/cpan 2>&1 | grep MakeMaker ExtUtils::MakeMaker 6.30 6.42 M/MS/MSCHWERN/ExtUtils-MakeMaker-6.42.tar.gz imacat@rinse ~ % I tried to create a patch against CPAN-1.9205, in order to do this, based on a script I'm using. I wonder if this patch can be applied to the CPAN in the next upcoming release. Hope that this helps. Please tell me if there is any problem, or if I could be of any help. Thank you.
Subject: CPAN-1.9205-updmodname.diff
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 diff -u -r CPAN-1.9205.orig/lib/CPAN.pm CPAN-1.9205/lib/CPAN.pm - --- CPAN-1.9205.orig/lib/CPAN.pm 2007-11-11 19:45:55.000000000 +0800 +++ CPAN-1.9205/lib/CPAN.pm 2008-01-23 02:03:46.000000000 +0800 @@ -2519,6 +2519,115 @@ # for metadata cache $CPAN::Frontend->myprint(sprintf "%d matches in the database\n", $expand); } + if ($what eq "r") { + @_ = grep $_->inst_file + && $_->inst_version ne "undef" + && CPAN::Version->vcmp($_->inst_version,0)!=0 + && CPAN::Version->vgt($_->cpan_version, $_->inst_version), + @expand; + if (@_ > 0) { + %_ = qw(); + # Only report unique distributions + # Sort modules by their distribution files + foreach (@_) { + $_{$_->cpan_file} = [] if !exists $_{$_->cpan_file}; + push @{$_{$_->cpan_file}}, $_; + push @result, $_->id; + } + # Keep only one module for each distribution + foreach my $file (keys %_) { + # Find the representive module, whose name matches + # the distribution name + my $pm; + $pm = $file; + $pm =~ s/^.+\///; + $pm =~ s/-\d+\..+$//; + $pm =~ s/-/::/g; + # The representive module exists + if ((@_ = grep $_->id eq $pm, @{$_{$file}}) > 0) { + $_{$file} = $_[0]; + # There is no representive module, take the first module + # sorted by module names. + } else { + $_{$file} = (sort { $a->id cmp $b->id } @{$_{$file}})[0]; + } + } + # Take the modules of unique distributions, sorted by + # module names. + @_ = sort { $a->id cmp $b->id } values %_; + + $CPAN::Frontend->myprint("\n"); + $CPAN::Frontend->myprint(sprintf( + $sprintf, + "", + "Package namespace", + "", + "installed", + "latest", + "in CPAN file" + )); + my $color_on = ""; + my $color_off = ""; + if ( + $COLOR_REGISTERED + && + $CPAN::META->has_inst("Term::ANSIColor") + && + $module->description + ) { + $color_on = Term::ANSIColor::color("green"); + $color_off = Term::ANSIColor::color("reset"); + } + $CPAN::Frontend->myprint(sprintf $sprintf, + $color_on, + $_->id, + $color_off, + $_->inst_version, + $_->cpan_version, + $_->cpan_file) + foreach @_; + } + $CPAN::Frontend->myprint("All modules are up to date for @args\n") + if @result == 0; + return if $CPAN::Signal; + @version_zeroes = map $_->as_glimpse, grep $_->inst_file + && $_->inst_version ne "undef" + && CPAN::Version->vcmp($_->inst_version,0)==0, @expand; + $version_zeroes = scalar @version_zeroes; + if ($version_zeroes) { + my $s_has = $version_zeroes > 1 ? "s have" : " has"; + $CPAN::Frontend->myprint(qq{$version_zeroes installed module$s_has }. + qq{a version number of 0\n}); + if ($CPAN::Config->{show_zero_versions}) { + local $" = "\t"; + $CPAN::Frontend->myprint(qq{ they are\n\t@version_zeroes\n}); + $CPAN::Frontend->myprint(qq{(use 'o conf show_zero_versions 0' }. + qq{to hide them)\n}); + } else { + $CPAN::Frontend->myprint(qq{(use 'o conf show_zero_versions 1' }. + qq{to show them)\n}); + } + } + return if $CPAN::Signal; + @version_undefs = map $_->as_glimpse, grep $_->inst_file + && $_->inst_version eq "undef", @expand; + $version_undefs = scalar @version_undefs; + if ($version_undefs) { + my $s_has = $version_undefs > 1 ? "s have" : " has"; + $CPAN::Frontend->myprint(qq{$version_undefs installed module$s_has no }. + qq{parseable version number\n}); + if ($CPAN::Config->{show_unparsable_versions}) { + local $" = "\t"; + $CPAN::Frontend->myprint(qq{ they are\n\t@version_undefs\n}); + $CPAN::Frontend->myprint(qq{(use 'o conf show_unparsable_versions 0' }. + qq{to hide them)\n}); + } else { + $CPAN::Frontend->myprint(qq{(use 'o conf show_unparsable_versions 1' }. + qq{to show them)\n}); + } + } + return @result; + } MODULE: for $module (@expand) { my $file = $module->cpan_file; next MODULE unless defined $file; # ?? @@ -2530,17 +2639,6 @@ if ($inst_file) { if ($what eq "a") { $have = $module->inst_version; - - } elsif ($what eq "r") { - - $have = $module->inst_version; - - local($^W) = 0; - - if ($have eq "undef") { - - $version_undefs++; - - push @version_undefs, $module->as_glimpse; - - } elsif (CPAN::Version->vcmp($have,0)==0) { - - $version_zeroes++; - - push @version_zeroes, $module->as_glimpse; - - } - - next MODULE unless CPAN::Version->vgt($latest, $have); # to be pedantic we should probably say: # && !($have eq "undef" && $latest ne "undef" && $latest gt ""); # to catch the case where CPAN has a version 0 and we have a version undef @@ -2550,8 +2648,6 @@ } else { if ($what eq "a") { next MODULE; - - } elsif ($what eq "r") { - - next MODULE; } elsif ($what eq "u") { $have = "-"; } @@ -2560,9 +2656,6 @@ $seen{$file} ||= 0; if ($what eq "a") { push @result, sprintf "%s %s\n", $module->id, $have; - - } elsif ($what eq "r") { - - push @result, $module->id; - - next MODULE if $seen{$file}++; } elsif ($what eq "u") { push @result, $module->id; next MODULE if $seen{$file}++; @@ -2604,38 +2697,6 @@ unless (%need) { if ($what eq "u") { $CPAN::Frontend->myprint("No modules found for @args\n"); - - } elsif ($what eq "r") { - - $CPAN::Frontend->myprint("All modules are up to date for @args\n"); - - } - - } - - if ($what eq "r") { - - if ($version_zeroes) { - - my $s_has = $version_zeroes > 1 ? "s have" : " has"; - - $CPAN::Frontend->myprint(qq{$version_zeroes installed module$s_has }. - - qq{a version number of 0\n}); - - if ($CPAN::Config->{show_zero_versions}) { - - local $" = "\t"; - - $CPAN::Frontend->myprint(qq{ they are\n\t@version_zeroes\n}); - - $CPAN::Frontend->myprint(qq{(use 'o conf show_zero_versions 0' }. - - qq{to hide them)\n}); - - } else { - - $CPAN::Frontend->myprint(qq{(use 'o conf show_zero_versions 1' }. - - qq{to show them)\n}); - - } - - } - - if ($version_undefs) { - - my $s_has = $version_undefs > 1 ? "s have" : " has"; - - $CPAN::Frontend->myprint(qq{$version_undefs installed module$s_has no }. - - qq{parseable version number\n}); - - if ($CPAN::Config->{show_unparsable_versions}) { - - local $" = "\t"; - - $CPAN::Frontend->myprint(qq{ they are\n\t@version_undefs\n}); - - $CPAN::Frontend->myprint(qq{(use 'o conf show_unparsable_versions 0' }. - - qq{to hide them)\n}); - - } else { - - $CPAN::Frontend->myprint(qq{(use 'o conf show_unparsable_versions 1' }. - - qq{to show them)\n}); - - } } } @result; @@ -3438,7 +3499,7 @@ $distro =~ s|.*?/authors/id/./../||; my $size = $eitem->findvalue("enclosure/\@length"); my $desc = $eitem->findvalue("description"); - - $desc =~ s/.+? - //; + $desc =~ s/.+? - //; $CPAN::Frontend->myprint("$distro [$size b]\n $desc\n"); push @distros, $distro; } -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (GNU/Linux) iEYEARECAAYFAkeWMLkACgkQi9gubzC5S1y0EwCfTAKC6SuTgpHoYS5hrMEpKVRY w5EAnjPO3cAYfu9XmO8nUnWREm12YY6q =sj7w -----END PGP SIGNATURE-----
A very nice feature idea, thank you! I just checked in a different implementation that needed less code changes. It's now in the repository and will be in the next release. Thanks & Regards,