fpm-cookery icon indicating copy to clipboard operation
fpm-cookery copied to clipboard

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

Open madelaney opened this issue 7 years ago • 3 comments

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.

madelaney avatar Nov 02 '17 15:11 madelaney

try env['JAVA_HOME'] ?

mnikhil-git avatar May 18 '18 22:05 mnikhil-git

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 avatar Aug 16 '19 23:08 kkaos

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

kkaos avatar Sep 06 '19 15:09 kkaos