How to use a CPANPLUS autobundle to update a new version of Perl?

纵饮孤独 提交于 2019-12-05 15:17:44

问题


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.)


回答1:


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.




回答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.




回答3:


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.



来源:https://stackoverflow.com/questions/6100492/how-to-use-a-cpanplus-autobundle-to-update-a-new-version-of-perl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!