forked from nahi/httpclient
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.rb
49 lines (40 loc) · 1.06 KB
/
install.rb
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
#!/usr/bin/env ruby
#
# Installer for httpclient
require "rbconfig"
require "fileutils"
include Config
SITELIBDIR = CONFIG["sitelibdir"]
SRCPATH = File.join(File.dirname($0), 'lib')
def install_file(from, to)
unless File.directory?(to)
to = File.dirname(to)
end
to_path = File.join(to, File.basename(from))
unless FileTest.exist?(to_path) and FileUtils.compare_file(from, to_path)
FileUtils.install(from, to_path, :mode => 0644, :preserve => true, :verbose => true)
end
end
def install(*path)
from_path = File.join(SRCPATH, *path)
if FileTest.directory?(from_path)
to_path_sitelib = File.join(SITELIBDIR, *path)
Dir[File.join(from_path, '*.rb')].each do |name|
FileUtils.mkdir_p(to_path_sitelib)
install_file(name, to_path_sitelib)
end
else
install_file(from_path, File.join(SITELIBDIR, *path))
end
end
begin
install('httpclient.rb')
install('httpclient')
install('httpclient', 'cacert.p7s')
install('http-access2.rb')
install('http-access2')
puts "install succeed!"
rescue
puts "install failed!"
raise
end