forked from rubinius/rubinius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.rake
127 lines (104 loc) · 3.71 KB
/
install.rake
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
# Tasks for installing Rubinius. There are two guidelines here:
#
# 1. Only use sudo if necessary
# 2. Build all Ruby files using the bootstrap Ruby implementation
# and install the files with the 'install' command
#
install_dirs = [
BUILD_CONFIG[:bindir],
BUILD_CONFIG[:libdir],
BUILD_CONFIG[:includedir],
BUILD_CONFIG[:mandir],
BUILD_CONFIG[:gemsdir]
]
# What the hell does this code do? We want to avoid sudo whenever
# possible. This code is based on the assumption that if A is a
# directory name, if any of the paths leading up to the full A are
# writable, then A can be created. So A is decomposed one directory
# at a time from the right-hand side. That path is checked for
# whether it is a directory. If it is and it is writable, we can
# create A. Otherwise, we can't create A and sudo is required.
def need_sudo?(dirs)
dirs.each do |name|
dir = File.expand_path name
until dir == "/"
if File.directory? dir
return true unless File.writable? dir
break
end
dir = File.dirname dir
end
end
return false
end
def need_install?
File.expand_path(Dir.pwd) != BUILD_CONFIG[:libdir]
end
def precompile(dir)
ruby "lib/bin/compile.rb -V -T default #{dir}"
end
def install_file(source, pattern, dest)
return if File.directory? source
dest_name = File.join(dest, source.sub(pattern, ""))
dir = File.dirname(dest_name)
mkdir_p dir unless File.directory? dir
install source, dest_name, :mode => 0644, :verbose => true
end
desc "Install Rubinius"
task :install => %w[ build install:build install:files ]
namespace :install do
desc "Compile all lib Ruby files"
task :build do
if need_install?
puts "Compiling library files for install..."
precompile "lib"
puts "Compiling pre-installed gem files for install..."
precompile "preinstalled-gems/rubinius/0.13/gems"
end
end
desc "Install all the Rubinius files"
task :files do
if need_sudo? install_dirs
sh "sudo #{FileUtils::RUBY} -S rake install:files", :verbose => true
elsif !need_install?
puts "Install directory is the same as build directory, nothing to install"
else
install_dirs.each { |name| mkdir_p name, :verbose => $verbose }
FileList["vm/capi/*.h"].each do |name|
install_file name, %r[^vm/capi], BUILD_CONFIG[:includedir]
end
FileList[
'runtime/index',
'runtime/platform.conf',
'runtime/**/*.rb{a,c}',
'runtime/**/load_order.txt'
].each do |name|
install_file name, /^runtime/, BUILD_CONFIG[:runtime]
end
# Install the .rb files for the standard library. This is a
# separate block from the .rbc files so that the .rb files
# have an older timestamp and do not trigger recompiling.
FileList['lib/**/*.rb'].each do |name|
install_file name, /^lib/, BUILD_CONFIG[:lib_path]
end
FileList['lib/**/*.rbc'].each do |name|
install_file name, /^lib/, BUILD_CONFIG[:lib_path]
end
# Install the C extensions for the standard library.
FileList["lib/ext/**/*.#{$dlext}"].each do |name|
install_file name, %r[^lib/ext], BUILD_CONFIG[:ext_path]
end
# Install pre-installed gems
gems_dest = "#{BUILD_CONFIG[:gemsdir]}/rubinius/preinstalled"
FileList["preinstalled-gems/data/**/*"].each do |name|
install_file name, %r[^preinstalled-gems/data], gems_dest
end
FileList["preinstalled-gems/bin/*"].each do |name|
install_file name, /^preinstalled-gems/, BUILD_CONFIG[:gemsdir]
end
# Install the Rubinius executable
exe = "#{BUILD_CONFIG[:bindir]}/#{BUILD_CONFIG[:program_name]}"
install "vm/vm", exe, :mode => 0755, :verbose => true
end
end
end