Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Update module in offline cpan

by Dirk80 (Pilgrim)
on Jul 12, 2022 at 09:58 UTC ( [id://11145435]=perlquestion: print w/replies, xml ) Need Help??

Dirk80 has asked for the wisdom of the Perl Monks concerning the following question:

I have an offline CPAN archive. Sometimes it happens that I have to update a module there. For example some weeks ago I used the module Mojo::DOM; for some XML stuff. Later I wanted to pack my script with pp. But it didn't work. Investigating a little bit showed up that a new version of Module::ScanDeps fixes the issue. But this new version is not in CPAN, but in a private github of the author.

So I decided to update Module::ScanDeps Version 1.31 in my offline CPAN with the new version 1.32 from Github.

I did it as follows.

  1. download ModuleScanDeps 1.32 from Github and put in the correct folder in my offline cpan
  2. update 02packages.details.txt.gz, i.e. replacing Module::ScanDeps 1.31 R/RS/RSCHUPP/Module-ScanDeps-1.31.tar.gz to Module::ScanDeps 1.32 R/RS/RSCHUPP/Module-ScanDeps-1.32.tar.gz
  3. update RECENT file, i.e. authors/id/R/RS/RSCHUPP/Module-ScanDeps-1.31.tar.gz to authors/id/R/RS/RSCHUPP/Module-ScanDeps-1.32.tar.gz
  4. update CHECKSUMS file by using use CPAN::Checksums qw(updatedir); updatedir("./cpan/sources/authors/id/R/RS/RSCHUPP");

It worked well. But I don't want to do so many steps manually each time I want to update a module in my offline CPAN. Furthermore CPAN::Checksums works only on Linux for me and not on Windows. Of course I could script the steps above by myself. But I think it is a bad idea to reinvent the wheel. For such a basic problem I'm sure there has to be a good solution out there.

So my question is. What is the best way to update a module in an offline CPAN?

Thank you very much in advance!

Replies are listed 'Best First'.
Re: Update module in offline cpan
by ikegami (Patriarch) on Jul 12, 2022 at 20:15 UTC

    ->mirror_file doesn't do the trick?

      I think that this method would be the right one. But I don't get it to run. Let's assume I'm in an offline environment and I have a tar.gz file I want to update my local offline CPAN with.

      The tar.gz file could be a change of a module which is NOT available on any remote CPAN mirror. I want to update my local CPAN with the new version of this file changed by myself or got from somewhere else than CPAN. Or it could even be that I want to add a self written package, e.g. My::Package to my local CPAN.

      What shall I specify for the remote mirror? I think that $path of $minicpan->mirror_file($path) refers to the remote mirror. Furthermore I have here the problem that I'm in an offline environment in the computer I'm using. So minicpan is unable to contact the remote mirror. My remote mirror has to be also local, so that it can be reached offline.

      my $minicpan = CPAN::Mini->new(local => "C:/Strawberry/cpan", remote => "???");

      UPDATE1:

      I see there is an offline option. I'll try with that now. At least the following code is compiling.

      use CPAN::Mini; my $minicpan = CPAN::Mini->new(local => "C:/Strawberry/cpan", offline => 1, remote => "file:://C:/Temp"); $minicpan->mirror_file("My-Package-0.01.tar.gz");

      But that code just copies My-Package-0.01.tar.gz to C:/Strawberry/cpan directory. But no other files were updated. But that's clear because on C:/Temp I just put the tar.gz file and no more other files. I think I have to make a real cpan mirror containing my self changed files. And then the mirror_file method should work for me. But then I have the same problem as before. I manually have to change all CPAN specific files like CHECKSUMS, ...

      UPDATE2:

      I think I know now better what I want. I already have an offline cpan created via CPAN::Mini which just contains files from an official cpan mirror. And now I want to have a second offline cpan archive which contains modules written by myself and bug fixes of cpan modules which are not yet on an official cpan mirror. But what is the best way to build this second cpan offline archive consisting of my own modules if don't want to create all cpan specific files by myself?

      UPDATE3:

      I investigated a little bit more. I found a module CPAN::Mini::Inject. It seems that this is the functionality I want. I'm off for two weeks now with no access to computers. I'll try then. I'm now unsure whether I should have two cpan offline archives, one for the official modules of cpan and one for my private modules in the My namespace. Or if it would be better to have everything together in one offline cpan. What is your opinion?

        Let's assume I'm in an offline environment

        The point of CPAN::Mini is to create a mirror when you are in an *online* environment (to be used in an offline environment).

        I found a module CPAN::Mini::Inject

        Yup, looks like it's exactly what you need. It even provides a command-line utility.

Re: Update module in offline cpan
by LanX (Saint) on Jul 12, 2022 at 10:13 UTC

      >Exactly, I used CPAN::Mini to create the offline CPAN.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11145435]
Approved by LanX
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-20 00:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found