-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.rb
37 lines (33 loc) · 998 Bytes
/
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
require 'rbconfig'
sitelibdir = Config::CONFIG.fetch("sitelibdir")
bindir = Config::CONFIG.fetch("bindir")
def copy(src, dest, mode)
p dest
open(src, "rb") do |infile|
open(dest, "wb") do |outfile|
while buf = infile.read(8192)
while buf.length > 0
wlen = outfile.write(buf)
buf = buf[wlen, buf.length]
end
end
outfile.chmod(mode)
end
end
end
if ARGV.length > 0 && ARGV[0] == "uninstall"
printf("uninstalling the library from %s ... ", sitelibdir)
File.unlink("#{sitelibdir}/tokyotyrant.rb")
printf("ok\n")
printf("uninstalling the test command from %s ... ", bindir)
File.unlink("#{bindir}/tcrtest.rb")
printf("ok\n")
else
printf("installing the library into %s ... ", sitelibdir)
copy("tokyotyrant.rb", "#{sitelibdir}/tokyotyrant.rb", 0644)
printf("ok\n")
printf("installing the test command into %s ... ", bindir)
copy("tcrtest.rb", "#{bindir}/tcrtest.rb", 0755)
printf("ok\n")
end
printf("done\n")