Skip to content

Commit

Permalink
Merge pull request #150 from praveen-db2/master
Browse files Browse the repository at this point in the history
Download clidriver issue fixed
  • Loading branch information
praveen-db2 authored Mar 29, 2023
2 parents fdf82ae + f1e202f commit bd74c62
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 32 deletions.
5 changes: 5 additions & 0 deletions IBM_DB_Adapter/ibm_db/CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Change Log
==============
2023/03/29 (IBM_DB adapter 5.4.1, driver 3.1.0)
- Download clidriver issue fixed and replaced http links with https.

2023/01/06 (IBM_DB adapter 5.4.0, driver 3.1.0)
- Support for Ruby 3.1 and Rails 7.0

2022/10/06 (IBM_DB adapter 5.3.2, driver 3.0.6)
- Allowed all rails versions < 6.2 in gemspec, replaced limit clause with FETCH FIRST n ROWS
Expand Down
3 changes: 2 additions & 1 deletion IBM_DB_Adapter/ibm_db/IBM_DB.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require 'pathname'
Gem::Specification.new do |spec|
# Required spec
spec.name = 'ibm_db'
spec.version = '5.4.0'
spec.version = '5.4.1'
spec.summary = 'Rails Driver and Adapter for IBM Data Servers: {DB2 on Linux/Unix/Windows, DB2 on zOS, DB2 on i5/OS, Informix (IDS)}'

# Optional spec
Expand All @@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/ibmdb/ruby-ibmdb'
spec.required_ruby_version = '>= 2.5.0'
spec.add_dependency('zip')
spec.add_dependency('down')
spec.add_dependency('activerecord', '<7.1')
spec.requirements << 'ActiveRecord, at least 7.0'

Expand Down
17 changes: 3 additions & 14 deletions IBM_DB_Adapter/ibm_db/ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'zlib'
require 'zip'
require 'fileutils'

require 'down'

# +----------------------------------------------------------------------+
# | Licensed Materials - Property of IBM |
Expand Down Expand Up @@ -114,24 +114,13 @@ def downloadCLIPackage(destination, link = nil)
downloadLink = link
end

uri = URI.parse(downloadLink)
if ZIP
filename = "#{destination}/clidriver.zip"
else
filename = "#{destination}/clidriver.tar.gz"
end

headers = {
'Accept-Encoding' => 'identity',
}

request = Net::HTTP::Get.new(uri.request_uri, headers)
http = Net::HTTP.new(uri.host, uri.port)
response = http.request(request)

f = open(filename, 'wb')
f.write(response.body)
f.close()

Down.download(downloadLink, destination: filename)

filename
end
Expand Down
54 changes: 37 additions & 17 deletions IBM_DB_Driver/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
require 'open-uri'
require 'rubygems/package'
require 'zlib'
require 'zip'
require 'fileutils'

require 'down'

# +----------------------------------------------------------------------+
# | Licensed Materials - Property of IBM |
Expand Down Expand Up @@ -42,6 +43,7 @@ def suppress_warnings
end

DOWNLOADLINK = ''
ZIP = false

if(RUBY_PLATFORM =~ /aix/i)
#AIX
Expand Down Expand Up @@ -94,6 +96,15 @@ def suppress_warnings
else
puts "Mac OS 32 bit not supported. Please use an x64 architecture."
end
elsif (RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/)
ZIP = true
if(is64Bit)
puts "Detected platform - windows 64"
DOWNLOADLINK= "https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ntx64_odbc_cli.zip"
else
puts "Detected platform - windows 32"
DOWNLOADLINK= "https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/nt32_odbc_cli.zip"
end
end

def downloadCLIPackage(destination, link = nil)
Expand All @@ -103,22 +114,27 @@ def downloadCLIPackage(destination, link = nil)
downloadLink = link
end

uri = URI.parse(downloadLink)
filename = "#{destination}/clidriver.tar.gz"

headers = {
'Accept-Encoding' => 'identity',
}
if ZIP
filename = "#{destination}/clidriver.zip"
else
filename = "#{destination}/clidriver.tar.gz"
end

Down.download(downloadLink, destination: filename)

request = Net::HTTP::Get.new(uri.request_uri, headers)
http = Net::HTTP.new(uri.host, uri.port)
response = http.request(request)
filename
end

f = open(filename, 'wb')
f.write(response.body)
f.close()
def extract_zip(file, destination)
FileUtils.mkdir_p(destination)

filename
Zip::File.open(file) do |zip_file|
zip_file.each do |f|
fpath = File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(fpath))
zip_file.extract(f, fpath) unless File.exist?(fpath)
end
end
end

def untarCLIPackage(archive,destination)
Expand Down Expand Up @@ -157,8 +173,12 @@ def untarCLIPackage(archive,destination)
puts "Environment variable IBM_DB_HOME is not set. Downloading and setting up the DB2 client driver\n"
destination = "#{File.expand_path(File.dirname(File.dirname(__FILE__)))}/../lib"

archive = downloadCLIPackage(destination)
untarCLIPackage(archive,destination)
archive = downloadCLIPackage(destination)
if (ZIP)
extract_zip(archive, destination)
else
untarCLIPackage(archive,destination)
end

IBM_DB_HOME="#{destination}/clidriver"

Expand Down Expand Up @@ -262,7 +282,7 @@ def libpathflag(libpath)
end
end
else
if(RUBY_VERSION =~ /2./ || RUBY_VERSION =~ /3./)
if(RUBY_VERSION =~ /2./ || RUBY_VERSION =~ /3./)
ldflags = case RbConfig::CONFIG["arch"]
when /solaris2/
libpath[0..-2].map {|path| " -R#{path}"}.join
Expand Down

0 comments on commit bd74c62

Please sign in to comment.