How do I make Alien use an existing tarball instead of downloading?

88 Views Asked by At

My distro does not offer any gsl <2.6 any more.

Given:

  • Alien::GSL 1.01
  • /tmp/gsl-2.5.tar.gz

How do I force it to compile that gsl instead of downloading from GNU FTP version 2.6, which I already have on the system anyway but is not delectable to Math::GSL 0.40?

I unsuccessfully tried:

  • copying the tarball into the unpacked Alien::GSL base directory
  • messing with alien_repository

This is for a throw-away project. I'm okay with manual installation instructions and patching toolchain code.

1

There are 1 best solutions below

0
daxim On BEST ANSWER

ikegami found the decisive hint:

It looks like you can set protocol of local to use a local file


Tested step-by-step instructions, plus some additional work-arounds; to me it looks like the build systems of the two modules are buggy/insufficiently tested:

cpanm --look Alien::GSL

patch Build.PL

diff --git a/Build.PL b/Build.PL
index 32f3057..6537138 100644
--- a/Build.PL
+++ b/Build.PL
@@ -20,10 +20,9 @@ my $builder = Alien::Base::ModuleBuild->new(
   alien_name => 'gsl',
   alien_repository => [
     {
-      protocol => 'ftp',
-      host     => 'ftp.gnu.org',
-      location => '/gnu/gsl',
-      pattern  => qr/^gsl-([\d\.]+)\.tar\.gz$/,
+      protocol => 'local',
+      location => '/tmp',
+      pattern  => 'gsl-2.5.tar.gz',
     },
   ],
   meta_merge => {
-- 
2.23.0
perl Build.PL
./Build

Pay attention to the generated configure/libtool commands here, they match the Perl configuration. A manual installation without those various options is not guaranteed to be compatible or usable. (This is not superstition: a similar problem historically shows up when installing mod_perl2 and libapreq2 from source on a system httpd; perl needs to be compiled first, then httpd to match, then the other packages, otherwise it won't work.) This shows the value of installing through Alien, since it delegates to M::B, the correct options will be figured out. It's above my level of knowledge to accurately create them from scratch.

./Build test

gsl-config in blib now erroneously contains build paths, not install paths, fix:

perl -MConfig -i -lpe'
    s|/.*(/auto/share/dist/Alien-GSL)|$Config{installsitelib}$1|
' blib/lib/auto/share/dist/Alien-GSL/bin/gsl-config
./Build install
exit # cpanm

cpanm --look Math::GSL
# let it pick up gsl-config on PATH
export PATH=$PATH:$(perl -mAlien::GSL -e'print Alien::GSL->bin_dir')
perl Build.PL
./Build
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(gsl-config --libs | perl -lne'/-L(\S+) / && print $1')
./Build test
./Build install
exit # cpanm

Finally rëexport the variables whenever you want to use Math::GSL.