This repository has been archived by the owner on Mar 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Rakefile
75 lines (68 loc) · 2.49 KB
/
Rakefile
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
task :default => :app
PATCH_DIR = File.join(File.dirname(__FILE__), "patches")
MAGLEV_HOME = ENV['MAGLEV_HOME']
desc "Do one-time install of gems and patch rails gems"
task :init => [:'bundler:install', :'patch:activesupport']
desc "Run myapp, with maglev."
task :app do
cd('myapp') do
sh "#{MAGLEV_HOME}/bin/rails server"
end
end
# The tasks in this namespace use Bundler to install the appropriate Rails
# 3.0.0 gems, and the other gems needed to run rails. They only manage
# gems for MagLev installed in $MAGLEV_HOME. The tasks in this namespace
# need only be run once.
namespace :bundler do
desc "Install rails 3.0.0 gems from myapp/Gemfile.lock into MagLev"
task :install do
cd('myapp') do
sh %{ #{MAGLEV_HOME}/bin/bundle install }
end
end
end
namespace :patch do
desc "Patch ActiveSupport 3.0.0 gem."
task :activesupport do
patch_info = {
"activesupport-3.0.0" => ['activesupport_class_patch.diff',
'activesupport_time_zone_patch.diff',
'activesupport_descendents_tracker_patch.diff'],
"activesupport-3.0.3" => ['activesupport_class_patch.diff',
'activesupport_time_zone_patch.diff',
'activesupport_descendents_tracker_patch.diff'],
"activesupport-3.0.4" => ['activesupport_class_patch.diff',
'activesupport_time_zone_patch.diff',
'activesupport_descendents_tracker_patch.diff'],
"activesupport-3.1.0.rc4" => ['activesupport_class_patch-3.1.diff',
'activesupport_time_patch-3.1.diff']
}
apply_patches(patch_info)
end
end
# Apply several patches to a versioned gem
# the patch_info is a hash: { 'activesupport-3.0.0.beta4' => ['patch1.diff', 'patch2.diff'],
# ...}
def apply_patches(patch_info)
patch_info.each do |gem_version, patches|
patch_dir = "#{MAGLEV_HOME}/lib/maglev/gems/1.8/gems/#{gem_version}"
if File.directory? patch_dir
puts "Patching #{patch_dir}"
patches.each do |patch|
apply_patch(patch_dir, patch)
end
else
puts "Skipping #{patch_dir} (does not exist)"
end
end
end
# Apply one patch
def apply_patch(patch_dir, patch_file)
if File.directory? patch_dir
puts "Applying patch #{patch_file} in #{patch_dir}"
cd(patch_dir) do
patch_path = File.join(PATCH_DIR, patch_file)
sh %{ patch -p1 < #{patch_path} }
end
end
end