diff --git a/IBM_DB_Adapter/ibm_db/CHANGES b/IBM_DB_Adapter/ibm_db/CHANGES index 5b8005e..25ac607 100644 --- a/IBM_DB_Adapter/ibm_db/CHANGES +++ b/IBM_DB_Adapter/ibm_db/CHANGES @@ -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 diff --git a/IBM_DB_Adapter/ibm_db/IBM_DB.gemspec b/IBM_DB_Adapter/ibm_db/IBM_DB.gemspec index dfeaa67..3dc454d 100644 --- a/IBM_DB_Adapter/ibm_db/IBM_DB.gemspec +++ b/IBM_DB_Adapter/ibm_db/IBM_DB.gemspec @@ -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 @@ -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' diff --git a/IBM_DB_Adapter/ibm_db/ext/extconf.rb b/IBM_DB_Adapter/ibm_db/ext/extconf.rb index f6e67ee..f6f86ac 100644 --- a/IBM_DB_Adapter/ibm_db/ext/extconf.rb +++ b/IBM_DB_Adapter/ibm_db/ext/extconf.rb @@ -5,7 +5,7 @@ require 'zlib' require 'zip' require 'fileutils' - +require 'down' # +----------------------------------------------------------------------+ # | Licensed Materials - Property of IBM | @@ -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 diff --git a/IBM_DB_Driver/extconf.rb b/IBM_DB_Driver/extconf.rb index 91855e2..f6f86ac 100644 --- a/IBM_DB_Driver/extconf.rb +++ b/IBM_DB_Driver/extconf.rb @@ -3,8 +3,9 @@ require 'open-uri' require 'rubygems/package' require 'zlib' +require 'zip' require 'fileutils' - +require 'down' # +----------------------------------------------------------------------+ # | Licensed Materials - Property of IBM | @@ -42,6 +43,7 @@ def suppress_warnings end DOWNLOADLINK = '' +ZIP = false if(RUBY_PLATFORM =~ /aix/i) #AIX @@ -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) @@ -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) @@ -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" @@ -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