質問

First of all, I'm not familiar with Perl and it's practices.

I'm trying to develop an ebuild that installs a Perl application. However I don't know where to put the library files of the application.

The application's directory structure is

binary
share/app/*.pl
share/app/icons/*.png

binary being the Perl executable.

In the binary I see lines like require 'someLibrary.pl'; these refer to the Perl libraries in the share/app/ directory. I also notice a use lib "$BIN/share/app"; line, which tells the binary where to locate the additional libraries I guess.

Now I face the problem how to install the application.

Solution #1: Install the binary in /usr/bin/ and the libraries in /usr/lib/perl5/.

Problem: Where to put the icons? The icons are referred in the binary and libraries using $Bin/share/app/icons/*.png. This won't work I guess.

Solution #2: Install everything in /usr/share/app/.

Problem: Where to put the binary? Create a symlink in /usr/bin/ to the binary?

Solution #3: Patch the Perl files so they look for icons in /usr/share/app/icons, place the binary in /usr/bin/ and the libraries in /usr/lib/perl5/.

Problem: I have to create a patch for the files. This doesn't seem like a good/normal way.

Of course other solutions are more than welcome.

Update: I've tried solution #2 and as I suspected, when I execute /usr/bin/binary the library path gets turned into /usr/bin/share/app. This of course results in the libraries not being found.

役に立ちましたか?

解決

The given code uses FindBin to locate the applications data directory. This makes solution 2 viable with the script in /usr/share/app/script.pl.

If the script was using $RealBin instead of $Bin (both exported by FindBin) you would just have been able to add a symlink in /usr/bin to the real script. But as noticed this does not work with the current script.

Alternative 1 is to write a small wrapper and put this in /usr/bin. Something like this seems to work for me:

#!/bin/sh
exec /usr/share/app/script.pl "$@"

Alternative 2 is to patch the script to use $RealBin. Either just a simple search-n-replace or just a minimal patch replacing

use Findbin qw($Bin)

with

our $Bin;
use FindBin qw($RealBin);
BEGIN { $Bin = $RealBin; }

Both patches would be a lot less intrusive that the patch you propose yourself as Solution 3.

I would probably recommend the first alternative. This shoudl work in most occasions and is the least intrusive both with respect to the script and the system as such.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top