3

I developped a script in Perl that uses 2 extra libraries, Net::SSH::Perl and Spreadsheet::WriteExcel, which I installed easily using CPAN on my Debian laptop.

Ultimatly, my goal is to deploy this script on a solaris server. However, this server is not connected to internet and thus cannot auto install missing dependencies.

So far, I tried using PP, which allowed me to run this script on another Ubuntu computer without needing to install manually the extra libraries, but returned an error : Cannot find /lib64/ld-linux-x86-64.so.2 on Solaris.

As I suspected this was due to the differences between both architectures, I packed my script with a ./lib folder containing all dependencies (the ./lib was obtained by doing pp -B -p -o script.par myscript.pl and extracting the resulting ./lib folder).

Following the leads I found in this question, I tried with use lib "./lib and with BEGIN { unshift @INC, "lib"; } at the start of my script, but I got an error saying I didn't include my libraries when I ran it.

Is there a way to port those libraries ? Is there another approach ?

Community
  • 1
  • 1
Aserre
  • 4,916
  • 5
  • 33
  • 56
  • Make `pp` on your own Solaris which is 'internet enabled'? `:)` – mpapec Jun 17 '14 at 14:33
  • I don't have one :) Otherwise I would just develop my script on it (the solaris server is from my company, it can only comunicate with other machines on the local network) – Aserre Jun 17 '14 at 14:36
  • You can install Solaris in a virtual machine (e.g. VirtualBox) and use it for development. Installing Net::SSH::Perl in Solaris may be quite hard, though. You may like to investigate other Perl SSH packages as Net::SSH2, Net::OpenSSH and Net::SSH::Any. – salva Jun 17 '14 at 14:57
  • Can your Solaris box connect to another server in your network which has Internet access? If so, then setup a local cpan mirror on that system and point to that mirror when installing modules on the Solaris box. – Ron Bergin Jun 17 '14 at 15:02
  • @salva Thanks for the insight. I'll try those libraries at home, and give a feedback once I try it. Is there a specific reason as to why `Net::SSH::Perl` doesn't work well on Solaris? I'm just a bit frustrated there isn't a simple way to port existing libraries without cpan... – Aserre Jun 17 '14 at 15:06
  • @RonBergin No, the network is local only. Furtherrmore, I have to take my computer home when I want to work with cpan as nertworking actions are blocked by the company proxy if not executed throug a web browser. – Aserre Jun 17 '14 at 15:08
  • cpan can happily work across a proxy! You can configure it at the CPAN shell or just setting the environment variable `http_proxy=http://...`. Another alternative is to use [CPAN::Mini](https://metacpan.org/pod/CPAN::Mini) to build a local mirror of CPAN. – salva Jun 17 '14 at 15:20
  • @salva when I said proxy, it was a euphemism :) My computer is heavily locked when I connect to my work network (no admin rights, limited connectivity, control panel locked, vpn with no access to config, ...), a bit less when I take it home. I'll try it there and update with feedback later. – Aserre Jun 17 '14 at 15:25
  • Well, can you run VirtualBox? can you install CPAN::Mini? that would make your life happier... otherwise look for a better job in a place where people is empowered to actually get things done, really! – salva Jun 18 '14 at 09:02

1 Answers1

2

Net::SSH::Perl relies upon several XS modules, such as Math::GMP, Math::Pari and others. There's no way around actually compiling them (as in compiling them with C, not Perl) on the Solaris box.

You will also need the underlying C libraries (i.e. libgmp, libpari). The Math::Pari build script will download its library, but you've indicated that's not possible on your target Solaris box.

cpanm can help you download the Perl dependencies in preparation for moving them to your target machine and build them on it.

If you have proper dependency entries in your project's Makefile.PL or cpanfile, running

cpanm --installdeps  -L deps --save-dists dists .

on your devel machine in your project directory (note the trailing dot) will download all of its dependencies into the dists directory.

You can then copy that directory to your target Solaris box (along with cpanm) and pass it to cpanm using its --mirror option.

For example, I just did this for Net::SSH::Perl's dependencies:

cpanm --installdeps -L deps --save-dists dists Net::SSH::Perl

It downloaded and installed 34 distributions into deps, saving the archives in dists.

I can build Net::SSH::Perl using the downloaded distributions via:

cpanm --mirror file://${PWD}/dists  Net::SSH::Perl

Note that while cpanm is handy, you don't actually need it to install the required modules. You can manually install them (in the correct order) by unpacking them and then running

perl Makefile.PL
make
make install

or

perl Build.PL
./Build
./Build install

as appropriate for the specific module

Diab Jerius
  • 2,310
  • 13
  • 18