Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

how to collect all CPAN modules from an existing system?

by khandielas (Sexton)
on Jan 11, 2018 at 06:54 UTC ( #1207100=perlquestion: print w/replies, xml ) Need Help??
khandielas has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Monks, I wonder who has this kind of experience.

I have an existing server running Ubuntu 12.04. Over the years, we have installed a lot of modules from both Ubuntu repository and by CPAN command. Now I want to move to 16.04.

Is there a way to build a large Debian package that contains my server source code and all the CPAN modules my code depends on, as well as all the dependencies of those CPAN modules? so that I can drop this large Debian package in a fresh installed Ubuntu 16.04 to create a live server? And other people can also use this package to have an environment same as mine?

I wonder whether this is even possible because some of the package are not from Ubuntu repository. Many thanks!

  • Comment on how to collect all CPAN modules from an existing system?

Replies are listed 'Best First'.
Re: how to collect all CPAN modules from an existing system?
by marto (Bishop) on Jan 11, 2018 at 10:02 UTC

    I avoid using the system perl, installing my own elsewhere. This also removes the issue of mixing and matching cpan and apt (or other package manager) module installs, which has issues of it's own. OS rolling out different versions of things, removing that control from me. I want to retain control of the software stack.

    At work we have /app/productname I install perl, and the other dependencies. This means that I can simply transfer what I require from development into our other environments. I use a local cpan mirror created by minicpan as the basis for installation. All our servers are the same OS/Hardware.

    cpan has the autobundle option, which you could use as a starting point for generating a single package for installing your dependencies. Take a look at the output and you'll see why I suggest only using it as a starting point.

    12.04 & 16.04 ship with different versions of perl and you'll run into the binary compatibility issue if you try and copy modules which aren't pure perl.

    If possible I'd suggest you consider starting fresh with a 16.04 server and start from scratch.

    Update: Slight formatting change.

Re: how to collect all CPAN modules from an existing system?
by jahero (Monk) on Jan 11, 2018 at 07:54 UTC

    Hello!

    This is a thought provoking question, and I am curious how more knowledgable monks will respond. In the meantime, perhaps these vague tips will help to direct you in the right way.

    First we need to get the list of modules... Here a thread which could help you: Listing all of the perl modules installed

    After that, it should be simply matter of transferring these packages to the new machine. In my opinion, this is the interesting (thought provoking) part. Do you use system perl, installing these packages using cpan command? Do you use perlbrew and carton to create the new environment?

    Looking forward to resulting discussion.

    Please let us know how you resolved the problem in the end.

Re: how to collect all CPAN modules from an existing system?
by ikegami (Pope) on Jan 11, 2018 at 16:49 UTC

    Those two systems have two different versions of Perl. You can't simply copy modules from one to the other. They will need to be re-installed.

Re: how to collect all CPAN modules from an existing system?
by thomas895 (Chaplain) on Jan 11, 2018 at 09:58 UTC

    Step 1 is to find all the modules your application depends on. Hopefully you know what these are, if not, try greping your code directory for all use statements.

    Step 2 is to try to find apt packages for those modules. Hopefully someone else has already made them, otherwise you will need to do so yourself (create deb for Perl module). Then you can package your code as a Deb, listing all the dependencies you found in step 1. Those, in turn, may depend on yet other dependencies.

    -Thomas
    "Excuse me for butting in, but I'm interrupt-driven..."
Re: how to collect all CPAN modules from an existing system?
by shmem (Chancellor) on Jan 12, 2018 at 11:42 UTC
    Over the years, we have installed a lot of modules from both Ubuntu repository and by CPAN command. Now I want to move to 16.04.

    They should have told you that not keeping a coherent change log for any system is going to bite you sooner or later. They didn't? Shame on them.

    For modules pertaining to the perl core, there is corelist . Packages installed via the Debian package managers can be found via dpkg -l *-perl (not all of them, some bundles don't have a trailing "-perl" in the package name). For CPAN installed modules, there's perllocal.pod. Finally, you could run locate .pm | grep '.pm$' | xargs dpkg -S | sort | uniq or such to get all debian packages which sport some perl module. Modules which aren't shown by these methods must have been installed by other means.

    To get at the statically loaded modules of any scripts, you can add a CHECK block to them, in which you examine %INC, and run them via perl -c .


    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re: how to collect all CPAN modules from an existing system?
by stevieb (Abbot) on Jan 12, 2018 at 17:05 UTC
    cpan -a ... Wrote bundle file /home/steve/.cpan/Bundle/Snapshot_2018_01_12_00.pm # move the Snapshot pm file to ~/.cpan/Bundle dir # on a remote system, log into it, then: cpan Bundle::Snapshot_2018_01_12_00.pm

    This does not copy the installations directly, it will install anything that isn't on the new system that is on the old.

Re: how to collect all CPAN modules from an existing system?
by holli (Monsignor) on Jan 11, 2018 at 22:44 UTC
    Docker.I am surprised nobody mentioned it yet.


    holli

    You can lead your users to water, but alas, you cannot drown them.
Re: how to collect all CPAN modules from an existing system?
by sundialsvc4 (Abbot) on Jan 11, 2018 at 19:20 UTC

    This topic was discussed in this StackOverflow post some time ago, which also refers to this perldoc entry (perlfaq3).

    It can be problematic.   You definitely want to set up your own application-specific repository, as (say) any Google search on “Perl in shared hosting” will discuss at great length, so that any packages which you install will be installed there and, once installed there, will be seen in preference to the system environment’s set of global packages (which you should not touch).   Things can get interesting since the explicit request to install one package might install its pre- and co-requisites, and sometimes CPAN will decide that system libraries satisfy some of those dependencies ... while a different system might have a different set.

    When you install on the new system, use the list that you have built to re-install the packages on the target system ... allowing CPAN to deal with all of the requisites and, of course, to install the binary libraries that are correct for the new environment.   As others have already said, you cannot reliably just copy the directory’s contents verbatim, because there’s a lot more stuff in there than just Perl source-code.

    More rare but I do still encounter it from time to time is software that is actually dependent upon a certain version of a module such that it won’t work properly with a later one.   Anytime you discover this, you should raise the issue within the project team so that (if practicable) the software can be re-written to remove it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1207100]
Approved by Athanasius
Front-paged by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2018-02-24 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (310 votes). Check out past polls.

    Notices?