2

I'm setting up a CPAN::Mini mirror and I want to be able to download multiple versions of modules from the mirror. How do I get it to index more that the latest version of modules I inject:

$ mcpani -v --add --module Foo --authorid DUMMY --modversion 0.001 --file Foo/Foo-0.001.tar.gz
$ mcpani -v --add --module Foo --authorid DUMMY --modversion 0.002 --file Foo/Foo-0.002.tar.gz
$ mcpani -v --update

such that I can do:

$ cpanm -M ~/CPAN Foo@0.001

NOTE:

The different versions of the module are present within the mirror:

$ find ~/CPAN -name 'Foo-0.00[12].tar.gz'
~/CPAN/authors/id/D/DU/DUMMY/Foo-0.001.tar.gz
~/CPAN/authors/id/D/DU/DUMMY/Foo-0.002.tar.gz

Even if I edit the index file by hand, only the first one listed is available for download:

$ zgrep '^Foo\s' ~/CPAN/modules/02packages.details.txt.gz 
Foo                               0.002  D/DU/DUMMY/Foo-0.002.tar.gz
Foo                               0.001  D/DU/DUMMY/Foo-0.001.tar.gz

I have used CPAN::Mini::Inject in my examples here but I have tried the following with the same outcome:

j1n3l0
  • 517
  • 4
  • 16
  • I'm not familiar with how CPAN::Mini works, but that cpanm syntax just requires a release with version 0.001 to be present, not to be indexed - though it may rely on metacpan knowing about it, in which case it won't work for a minicpan. – Grinnz Feb 19 '19 at 17:44
  • If you're up for trying more alternatives, check out [App::opan](http://metacpan.org/pod/App::opan). – Grinnz Feb 19 '19 at 17:44
  • I think when you do `cpanm -M ${MIRROR} Foo@0.001` it will only use the first version it finds in the local mirror file `02packages.details.txt.gz`. So it is not possible to install a specific version from a local mirror using `cpanm`. You could try ask at [the issue tracker](https://github.com/miyagawa/cpanminus/issues) to get more help. – Håkon Hægland Feb 19 '19 at 21:29
  • I have edited the question to indicate that the releases are all present but only the first one on the index is ever available. I am able to download older versions of modules from CPAN. I am trying to do the same (at least for my modules) on a local mirror. – j1n3l0 Feb 20 '19 at 09:47
  • @j1n3l0 *"but only the first one on the index is ever available*" : Yes that was my impression also, I think this is a shortcoming of `cpanm`. It simply picks the first version it finds in the local mirror, even if there are more versions available. – Håkon Hægland Feb 20 '19 at 09:56
  • Part of the problem here is that anything which parses `02packages.details.txt.gz` will only expect to find the latest version of a module there, since that's essentially what that file is supposed to be tracking. You can still give `cpanm` the full path to the module that you want to install, so you can bypass the index and still be able to install multiple versions. – oalders Feb 20 '19 at 13:51

0 Answers0