forked from emerose/flint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile.rb
166 lines (135 loc) · 4.82 KB
/
rakefile.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
begin
require 'rubygems'
rescue LoadError
puts "******************************************************************************"
puts "Please install RubyGems, see: http://docs.rubygems.org/read/chapter/3"
puts "******************************************************************************"
exit 1
end
begin
require 'ralex/ralextask.rb'
# Ralex files
Ralex::RalexTask.new('lib/cisco/ralex_pix.rb')
# Racc file
rescue LoadError
#puts "Cannot load Ralex, so you will not be able to update the lexers"
end
RACC="racc"
FLINT_VERSION = File.read('VERSION')
GEM_DIR = File.dirname(__FILE__) + "/vendor"
ENV['GEM_HOME']=GEM_DIR
namespace "bundler" do
task :gem do
# install bundler
maj,min,rev = `gem --version`.split(".").map{|n| n.to_i}
current_gem_version = ( maj * 1000) + (min * 100) + (rev * 10 )
target_gem_version = ( 1 * 1000) + ( 3 * 100) + ( 6 * 10 )
unless current_gem_version >= target_gem_version
puts "******************************************************************************"
puts " Please upgrade your rubygems to 1.3.6 or better:"
puts " sudo gem install rubygems-update"
puts " sudo update_rubygems"
puts "******************************************************************************"
exit 1
end
sh("[ -e vendor/bin/bundle ] || gem install vendor/cache/bundler*.gem --no-rdoc --no-ri --install-dir \"#{GEM_DIR}\" --bindir vendor/bin")
end
task :uninstall do
sh("gem uninstall -i vendor")
end
task :install => [ :gem ] do
# install our dependencies
sh("vendor/bin/bundle check || vendor/bin/bundle install \"#{GEM_DIR}\" --disable-shared-gems --without development")
end
end
namespace "redis" do
task :uninstall do
sh("[ -e vendor/bin/redis-server ] && rm vendor/bin/redis-server")
end
task :install do
sh("[ -e vendor/bin/redis-server ] || ( cd vendor && tar xzvf redis-1.2.5.tar.gz && cd redis-1.2.5 && make && cp redis-server ../bin/redis-server )" )
end
end
task :install => [ "bundler:install", "redis:install"]
task :uninstall => [ "bundler:uninstall", "redis:uninstall"]
file 'lib/cisco/pix_parser.rb' => [ 'lib/cisco/pix_parser.racc',
'lib/cisco/ralex_pix.rb'] do
sh "cd lib/cisco; #{RACC} -gv -e `which ruby` pix_parser.racc -o pix_parser.rb"
end
task :racc => ['lib/cisco/pix_parser.rb']
task :ralex => ['lib/cisco/ralex_pix.rb']
task :spec => [:racc, :ralex, :redis] do
sh "spec --format nested --colour spec/flint/*_spec.rb"
end
task :build => [:racc, :ralex]
task :init => [:build, :redis] do
sh "./script/init"
end
task :redis do
# restarts the redis if it is already running
rpid = nil
if File.exists?('redis.pid')
rpid = File.read('redis.pid').to_i
begin
Process.kill(0,rpid)
puts "redis-server already running (pid: #{rpid})"
rescue
puts "redis.pid file is stale, removing"
File.delete('redis.pid')
rpid = nil
end
end
unless rpid
sh "vendor/bin/redis-server redis.conf"
end
end
task :redis_down do
if File.exists?('redis.pid')
rpid = File.read('redis.pid').to_i
File.delete('redis.pid')
Process.kill(15,rpid)
end
end
task :reset => [:redis] do
sh "./script/reset"
end
task :app => [:redis, :init] do
sh "cd app; ruby app.rb"
sh "rake redis_down"
end
task :gems do
end
namespace "release" do
task :changelog do
sh "script/git-changelog > ChangeLog"
end
task :tarball do
sh "git archive --format=tar --prefix=flint-#{FLINT_VERSION}/ HEAD | gzip > flint-#{FLINT_VERSION}.tgz"
end
task :upload_tarball do
sh "scp flint-#{FLINT_VERSION}.tgz [email protected]:/root/runplaybook-staging/shared/system/storage/flint/flint-#{FLINT_VERSION}.tgz"
end
task :make_current do
# put the readme in place
sh "scp README [email protected]:/root/runplaybook-staging/shared/system/storage/flint/README"
# link the flint-current.tgz to the tarball
sh "ssh [email protected] ln -sf /root/runplaybook-staging/shared/system/storage/flint/flint-#{FLINT_VERSION}.tgz /root/runplaybook-staging/shared/system/storage/flint/flint-current.tgz"
# and at this old location too
sh "ssh [email protected] ln -sf /root/runplaybook-staging/shared/system/storage/flint/flint-#{FLINT_VERSION}.tgz /root/runplaybook-staging/shared/system/storage/flint-current.tgz"
end
task :push => [:tarball, :upload_tarball, :make_current ]
end
begin
require 'rake/rdoctask'
rescue LoadeError => e
puts "Install the rdoc gem please."
end
if defined?(RDoc) then
DOC = RDoc::Task.new(:rdoc) do |rd|
rd.title = 'Flint -- Documentation'
rd.main = 'README'
rd.rdoc_dir = 'doc/api'
rd.options << '--line-numbers' << '--main' << 'README' << '--title' << 'Flint -- Documentation'
rd.rdoc_files.include %w(README LICENSE.txt lib/**/*.rb)
end
end