-
Notifications
You must be signed in to change notification settings - Fork 75
/
metaconfig
142 lines (123 loc) · 3.14 KB
/
metaconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# --*- ruby -*--
ToplevelInstaller::TASKS.push ['test', 'run test.']
ToplevelInstaller::TASKS.push ['distbin', 'make binary package.']
ToplevelInstaller.module_eval {
alias parsearg_test parsearg_no_options
alias parsearg_distbin parsearg_no_options
def exec_test
old = Dir.pwd
@installer.mkdir_p "#{objdir_root}/test"
Dir.chdir "#{objdir_root}/test"
@installer.ruby("-w -I#{srcdir_root}/ext/oci8 -I#{srcdir_root}/lib -I#{srcdir_root}/support -I#{srcdir_root}/test #{srcdir_root}/test/test_all.rb")
Dir.chdir old
end
def get_zcontent(file)
require 'base64'
require 'zlib'
File.open(file, 'rb') do |f|
Base64.encode64(Zlib::Deflate::deflate(f.read))
end
end
def exec_distbin
File.open("ruby-oci8-#{RUBY_PLATFORM}.rb", 'w') do |f|
f.write <<-EOT
# ruby-oci8 binary installer for #{RUBY_PLATFORM}
require 'rbconfig'
require 'base64'
require 'ftools'
require 'zlib'
def msg_error(msg)
puts "ERROR: "
puts msg
exit 1
end
def msg_ok(msg)
puts msg
end
def msg_ask(msg)
puts msg
$stdout.print "Enter Yes/No: "
$stdout.flush
ret = gets().chomp.downcase
if ret == 'y' || ret == 'ye' || ret == 'yes'
return
else
exit 1
end
end
if '#{RUBY_PLATFORM}' != RUBY_PLATFORM
msg_ask "This package is for #{RUBY_PLATFORM}\\ninstall anyway?"
end
class Installer
@@log = ""
def initialize(install_files)
@files = []
install_files.each do |file, content|
basename = File.basename(file)
dirname = File.dirname(file)
if dirname == '.'
dirname = ''
else
dirname = '/' + dirname
end
case basename
when /\.so$/
dirname = "\#{Config::CONFIG['sitearchdir']}\#{dirname}"
else
dirname = "\#{Config::CONFIG['sitelibdir']}\#{dirname}"
end
@files << [basename, dirname, content]
end
@files.sort! do |x, y| x[0] <=> y[0] end
end
def confirm
msg = ""
@files.each do |f|
basename, dirname, content = f
msg << "Copy \#{basename} to \#{dirname}\\n"
end
msg << "OK?\\n"
msg_ask(msg)
end
def install
@@log = ""
@files.each do |f|
basename, dirname, content = f
@@log << "Copying \#{basename} to \#{dirname} ... "
if not FileTest.directory?(dirname)
File.makedirs(dirname)
end
File.open("\#{dirname}/\#{basename}", "wb") do |f|
f.write(Zlib::Inflate::inflate(Base64.decode64(content)))
end
@@log << "done\\n"
end
@@log << "OK\\n"
msg_ok(@@log)
end
def self.log
@@log
end
end
install_files = {}
install_files['oci8lib.so'] = <<-EOS
#{get_zcontent('ext/oci8/oci8lib.so')}EOS
install_files['oci8.rb'] = <<-EOS
#{get_zcontent('lib/oci8.rb')}EOS
install_files['DBD/OCI8/OCI8.rb'] = <<-EOS
#{get_zcontent('lib/DBD/OCI8/OCI8.rb')}EOS
begin
installer = Installer.new(install_files)
installer.confirm
installer.install
rescue
msg_error(Installer.log + "\\n" + $!.to_s)
end
EOT
end
end
}
ConfigTable.add_entry('oracle_version', ['',
'name',
'Oracle version name',
'NONE' ])