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

Fellow Monasterians:

Debian is great for installing CPAN modules when there is an existing package...bada-bing

But rolling one with dh-make-perl can have its moments. I was told never to run it as root (CPAN can apparently do unpredictable things), but all I get is errors if I don't:

dh-make-perl --build --cpan String-Random-0.22 <snip> mv: cannot move `/home/bradc/.cpan/build/String-Random-0.22' to `//Str +ing-Random-0.22': Permission denied Cannot open //String-Random-0.22/Makefile.PL: No such file or director +y

So I bend to the pressure and run it as sudo. I have successfully built a few, but more often than not I get:

# Add commands to compile the package here /usr/bin/perl Build.PL installdirs=vendor Can't locate Module/Build.pm in @INC (@INC contains: /etc/perl /usr/lo +cal/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/sh +are/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_p +erl .) at Build.PL line 3. BEGIN failed--compilation aborted at Build.PL line 3. make: *** [build-stamp] Error 2 make: Leaving directory `/String-Random-0.22' Cannot create deb package

It's usually Can't locate Module/Build.pm that does me in. So, I looked in </code>/Module</code> and not surprisingly, no Build.pm:

$ /usr/share/perl5/Module$ ls drwxr-xr-x 2 root root 4096 2008-08-03 11:24 Depends -rw-r--r-- 1 root root 2576 2005-06-02 11:58 Depends.pm $ sudo find / -name Build.pm

Should the CPAN modules come with Build.pm or is that something I need to find and install? Thanks!

—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Replies are listed 'Best First'.
Re: Issues installing CPAN modules on Debian (OT)
by FunkyMonk (Bishop) on Aug 03, 2008 at 21:46 UTC
    I get
    $ dh-make-perl --build --cpan String-Random-0.22 Dispatching deprecated method 'CPAN::Config::load' to CPAN::HandleConf +ig CPAN: File::HomeDir loaded ok (v0.69) CPAN: Storable loaded ok (v2.18) Going to read /home/bri/.cpan/Metadata Database was generated on Sun, 03 Aug 2008 02:03:08 GMT Can't find 'String::Random::0.22' module on CPAN
    dh-make-perl --build --cpan ... expects a package name ie dh-make-perl --build --cpan String::Random

    I've built hundreds of packages using dh-make perl. Here's how I do it...

    1. cd ~/.cpanplus/5.10.0/build/
    2. cpanp t MooseX::Getopt # I let CPANPLUS handle the dependencies
    3. dh-make-perl --build MooseX-Getopt-0.15
    4. This leaves the built deb, libmoosex-getopt-perl_0.15-1_all.deb in my cpanplus build directory. You could use this file, but I continue
    5. rm libmoosex-getopt-perl_0.15-1_all.deb
    6. cd MooseX-Getopt-0.15/
    7. emacs debian/changelog # change first line from (0.15-1) to (0.15-0) so that any official package will overwrite mine
    8. dpkg-buildpackage -us -uc # rebuild the package
    9. cd ..
    10. sudo dpkg -i libmoosex-getopt-perl_0.15-0_all.deb

    There's probably an option to dh-make-perl to set the debian version number that would make steps 5-9 unnecessary, but it's so little effort I haven't looked.

    I actually followed these steps as I've typed them up, so why not follow along and report back which bit doesn't work for you?

    Update:

    There is indeed an option to set the package's version number, but you have to include the upstream version number too: dh-make-perl --version 0.15-0.0 --build MooseX-Getopt-0.15

      Thanks for the indepth reply FunkyMonk, but I bomb at the very first step:

      cd ~/.cpanplus/5.10.0/build -bash: cd: /home/bradc/.cpanplus: No such file or directory

      I'm not sure what I should be looking for. I was able to get to ~/.cpan/build but the cpanp is not found (expected). Is ./cpanplus part of Perl 5.10?

      —Brad
      "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
        Yes, CPANPLUS is included with 5.10, but it's also available for other Perls from CPAN.

        However, that shouldn't matter. cpan -t MooseX::Getopt will fetch & test MooseX::Getopt in ~/.cpan/build/. Other than that I think the steps should be the same.

        Let us know how you get on.