fpm-cookery
fpm-cookery copied to clipboard
Setting an environment variable, in recipe.rb, not respected during the configure step.
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.
try env['JAVA_HOME'] ?
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.
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