[ruby-oci8-commit] [362] branches/ruby-oci8-1.0: * ext/oci8/oraconf.rb:

nobody at rubyforge.org nobody at rubyforge.org
Sun Oct 4 10:04:01 EDT 2009


Revision: 362
Author:   kubo
Date:     2009-10-04 10:04:01 -0400 (Sun, 04 Oct 2009)

Log Message:
-----------
* ext/oci8/oraconf.rb:
    1. Fix for ruby 1.8.5 with Oracle 8.x which needs some object
       files to link with.
       (reported by Jayson Cena)
    2. Add additional error message if under the sudo environemnt.
    3. Print not only error message but also the error backtrace when
       oraconf.rb fails.

Modified Paths:
--------------
    branches/ruby-oci8-1.0/ChangeLog
    branches/ruby-oci8-1.0/ext/oci8/oraconf.rb

Modified: branches/ruby-oci8-1.0/ChangeLog
===================================================================
--- branches/ruby-oci8-1.0/ChangeLog	2009-10-04 14:01:58 UTC (rev 361)
+++ branches/ruby-oci8-1.0/ChangeLog	2009-10-04 14:04:01 UTC (rev 362)
@@ -1,3 +1,12 @@
+2009-10-04  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/oraconf.rb:
+	    1. Fix for ruby 1.8.5 with Oracle 8.x which needs some object
+	       files to link with.
+	       (reported by Jayson Cena)
+	    2. Add additional error message if under the sudo environemnt.
+	    3. Print not only error message but also the error backtrace when
+	       oraconf.rb fails.
+
 2009-09-13  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/lob.c, ext/oci8/oci8.h, test/test_clob.rb: Change
 	    OCI8::LOB#write to accept an object which is not a String and

Modified: branches/ruby-oci8-1.0/ext/oci8/oraconf.rb
===================================================================
--- branches/ruby-oci8-1.0/ext/oci8/oraconf.rb	2009-10-04 14:01:58 UTC (rev 361)
+++ branches/ruby-oci8-1.0/ext/oci8/oraconf.rb	2009-10-04 14:04:01 UTC (rev 362)
@@ -353,8 +353,10 @@
       end
       print <<EOS
 ---------------------------------------------------
-error messages:
-#{$!.to_s}
+Error Message:
+  #{$!.to_s.gsub(/\n/, "\n  ")}
+Backtrace:
+  #{$!.backtrace.join("\n  ")}
 ---------------------------------------------------
 See:
  * http://ruby-oci8.rubyforge.org/#{lang}/HowToInstall.html
@@ -616,6 +618,7 @@
 EOS
     end
     puts "ok"
+    $stdout.flush
   end # check_ruby_header
 
   def try_link_oci
@@ -863,10 +866,33 @@
     def get_home
       oracle_home = ENV['ORACLE_HOME']
       if oracle_home.nil?
-        raise <<EOS
+        msg = <<EOS
 Set the environment variable ORACLE_HOME if Oracle Full Client.
 Append the path of Oracle client libraries to #{OraConf.ld_envs[0]} if Oracle Instant Client.
 EOS
+
+        # check sudo environment
+        sudo_command = ENV['SUDO_COMMAND']
+        if /\w*make\b/ =~ sudo_command
+          msg += <<EOS
+
+The 'sudo' command unset some environment variables for security reasons.
+Use it only when running 'make install' as follows
+     make
+     sudo make install
+EOS
+        end
+        if /\w+\/gem\b/ =~ sudo_command
+          msg += <<EOS
+
+The 'sudo' command unset some environment variables for security reasons.
+Pass required varialbes as follows
+     sudo env #{OraConf.ld_envs[0]}=$#{OraConf.ld_envs[0]} #{sudo_command}
+  or 
+     sudo env ORACLE_HOME=$ORACLE_HOME #{sudo_command}
+EOS
+        end
+        raise msg
       end
       oracle_home
     end
@@ -956,10 +982,10 @@
 
         # monkey patching!
         Object.module_eval do
-          alias :orig_link_command :link_command
-          def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
-            opt = "" if opt == $libs
-            orig_link_command(ldflags, opt, libpath)
+          alias :link_command_pre_oci8 :link_command
+          def link_command(*args)
+            args[1] = "" if args[1] == $libs
+            link_command_pre_oci8(*args)
           end
         end
 




More information about the ruby-oci8-commit mailing list