19 |
19 |
20 $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s ) |
20 $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s ) |
21 $LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s ) |
21 $LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s ) |
22 } |
22 } |
23 |
23 |
|
24 require 'rubygems' |
|
25 gem 'rake', '>= 0.8.3' |
24 |
26 |
25 require 'rbconfig' |
27 require 'rbconfig' |
26 require 'rubygems' |
|
27 require 'rake' |
28 require 'rake' |
28 require 'rake/rdoctask' |
29 require 'rake/rdoctask' |
29 require 'rake/testtask' |
30 require 'rake/testtask' |
30 require 'rake/packagetask' |
31 require 'rake/packagetask' |
31 require 'rake/clean' |
32 require 'rake/clean' |
32 |
33 |
33 $dryrun = false |
34 $dryrun = false |
34 |
35 |
35 ### Config constants |
36 ### Config constants |
36 BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd ) |
37 BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd ) |
|
38 BINDIR = BASEDIR + 'bin' |
37 LIBDIR = BASEDIR + 'lib' |
39 LIBDIR = BASEDIR + 'lib' |
38 EXTDIR = BASEDIR + 'ext' |
40 EXTDIR = BASEDIR + 'ext' |
39 DOCSDIR = BASEDIR + 'docs' |
41 DOCSDIR = BASEDIR + 'docs' |
40 PKGDIR = BASEDIR + 'pkg' |
42 PKGDIR = BASEDIR + 'pkg' |
41 |
43 DATADIR = BASEDIR + 'data' |
42 PKG_NAME = 'jparallel' |
44 |
|
45 PROJECT_NAME = 'jparallel' |
|
46 PKG_NAME = PROJECT_NAME.downcase |
43 PKG_SUMMARY = 'A "parallel jail shell" written in Ruby' |
47 PKG_SUMMARY = 'A "parallel jail shell" written in Ruby' |
|
48 |
44 VERSION_FILE = LIBDIR + 'jparallel.rb' |
49 VERSION_FILE = LIBDIR + 'jparallel.rb' |
45 PKG_VERSION = VERSION_FILE.read[ /VERSION = '(\d+\.\d+\.\d+)'/, 1 ] |
50 if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL'] |
|
51 PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev |
|
52 elsif VERSION_FILE.exist? |
|
53 PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] |
|
54 else |
|
55 PKG_VERSION = '0.0.0' |
|
56 end |
|
57 |
46 PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}" |
58 PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}" |
47 GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem" |
59 GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem" |
48 |
60 |
|
61 EXTCONF = EXTDIR + 'extconf.rb' |
|
62 |
49 ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' ) |
63 ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' ) |
50 |
64 |
51 TEXT_FILES = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename } |
65 TEXT_FILES = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename } |
|
66 BIN_FILES = Pathname.glob( BINDIR + '*' ).delete_if {|item| item =~ /\.svn/ } |
52 LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ } |
67 LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ } |
53 EXT_FILES = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ } |
68 EXT_FILES = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ } |
|
69 DATA_FILES = Pathname.glob( DATADIR + '**/*' ).delete_if {|item| item =~ /\.svn/ } |
54 |
70 |
55 SPECDIR = BASEDIR + 'spec' |
71 SPECDIR = BASEDIR + 'spec' |
56 SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ } |
72 SPECLIBDIR = SPECDIR + 'lib' |
|
73 SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ } + |
|
74 Pathname.glob( SPECLIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ } |
57 |
75 |
58 TESTDIR = BASEDIR + 'tests' |
76 TESTDIR = BASEDIR + 'tests' |
59 TEST_FILES = Pathname.glob( TESTDIR + '**/*.tests.rb' ).delete_if {|item| item =~ /\.svn/ } |
77 TEST_FILES = Pathname.glob( TESTDIR + '**/*.tests.rb' ).delete_if {|item| item =~ /\.svn/ } |
60 |
78 |
61 RAKE_TASKDIR = BASEDIR + 'rake' |
79 RAKE_TASKDIR = BASEDIR + 'rake' |
62 RAKE_TASKLIBS = Pathname.glob( RAKE_TASKDIR + '*.rb' ) |
80 RAKE_TASKLIBS = Pathname.glob( RAKE_TASKDIR + '*.rb' ) |
63 |
81 |
64 LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local' |
82 LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local' |
65 |
83 |
66 EXTRA_PKGFILES = [] |
84 EXTRA_PKGFILES = [] |
67 EXTRA_PKGFILES += Pathname.glob( BASEDIR + 'examples/*.{c,rb}' ).delete_if {|item| item =~ /\.svn/ } |
85 EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'examples/*.{c,rb}' ).delete_if {|item| item =~ /\.svn/ } |
68 EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'misc/monkeypatches.rb' ).delete_if {|item| item =~ /\.svn/ } |
86 EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'misc/monkeypatches.rb' ).delete_if {|item| item =~ /\.svn/ } |
69 |
87 |
70 RELEASE_FILES = TEXT_FILES + |
88 RELEASE_FILES = TEXT_FILES + |
71 SPEC_FILES + |
89 SPEC_FILES + |
72 TEST_FILES + |
90 TEST_FILES + |
|
91 BIN_FILES + |
73 LIB_FILES + |
92 LIB_FILES + |
74 EXT_FILES + |
93 EXT_FILES + |
|
94 DATA_FILES + |
75 RAKE_TASKLIBS + |
95 RAKE_TASKLIBS + |
76 EXTRA_PKGFILES |
96 EXTRA_PKGFILES |
77 |
97 |
78 RELEASE_FILES << LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist? |
98 RELEASE_FILES << LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist? |
79 |
99 |
107 PKG_BUILD = get_svn_rev( BASEDIR ) || 0 |
127 PKG_BUILD = get_svn_rev( BASEDIR ) || 0 |
108 SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}" |
128 SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}" |
109 SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem" |
129 SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem" |
110 |
130 |
111 # Documentation constants |
131 # Documentation constants |
|
132 RDOCDIR = DOCSDIR + 'api' |
112 RDOC_OPTIONS = [ |
133 RDOC_OPTIONS = [ |
113 '-w', '4', |
134 '-w', '4', |
114 '-SHN', |
135 '-SHN', |
115 '-i', '.', |
136 '-i', '.', |
116 '-m', 'README', |
137 '-m', 'README', |
117 '-W', 'http://deveiate.org/projects/Jparallel//browser/trunk/' |
138 '-W', 'http://deveiate.org/projects/jParallel//browser/trunk/' |
118 ] |
139 ] |
119 |
140 |
120 # Release constants |
141 # Release constants |
121 SMTP_HOST = 'mail.faeriemud.org' |
142 SMTP_HOST = 'mail.faeriemud.org' |
122 SMTP_PORT = 465 # SMTP + SSL |
143 SMTP_PORT = 465 # SMTP + SSL |
123 |
144 |
124 # Project constants |
145 # Project constants |
125 PROJECT_HOST = 'deveiate.org' |
146 PROJECT_HOST = 'deveiate.org' |
126 PROJECT_PUBDIR = "/usr/local/www/public/code" |
147 PROJECT_PUBDIR = "/usr/local/www/public/code" |
127 PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}" |
148 PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}" |
128 PROJECT_SCPURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}" |
149 PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}" |
|
150 PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}" |
129 |
151 |
130 # Rubyforge stuff |
152 # Rubyforge stuff |
131 RUBYFORGE_GROUP = 'deveiate' |
153 RUBYFORGE_GROUP = 'deveiate' |
132 RUBYFORGE_PROJECT = 'jparallel' |
154 RUBYFORGE_PROJECT = 'jparallel' |
133 |
155 |
134 # Gem dependencies: gemname => version |
156 # Gem dependencies: gemname => version |
135 DEPENDENCIES = { |
157 DEPENDENCIES = { |
136 } |
158 } |
137 |
159 |
|
160 # Developer Gem dependencies: gemname => version |
|
161 DEVELOPMENT_DEPENDENCIES = { |
|
162 'amatch' => '>= 0.2.3', |
|
163 'rake' => '>= 0.8.1', |
|
164 'rcodetools' => '>= 0.7.0.0', |
|
165 'rcov' => '>= 0', |
|
166 'RedCloth' => '>= 4.0.3', |
|
167 'rspec' => '>= 0', |
|
168 'rubyforge' => '>= 0', |
|
169 'termios' => '>= 0', |
|
170 'text-format' => '>= 1.0.0', |
|
171 'tmail' => '>= 1.2.3.1', |
|
172 'ultraviolet' => '>= 0.10.2', |
|
173 'libxml-ruby' => '>= 0.8.3', |
|
174 } |
|
175 |
138 # Non-gem requirements: packagename => version |
176 # Non-gem requirements: packagename => version |
139 REQUIREMENTS = { |
177 REQUIREMENTS = { |
140 'FreeBSD' => '>= 7.0', |
178 'FreeBSD' => '>= 5.0', |
141 } |
179 } |
142 |
180 |
143 # RubyGem specification |
181 # RubyGem specification |
144 GEMSPEC = Gem::Specification.new do |gem| |
182 GEMSPEC = Gem::Specification.new do |gem| |
145 gem.name = PKG_NAME.downcase |
183 gem.name = PKG_NAME.downcase |
146 gem.version = PKG_VERSION |
184 gem.version = PKG_VERSION |
147 |
185 |
148 gem.summary = PKG_SUMMARY |
186 gem.summary = PKG_SUMMARY |
149 gem.description = <<-EOD |
187 gem.description = <<-EOD |
150 This is shell that can be used to interact with multiple FreeBSD jail instances |
188 This is shell that can be used to interact with multiple FreeBSD jail instances |
151 |
|
152 simultaneously. It includes a Ruby binding to the FreeBSD jail(2) functions. |
189 simultaneously. It includes a Ruby binding to the FreeBSD jail(2) functions. |
153 EOD |
190 EOD |
154 |
191 |
155 gem.authors = 'Michael Granger and Mahlon Smith' |
192 gem.authors = 'Michael Granger and Mahlon Smith' |
156 gem.email = 'ged@FaerieMUD.org, mahlon@martini.nu' |
193 gem.email = 'ged@FaerieMUD.org, mahlon@martini.nu' |
157 gem.homepage = 'http://deveiate.org/projects/Jparallel/' |
194 gem.homepage = 'http://deveiate.org/projects/jParallel/' |
158 gem.rubyforge_project = RUBYFORGE_PROJECT |
195 gem.rubyforge_project = RUBYFORGE_PROJECT |
159 |
196 |
160 gem.has_rdoc = true |
197 gem.has_rdoc = true |
161 gem.rdoc_options = RDOC_OPTIONS |
198 gem.rdoc_options = RDOC_OPTIONS |
|
199 |
|
200 gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s |
|
201 |
|
202 if EXTCONF.exist? |
|
203 gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s |
|
204 end |
162 |
205 |
163 gem.files = RELEASE_FILES. |
206 gem.files = RELEASE_FILES. |
164 collect {|f| f.relative_path_from(BASEDIR).to_s } |
207 collect {|f| f.relative_path_from(BASEDIR).to_s } |
165 gem.test_files = SPEC_FILES. |
208 gem.test_files = SPEC_FILES. |
166 collect {|f| f.relative_path_from(BASEDIR).to_s } |
209 collect {|f| f.relative_path_from(BASEDIR).to_s } |
167 |
210 |
168 DEPENDENCIES.each do |name, version| |
211 DEPENDENCIES.each do |name, version| |
169 version = '>= 0' if version.length.zero? |
212 version = '>= 0' if version.length.zero? |
170 gem.add_dependency( name, version ) |
213 gem.add_runtime_dependency( name, version ) |
|
214 end |
|
215 |
|
216 # Developmental dependencies don't work as of RubyGems 1.2.0 |
|
217 unless Gem::Version.new( Gem::RubyGemsVersion ) <= Gem::Version.new( "1.2.0" ) |
|
218 DEVELOPMENT_DEPENDENCIES.each do |name, version| |
|
219 version = '>= 0' if version.length.zero? |
|
220 gem.add_development_dependency( name, version ) |
|
221 end |
171 end |
222 end |
172 |
223 |
173 REQUIREMENTS.each do |name, version| |
224 REQUIREMENTS.each do |name, version| |
174 gem.requirements << [ name, version ].compact.join(' ') |
225 gem.requirements << [ name, version ].compact.join(' ') |
175 end |
226 end |
176 end |
227 end |
|
228 |
|
229 # Manual-generation config |
|
230 MANUALDIR = DOCSDIR + 'manual' |
177 |
231 |
178 $trace = Rake.application.options.trace ? true : false |
232 $trace = Rake.application.options.trace ? true : false |
179 $dryrun = Rake.application.options.dryrun ? true : false |
233 $dryrun = Rake.application.options.dryrun ? true : false |
180 |
234 |
181 |
235 |
225 end |
282 end |
226 |
283 |
227 |
284 |
228 ### Task: cruise (Cruisecontrol task) |
285 ### Task: cruise (Cruisecontrol task) |
229 desc "Cruisecontrol build" |
286 desc "Cruisecontrol build" |
230 task :cruise => [:clean, :spec, :package] do |task| |
287 task :cruise => [:clean, 'spec:quiet', :package] do |task| |
231 raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty? |
288 raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty? |
232 artifact_dir = ARTIFACTS_DIR.cleanpath |
289 artifact_dir = ARTIFACTS_DIR.cleanpath + ENV['CC_BUILD_LABEL'] |
233 artifact_dir.mkpath |
290 artifact_dir.mkpath |
234 |
291 |
235 $stderr.puts "Copying coverage stats..." |
292 coverage = BASEDIR + 'coverage' |
236 FileUtils.cp_r( 'coverage', artifact_dir ) |
293 if coverage.exist? && coverage.directory? |
|
294 $stderr.puts "Copying coverage stats..." |
|
295 FileUtils.cp_r( 'coverage', artifact_dir ) |
|
296 end |
237 |
297 |
238 $stderr.puts "Copying packages..." |
298 $stderr.puts "Copying packages..." |
239 FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir ) |
299 FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir ) |
240 end |
300 end |
241 |
301 |