-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.rb
66 lines (59 loc) · 1.34 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env ruby
require 'rbconfig'
require 'fileutils'
include FileUtils
EXECUTABLES = ['roombox', 'roomboxctl']
LIBRARIES = ['lib/roombox']
def usage
$stderr.puts <<-"EOM"
usage:
#$0 system [bindir [libdir]]
or
#$0 user bindir libdir
EOM
exit 1
end
if ARGV.length > 0 then
action = ARGV[0]
if action == 'system' then
bindir = ARGV[1] || '/usr/local/bin'
libdir = ARGV[2] || Config::CONFIG['sitelibdir']
elsif action == 'user' then
bindir = ARGV[1] or usage
libdir = ARGV[2] or usage
else
usage
end
puts <<-"EOD"
This is the installation script for Roombox.
You wish to install in the following directories:
Binaries in #{bindir}
Libraries in #{libdir}
EOD
print "Is that right? [y/N] "
$stdout.flush
resp = $stdin.gets
if resp =~ /y/i then
puts "All right then. Installing..."
begin
EXECUTABLES.each do |exe|
puts "* #{exe} -> #{bindir}/#{exe}"
cp(exe, bindir)
end
LIBRARIES.each do |lib|
puts "* #{lib} -> #{libdir}/#{lib}"
cp_r(lib, libdir)
end
puts "All done. Have fun. Exiting."
rescue => err
puts "Oops! An error occurred during installation."
puts "The error was:"
puts "\t#{err.class}: #{err.message}"
puts "Exiting."
end
else
puts "All right then. Exiting."
end
else
usage
end