Merge tag 'sisu_7.1.7' into debian/sid
[software/sisu] / setup / rbuild
1 #!/usr/bin/env ruby
2 =begin
3 Common Rakefile, Rantfile installer for SiSU
4 softlink Rakefile and Rantfile to this file
5
6 * Homepage: <http://www.jus.uio.no/sisu/SiSU>
7 <http://search.sisudoc.org>
8 * Download: <http://www.jus.uio.no/sisu/download>
9
10 Copyright (C) 2007 Ralph Amissah
11
12 * License: LGPL - GNU Lesser General Public License
13 [same license as Rant provided within the Rant package]
14
15 * Ralph Amissah <ralph@amissah.com>
16 Ralph Amissah <ralph.amissah@gmail.com>
17
18 Rake is a Ruby build program by Jim Weirich
19 * Rake may be downloaded and installed from:
20 <http://rake.rubyforge.org/>
21
22 Rant is a Ruby build program by Stefan Lang
23 * Rant may be downloaded and installed from:
24 <http://make.rubyforge.org/>
25
26 Notes on use:
27 [if rake is preferred and installed]
28 rake -T
29 [if rant is preferred and installed]
30 rant -T
31
32 SiSU can also be Setup/Installation using:
33 * Minero Aoki's setup.rb, provided along with SiSU, or
34
35 =end
36 #%% produce a makefile suitable for the target platform
37 #require 'mkmf'
38 #create_makefile("sisu")
39 #% manual settings, edit/update as required (note current default settings are obtained from sisu version yml file)
40 require 'find'
41 require 'fileutils'
42 #require 'ftools'
43 require 'rbconfig.rb'
44 require 'yaml'
45 include FileUtils
46 require_relative 'sisu_version' # sisu_version.rb
47 include SiSUversion
48 require_relative 'rbuild_libs' # rbuild_libs.rb
49 include Project_details
50 include Utils
51 include Version_info
52 include Gemspecs
53 include GitExtractTaggedVersionBuild
54 require_relative 'rbuild_help' # rbuild_help.rb
55 include Help
56 #% tasks
57 desc "show rake/rant tasks for sisu install, and sisu gem (create spec, build &) install"
58 task :default =>
59 [:note_sources,:tasks,:note_installation] #[:default_notice,:setup_base]
60 desc "Setup/Install #{Project_details.name}"
61 task :setup_project=>
62 [:setup_bin_,:setup_lib_,:setup_conf_,:setup_share_,:setup_data_,:setup_man_,:setup_vim_,:src_note]
63 task :project=> \
64 [:setup_project]
65 desc "Setup/Install #{Project_details.name}"
66 task :setup=>
67 [:setup_bin_, :setup_lib_,:setup_conf_,:setup_share_,:setup_data_] #, :help]
68 desc "Setup/Install #{Project_details.name}: bin, lib and conf (no data)"
69 task :setup_base=>
70 [:setup_bin_,:setup_lib_,:setup_conf_,:setup_share_,:setup_man_,:setup_vim_,:note_sources]
71 task :base=>
72 [:setup_base]
73 desc "Setup/Install #{Project_details.name}: bin, lib, conf & data"
74 task :setup_with_data=>
75 [:setup_base,:setup_data]
76 desc "check package version"
77 task :sisuversion =>
78 [:sisu_version]
79 task :version =>
80 [:sisu_version]
81 #desc "set package version"
82 task :sisuversionset =>
83 [:sisu_version_set,:changelog_headers]
84 desc "check gemspec info"
85 task :gem_spec =>
86 [:gemspec_info]
87 desc "create sisu v_stable gemspec"
88 task :gem_create_spec_stable =>
89 [:gemspecs_stable_create_default_version]
90 task :gem5cs =>
91 [:gem_create_spec_stable]
92 task :gem5createspecs =>
93 [:gemspecs_stable_create_default_version]
94 desc "create gemspec"
95 task :gem_create_spec =>
96 [:gemspecs_create_default_version]
97 task :gem_create =>
98 [:gemspecs_create_default_version]
99 task :gemc =>
100 [:gemspecs_create_default_version]
101 #---
102 desc "build gem"
103 task :gem_build =>
104 [:gem_build_]
105 task :gemb =>
106 [:gem_build]
107 task :gembuild =>
108 [:gem_build]
109 desc "build sisu v_stable gem"
110 task :gem_build_stable =>
111 [:gem_stable_build]
112 task :gem5b =>
113 [:gem_build_stable]
114 task :gem5build =>
115 [:gem_build_stable]
116 #---
117 desc "create, build & install sisu v_stable gem"
118 task :gem_create_build_install_stable =>
119 [:gemspecs_stable_create_default_version,:gem_stable_build,:gem_stable_install]
120 task :gem5cbi =>
121 [:gem_create_build_install_stable]
122 desc "create, build & install sisu gem"
123 task :gem_create_build_install =>
124 [:gemspecs_create_default_version,:gem_build_,:gem_install_]
125 task :gemcbi =>
126 [:gem_create_build_install]
127 #---
128 desc "install gem"
129 task :gem_install =>
130 [:gem_install_]
131 task :gemi =>
132 [:gem_install]
133 task :geminstall =>
134 [:gem_install]
135 desc "build & install sisu v_stable gem"
136 task :gem_build_install_stable =>
137 [:gem_stable_build,:gem_install_]
138 task :gem5bi =>
139 [:gem_build_install_stable]
140 desc "build & install gem"
141 task :gem_build_install =>
142 [:gem_build,:gem_install_]
143 task :gembi =>
144 [:gem_build_install]
145 #-- manually set next version
146 #desc "create sisu v_stable gemspec, manually set next version"
147 task :gem5csn =>
148 [:gemspecs_stable_create_next_version]
149 #desc "create gemspec, manually set next version"
150 task :gemcsn =>
151 [:gemspecs_create_next_version]
152 task :gemcn =>
153 [:gemspecs_create_next_version]
154 #desc "build gem, manually set next version"
155 task :gembn =>
156 [:gem_build_next_version]
157 #desc "build sisu v_stable gem, manually set next version"
158 task :gem5bn =>
159 [:gem_stable_build_next_version]
160 #desc "install gem, manually set next version"
161 task :gemin =>
162 [:gem_install_next_version]
163 #desc "build & install sisu v_stable gem, manually set next version"
164 task :gem5bin =>
165 [:gem_stable_build_next_version,:gem_install_next_version]
166 #desc "build & install gem, manually set next version"
167 task :gembin =>
168 [:gem_build_next_version,:gem_install_next_version]
169 #desc "create, build & install sisu v_stable gem, manually set next version"
170 task :gem5cbin =>
171 [:gemspecs_stable_create_next_version,:gem_stable_build_next_version,:gem_stable_install_next_version]
172 #desc "create, build & install sisu gem, manually set next version"
173 task :gemcbin =>
174 [:gemspecs_create_next_version,:gem_build_next_version,:gem_install_next_version]
175 #---
176 #desc "check changelog headers"
177 task :changelogheaders =>
178 [:changelog_headers]
179 task :dev =>
180 [:note_developer]
181 task :developer_note =>
182 [:note_developer]
183 if File.directory?('bin')
184 desc "Setup #{Project_details.name} bin only, synonym :bin"
185 task :setup_bin =>
186 [:setup_bin_]
187 task :bin =>
188 [:setup_bin]
189 end
190 if File.directory?('lib')
191 desc "Setup #{Project_details.name} lib only, synonym :lib"
192 task :setup_lib =>
193 [:setup_lib_]
194 task :lib =>
195 [:setup_lib]
196 end
197 if File.directory?('conf')
198 desc "Setup #{Project_details.name} conf only, synonyms :conf & :etc"
199 task :setup_conf =>
200 [:setup_conf_]
201 task :conf =>
202 [:setup_conf]
203 task :setup_etc =>
204 [:setup_conf]
205 task :etc =>
206 [:setup_conf]
207 end
208 if File.directory?('data')
209 desc "Setup #{Project_details.name} data only, synonyms :data & :examples"
210 task :setup_data =>
211 [:setup_data_]
212 task :data =>
213 [:setup_data]
214 task :setup_examples =>
215 [:setup_data]
216 task :examples =>
217 [:setup_data]
218 end
219 if File.directory?('data/sisu')
220 #desc "Setup #{Project_details.name} shared data only (odf & shared images)"
221 task :setup_share =>
222 [:setup_share_]
223 task :share =>
224 [:setup_share]
225 end
226 if File.directory?('man')
227 desc "Setup #{Project_details.name} man pages only, synonyms :man"
228 task :setup_man =>
229 [:setup_man_]
230 task :man =>
231 [:setup_man]
232 end
233 if File.directory?('data/vim')
234 desc "Setup #{Project_details.name} vim config files only, synonyms :vim"
235 task :setup_vim =>
236 [:setup_vim_]
237 task :vim =>
238 [:setup_vim]
239 end
240 desc "Remove #{Project_details.name} (all versions)"
241 task :remove_package =>
242 [:remove_bin, :remove_lib, :remove_conf]
243 if File.directory?('bin')
244 #desc "Remove #{Project_details.name} bin only"
245 task :remove_bin =>
246 [:remove_bin]
247 end
248 if File.directory?('lib')
249 #desc "Remove #{Project_details.name} lib only"
250 task :remove_lib =>
251 [:remove_lib]
252 end
253 if File.directory?('conf')
254 #desc "Remove #{Project_details.name} conf only"
255 task :remove_conf =>
256 [:remove_conf]
257 end
258 desc "Re-setup #{Project_details.name}, synonym :reinstall"
259 task :resetup =>
260 [:remove, :setup]
261 task :reinstall =>
262 [:remove, :setup]
263 #desc "Re-setup #{Project_details.name}: bin, lib, conf (ignore data), synonym :reinstall"
264 task :resetup_base =>
265 [:remove, :setup_base_]
266 task :reinstall_base =>
267 [:remove, :setup_base_]
268 if File.directory?('bin')
269 #desc "Re-setup #{Project_details.name} bin, synonym :reinstall"
270 task :resetup_bin =>
271 [:remove_bin, :setup_bin_]
272 task :reinstall_bin =>
273 [:remove_bin, :setup_bin_]
274 end
275 if File.directory?('lib')
276 #desc "Re-setup #{Project_details.name} lib, synonym :reinstall_lib"
277 task :resetup_lib =>
278 [:remove_lib, :setup_lib_]
279 task :reinstall_lib =>
280 [:remove_lib, :setup_lib_]
281 end
282 if File.directory?('conf')
283 #desc "Re-setup #{Project_details.name} conf, synonyms :reinstall_conf & :resetup_etc"
284 task :resetup_conf =>
285 [:remove_conf, :setup_conf_]
286 task :reinstall_conf =>
287 [:remove_conf, :setup_conf_]
288 task :resetup_etc =>
289 [:remove_conf, :setup_conf_]
290 task :reinstall_etc =>
291 [:remove_conf, :setup_conf_]
292 end
293 if File.directory?('data/sisu')
294 #desc "Re-setup #{Project_details.name} shared data, (odf & images)"
295 task :resetup_share =>
296 [:remove_share, :setup_share_]
297 task :reinstall_share =>
298 [:remove_share, :setup_share_]
299 end
300 if File.directory?('man')
301 #desc "Re-setup #{Project_details.name} man, synonym :reinstall_man"
302 task :resetup_man =>
303 [:remove_man, :setup_man_]
304 task :reinstall_man =>
305 [:remove_man, :setup_man_]
306 end
307 desc 'Setup Note'
308 task :setup_note =>
309 [:help]
310 desc "System information used by #{Project_details.name}"
311 task :system =>
312 [:system_info,:project_help,:note_sources]
313 desc "show all system info available - parameters found"
314 task :system_param =>
315 [:system_param_]
316 desc "Gem environment information used ruby gems for #{Project_details.name}"
317 task :gem_env =>
318 [:gem_env_]
319 desc 'Help'
320 task :help =>
321 [:project_help,:system_info,:tasks]
322 #desc "Setup/Install #{Project_details.name} (uses filelist)"
323 task :install =>
324 [:default_notice,:project]
325 task :install_bin =>
326 [:setup_bin_]
327 #desc "search for a version tag e.g. 'tag[5.6.0]'"
328 task :tag, [:tag] do |t, args|
329 args.with_defaults(:tag => Version_info::Next.setting_stable[:version])
330 puts "Check for Version Tag: #{args.tag}"
331 print "Version Tag: "
332 GitExtractTaggedVersionBuild::git_tagged_versions(args)
333 end
334 #desc "build and install a specific git tagged version of sisu, e.g. 'build[5.6.0]'"
335 task :build, [:tag, :branch] => :done do |t, args|
336 args.with_defaults(:tag => '5.6.0', :branch => 'stable')
337 puts "Version Tag: #{args.tag}"
338 puts "Branch: #{args.branch}"
339 GitExtractTaggedVersionBuild::git_tagged_versions(args.tag)
340 ans= <<-WOK
341 Gem Install SiSU Version
342 WOK
343 resp=Utils.answer?(ans)
344 exit unless resp
345 GitExtractTaggedVersionBuild::git_checkout_and_build_version(args)
346 end
347 task :done do
348 puts 'done'
349 end
350 #%% setup/install tasks
351 task :rant_independence do #notice
352 resp=''
353 while resp.length < 4
354 resp='sisu-install' #default name install
355 print %{#{Project_details.rake_rant}
356 Create a rant dependency independent file
357 provide filename default name is "install"
358 [Warning, will overwrite file of name provided
359 provide name or "quit" to exit]: }
360 exit if resp =~/^(?:n|quit|exit)$/
361 end
362 remove='y' #remove='n'
363 if remove =~/y/
364 system("rant-import --force --auto #{resp};
365 chmod 755 #{resp}
366 ")
367 else #puts "#{resp} not replaced"
368 end
369 end
370
371 task :default_notice do #notice
372 Utils.default_notice
373 end
374 task :default2 do #secondary
375 setup_find_cp_r('bin',Project_details.dir.bin) \
376 if File.directory?('bin')
377 setup_find_cp_r('lib',Project_details.dir.lib) \
378 if File.directory?('lib')
379 setup_find_cp_r('conf',Project_details.dir.conf) \
380 if File.directory?('conf')
381 setup_find_cp_r('data/sisu',Project_details.dir.share) \
382 if File.directory?('data/sisu') #
383 setup_find_cp_r('data',Project_details.dir.data) \
384 if File.directory?('data')
385 setup_find_cp_r('data/vim',"#{Project_details.dir.data}/vim") \
386 if File.directory?('data/vim')
387 setup_find_cp_r('man',Project_details.dir.man) \
388 if File.directory?('man')
389 end
390 task :setup_bin_ do
391 exclude_files=['sisugem']
392 Install.setup_find_create('bin',Project_details.dir.bin,exclude_files) \
393 if File.directory?('bin')
394 end
395 task :setup_lib_ do
396 Install.setup_find_create('lib',Project_details.dir.lib) \
397 if File.directory?('lib')
398 end
399 task :setup_conf_ do
400 Install.setup_find_create('conf',Project_details.dir.conf) \
401 if File.directory?('conf')
402 end
403 task :setup_share_ do
404 Install.setup_find_create('data/sisu',Project_details.dir.share) \
405 if File.directory?('data/sisu')
406 end
407 task :setup_data_ do
408 Install.setup_find_create('data',Project_details.dir.data) \
409 if File.directory?('data')
410 end
411 task :setup_man_ do
412 Install.setup_find_create('man',Project_details.dir.man) \
413 if File.directory?('man')
414 Install.setup_find_create('man.deb/man',Project_details.dir.man) \
415 if File.directory?('man.deb/man')
416 end
417 task :setup_vim_ do
418 Install.setup_find_create('data/vim',Project_details.dir.vim) \
419 if File.directory?('data/vim')
420 end
421 task :gemspec_info do
422 Gemspecs.info_stable
423 end
424 task :gemspecs_stable_create_default_version do
425 Gemspecs::Current.create_stable
426 end
427 task :gemspecs_create_default_version do
428 Gemspecs::Current.create_stable
429 end
430 task :gemspecs_stable_create_next_version do
431 Gemspecs::Next.create_stable
432 end
433 task :gemspecs_create_next_version do
434 Gemspecs::Next.create_stable
435 end
436 task :gem_stable_build do
437 Gemspecs::Current.build_stable
438 end
439 task :gem_build_ do
440 Gemspecs::Current.build_stable
441 end
442 task :gem_stable_build_next_version do
443 Gemspecs::Next.build_stable
444 end
445 task :gem_build_next_version do
446 Gemspecs::Next.build_stable
447 end
448 task :gem_stable_install do
449 Gemspecs::Current.install_stable
450 end
451 task :gem_install_ do
452 Gemspecs::Current.install_stable
453 end
454 task :gem_stable_install_next_version do
455 Gemspecs::Next.install_stable
456 end
457 task :gem_install_next_version do
458 Gemspecs::Next.install_stable
459 end
460 task :changelog_headers do
461 puts '---'
462 puts Version_info::Update.changelog_header_stable
463 end
464 task :sisu_version do
465 puts Version_info::Next.setting_stable
466 puts '---'
467 puts Version_info::Current.setting_stable[:project]
468 puts Version_info::Current.setting_stable[:version]
469 puts Version_info::Current.setting_stable[:date]
470 puts Version_info::Current.setting_stable[:date_stamp]
471 end
472 task :sisu_version_set do
473 Version_info::Update.update_stable
474 end
475 #%% post install
476 #%% clobber/remove tasks
477 task :remove_bin do
478 rm_r "#{Project_details.dir.bin}/#{Project_details.dir.proj}" \
479 if FileTest.file?("#{Project_details.dir.bin}/#{Project_details.dir.proj}")
480 end
481 task :remove_lib do
482 rm_r "#{Project_details.dir.lib}/#{Project_details.dir.proj}" \
483 if FileTest.directory?("#{Project_details.dir.lib}/#{Project_details.dir.proj}")
484 end
485 task :remove_conf do
486 rm_r "#{Project_details.dir.conf}/#{Project_details.dir.proj}" \
487 if FileTest.directory?("#{Project_details.dir.conf}/#{Project_details.dir.proj}")
488 end
489 task :remove_man do
490 rm_r "#{Project_details.dir.man}/**/#{Project_details.dir.proj}" \
491 if FileTest.directory?("#{Project_details.dir.man}/man1/#{Project_details.dir.proj}")
492 end
493 task :remove_version do
494 rm_r "#{Project_details.dir.bin}/#{Project_details.dir.proj}" \
495 if FileTest.file?("#{Project_details.dir.bin}/#{Project_details.dir.proj}")
496 rm_r "#{Project_details.dir.lib}/#{Project_details.dir.proj}/#{Project_details.version}" \
497 if FileTest.directory?("#{Project_details.dir.lib}/#{Project_details.dir.proj}/#{Project_details.version}")
498 rm_r "#{Project_details.dir.conf}/#{Project_details.dir.proj} \
499 if FileTest.directory?("#{Project_details.dir.conf}/#{Project_details.dir.proj}")
500 end
501 task :remove_package do
502 rm_r "#{Project_details.dir.bin}/#{Project_details.dir.proj}" \
503 if FileTest.file?("#{Project_details.dir.bin}/#{Project_details.dir.proj}")
504 rm_r "#{Project_details.dir.lib}/#{Project_details.dir.proj}" \
505 if FileTest.directory?("#{Project_details.dir.lib}/#{Project_details.dir.proj}")
506 rm_r "#{Project_details.dir.conf}/#{Project_details.dir.proj}" \
507 if FileTest.directory?("#{Project_details.dir.conf}/#{Project_details.dir.proj}")
508 end
509 task :note_sources do
510 puts <<-WOK
511
512 SiSU project:
513 <http://sisudoc.org>
514 <http://www.jus.uio.no/sisu>
515 sisu source code is available at:
516 <http://git.sisudoc.org>
517 <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
518 sisu markup samples are provided/packaged separately as sisu-markup-samples:
519 <http://git.sisudoc.org/gitweb/?p=doc/sisu-markup-samples.git;a=summary>
520 WOK
521 end
522 task :note_installation do
523 puts <<-WOK
524 alternative 0: distribution install, rather than this Rakefile
525 a distribution install pulls in the many dependencies used by sisu after
526 initial processing to generate and store output, significant amongst these are
527 XeTeX & databases (sqlite3 and postgresql)
528
529 alternative 1: gem install, you need to:
530 create the gemspec; build the gem (from the gemspec); install the gem
531 which can be done with the single command:
532 rake gem_create_build_install # (to build and install sisu v5 & sisu v6, alias gemcbi)
533 separate gems are made/installed for sisu v5 & sisu v6 contained in source:
534 rake gem_create_build_install_stable # (to build and install sisu v5, alias gem5cbi)
535 for individual steps (create, build, install) see rake options, rake -T
536 to specify sisu version for sisu installed via gem
537 sisu _#{Version_info::Current.setting_stable[:version]}_ --version
538 to uninstall sisu installed via gem
539 sudo gem uninstall --verbose sisu
540 WOK
541 end
542 task :note_developer do
543 puts <<-WOK
544
545 changelogheaders
546
547 sisuversion
548 sisuversionset
549
550 gemcsn gem5csn gem6csn
551 gembn gem5bn gem6bn
552 gemin gem5in gem6in
553 gembin gem5bin gem6bin
554 gemcbin gem5cbin gem6cbin
555 WOK
556 end
557 #%% help & system info
558 task :system_info do
559 Project_details.system_info
560 end
561 task :system_param_ do
562 Project_details.env.each {|c| puts c.inspect }
563 end
564 task :gem_env_ do
565 Project_details.gem_env
566 end
567 task :project_help do
568 Help.project_help
569 end
570 task :tasks do
571 Help.tasks
572 end