Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

How to patch standard modules from CPAN on Linux etc?

by BerntB (Deacon)
on Oct 24, 2008 at 14:49 UTC ( #719352=perlquestion: print w/replies, xml ) Need Help??

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

I have a problem with using Spreadsheet::ParseExcel. The problem is not the module itself but bad data I need to use. (The Date formatting was strange in a bunch of cells. It was probably not Excel which created the spreadsheets. OTOH, Open Office can handle it.)

I use Ubuntu/Debian. Spreadsheet::ParseExcel is in the standard apt-get package archive. I need to patch the local install. I also need to make a patch for Red Hat's Linux variants.

The obvious thing to do here is to not install the Ubuntu version and use CPAN for the module. Then modify the locally installed module. My question is -- should I do it like this?

I don't know much about the Red Hat stuff. What is the standard practice there?

Extra question: How should I pack this down for install on different servers?

(BTW, I did send in a bug report.)

  • Comment on How to patch standard modules from CPAN on Linux etc?

Replies are listed 'Best First'.
Re: How to patch standard modules from CPAN on Linux etc?
by moritz (Cardinal) on Oct 24, 2008 at 15:54 UTC
    IMHO the obvious (and cleanest) solution is to build patched .deb packages. It's as simple as
    apt-get source libspreadsheet-parseexcel-perl cd libspreadsheet-parseexcel-perl-*/ # apply your changes now dpkg-buildpackage -rfakeroot

    And then put the so-created .deb in a local repository, and install from that. (Or simply install it with dpkg -i  $filename).

    I don't know very much about the .rpm stuff, but it shouldn't be that much different.

      Between you and JavaFan I have enough information to handle locally patched CPAN modules, thanks guys!
Re: How to patch standard modules from CPAN on Linux etc?
by salva (Canon) on Oct 24, 2008 at 19:39 UTC
    Instead of patching Spreadsheet::ParseExcel, being it an object oriented module, maybe you could subclass it replacing the affected methods for your own versions.

    Also, if the problem can potentially affect any file created by some common application (as for instance or gnumeric) it would make sense to get the patch incorporated on the main version.

      Even better, convert the files to XML, then apply a filter to change the weird dates. Then an update on a client's system doesn't trash your patched local version of a standard CPAN module.


      Should have thought about that myself. :-) That might be easiest. You can override the formatting class for Spreadsheet::ParseExcel (and there is some alternative for different languages already).

      Update: I should add that I ended up overriding the Spreadsheet::ParseExcel::FmtDefault module (really easy and neat design) and just changed what the FmtString returned. I learned a bit about making my own code flexible.

Re: How to patch standard modules from CPAN on Linux etc?
by JavaFan (Canon) on Oct 24, 2008 at 15:11 UTC
    There's too little information to give a good answer; it depends on lot on what your environment is, where you need to distribute your changes to, and how those environments look like.

    I've worked in environments where we used yum to install RPM packages system wide. RPM is a format that not only can be deployed on Redhat but also on other (Unix) platforms. You might even want to use a tool like cfengine to automate distribution. (I'm not the biggest fan of cfengine, but that probably has more to do with inherited bad setups than with the tool itself).

    For modules that need local patches, we'd start with the source RPMs (SRPM). Then we modify the spec file to first run a set of patches before building the RPMs. Those RPMs would end up in the yum repository. This separates the original code from your patches, so if a new release comes (and you still need your local patch), and you want to use the new release, deployment is "relatively" easy. Now I say relative - I've also worked for a company where we compiled the Linux kernel ourselves -- after running 350 patches. But we also used a similar setup: keep the Linux kernel source unmodified, have a directory of patches, and let the spec file apply the patches before compiling.

Re: How to patch standard modules from CPAN on Linux etc?
by andreas1234567 (Vicar) on Oct 29, 2008 at 08:46 UTC

      Thanks, he already emailed me about the bug report. :-)

      (I'm looking forward to reading the code after he has reviewed it; I thought it didn't look bad as it was.)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://719352]
Approved by jettero
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2021-10-26 19:05 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.