nowox
nowox

Reputation: 29116

Install CPAN modules from a local mirror without CPAN::Mini

In some computers in my company, only IE have access to Internet. So I would like to know if I can have a local copy of some CPAN modules in a local mirror. I heard of the CPAN::Mini module that can synchronize the local mirror with a public one.

How can I manually download the modules I want in my mirror with IE and configure cpan to look locally for the modules?

EDIT

I cannot use CPAN::Mini or other similar tools because only IE has access to internet. I need to replicate my mirror through IE first.

Upvotes: 0

Views: 609

Answers (2)

brian d foy
brian d foy

Reputation: 132896

CPAN::Mini uses LWP to fetch files. The meat of the problem is this simple line:

my $res = $self->{__lwp}->mirror($remote_uri, $local_file);

That's just the mirror from LWP::UserAgent. Come up with a replacement method that uses IE instead, perhaps using Win32::OLE to drive IE and there you are. CPAN::Mini could use a bit of dependency injection for the thing that fetches files.

There used to be a tool named Win32::Mechanize::IE, but it stopped working with the new IE8 security module.

Alternately, I would explore ways to make the internal LWP object look like it's IE. I don't know the details of your proxy or network, but I bet there are some magic headers or settings that you could fake from LWP. See, for instance, HTTPS Proxy and LWP::UserAgent. I have to believe that more than IE gets to access the internet.

As a last ditch effort, take some beer to the Windows admin with all the power. Make a friend and save some coding. :)


I might have done the dependency injection work had I not discovered that the source has been perverted with Dist::Zilla nonsense. I've never particularly cared what tools people use as long as they don't force me to use the same ones and that the literal source code doesn't depend on requirements of an external tool.

It's getting to the point that people are throwing away participation for a seat at the cool kids table by making the barrier to collaboration so high. I only make a stink of that because I don't think people realize the trade off. No one tells you when they decide to not help. They simply don't help and you don't realize you gave up all the hours they could have contributed.

Upvotes: 1

oalders
oalders

Reputation: 5279

If you just want a partial mirror of CPAN, you can do this easily with OrePAN2.

orepan2-inject --simple Module::Name /path/to/darkpan/

This will also generate on 02packages file for you, which CPAN clients can read.

orepan2-inject --simple Carton darkpan
Wrote 1 from Carton
[INFO] Could not find useful meta from 'darkpan/authors/id/D/DU/DUMMY/Carton-    v1.0.12.tar.gz'
[INFO] Scanning for provided modules...
/tmp/foo ∙ tree darkpan/
darkpan/
├── authors
│   └── id
│       └── D
│           └── DU
│               └── DUMMY
│                   └── Carton-v1.0.12.tar.gz
├── modules
│   └── 02packages.details.txt.gz
└── orepan2-cache.json

Upvotes: 1

Related Questions