dpanneur – your friendly DarkPAN/CPAN proxy corner store
Mar 15, 2010 / By Yanick Champoux
There were two things I have wanted to do for some time now. The first was to come up with a way to quickly and easily set up a DarkPAN mirror so that we would have more control over our dependency chain at work. The second was to make a portable CPAN proxy service, so that I can always have access to my favorite modules, even if the machine I’m working on has no Internet access. Last week, I finally had a few ‘rount tuits’ to spend on this type of background itch, and the result is dpanneur (for dépanneur, French Canadian for convenience store).
As it stands, dpanneur is a very thin Catalyst application gluing together the goodiness of CPAN::Cache and MyCPAN::App::DPAN, and throwing in Git as the archive manager.
To get it running, first fetch it from Github
$ git clone git://github.com/yanick/dpanneur.git
then check that you have all the dependencies
$ perl Makefile.PL
and run the script that will create the module repository
For now, the module repository is hard-coded to be in the subdirectory cpan of dpanneur. A branch called proxy is created and checked out. Eventually, I’ll use GitStore to push newly fetched modules to the repository, but for the time being if dpanneur is to be used as a proxy, that branch must remain as the one being checked out.
All that is left is to fire up the server in whichever mode you prefer (single-thread test server would do nicely for now)
and there you are, running your first dpanneur. Congrats! :-)
Using it as a caching proxy
You can use the server as a caching proxy, either for its own sake, or to seed the DarkPAN branches. To do that, you just have to configure your CPAN client to use http://yourmachine:3000/proxy:
$ cpan cpan> o conf urllist = http://localhost:3000/proxy cpan> reload index cpan> install Acme::EyeDrops Running install for module 'Acme::EyeDrops' Running make for A/AS/ASAVIGE/Acme-EyeDrops-1.55.tar.gz Fetching with LWP: http://localhost:3000/proxy/authors/id/A/AS/ASAVIGE/Acme-EyeDrops-1.55.tar.gz etc..
As the modules are downloaded, they are also saved and committed within the repo
[dpanneur]$ cd cpan [cpan (proxy)]$ git log -n 3 commit d065ad152f2204295334c5475104a3da517b6ae1 Author: Yanick Champoux <firstname.lastname@example.org> Date: Wed Mar 10 20:32:52 2010 -0500 authors/id/A/AS/ASAVIGE/Acme-EyeDrops-1.55.tar.gz commit e8d2e83d1b16e2e0713d125f9a4bd2742681f859 Author: Yanick Champoux <email@example.com> Date: Wed Mar 10 20:31:42 2010 -0500 authors/id/D/DC/DCONWAY/Acme-Bleach-1.12.tar.gz commit 7e0b4b600bac8424c519199ee96dc56ffbb177eb Author: Yanick Champoux <firstname.lastname@example.org> Date: Wed Mar 10 20:30:47 2010 -0500 modules/03modlist.data.gz
Using it as a DarkPAN server
There is not much more involved to enabling DarkPAN repos. All we have to do is to create a branch with the modules we want and have the ‘dpan’ utility bundled with MyCPAN::App::DPAN generate the right files for us.
To continue with the example of the previous section, let’s say that we want a DarkPAN branch containing Acme::EyeDrops, but not Acme::Bleach. Then we’d do
# only necessary if you are running # the server while you work on the branch [dpanneur]$ git clone cpan cpan-work [dpanneur]$ cd cpan-work # branch just before we imported Acme::Bleach [cpan-work (proxy)]$ git branch pictoral 7e0b4b600bac8424c519199ee96dc56ffbb177eb [cpan-work (proxy)]$ git checkout pictoral Switched to branch 'pictoral' # cherry-pick the Acme::EyeDrops commit [cpan-work (pictoral)]$ git cherry-pick d065ad152f2204295334c5475104a3da517b6ae1 # rebuild the module list [cpan-work (pictoral)]$ dpan # commit the new 02packages.details.txt.gz [cpan-work (pictoral)]$ git add . [cpan-work (pictoral)]$ git commit -m "dpan processing" # push back to the mothership [cpan-work (pictoral)]$ git push origin pictoral
And that’s it. Now point the cpan client to http://yourmachine:3000/pictoral, and you’ll get the limited mirror.
cpan> o conf urllist http://localhost:3000/pictoral cpan> reload index cpan> i Acme::EyeDrops Strange distribution name [Acme::EyeDrops] Module id = Acme::EyeDrops CPAN_USERID ASAVIGE (Andrew J. Savige <email@example.com>) CPAN_VERSION 1.55 CPAN_FILE A/AS/ASAVIGE/Acme-EyeDrops-1.55.tar.gz UPLOAD_DATE 2008-12-02 MANPAGE Acme::EyeDrops - Visual Programming in Perl INST_FILE /usr/local/share/perl/5.10.0/Acme/EyeDrops.pm INST_VERSION 1.55 cpan> i Acme::Bleach Strange distribution name [Acme::Bleach] No objects found of any type for argument Acme::Bleach