[Groonga-commit] groonga/heroku-buildpack-groonga at cae4144 [master] Support loading environment variables from env_dir

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jul 7 23:41:49 JST 2014


Kouhei Sutou	2014-07-07 23:41:49 +0900 (Mon, 07 Jul 2014)

  New Revision: cae414470437b47fb113921e750e54783ba603b1
  https://github.com/groonga/heroku-buildpack-groonga/commit/cae414470437b47fb113921e750e54783ba603b1

  Message:
    Support loading environment variables from env_dir

  Modified files:
    bin/compile

  Modified: bin/compile (+19 -0)
===================================================================
--- bin/compile    2014-07-07 23:36:06 +0900 (ef83a26)
+++ bin/compile    2014-07-07 23:41:49 +0900 (713dd5a)
@@ -21,6 +21,18 @@ def ruby(*command_line)
   sh(*command_line)
 end
 
+def load_environment_variables(env_dir)
+  return {} if env_dir.nil?
+
+  variables = {}
+  Dir.chdir(env_dir) do
+    Dir.glob("*") do |key|
+      variables[key] = File.read(key)
+    end
+  end
+  variables
+end
+
 def remove_needless_files(prefix)
   rm(Dir.glob("#{prefix}/lib/**/*.a"))
   rm_r("#{prefix}/share/groonga/examples")
@@ -45,6 +57,9 @@ def fix_prefix_in_pc(prefix, real_prefix)
   end
 end
 
+puts("-----> Loading environment variables")
+environment_variables = load_environment_variables(env_dir)
+
 Dir.chdir(build_dir) do
   puts("-----> Installing Groonga #{version}")
 
@@ -67,12 +82,14 @@ Dir.chdir(build_dir) do
   puts("-----> Creating Groonga database")
   paths = [
     "#{absolete_prefix}/bin",
+    environment_variables["PATH"],
     ENV["PATH"],
   ]
   ENV["PATH"] = paths.compact.join(File::PATH_SEPARATOR)
   lib_dir = "#{absolete_prefix}/lib"
   ld_library_paths = [
     lib_dir,
+    environment_variables["LD_LIBRARY_PATH"],
     ENV["LD_LIBRARY_PATH"],
   ]
   ENV["LD_LIBRARY_PATH"] = ld_library_paths.compact.join(File::PATH_SEPARATOR)
@@ -91,6 +108,7 @@ Dir.chdir(build_dir) do
   open("#{env_dir}/PKG_CONFIG_PATH", "w") do |env_file|
     pkg_config_paths = [
       "#{lib_dir}/pkgconfig",
+      environment_variables["PKG_CONFIG_PATH"],
       ENV["PKG_CONFIG_PATH"]
     ]
     pkg_config_path = pkg_config_paths.compact.join(File::PATH_SEPARATOR)
@@ -103,6 +121,7 @@ Dir.chdir(build_dir) do
   open("#{profile_dir}/groonga.sh", "w") do |env_file|
     ld_library_paths = [
       "#{app_dir}/#{prefix}/lib",
+      environment_variables["LD_LIBRARY_PATH"],
       ENV["LD_LIBRARY_PATH"]
     ]
     ld_library_path = ld_library_paths.compact.join(File::PATH_SEPARATOR)
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index