Subject: | pls add support for own search server for module meta :-) |
Hola,
I run a local CPAN mirror which has some 'private' modules injected. I'd love to use your
awesome cpanminus also for my local CPAN instance; but it fails because it looks for module
metadata (distfile and version) on external servers. I've attached a patch, which adds a new
command line argument called 'search' which can be used to define a URL which is then being
used to search for module metadata first. For example, I use this switch within the
PERL_CPANM_OPT environment variable like so:
PERL_CPANM_OPT="--mirror http://cpan.my.server.com --search
http://cpan.my.server.com/search.pl?q={module}"
where {module} is being replaced by the actual module name. The response of the search
script should be compatible to that what's coming from
http://cpanmetadb.appspot.com/v1.0/package/<module> - a YAML response with distfile
and version element.
Would be cool if you could have a look at the patch and eventually add it to your application.
Maybe it's helpful for other people too :-)
Cheers, Marc
Subject: | cpanm.patch |
354a355
> search => undef,
396a398
> 'search=s' => \$self->{search},
485c487,499
<
---
>
> if ($self->{search} && $self->{search} =~ m!^https?://.+!) {
> my $uri = $self->{search};
> $uri =~ s/\{module\}/$module/g;
> $self->chat("Searching $module on $uri ...\n");
> my $yaml = $self->get($uri);
> my $meta = $self->parse_meta_string($yaml);
> if ($meta->{distfile}) {
> return $self->cpan_module($module, $meta->{distfile}, $meta->{version});
> }
> $self->diag_fail("Finding $module on $uri failed.");
> }
>
550a565
> --search Specify a URI to use for searching (e.g. http://your.server.com/search.pl?q={module})