10

I wrote a script for my company and I am using some libraries I obtained from CPAN. My manager wanted me to consolidate and remove the extra libraries - which is a little funny because I include them for the script to work.

A few notes:

  • I do not have root access on this server nor can I request access
  • To use CPAN modules w/o root I have them installed to my user directory
  • To allow other users to run my scripts I usually include a folder called 'libs' and inside of my script's directory and in the script I have: use 'libs'; at the top before I use my CPAN modules.

The only solution I have right now is to literally put the contents of the perl modules inside of my perl script. However I want to give credit where it is due and also not get in trouble for including opensource code w/o proper credit to its authors and organizations.

Therefore, how should I go about this? I am not trying to get away with anything.. I honestly want to go about doing this the right way.

All three modules say "licensed under the same terms as Perl itself" but I feel like it shouldn't be this easy.

I would also like to explore any other ideas too!

The modules are:

  • Text::Table
  • Text::Aligner
  • Term::ANSIColor
rusty
  • 307
  • 1
  • 4
  • 16
  • 4
    Finally, someone who didn't give up on CPAN just because they don't have root access. Kudos to you, sir! – ThisSuitIsBlackNot Jan 12 '15 at 19:31
  • Haha, thank you. A difficult task at the time but worth it. – rusty Jan 12 '15 at 19:31
  • I think it would make more sense for someone with root access to install the required libraries on the system(s) where your script needs to run. That's going to be a lot simpler and more reliable than copy-and-pasting the modules' code into your script. (Convincing your manager might be an obstacle, though.) – Keith Thompson Jan 12 '15 at 20:00
  • Yeah I agree, Keith. My manager could be convinced by sysadm may not be obliged to do so. I'd rather explore my options first before going up the ladder for such a small PM. – rusty Jan 12 '15 at 20:10
  • can you say what the modules in question are? – ysth Jan 12 '15 at 20:14
  • Just edited the post, forgot to mention them. Thanks! – rusty Jan 12 '15 at 20:15
  • 2
    I think it's important to try to educate you manager and sysadm about the right approach to take here. Most of the power of Modern Perl is in CPAN modules. If you can't use CPAN modules easily then half of Perl's power to solve problems easily will be unavailable to you. – Dave Cross Jan 13 '15 at 10:22
  • Yeah I know. Perl isn't widely used at my company but since my previous sysadm job used it so much I tend to write my scripts here in Perl as well. Worst case I can ask them and I am sure they could get it installed for me since my managers really want my scripts to work. – rusty Jan 13 '15 at 15:26

4 Answers4

2

Is using PAR Packager an option for you? That would generate a standalone executable.

dsolimano
  • 8,870
  • 3
  • 48
  • 63
  • I tried installing it but I am getting error 255 during make. I even tried installing it on my home server... same error. Really confusing and unfortunate. Maybe I will keep playing with it. – rusty Jan 12 '15 at 20:06
  • 1
    error 255 from make just says there was an earlier error; you'd need to look at the first error message to see what went wrong – ysth Jan 12 '15 at 20:13
  • 2
    this is really the best solution for your situation; if you do pull stuff out of modules into your script, you risk breakage and give up on ever getting newer bug fixes for the code in question – ysth Jan 12 '15 at 20:14
  • Yeah, makes sense. Just need to get it installed! Still working on it. – rusty Jan 12 '15 at 20:16
1

Interesting question & perspective. I don't understand what is against using libraries or modules, but I'll let your manager do the thinking ;-)

Regarding copyright, you're best to consult a lawyer if you want to be sure, but as far as I understand it, you can combine the work of others provided you retain the copyright notices. The combined work may not be covered by copyleft, so you may be able to use it commercially (i.e., distribute it without disclosing the source). But do check with a lawyer.

But, since you said you wanted to explore other ideas, App::Staticperl may be a solution? I do not have experience with it, but I tried it with a simple example and got a working executable.

App::Staticperl builds a stand-alone executable from the Perl interpreter with embedded CPAN modules. The steps I followed were roughly (you'll need to adapt, because obviously I couldn't test with your script):

  1. latest version of App::Staticperl is 1.43: https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/App-Staticperl-1.43.tar.gz
  2. either install the module via CPAN, or simply extract bin/staticperl from the tar - it's a standalone script
  3. edit staticperl to change EMAIL and CPAN (optional, but you may want to change the CPAN mirror)
  4. ./staticperl install downloads and builds Perl; it ended with an error message on my box, but did produce a working Perl
  5. ./staticperl cpan enters an interactive CPAN prompt; install Text::Table, install Term::ANSIColor, and whatever else you need
  6. ./staticperl mkapp my_app --boot path/to/your/script -MText::Table -MText::Aligner -MTerm::ANSIColor
  7. try the app: ./my_app - it will most likely fail with an error message about missing modules; repeat the previous step and include the missing modules in the -M flags

Good luck!

Edward
  • 486
  • 4
  • 14
  • Not being covered by a license does not *add* to your rights! Any rights you have to somebody else's work are specified in the licenses or possibly by fair use, and commercial use is not a good start for claiming fair use rights. – tjd Jan 13 '15 at 15:12
  • Thanks Edward! Unfortunately I didn't have time to try using `Staticperl` but I do intend to in the future. I appreciate the help! – rusty Jan 14 '15 at 07:53
1

If the modules are pure Perl modules, you may be able to simply append the code (including those package statements) into your program. I'd also include the POD which would include the copyright statements and the names of the authors too. That should satisfy the Artistic License Requirement (but may not satisfy GNU licensing requirements).

Another possibility is to use Perlbrew which will allow you to install a user version of Perl on the system. This way, you can install CPAN modules without needing Administrative permission, and you can tell other users to use Perlbrew too.

I use it because I can install and switch between various versions of Perl which allows me to test my Perl scripts in various versions of Perl. I've also used it on our servers where I need a newer version of Perl or modules that weren't included in the standard release.

You need to get your IT approval before installing Perlbrew, but a lot of times they're relieved that they no longer have to be bothered with maintaining and installing CPAN modules for your use.

David W.
  • 105,218
  • 39
  • 216
  • 337
  • I selected this as the answers because appending it solved my issue. I would prefer using a package manager as suggested by others, but I could not install PAR:Packer due to compiler issues on multiple machines (which still perplexes me). I did not try using `Staticperl` as suggested by @Edward but I intend to explore it. – rusty Jan 14 '15 at 07:52
  • Note that this is called 'fat packing'. There are apps for this on CPAN which analyze your code for dependencies and build one large Perl programm which only needs a Perl interpreter. The one thing that doesn't work are XS modules that are compiled C code and therefore platform dependent. – Alexander Hartmaier Jan 19 '15 at 08:08
0

Can you reduce the unnecessary code (to satisfy your manager's concerns). Leave in tact the needed code in the file it came in - and give the author's credit within that module/package.

Eg: This was inspired (stolen) from Joe E Perl.

terary
  • 940
  • 13
  • 30
  • I can do that but explicitly they want the script to run on it's own, independent my 'libs' folder. Stripping the code down would help with size but not their goal. The only module I use (it has 2 dependencies that I include) is Text::Table, unsure if that info helps. – rusty Jan 12 '15 at 19:39