11

I have Perl 5.13.4 with a large collection of installed CPAN modules.

I have just compiled Perl 5.14.0. I'd like to install (recompile) all the modules in 5.13.4 into 5.14.0.

I can/have generated a bundle of the installed modules with 'cpanp' and the 'b' option; I now have a file ~/.cpanplus/5.13.4/dist/autobundle/Snapshot_2011_05_18_00.pm.

  • What is the command to use in the 5.14.0 version of 'cpanp' that will go through that snapshot bundle and ensure 5.14.0 has all those modules installed?

  • Or, if the combination of cpanp and a bundle isn't the appropriate way to go, what is the easiest way to replicate (recompile) the modules installed in the old version of Perl for the new version of Perl? (If CPAN can deal with the bundle file, I'll use it - it is the result I care about, not the mechanism used to achieve it.)

(I did take a quick look at the list of questions for 'perl cpanplus bundle' here on SO without finding the information I'm after. I've also looked at 'perldoc cpanp' on several occasions and failed to find the information I'm after. That isn't the same as saying "the information is not there"; it may simply mean I've not spotted it.)

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278

3 Answers3

8

A bundle file is a CPAN special-cased thing that - to my surprise - does not happen to also work in CPANPLUS. That's why no one talks of CPANPLUS bundles and you couldn't find anything. So employ CPAN. First find out where your CPAN root is, by default it's ~/.cpan or ~/.local/share/.cpan on a Free Desktop XDG-compliant system. Alter the instructions accordingly.

mkdir -p ~/.cpan/Bundle
mv ~/.cpanplus/5.13.4/dist/autobundle/Snapshot_2011_05_18_00.pm ~/.cpan/Bundle
cpan Bundle::Snapshot_2011_05_18_00   # DTRT

As you were talking about recompile, CPAN has that command and you can issue it from either the CPAN shell or as API call from the command-line, but it's useful only if you have modules at a fixed location across versions of Perl.

daxim
  • 39,270
  • 4
  • 65
  • 132
  • This worked nicely, thank you. I'd give you extra up-votes if that was an option. I mentioned/specified 'recompile' to indicate that I expected to rebuild the modules from source - a solution that provided access to the old, already compiled versions from the new Perl would not meet my requirements. – Jonathan Leffler May 23 '11 at 19:30
2

CPANPLUS autobundles work fine as of now. Just be sure to reference the bundle with 'file://' prefixed to the full path of the bundle.

There will certainly be some diddlin' that you'll have to do with some modules, but for the most part it should be completely doable.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
BergBrains
  • 302
  • 2
  • 4
  • Thank you: I've (finally) got around to installing 5.14.2, and after creating my snapshot in 5.14.1, I was able to run the 5.14.2 `cpanp` and run `i file:///Users/jleffler/.cpanplus/5.14.1/dist/autobundle/Snapshot_2012_05_04_00.pm` and it certainly worked in the sense of reading the file and starting the compilations. I ended up manually installing `CPANPLUS` and `Module::Signature` as the absence of these caused some problems, but the `file://` prefix was key information that I'd not seen before. Thanks again. – Jonathan Leffler May 04 '12 at 14:59
0

Some extra information that may save other people some hair-tearing.

  1. If you have a snapshot file $HOME/Snapshot_2013_12_23_00.pm, you can run:

    cpanp -i file://$HOME/Snapshot_2013_12_23_00.pm
    

    and the install will start.

  2. When you do this, Perl will create a file such as:

    $HOME/cpan/authors/id/UNKNOWN-ORIGIN/Snapshot_2013_12_23_00.pm
    

    (The exact location will depend on where you've configured your CPANPLUS repository; mine goes into $HOME/cpan.)

    If you need to hack the snapshot file (because some module won't compile), you can edit and specify the filename on the command line until you're blue in the face and completely hairless, and it won't make the slightest diffence because despite you telling it to look in $HOME, CPANPLUS is looking at the file it copied into the UNKNOWN_ORIGIN directory. Removing the file certainly works; you could probably edit it too.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278