Skip to content

Commit

Permalink
Merge pull request jordansissel#447 from dnbert/master
Browse files Browse the repository at this point in the history
Provide support for LIB and --install_path
  • Loading branch information
jordansissel committed May 28, 2013
2 parents e69a23c + 38b1507 commit b42878e
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions lib/fpm/package/cpan.rb
Expand Up @@ -13,6 +13,7 @@ class FPM::Package::CPAN < FPM::Package
option "--package-name-prefix", "NAME_PREFIX", "Name to prefix the package " \
"name with.", :default => "perl"
option "--test", :flag, "Run the tests before packaging?", :default => true
option "--perl-lib-path", "PERL_LIB_PATH", "Path of target Perl Libraries"

private
def input(package)
Expand Down Expand Up @@ -108,12 +109,23 @@ def input(package)
# Try Makefile.PL, Build.PL
#
if File.exists?("Makefile.PL")
safesystem(attributes[:cpan_perl_bin],
"-Mlocal::lib=#{build_path("cpan")}",
"Makefile.PL",
"PREFIX=#{prefix}",
# Empty install_base to avoid local::lib being used.
"INSTALL_BASE=")
if attributes[:cpan_perl_lib_path]
perl_lib_path = attributes[:cpan_perl_lib_path]
safesystem(attributes[:cpan_perl_bin],
"-Mlocal::lib=#{build_path("cpan")}",
"Makefile.PL",
"PREFIX=#{prefix}",
"LIB=#{perl_lib_path}",
# Empty install_base to avoid local::lib being used.
"INSTALL_BASE=")
else
safesystem(attributes[:cpan_perl_bin],
"-Mlocal::lib=#{build_path("cpan")}",
"Makefile.PL",
"PREFIX=#{prefix}",
# Empty install_base to avoid local::lib being used.
"INSTALL_BASE=")
end
make = [ "make" ]
safesystem(*make)
safesystem(*(make + ["test"])) if attributes[:cpan_test?]
Expand All @@ -128,11 +140,16 @@ def input(package)
if attributes[:cpan_test?]
safesystem("./Build", "test")
end

safesystem("./Build", "install",
"--prefix", prefix, "--destdir", staging_path,
# Empty install_base to avoid local::lib being used.
"--install_base", "")
if attributes[:cpan_perl_lib_path]
perl_lib_path = attributes[:cpan_perl_lib_path]
safesystem("./Build install --install_path lib=#{perl_lib_path} \
--destdir #{staging_path} --prefix #{prefix} --destdir #{staging_path}")
else
safesystem("./Build", "install",
"--prefix", prefix, "--destdir", staging_path,
# Empty install_base to avoid local::lib being used.
"--install_base", "")
end
else
raise FPM::InvalidPackageConfiguration,
"I don't know how to build #{name}. No Makefile.PL nor " \
Expand Down

0 comments on commit b42878e

Please sign in to comment.