ibm_db 2.5.27-x86-mingw32 → 2.6.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +5 -0
- data/MANIFEST +14 -14
- data/README +225 -225
- data/ext/Makefile.nt32 +181 -181
- data/ext/Makefile.nt32.191 +212 -212
- data/ext/extconf.rb +264 -264
- data/ext/extconf_MacOS.rb +269 -0
- data/ext/ibm_db.c +1 -1
- data/ext/ruby_ibm_db.h +241 -241
- data/init.rb +41 -41
- data/lib/IBM_DB.rb +27 -3
- data/lib/active_record/connection_adapters/ibm_db_adapter.rb +3290 -3290
- data/lib/active_record/connection_adapters/ibmdb_adapter.rb +1 -1
- data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -328
- data/lib/mswin32/ibm_db.rb +104 -20
- data/lib/mswin32/rb19x/ibm_db.so +0 -0
- data/lib/mswin32/rb21x/i386/ibm_db.so +0 -0
- data/lib/mswin32/rb22x/i386/ibm_db.so +0 -0
- data/lib/mswin32/rb2x/i386/ibm_db.so +0 -0
- data/test/cases/adapter_test.rb +207 -207
- data/test/cases/associations/belongs_to_associations_test.rb +711 -711
- data/test/cases/associations/cascaded_eager_loading_test.rb +181 -181
- data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +851 -851
- data/test/cases/associations/join_model_test.rb +743 -743
- data/test/cases/attribute_methods_test.rb +822 -822
- data/test/cases/base_test.rb +2133 -2133
- data/test/cases/calculations_test.rb +482 -482
- data/test/cases/migration_test.rb +2408 -2408
- data/test/cases/persistence_test.rb +642 -642
- data/test/cases/query_cache_test.rb +257 -257
- data/test/cases/relations_test.rb +1182 -1182
- data/test/cases/schema_dumper_test.rb +256 -256
- data/test/cases/transaction_callbacks_test.rb +300 -300
- data/test/cases/validations/uniqueness_validation_test.rb +299 -299
- data/test/cases/xml_serialization_test.rb +408 -408
- data/test/config.yml +154 -154
- data/test/connections/native_ibm_db/connection.rb +43 -43
- data/test/ibm_db_test.rb +24 -24
- data/test/models/warehouse_thing.rb +4 -4
- data/test/schema/schema.rb +751 -751
- metadata +31 -16
data/ext/extconf.rb
CHANGED
@@ -1,264 +1,264 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'net/http'
|
3
|
-
require 'open-uri'
|
4
|
-
require 'rubygems/package'
|
5
|
-
require 'zlib'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
|
9
|
-
# +----------------------------------------------------------------------+
|
10
|
-
# | Licensed Materials - Property of IBM |
|
11
|
-
# | |
|
12
|
-
# | (C) Copyright IBM Corporation 2006 - 2015 |
|
13
|
-
# +----------------------------------------------------------------------+
|
14
|
-
|
15
|
-
TAR_LONGLINK = '././@LongLink'
|
16
|
-
|
17
|
-
WIN = RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
|
18
|
-
|
19
|
-
# use ENV['IBM_DB_HOME'] or latest db2 you can find
|
20
|
-
IBM_DB_HOME = ENV['IBM_DB_HOME']
|
21
|
-
|
22
|
-
machine_bits = ['ibm'].pack('p').size * 8
|
23
|
-
|
24
|
-
is64Bit = true
|
25
|
-
|
26
|
-
if machine_bits == 64
|
27
|
-
is64Bit = true
|
28
|
-
puts "Detected 64-bit Ruby\n "
|
29
|
-
else
|
30
|
-
is64Bit = false
|
31
|
-
puts "Detected 32-bit Ruby\n "
|
32
|
-
end
|
33
|
-
|
34
|
-
module Kernel
|
35
|
-
def suppress_warnings
|
36
|
-
origVerbosity = $VERBOSE
|
37
|
-
$VERBOSE = nil
|
38
|
-
result = yield
|
39
|
-
$VERBOSE = origVerbosity
|
40
|
-
return result
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
DOWNLOADLINK = ''
|
45
|
-
|
46
|
-
if(RUBY_PLATFORM =~ /aix/i)
|
47
|
-
#AIX
|
48
|
-
if(is64Bit)
|
49
|
-
puts "Detected platform - aix 64"
|
50
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/aix64_odbc_cli.tar.gz"
|
51
|
-
else
|
52
|
-
puts "Detected platform - aix 32"
|
53
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/aix32_odbc_cli.tar.gz"
|
54
|
-
end
|
55
|
-
elsif (RUBY_PLATFORM =~ /powerpc/ || RUBY_PLATFORM =~ /ppc/)
|
56
|
-
#PPC
|
57
|
-
if(is64Bit)
|
58
|
-
puts "Detected platform - ppc linux 64"
|
59
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ppc64_odbc_cli.tar.gz"
|
60
|
-
else
|
61
|
-
puts "Detected platform - ppc linux 64"
|
62
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ppc32_odbc_cli.tar.gz"
|
63
|
-
end
|
64
|
-
elsif (RUBY_PLATFORM =~ /linux/)
|
65
|
-
#x86
|
66
|
-
if(is64Bit)
|
67
|
-
puts "Detected platform - linux x86 64"
|
68
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz"
|
69
|
-
else
|
70
|
-
puts "Detected platform - linux 32"
|
71
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxia32_odbc_cli.tar.gz"
|
72
|
-
end
|
73
|
-
elsif (RUBY_PLATFORM =~ /sparc/i)
|
74
|
-
#Solaris
|
75
|
-
if(is64Bit)
|
76
|
-
puts "Detected platform - sun sparc64"
|
77
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sun64_odbc_cli.tar.gz"
|
78
|
-
else
|
79
|
-
puts "Detected platform - sun sparc32"
|
80
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sun32_odbc_cli.tar.gz"
|
81
|
-
end
|
82
|
-
elsif (RUBY_PLATFORM =~ /solaris/i)
|
83
|
-
if(is64Bit)
|
84
|
-
puts "Detected platform - sun amd64"
|
85
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sunamd64_odbc_cli.tar.gz"
|
86
|
-
else
|
87
|
-
puts "Detected platform - sun amd32"
|
88
|
-
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sunamd32_odbc_cli.tar.gz"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def downloadCLIPackage(destination, link = nil)
|
93
|
-
if(link.nil?)
|
94
|
-
downloadLink = DOWNLOADLINK
|
95
|
-
else
|
96
|
-
downloadLink = link
|
97
|
-
end
|
98
|
-
|
99
|
-
uri = URI.parse(downloadLink)
|
100
|
-
filename = "#{destination}/clidriver.tar.gz"
|
101
|
-
|
102
|
-
headers = {
|
103
|
-
'Accept-Encoding' => 'identity',
|
104
|
-
}
|
105
|
-
|
106
|
-
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
107
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
108
|
-
response = http.request(request)
|
109
|
-
|
110
|
-
f = open(filename, 'wb')
|
111
|
-
f.write(response.body)
|
112
|
-
f.close()
|
113
|
-
|
114
|
-
filename
|
115
|
-
end
|
116
|
-
|
117
|
-
def untarCLIPackage(archive,destination)
|
118
|
-
Gem::Package::TarReader.new( Zlib::GzipReader.open(archive) ) do |tar|
|
119
|
-
tar.each do |entry|
|
120
|
-
file = nil
|
121
|
-
if entry.full_name == $TAR_LONGLINK
|
122
|
-
file = File.join destination, entry.read.strip
|
123
|
-
next
|
124
|
-
end
|
125
|
-
file ||= File.join destination, entry.full_name
|
126
|
-
if entry.directory?
|
127
|
-
File.delete file if File.file? file
|
128
|
-
FileUtils.mkdir_p file, :mode => entry.header.mode, :verbose => false
|
129
|
-
elsif entry.file?
|
130
|
-
FileUtils.rm_rf file if File.directory? file
|
131
|
-
File.open file, "wb" do |f|
|
132
|
-
f.print entry.read
|
133
|
-
end
|
134
|
-
FileUtils.chmod entry.header.mode, file, :verbose => false
|
135
|
-
elsif entry.header.typeflag == '2' #Symlink!
|
136
|
-
File.symlink entry.header.linkname, file
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
if(IBM_DB_HOME == nil || IBM_DB_HOME == '')
|
143
|
-
IBM_DB_INCLUDE = ENV['IBM_DB_INCLUDE']
|
144
|
-
IBM_DB_LIB = ENV['IBM_DB_LIB']
|
145
|
-
|
146
|
-
if( ( (IBM_DB_INCLUDE.nil?) || (IBM_DB_LIB.nil?) ) ||
|
147
|
-
( IBM_DB_INCLUDE == '' || IBM_DB_LIB == '' )
|
148
|
-
)
|
149
|
-
if(!DOWNLOADLINK.nil? && !DOWNLOADLINK.empty?)
|
150
|
-
puts "Environment variable IBM_DB_HOME is not set. Downloading and setting up the DB2 client driver\n"
|
151
|
-
destination = "#{File.expand_path(File.dirname(File.dirname(__FILE__)))}/../lib"
|
152
|
-
|
153
|
-
archive = downloadCLIPackage(destination)
|
154
|
-
untarCLIPackage(archive,destination)
|
155
|
-
|
156
|
-
IBM_DB_HOME="#{destination}/clidriver"
|
157
|
-
|
158
|
-
IBM_DB_INCLUDE = "#{IBM_DB_HOME}/include"
|
159
|
-
IBM_DB_LIB="#{IBM_DB_HOME}/lib"
|
160
|
-
else
|
161
|
-
puts "Environment variable IBM_DB_HOME is not set. Set it to your DB2/IBM_Data_Server_Driver installation directory and retry gem install.\n "
|
162
|
-
exit 1
|
163
|
-
end
|
164
|
-
end
|
165
|
-
else
|
166
|
-
IBM_DB_INCLUDE = "#{IBM_DB_HOME}/include"
|
167
|
-
|
168
|
-
if(is64Bit)
|
169
|
-
IBM_DB_LIB="#{IBM_DB_HOME}/lib64"
|
170
|
-
else
|
171
|
-
IBM_DB_LIB="#{IBM_DB_HOME}/lib32"
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
if( !(File.directory?(IBM_DB_LIB)) )
|
176
|
-
suppress_warnings{IBM_DB_LIB = "#{IBM_DB_HOME}/lib"}
|
177
|
-
if( !(File.directory?(IBM_DB_LIB)) )
|
178
|
-
puts "Cannot find #{IBM_DB_LIB} directory. Check if you have set the IBM_DB_HOME environment variable's value correctly\n "
|
179
|
-
exit 1
|
180
|
-
end
|
181
|
-
notifyString = "Detected usage of IBM Data Server Driver package. Ensure you have downloaded "
|
182
|
-
|
183
|
-
if(is64Bit)
|
184
|
-
notifyString = notifyString + "64-bit package "
|
185
|
-
else
|
186
|
-
notifyString = notifyString + "32-bit package "
|
187
|
-
end
|
188
|
-
notifyString = notifyString + "of IBM_Data_Server_Driver and retry the 'gem install ibm_db' command\n "
|
189
|
-
|
190
|
-
puts notifyString
|
191
|
-
end
|
192
|
-
|
193
|
-
if( !(File.directory?(IBM_DB_INCLUDE)) )
|
194
|
-
puts " #{IBM_DB_HOME}/include folder not found. Check if you have set the IBM_DB_HOME environment variable's value correctly\n "
|
195
|
-
exit 1
|
196
|
-
end
|
197
|
-
|
198
|
-
require 'mkmf'
|
199
|
-
|
200
|
-
dir_config('IBM_DB',IBM_DB_INCLUDE,IBM_DB_LIB)
|
201
|
-
|
202
|
-
def crash(str)
|
203
|
-
printf(" extconf failure: %s\n", str)
|
204
|
-
exit 1
|
205
|
-
end
|
206
|
-
|
207
|
-
if( RUBY_VERSION =~ /1.9/ || RUBY_VERSION =~ /2./)
|
208
|
-
create_header('gil_release_version')
|
209
|
-
create_header('unicode_support_version')
|
210
|
-
end
|
211
|
-
|
212
|
-
unless (have_library(WIN ? 'db2cli' : 'db2','SQLConnect') or find_library(WIN ? 'db2cli' : 'db2','SQLConnect', IBM_DB_LIB))
|
213
|
-
crash(<<EOL)
|
214
|
-
Unable to locate libdb2.so/a under #{IBM_DB_LIB}
|
215
|
-
|
216
|
-
Follow the steps below and retry
|
217
|
-
|
218
|
-
Step 1: - Install IBM DB2 Universal Database Server/Client
|
219
|
-
|
220
|
-
step 2: - Set the environment variable IBM_DB_HOME as below
|
221
|
-
|
222
|
-
(assuming bash shell)
|
223
|
-
|
224
|
-
export IBM_DB_HOME=<DB2/IBM_Data_Server_Driver installation directory> #(Eg: export IBM_DB_HOME=/opt/ibm/db2/v10)
|
225
|
-
|
226
|
-
step 3: - Retry gem install
|
227
|
-
|
228
|
-
EOL
|
229
|
-
end
|
230
|
-
|
231
|
-
if(RUBY_VERSION =~ /2./)
|
232
|
-
require 'rbconfig'
|
233
|
-
end
|
234
|
-
|
235
|
-
alias :libpathflag0 :libpathflag
|
236
|
-
def libpathflag(libpath)
|
237
|
-
if(RUBY_VERSION =~ /2./)
|
238
|
-
ldflags = case RbConfig::CONFIG["arch"]
|
239
|
-
when /solaris2/
|
240
|
-
libpath[0..-2].map {|path| " -R#{path}"}.join
|
241
|
-
when /linux/
|
242
|
-
libpath[0..-2].map {|path| " -R#{path} "}.join
|
243
|
-
else
|
244
|
-
""
|
245
|
-
end
|
246
|
-
else
|
247
|
-
ldflags = case Config::CONFIG["arch"]
|
248
|
-
when /solaris2/
|
249
|
-
libpath[0..-2].map {|path| " -R#{path}"}.join
|
250
|
-
when /linux/
|
251
|
-
libpath[0..-2].map {|path| " -R#{path} "}.join
|
252
|
-
else
|
253
|
-
""
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
#libpathflag0 + " '-Wl,-R$$ORIGIN/clidriver/lib #{ldflags}' "
|
258
|
-
libpathflag0 + " '-Wl,-R$$ORIGIN/clidriver/lib' "
|
259
|
-
end
|
260
|
-
|
261
|
-
have_header('gil_release_version')
|
262
|
-
have_header('unicode_support_version')
|
263
|
-
|
264
|
-
create_makefile('ibm_db')
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'net/http'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'rubygems/package'
|
5
|
+
require 'zlib'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
|
9
|
+
# +----------------------------------------------------------------------+
|
10
|
+
# | Licensed Materials - Property of IBM |
|
11
|
+
# | |
|
12
|
+
# | (C) Copyright IBM Corporation 2006 - 2015 |
|
13
|
+
# +----------------------------------------------------------------------+
|
14
|
+
|
15
|
+
TAR_LONGLINK = '././@LongLink'
|
16
|
+
|
17
|
+
WIN = RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
|
18
|
+
|
19
|
+
# use ENV['IBM_DB_HOME'] or latest db2 you can find
|
20
|
+
IBM_DB_HOME = ENV['IBM_DB_HOME']
|
21
|
+
|
22
|
+
machine_bits = ['ibm'].pack('p').size * 8
|
23
|
+
|
24
|
+
is64Bit = true
|
25
|
+
|
26
|
+
if machine_bits == 64
|
27
|
+
is64Bit = true
|
28
|
+
puts "Detected 64-bit Ruby\n "
|
29
|
+
else
|
30
|
+
is64Bit = false
|
31
|
+
puts "Detected 32-bit Ruby\n "
|
32
|
+
end
|
33
|
+
|
34
|
+
module Kernel
|
35
|
+
def suppress_warnings
|
36
|
+
origVerbosity = $VERBOSE
|
37
|
+
$VERBOSE = nil
|
38
|
+
result = yield
|
39
|
+
$VERBOSE = origVerbosity
|
40
|
+
return result
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
DOWNLOADLINK = ''
|
45
|
+
|
46
|
+
if(RUBY_PLATFORM =~ /aix/i)
|
47
|
+
#AIX
|
48
|
+
if(is64Bit)
|
49
|
+
puts "Detected platform - aix 64"
|
50
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/aix64_odbc_cli.tar.gz"
|
51
|
+
else
|
52
|
+
puts "Detected platform - aix 32"
|
53
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/aix32_odbc_cli.tar.gz"
|
54
|
+
end
|
55
|
+
elsif (RUBY_PLATFORM =~ /powerpc/ || RUBY_PLATFORM =~ /ppc/)
|
56
|
+
#PPC
|
57
|
+
if(is64Bit)
|
58
|
+
puts "Detected platform - ppc linux 64"
|
59
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ppc64_odbc_cli.tar.gz"
|
60
|
+
else
|
61
|
+
puts "Detected platform - ppc linux 64"
|
62
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ppc32_odbc_cli.tar.gz"
|
63
|
+
end
|
64
|
+
elsif (RUBY_PLATFORM =~ /linux/)
|
65
|
+
#x86
|
66
|
+
if(is64Bit)
|
67
|
+
puts "Detected platform - linux x86 64"
|
68
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz"
|
69
|
+
else
|
70
|
+
puts "Detected platform - linux 32"
|
71
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxia32_odbc_cli.tar.gz"
|
72
|
+
end
|
73
|
+
elsif (RUBY_PLATFORM =~ /sparc/i)
|
74
|
+
#Solaris
|
75
|
+
if(is64Bit)
|
76
|
+
puts "Detected platform - sun sparc64"
|
77
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sun64_odbc_cli.tar.gz"
|
78
|
+
else
|
79
|
+
puts "Detected platform - sun sparc32"
|
80
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sun32_odbc_cli.tar.gz"
|
81
|
+
end
|
82
|
+
elsif (RUBY_PLATFORM =~ /solaris/i)
|
83
|
+
if(is64Bit)
|
84
|
+
puts "Detected platform - sun amd64"
|
85
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sunamd64_odbc_cli.tar.gz"
|
86
|
+
else
|
87
|
+
puts "Detected platform - sun amd32"
|
88
|
+
DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sunamd32_odbc_cli.tar.gz"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def downloadCLIPackage(destination, link = nil)
|
93
|
+
if(link.nil?)
|
94
|
+
downloadLink = DOWNLOADLINK
|
95
|
+
else
|
96
|
+
downloadLink = link
|
97
|
+
end
|
98
|
+
|
99
|
+
uri = URI.parse(downloadLink)
|
100
|
+
filename = "#{destination}/clidriver.tar.gz"
|
101
|
+
|
102
|
+
headers = {
|
103
|
+
'Accept-Encoding' => 'identity',
|
104
|
+
}
|
105
|
+
|
106
|
+
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
107
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
108
|
+
response = http.request(request)
|
109
|
+
|
110
|
+
f = open(filename, 'wb')
|
111
|
+
f.write(response.body)
|
112
|
+
f.close()
|
113
|
+
|
114
|
+
filename
|
115
|
+
end
|
116
|
+
|
117
|
+
def untarCLIPackage(archive,destination)
|
118
|
+
Gem::Package::TarReader.new( Zlib::GzipReader.open(archive) ) do |tar|
|
119
|
+
tar.each do |entry|
|
120
|
+
file = nil
|
121
|
+
if entry.full_name == $TAR_LONGLINK
|
122
|
+
file = File.join destination, entry.read.strip
|
123
|
+
next
|
124
|
+
end
|
125
|
+
file ||= File.join destination, entry.full_name
|
126
|
+
if entry.directory?
|
127
|
+
File.delete file if File.file? file
|
128
|
+
FileUtils.mkdir_p file, :mode => entry.header.mode, :verbose => false
|
129
|
+
elsif entry.file?
|
130
|
+
FileUtils.rm_rf file if File.directory? file
|
131
|
+
File.open file, "wb" do |f|
|
132
|
+
f.print entry.read
|
133
|
+
end
|
134
|
+
FileUtils.chmod entry.header.mode, file, :verbose => false
|
135
|
+
elsif entry.header.typeflag == '2' #Symlink!
|
136
|
+
File.symlink entry.header.linkname, file
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
if(IBM_DB_HOME == nil || IBM_DB_HOME == '')
|
143
|
+
IBM_DB_INCLUDE = ENV['IBM_DB_INCLUDE']
|
144
|
+
IBM_DB_LIB = ENV['IBM_DB_LIB']
|
145
|
+
|
146
|
+
if( ( (IBM_DB_INCLUDE.nil?) || (IBM_DB_LIB.nil?) ) ||
|
147
|
+
( IBM_DB_INCLUDE == '' || IBM_DB_LIB == '' )
|
148
|
+
)
|
149
|
+
if(!DOWNLOADLINK.nil? && !DOWNLOADLINK.empty?)
|
150
|
+
puts "Environment variable IBM_DB_HOME is not set. Downloading and setting up the DB2 client driver\n"
|
151
|
+
destination = "#{File.expand_path(File.dirname(File.dirname(__FILE__)))}/../lib"
|
152
|
+
|
153
|
+
archive = downloadCLIPackage(destination)
|
154
|
+
untarCLIPackage(archive,destination)
|
155
|
+
|
156
|
+
IBM_DB_HOME="#{destination}/clidriver"
|
157
|
+
|
158
|
+
IBM_DB_INCLUDE = "#{IBM_DB_HOME}/include"
|
159
|
+
IBM_DB_LIB="#{IBM_DB_HOME}/lib"
|
160
|
+
else
|
161
|
+
puts "Environment variable IBM_DB_HOME is not set. Set it to your DB2/IBM_Data_Server_Driver installation directory and retry gem install.\n "
|
162
|
+
exit 1
|
163
|
+
end
|
164
|
+
end
|
165
|
+
else
|
166
|
+
IBM_DB_INCLUDE = "#{IBM_DB_HOME}/include"
|
167
|
+
|
168
|
+
if(is64Bit)
|
169
|
+
IBM_DB_LIB="#{IBM_DB_HOME}/lib64"
|
170
|
+
else
|
171
|
+
IBM_DB_LIB="#{IBM_DB_HOME}/lib32"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
if( !(File.directory?(IBM_DB_LIB)) )
|
176
|
+
suppress_warnings{IBM_DB_LIB = "#{IBM_DB_HOME}/lib"}
|
177
|
+
if( !(File.directory?(IBM_DB_LIB)) )
|
178
|
+
puts "Cannot find #{IBM_DB_LIB} directory. Check if you have set the IBM_DB_HOME environment variable's value correctly\n "
|
179
|
+
exit 1
|
180
|
+
end
|
181
|
+
notifyString = "Detected usage of IBM Data Server Driver package. Ensure you have downloaded "
|
182
|
+
|
183
|
+
if(is64Bit)
|
184
|
+
notifyString = notifyString + "64-bit package "
|
185
|
+
else
|
186
|
+
notifyString = notifyString + "32-bit package "
|
187
|
+
end
|
188
|
+
notifyString = notifyString + "of IBM_Data_Server_Driver and retry the 'gem install ibm_db' command\n "
|
189
|
+
|
190
|
+
puts notifyString
|
191
|
+
end
|
192
|
+
|
193
|
+
if( !(File.directory?(IBM_DB_INCLUDE)) )
|
194
|
+
puts " #{IBM_DB_HOME}/include folder not found. Check if you have set the IBM_DB_HOME environment variable's value correctly\n "
|
195
|
+
exit 1
|
196
|
+
end
|
197
|
+
|
198
|
+
require 'mkmf'
|
199
|
+
|
200
|
+
dir_config('IBM_DB',IBM_DB_INCLUDE,IBM_DB_LIB)
|
201
|
+
|
202
|
+
def crash(str)
|
203
|
+
printf(" extconf failure: %s\n", str)
|
204
|
+
exit 1
|
205
|
+
end
|
206
|
+
|
207
|
+
if( RUBY_VERSION =~ /1.9/ || RUBY_VERSION =~ /2./)
|
208
|
+
create_header('gil_release_version')
|
209
|
+
create_header('unicode_support_version')
|
210
|
+
end
|
211
|
+
|
212
|
+
unless (have_library(WIN ? 'db2cli' : 'db2','SQLConnect') or find_library(WIN ? 'db2cli' : 'db2','SQLConnect', IBM_DB_LIB))
|
213
|
+
crash(<<EOL)
|
214
|
+
Unable to locate libdb2.so/a under #{IBM_DB_LIB}
|
215
|
+
|
216
|
+
Follow the steps below and retry
|
217
|
+
|
218
|
+
Step 1: - Install IBM DB2 Universal Database Server/Client
|
219
|
+
|
220
|
+
step 2: - Set the environment variable IBM_DB_HOME as below
|
221
|
+
|
222
|
+
(assuming bash shell)
|
223
|
+
|
224
|
+
export IBM_DB_HOME=<DB2/IBM_Data_Server_Driver installation directory> #(Eg: export IBM_DB_HOME=/opt/ibm/db2/v10)
|
225
|
+
|
226
|
+
step 3: - Retry gem install
|
227
|
+
|
228
|
+
EOL
|
229
|
+
end
|
230
|
+
|
231
|
+
if(RUBY_VERSION =~ /2./)
|
232
|
+
require 'rbconfig'
|
233
|
+
end
|
234
|
+
|
235
|
+
alias :libpathflag0 :libpathflag
|
236
|
+
def libpathflag(libpath)
|
237
|
+
if(RUBY_VERSION =~ /2./)
|
238
|
+
ldflags = case RbConfig::CONFIG["arch"]
|
239
|
+
when /solaris2/
|
240
|
+
libpath[0..-2].map {|path| " -R#{path}"}.join
|
241
|
+
when /linux/
|
242
|
+
libpath[0..-2].map {|path| " -R#{path} "}.join
|
243
|
+
else
|
244
|
+
""
|
245
|
+
end
|
246
|
+
else
|
247
|
+
ldflags = case Config::CONFIG["arch"]
|
248
|
+
when /solaris2/
|
249
|
+
libpath[0..-2].map {|path| " -R#{path}"}.join
|
250
|
+
when /linux/
|
251
|
+
libpath[0..-2].map {|path| " -R#{path} "}.join
|
252
|
+
else
|
253
|
+
""
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
#libpathflag0 + " '-Wl,-R$$ORIGIN/clidriver/lib #{ldflags}' "
|
258
|
+
libpathflag0 + " '-Wl,-R$$ORIGIN/clidriver/lib' "
|
259
|
+
end
|
260
|
+
|
261
|
+
have_header('gil_release_version')
|
262
|
+
have_header('unicode_support_version')
|
263
|
+
|
264
|
+
create_makefile('ibm_db')
|