bernd / fpm-cookery

A tool for building software packages with fpm.
Other
460 stars 88 forks source link

Setting an environment variable, in recipe.rb, not respected during the configure step. #193

Open madelaney opened 6 years ago

madelaney commented 6 years ago

I have a recipe in which I want to set a unique value for JAVA_HOME.

I have the following code:

class Package < FPM::Cookery::Recipe
  ...
  def build
    environment['JAVA_HOME'] = '/usr/lib/jvm/openjdk-8-jdk'
    configure 
  end
  ...
end

However, during the configure phase, the build does not see the aforementioned JAVA_HOME value.

mnikhil-git commented 6 years ago

try env['JAVA_HOME'] ?

kkaos commented 5 years ago

I have come across a similar issue. I want to accomplish the following in recipe.rb, especially so that the dl library gets linked when compiling is performed via gcc:

export LIBS="-Wl,--no-as-needed -ldl"

When building the software in question, I run that statement before running configure, make, and then "make install". In my recipe.rb, I have tried both this:

def build
    environment['LIBS'] = '-Wl,--no-as-needed -ldl'
    sh './configure',
       "--prefix=#{prefix}",
       "--with-hdf5=/cm/shared/apps/hdf5_18/current",
       "--enable-64bit=true"
    make "--jobs=#{nproc}"
  end

and this:

 def build
    env['LIBS'] = '-Wl,--no-as-needed -ldl'
    sh './configure',
       "--prefix=#{prefix}",
       "--with-hdf5=/cm/shared/apps/hdf5_18/current",
       "--enable-64bit=true"
    make "--jobs=#{nproc}"
  end

While "environment" is recognized as a valid keyword with fpm-cookery, "env" is not; however, neither accomplishes what the export statement does outside of fpm-cookery, as the dl library never gets linked thereby causing compilation to fail.

kkaos commented 5 years ago

Ok, this does the trick:

environment :LIBS => "-Wl,--no-as-needed -ldl"
def build
    environment.with_clean do
       sh './configure',
          "--prefix=#{prefix}",
          "--with-hdf5=/cm/shared/apps/hdf5_18/current",
          "--enable-64bit=true"
       make "--jobs=#{nproc}"
    end
end