summaryrefslogtreecommitdiffstats
path: root/rbuild
blob: 6b8e82c51e1b207bf86bf45cebd7e74915a43c4e (plain)
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
#!/usr/bin/env ruby
raise 'Please, use ruby1.9.3 or later.' if RUBY_VERSION < '1.9.3'
=begin
 Common Rakefile, Rantfile installer for SiSU
   softlink Rakefile and Rantfile to this file

 * Homepage: <http://www.jus.uio.no/sisu/SiSU>
             <http://search.sisudoc.org>
 * Download: <http://www.jus.uio.no/sisu/download>

 Copyright (C) 2007 Ralph Amissah

 * License: LGPL - GNU Lesser General Public License
     [same license as Rant provided within the Rant package]

 * Ralph Amissah <ralph@amissah.com>
   Ralph Amissah <ralph.amissah@gmail.com>

 Rake is a Ruby build program by Jim Weirich
 * Rake may be downloaded and installed from:
     <http://rake.rubyforge.org/>

 Rant is a Ruby build program by Stefan Lang
 * Rant may be downloaded and installed from:
     <http://make.rubyforge.org/>

 Notes on use:
   [if rake is preferred and installed]
     rake -T
   [if rant is preferred and installed]
     rant -T

 SiSU can also be Setup/Installation using:
 * Minero Aoki's setup.rb, provided along with SiSU, or

=end
#%% produce a makefile suitable for the target platform
#require 'mkmf'
#create_makefile("sisu")
#% manual settings, edit/update as required (note current default settings are obtained from sisu version yml file)
SiSU_version_next_stable     = '4.2.18'
SiSU_version_next_unstable   = '5.2.1'
#% rake file
SiSU_version_generic_next_stable     = '4.2.x'
SiSU_version_generic_next_unstable   = '5.2.x'
SiSU_version_dir_stable            = 'v4'
SiSU_version_dir_unstable          = 'v5'
require 'find'
require 'fileutils'
#require 'ftools'
require 'rbconfig.rb'
require 'yaml'
include FileUtils
module Project_details
  def self.name
    'SiSU'
  end
  def self.rake_rant
    "Rakefile/Rantfile for the installation/setup of #{name}"
  end
  def self.platform_notice
    "[#{name} is for Linux/Unix Platforms]"
  end
  def self.env
    RbConfig::CONFIG
  end
  def self.host
    env['host']
  end
  def self.dir
    def self.proj
      Project_details.name.downcase
    end
    def self.arch
      env['archdir']
    end
    def self.sitearch
      env['sitearchdir']
    end
    def self.bin
      env['bindir']
    end
    def self.lib
      env['sitelibdir']
    end
    def self.data
      env['datadir']
    end
    def self.share
      "#{env['datadir']}/sisu"
    end
    def self.conf
      env['sysconfdir']
    end
    def self.man
      env['mandir']
    end
    def self.vim
      "#{env['datadir']}/sisu/vim"
    end
    def self.out
      "#{env['localstatedir']}/#{proj}"
    end
    def self.rubylib
      env['LIBRUBYARG_SHARED']
    end
    def self.pwd
      Dir.pwd #ENV['PWD']
    end
    self
  end
  def self.version
    stamp={}
    v="#{dir.pwd}/conf/sisu/version.yml"
    if File.exist?(v)
      stamp=YAML::load(File::open(v))
      stamp[:version]
    else ''
    end
  end
  def self.system_info
    ##{Project_details.platform_notice}
    puts <<-WOK
  Host
    host:             #{Project_details.host}
    arch:             #{Project_details.dir.arch}
    sitearch:         #{Project_details.dir.sitearch}
  Directories for installation
    bin:                                          #{Project_details.dir.bin}
    lib (site-ruby):                              #{Project_details.dir.lib}/#{Project_details.dir.proj}/v*
    conf [etc]:                                   #{Project_details.dir.conf}/#{Project_details.dir.proj}
    data (odf, shared images):                    #{Project_details.dir.share}
    vim  (vim syntax, highlighting, ftplugin):    #{Project_details.dir.data}/sisu/vim
    data (README, version_manifest):              #{Project_details.dir.data}/doc/#{Project_details.dir.proj}
    man (manual pages):                           #{Project_details.dir.man}
    output:                                       #{Project_details.dir.out}
      processing:                                 #{Project_details.dir.out}/processing
      www:                                        #{Project_details.dir.out}/www
    rubylib:                                      #{Project_details.dir.rubylib}

    WOK
  end
  def self.gem_env
    system("gem env")
  end
end
module Utils
  def self.answer?(ask)
    resp='redo'
    print ask + " ['yes', 'no' or 'quit']: "
    resp=File.new('/dev/tty').gets.strip #resp=gets.strip
    if resp == 'yes'; true
    elsif resp == 'no'; false
    elsif resp =~/^quit|exit$/; exit
    else puts "[please type: 'yes', 'no' or 'quit']"
      answer?(ask)
    end
  end
  def self.default_notice
    ans= %{#{Project_details.rake_rant}
    Information on alternative actions is available using:
    [if rake (or rant) is installed:]
      "rake help" or "rake -T" (or "rant help" or "rant -T")
    Default action selected - "install #{Project_details.name}" proceed? }
    resp=answer?(ans)
    exit unless resp
  end
  def self.chmod_file(place)
    if place =~/\/bin/; File.chmod(0755,place)
    else                File.chmod(0644,place)
    end
  end
  def self.chmod_util(place)
    if place =~/\/bin/; chmod(0755,place)
    else                chmod(0644,place)
    end
  end
  def self.system_date
    `date "+%Y-%m-%d"`.strip
  end
  def self.system_date_stamp
    `date "+%Yw%W/%u"`.strip
  end
  def self.program_found?(prog)
    found=`which #{prog}` #`whereis #{make}`
    (found =~/bin\/#{prog}\b/) ? :true : :false
  end
end
module Install
                                                           #%% using a directory and its mapping
  def self.setup_find_create(dir_get,dir_put,exclude_files=[''])               #primary,
    begin
    Find.find("#{Project_details.dir.pwd}/#{dir_get}") do |f|
      stub=f.scan(/#{Project_details.dir.pwd}\/#{dir_get}\/(\S+)/).join
      place="#{dir_put}/#{stub}"
      action=case
      when File.file?(f)
        unless f =~/#{exclude_files.inspect}/
          cp(f,place)
          Utils.chmod_file(place)
          "->  #{dir_put}/"
        end
      when File.directory?(f)
        FileUtils.mkpath(place) unless FileTest.directory?(place)
        "./#{dir_get}/"
      else '?'
      end
      puts "#{action}#{stub}"
    end
    rescue
      puts "\n\n<< are you root? required for install >>"
    end
  end
  def self.setup_find_cp_r(dir_get,dir_put)                                    #secondary, using recursive copy
    Find.find("#{Project_details.dir.pwd}/#{dir_get}") do |f|
      stub=f.scan(/#{Project_details.dir.pwd}\/#{dir_get}\/(\S+)/).join
      place="#{dir_put}/#{stub}"
      case
      when File.file?(f)
        cp_r(f,place)
        Utils.chmod_util(place)
      when File.directory?(f)
        mkdir(place) unless FileTest.directory?(place)
      end
    end
  end
end
module Version_info
  def self.contents(vi)
    <<-WOK
---
:project: #{vi[:project]}
:version: #{vi[:version]}
:date_stamp: #{vi[:date_stamp]}
:date: "#{vi[:date]}"
    WOK
  end
  module Current
    def self.yml_file_path(version)
      "data/sisu/#{version}/v/version.yml"
    end
    def self.settings(file)
      v="#{Dir.pwd}/#{file}"
      if File.exist?(v)
        YAML::load(File::open(v))
      else ''
      end
    end
    def self.file_stable
      yml_file_path(SiSU_version_dir_stable)
    end
    def self.file_unstable
      yml_file_path(SiSU_version_dir_unstable)
    end
    def self.setting_stable
      settings(file_stable)
    end
    def self.setting_unstable
      settings(file_unstable)
    end
    def self.content_stable
      Version_info.contents(setting_stable)
    end
    def self.content_unstable
      Version_info.contents(setting_unstable)
    end
  end
  module Next
    def self.settings(v)
      {
        project:        "#{Project_details.name}",
        version:        "#{v}",
        date:           "#{Utils.system_date}",
        date_stamp:     "#{Utils.system_date_stamp}",
      }
    end
    def self.setting_stable
      settings(SiSU_version_next_stable)
    end
    def self.setting_unstable
      settings(SiSU_version_next_unstable)
    end
    def self.content_stable
      Version_info.contents(setting_stable)
    end
    def self.content_unstable
      Version_info.contents(setting_unstable)
    end
  end
  module Update
    def self.version_info_update_commit(filename,vi_hash_current,vi_content_current,vi_hash_next,vi_content_next)
      ans=%{update #{Project_details.name.downcase} version info replacing:
  #{vi_hash_current.sort}
with:
  #{vi_hash_next.sort}

#{vi_content_current} becoming:
#{vi_content_next}
proceed? }
      resp=Utils.answer?(ans)
      exit unless resp
      fn="#{Dir.pwd}/#{filename}"
      if File.writable?("#{Dir.pwd}/.")
        file_version=File.new(fn,'w+')
        file_version << vi_content_next
        file_version.close
      else
        puts %{*WARN* is the file or directory writable? could not create #{filename}}
      end
    end
    def self.update_stable
      version_info_update_commit(Version_info::Current.file_stable,Version_info::Current.setting_stable,Version_info::Current.content_stable,Version_info::Next.setting_stable,Version_info::Next.content_stable)
    end
    def self.update_unstable
      version_info_update_commit(Version_info::Current.file_unstable,Version_info::Current.setting_unstable,Version_info::Current.content_unstable,Version_info::Next.setting_unstable,Version_info::Next.content_unstable)
    end
    def self.changelog_header(vi)
      <<-WOK
%% #{vi[:version]}.orig.tar.xz (#{vi[:date]}:#{vi[:date_stamp].gsub(/20\d\dw/,'')})
http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_#{vi[:version]}
http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_#{vi[:version]}-1
http://www.jus.uio.no/sisu/pkg/src/sisu_#{vi[:version]}.orig.tar.xz
  sisu_#{vi[:version]}.orig.tar.xz
  sisu_#{vi[:version]}-1.dsc
      WOK
    end
    def self.changelog_header_stable
      changelog_header(Version_info::Current.setting_stable)
    end
    def self.changelog_header_unstable
      changelog_header(Version_info::Current.setting_unstable)
    end
  end
  self
end
module Gemspecs
  def self.info(vi)
    puts <<-WOK
--
name:       #{vi[:project].downcase}
version:    #{vi[:version]}
date:       #{vi[:date]}
summary:    #{vi[:project]}
    WOK
  end
  def self.contents(vi,version)
    <<-WOK
Gem::Specification.new do |s|
  s.name           = '#{vi[:project].downcase}'
  s.version        = '#{vi[:version]}'
  s.date           = '#{vi[:date]}'
  s.summary        = '#{vi[:project]}'
  s.description    = '#{Project_details.name} gem'
  s.authors        = ["Ralph Amissah"]
  s.email          = 'ralph.amissah@gmail.com'
  s.files          = Dir['lib/#{Project_details.name.downcase}/#{version}/*.rb'] +
                     Dir['data/#{Project_details.name.downcase}/#{version}/v/version.yml'] +
                     Dir['bin/#{Project_details.name.downcase}gem'] +
                     Dir['bin/#{Project_details.name.downcase}']
  s.license        = 'GPL3'
  s.executables << '#{Project_details.name.downcase}gem' << '#{Project_details.name.downcase}'
end
    WOK
  end
  def self.create(filename,gemspec)
    fn="#{Dir.pwd}/#{filename}.gemspec"
    if File.writable?("#{Dir.pwd}/.")
      file_sisu_gemspec=File.new(fn,'w+')
      file_sisu_gemspec << gemspec
      file_sisu_gemspec.close
    else
      puts %{*WARN* is the file or directory writable? could not create #{filename}}
    end
  end
  def self.build(fn)
    system(%{ gem build #{fn}.gemspec })
  end
  def self.install(fn)
    system(%{
      sudo gem install --no-rdoc --no-ri --verbose #{fn}.gem
    })
  end
  module Current
    def self.filename_stable
      "#{Project_details.name.downcase}-#{Version_info::Current.setting_stable[:version]}"
    end
    def self.filename_unstable
      "#{Project_details.name.downcase}-#{Version_info::Current.setting_unstable[:version]}"
    end
    def self.info_stable
      Gemspecs.info(Version_info::Current.setting_stable)
    end
    def self.info_unstable
      Gemspecs.info(Version_info::Current.setting_unstable)
    end
    def self.current_stable
      Gemspecs.contents(Version_info::Current.setting_stable,SiSU_version_dir_stable)
    end
    def self.current_unstable
      Gemspecs.contents(Version_info::Current.setting_unstable,SiSU_version_dir_unstable)
    end
    def self.create_stable
      Gemspecs.create(filename_stable,current_stable)
      Gemspecs.create("#{Project_details.name.downcase}-stable",current_stable)
    end
    def self.create_unstable
      Gemspecs.create(filename_unstable,current_unstable)
      Gemspecs.create("#{Project_details.name.downcase}-unstable",current_unstable)
    end
    def self.build_stable
      Gemspecs.build(filename_stable)
    end
    def self.build_unstable
      Gemspecs.build(filename_unstable)
    end
    def self.install_stable
      Gemspecs.install(filename_stable)
    end
    def self.install_unstable
      Gemspecs.install(filename_unstable)
    end
  end
  module Next
    def self.filename_stable
      "#{Project_details.name.downcase}-#{Version_info::Next.setting_stable[:version]}"
    end
    def self.filename_unstable
      "#{Project_details.name.downcase}-#{Version_info::Next.setting_unstable[:version]}"
    end
    def self.setting_stable
      Gemspecs.contents(Version_info::Next.setting_stable,SiSU_version_dir_stable)
    end
    def self.setting_unstable
      Gemspecs.contents(Version_info::Next.setting_unstable,SiSU_version_dir_unstable)
    end
    def self.create_stable
      Gemspecs.create(filename_stable,setting_stable)
    end
    def self.create_unstable
      Gemspecs.create(filename_unstable,setting_unstable)
    end
    def self.build_stable
      Gemspecs.build(filename_stable)
    end
    def self.build_unstable
      Gemspecs.build(filename_unstable)
    end
    def self.install_stable
      Gemspecs.install(filename_stable)
    end
    def self.install_unstable
      Gemspecs.install(filename_unstable)
    end
  end
end
module Help
  def self.project_help
    puts <<WOK

#{Project_details.name}
  #{Project_details.rake_rant}
  #{Project_details.platform_notice}

Commands quick start list
  #{Project_details.name} Rake/Rant Help: (Rakefile or Rantfile)
    rake (rake -T or rant -T)                  # a task list, (generated by Rake or Rant) for more complete and up to date help

  Quick start install and remove project #{Project_details.name}, as root:
    rake setup                                  # install #{Project_details.name}
    rake resetup                                # reinstall #{Project_details.name}
    rake remove_package                         # clobber/remove #{Project_details.name}, all versions
  alternatively to install as a gem:
    rake gem_create_build_install               # create gemspec; build gem, &; install gem, for #{Project_details.name}

  NOTE: these install options DO NOT setup #{Project_details.name} dependencies for:
  LaTeX(XeTeX) pdf output; or
  databases (postgresql or sqlite3) for #{Project_details.name} search
  should you wish to produce outputs that depend on them
  (on Debian for example this is the work of the debian installer)

WOK
  end
  def self.tasks(make='rake')
    begin
      system("#{make} -T")
    rescue
      puts 'is either rake or rant installed?'
    end
  end
end
#% tasks
desc "show rake/rant tasks for sisu install, and sisu gem (create spec, build &) install"
  task :default => [:note_sources,:tasks,:note_installation] #[:default_notice,:setup_base]
desc "Setup/Install #{Project_details.name}"
  task :setup_project=> [:setup_bin_,:setup_lib_,:setup_conf_,:setup_share_,:setup_data_,:setup_man_,:setup_vim_,:src_note]
  task :project=> [:setup_project]
desc "Setup/Install #{Project_details.name}"
  task :setup=> [:setup_bin_, :setup_lib_,:setup_conf_,:setup_share_,:setup_data_] #, :help]
desc "Setup/Install #{Project_details.name}: bin, lib and conf (no data)"
  task :setup_base=> [:setup_bin_,:setup_lib_,:setup_conf_,:setup_share_,:setup_man_,:setup_vim_,:note_sources]
  task :base=> [:setup_base]
desc "Setup/Install #{Project_details.name}: bin, lib, conf & data"
  task :setup_with_data=> [:setup_base,:setup_data]
desc "check package version"
  task :sisuversion => [:sisu_version]
#desc "set package version"
  task :sisuversionset => [:sisu_version_set,:changelog_headers]
desc "check gemspec info"
  task :gem_spec => [:gemspec_info]
desc "create sisu v_stable gemspec"
  task :gem_create_spec_stable => [:gemspecs_stable_create_default_version]
  task :gem4cs => [:gem_create_spec_stable]
  task :gem4createspecs => [:gemspecs_stable_create_default_version]
desc "create sisu v_unstable gemspec"
  task :gem_create_spec_unstable => [:gemspecs_unstable_create_default_version]
  task :gem5cs => [:gem_create_spec_unstable]
  task :gem5createspecs => [:gemspecs_unstable_create_default_version]
desc "create gemspec"
  task :gem_create_spec => [:gemspecs_create_default_version]
  task :gemcs => [:gemspecs_create_default_version]
  task :gemc => [:gemspecs_create_default_version]
  task :gemspecscreate => [:gemspecs_create_default_version]
#---
desc "build gem"
  task :gem_build => [:gem_build_]
  task :gemb => [:gem_build]
  task :gembuild => [:gem_build]
desc "build sisu v_stable gem"
  task :gem_build_stable => [:gem_stable_build]
  task :gem4b => [:gem_build_stable]
  task :gem4build => [:gem_build_stable]
desc "build sisu v_unstable gem"
  task :gem_build_unstable => [:gem_unstable_build]
  task :gem5b => [:gem_build_unstable]
  task :gem5build => [:gem_build_unstable]
#---
desc "create, build & install sisu v_stable gem"
  task :gem_create_build_install_stable => [:gemspecs_stable_create_default_version,:gem_stable_build,:gem_stable_install]
  task :gem4cbi => [:gem_create_build_install_stable]
desc "create, build & install sisu v_unstable gem"
  task :gem_create_build_install_unstable => [:gemspecs_unstable_create_default_version,:gem_unstable_build,:gem_unstable_install]
  task :gem5cbi => [:gem_create_build_install_unstable]
desc "create, build & install sisu v_stable & v_unstable gem"
  task :gem_create_build_install => [:gemspecs_create_default_version,:gem_build_,:gem_install_]
  task :gemcbi => [:gem_create_build_install]
#---
desc "install gem"
  task :gem_install => [:gem_install_]
  task :gemi => [:gem_install]
  task :geminstall => [:gem_install]
desc "build & install sisu v_stable gem"
  task :gem_build_install_stable => [:gem_stable_build,:gem_install_]
  task :gem4bi => [:gem_build_install_stable]
desc "build & install sisu v_unstable gem"
  task :gem_build_install_unstable => [:gem_unstable_build,:gem_install_]
  task :gem5bi => [:gem_build_install_unstable]
desc "build & install gem"
  task :gem_build_install => [:gem_build,:gem_install_]
  task :gembi => [:gem_build_install]
#-- manually set next version
#desc "create sisu v_stable gemspec, manually set next version"
  task :gem4csn => [:gemspecs_stable_create_next_version]
#desc "create sisu v_unstable gemspec, manually set next version"
  task :gem5csn => [:gemspecs_unstable_create_next_version]
#desc "create gemspec, manually set next version"
  task :gemcsn => [:gemspecs_create_next_version]
  task :gemcn => [:gemspecs_create_next_version]
#desc "build gem, manually set next version"
  task :gembn => [:gem_build_next_version]
#desc "build sisu v_stable gem, manually set next version"
  task :gem4bn => [:gem_stable_build_next_version]
#desc "build sisu v_unstable gem, manually set next version"
  task :gem5bn => [:gem_unstable_build_next_version]
#desc "install gem, manually set next version"
  task :gemin => [:gem_install_next_version]
#desc "build & install sisu v_stable gem, manually set next version"
  task :gem4bin => [:gem_stable_build_next_version,:gem_install_next_version]
#desc "build & install sisu v_unstable gem, manually set next version"
  task :gem5bin => [:gem_unstable_build_next_version,:gem_install_next_version]
#desc "build & install gem, manually set next version"
  task :gembin => [:gem_build_next_version,:gem_install_next_version]
#desc "create, build & install sisu v_stable gem, manually set next version"
  task :gem4cbin => [:gemspecs_stable_create_next_version,:gem_stable_build_next_version,:gem_stable_install_next_version]
#desc "create, build & install sisu v_unstable gem, manually set next version"
  task :gem5cbin => [:gemspecs_unstable_create_next_version,:gem_unstable_build_next_version,:gem_unstable_install_next_version]
#desc "create, build & install sisu v_stable & v_unstable gem, manually set next version"
  task :gemcbin => [:gemspecs_create_next_version,:gem_build_next_version,:gem_install_next_version]
#---
#desc "check changelog headers"
  task :changelogheaders => [:changelog_headers]
  task :dev => [:note_developer]
  task :developer_note => [:note_developer]
if File.directory?('bin')
  desc "Setup #{Project_details.name} bin only, synonym :bin"
    task :setup_bin => [:setup_bin_]
    task :bin => [:setup_bin]
end
if File.directory?('lib')
  desc "Setup #{Project_details.name} lib only, synonym :lib"
    task :setup_lib => [:setup_lib_]
    task :lib => [:setup_lib]
end
if File.directory?('conf')
  desc "Setup #{Project_details.name} conf only, synonyms :conf & :etc"
    task :setup_conf => [:setup_conf_]
    task :conf => [:setup_conf]
    task :setup_etc => [:setup_conf]
    task :etc => [:setup_conf]
end
if File.directory?('data')
  desc "Setup #{Project_details.name} data only, synonyms :data & :examples"
    task :setup_data => [:setup_data_]
    task :data => [:setup_data]
    task :setup_examples => [:setup_data]
    task :examples => [:setup_data]
end
if File.directory?('data/sisu')
  #desc "Setup #{Project_details.name} shared data only (odf & shared images)"
    task :setup_share => [:setup_share_]
    task :share => [:setup_share]
end
if File.directory?('man')
  desc "Setup #{Project_details.name} man pages only, synonyms :man"
    task :setup_man => [:setup_man_]
    task :man => [:setup_man]
end
if File.directory?('data/vim')
  desc "Setup #{Project_details.name} vim config files only, synonyms :vim"
    task :setup_vim => [:setup_vim_]
    task :vim => [:setup_vim]
end
desc "Remove #{Project_details.name} (all versions)"
  task :remove_package => [:remove_bin, :remove_lib, :remove_conf]
if File.directory?('bin')
  #desc "Remove #{Project_details.name} bin only"
    task :remove_bin => [:remove_bin]
end
if File.directory?('lib')
  #desc "Remove #{Project_details.name} lib only"
    task :remove_lib => [:remove_lib]
end
if File.directory?('conf')
  #desc "Remove #{Project_details.name} conf only"
    task :remove_conf => [:remove_conf]
end
desc "Re-setup #{Project_details.name}, synonym :reinstall"
  task :resetup => [:remove, :setup]
  task :reinstall => [:remove, :setup]
#desc "Re-setup #{Project_details.name}: bin, lib, conf (ignore data), synonym :reinstall"
  task :resetup_base => [:remove, :setup_base_]
  task :reinstall_base => [:remove, :setup_base_]
if File.directory?('bin')
  #desc "Re-setup #{Project_details.name} bin, synonym :reinstall"
    task :resetup_bin => [:remove_bin, :setup_bin_]
    task :reinstall_bin => [:remove_bin, :setup_bin_]
end
if File.directory?('lib')
  #desc "Re-setup #{Project_details.name} lib, synonym :reinstall_lib"
    task :resetup_lib => [:remove_lib, :setup_lib_]
    task :reinstall_lib => [:remove_lib, :setup_lib_]
end
if File.directory?('conf')
  #desc "Re-setup #{Project_details.name} conf, synonyms :reinstall_conf & :resetup_etc"
    task :resetup_conf => [:remove_conf, :setup_conf_]
    task :reinstall_conf => [:remove_conf, :setup_conf_]
    task :resetup_etc => [:remove_conf, :setup_conf_]
    task :reinstall_etc => [:remove_conf, :setup_conf_]
end
if File.directory?('data/sisu')
  #desc "Re-setup #{Project_details.name} shared data, (odf & images)"
    task :resetup_share => [:remove_share, :setup_share_]
    task :reinstall_share => [:remove_share, :setup_share_]
end
if File.directory?('man')
  #desc "Re-setup #{Project_details.name} man, synonym :reinstall_man"
    task :resetup_man => [:remove_man, :setup_man_]
    task :reinstall_man => [:remove_man, :setup_man_]
end
desc 'Setup Note'
  task :setup_note => [:help]
desc "System information used by #{Project_details.name}"
  task :system => [:system_info,:project_help,:note_sources]
desc "show all system info available - parameters found"
  task :system_param => [:system_param_]
desc "Gem environment information used ruby gems for #{Project_details.name}"
  task :gem_env => [:gem_env_]
desc 'Help'
  task :help => [:project_help,:system_info,:tasks]
#desc "Setup/Install #{Project_details.name} (uses filelist)"
  task :install => [:default_notice,:project]
  task :install_bin => [:setup_bin_]
                                                           #%% setup/install tasks
task :rant_independence do                                 #notice
  resp=''
  while resp.length < 4
    resp='sisu-install'                                     #default name install
    print %{#{Project_details.rake_rant}
  Create a rant dependency independent file
  provide filename default name is "install"
    [Warning, will overwrite file of name provided
      provide name or "quit" to exit]: }
    exit if resp =~/^(?:n|quit|exit)$/
  end
  remove='y' #remove='n'
 if remove =~/y/
   system("rant-import --force --auto #{resp};
     chmod 755 #{resp}
   ")
 else #puts "#{resp} not replaced"
 end
end

task :default_notice do                                    #notice
  Utils.default_notice
end
task :default2 do                                     #secondary
  setup_find_cp_r('bin',Project_details.dir.bin) if File.directory?('bin')
  setup_find_cp_r('lib',Project_details.dir.lib) if File.directory?('lib')
  setup_find_cp_r('conf',Project_details.dir.conf) if File.directory?('conf')
  setup_find_cp_r('data/sisu',Project_details.dir.share) if File.directory?('data/sisu') #
  setup_find_cp_r('data',Project_details.dir.data) if File.directory?('data')
  setup_find_cp_r('data/vim',"#{Project_details.dir.data}/vim") if File.directory?('data/vim')
  setup_find_cp_r('man',Project_details.dir.man) if File.directory?('man')
end
task :setup_bin_ do
  exclude_files=['sisugem']
  Install.setup_find_create('bin',Project_details.dir.bin,exclude_files) if File.directory?('bin')
end
task :setup_lib_ do
  Install.setup_find_create('lib',Project_details.dir.lib) if File.directory?('lib')
end
task :setup_conf_ do
  Install.setup_find_create('conf',Project_details.dir.conf) if File.directory?('conf')
end
task :setup_share_ do
  Install.setup_find_create('data/sisu',Project_details.dir.share) if File.directory?('data/sisu')
end
task :setup_data_ do
  Install.setup_find_create('data',Project_details.dir.data) if File.directory?('data')
end
task :setup_man_ do
  Install.setup_find_create('man',Project_details.dir.man) if File.directory?('man')
  Install.setup_find_create('man.deb/man',Project_details.dir.man) if File.directory?('man.deb/man')
end
task :setup_vim_ do
  Install.setup_find_create('data/vim',Project_details.dir.vim) if File.directory?('data/vim')
end
task :gemspec_info do
  Gemspecs.info_stable
  Gemspecs.info_unstable
end
task :gemspecs_stable_create_default_version do
  Gemspecs::Current.create_stable
end
task :gemspecs_unstable_create_default_version do
  Gemspecs::Current.create_unstable
end
task :gemspecs_create_default_version do
  Gemspecs::Current.create_stable
  Gemspecs::Current.create_unstable
end
task :gemspecs_stable_create_next_version do
  Gemspecs::Next.create_stable
end
task :gemspecs_unstable_create_next_version do
  Gemspecs::Next.create_unstable
end
task :gemspecs_create_next_version do
  Gemspecs::Next.create_stable
  Gemspecs::Next.create_unstable
end
task :gem_stable_build do
  Gemspecs::Current.build_stable
end
task :gem_unstable_build do
  Gemspecs::Current.build_unstable
end
task :gem_build_ do
  Gemspecs::Current.build_stable
  Gemspecs::Current.build_unstable
end
task :gem_stable_build_next_version do
  Gemspecs::Next.build_stable
end
task :gem_unstable_build_next_version do
  Gemspecs::Next.build_unstable
end
task :gem_build_next_version do
  Gemspecs::Next.build_stable
  Gemspecs::Next.build_unstable
end
task :gem_stable_install do
  Gemspecs::Current.install_stable
end
task :gem_unstable_install do
  Gemspecs::Current.install_unstable
end
task :gem_install_ do
  Gemspecs::Current.install_stable
  Gemspecs::Current.install_unstable
end
task :gem_stable_install_next_version do
  Gemspecs::Next.install_stable
end
task :gem_unstable_install_next_version do
  Gemspecs::Next.install_unstable
end
task :gem_install_next_version do
  Gemspecs::Next.install_stable
  Gemspecs::Next.install_unstable
end
task :changelog_headers do
  puts '---'
  puts Version_info::Update.changelog_header_stable
  puts '---'
  puts Version_info::Update.changelog_header_unstable
end
task :sisu_version do
  puts Version_info::Next.setting_stable
  puts Version_info::Next.setting_unstable
  puts '---'
  puts Version_info::Current.setting_stable[:project]
  puts Version_info::Current.setting_stable[:version]
  puts Version_info::Current.setting_stable[:date]
  puts Version_info::Current.setting_stable[:date_stamp]
  puts '---'
  puts Version_info::Current.setting_unstable[:project]
  puts Version_info::Current.setting_unstable[:version]
  puts Version_info::Current.setting_unstable[:date]
  puts Version_info::Current.setting_unstable[:date_stamp]
end
task :sisu_version_set do
  Version_info::Update.update_stable
  Version_info::Update.update_unstable
end
                                                           #%% post install
                                                           #%% clobber/remove tasks
task :remove_bin do
  rm_r "#{Project_details.dir.bin}/#{Project_details.dir.proj}" if FileTest.file?("#{Project_details.dir.bin}/#{Project_details.dir.proj}")
end
task :remove_lib do
  rm_r "#{Project_details.dir.lib}/#{Project_details.dir.proj}" if FileTest.directory?("#{Project_details.dir.lib}/#{Project_details.dir.proj}")
end
task :remove_conf do
  rm_r "#{Project_details.dir.conf}/#{Project_details.dir.proj}" if FileTest.directory?("#{Project_details.dir.conf}/#{Project_details.dir.proj}")
end
task :remove_man do
  rm_r "#{Project_details.dir.man}/**/#{Project_details.dir.proj}" if FileTest.directory?("#{Project_details.dir.man}/man1/#{Project_details.dir.proj}")
end
task :remove_version do
  rm_r "#{Project_details.dir.bin}/#{Project_details.dir.proj}" if FileTest.file?("#{Project_details.dir.bin}/#{Project_details.dir.proj}")
  rm_r "#{Project_details.dir.lib}/#{Project_details.dir.proj}/#{Project_details.version}" if FileTest.directory?("#{Project_details.dir.lib}/#{Project_details.dir.proj}/#{Project_details.version}")
  rm_r "#{Project_details.dir.conf}/#{Project_details.dir.proj} if FileTest.directory?("#{Project_details.dir.conf}/#{Project_details.dir.proj}")
end
task :remove_package do
  rm_r "#{Project_details.dir.bin}/#{Project_details.dir.proj}" if FileTest.file?("#{Project_details.dir.bin}/#{Project_details.dir.proj}")
  rm_r "#{Project_details.dir.lib}/#{Project_details.dir.proj}" if FileTest.directory?("#{Project_details.dir.lib}/#{Project_details.dir.proj}")
  rm_r "#{Project_details.dir.conf}/#{Project_details.dir.proj}" if FileTest.directory?("#{Project_details.dir.conf}/#{Project_details.dir.proj}")
end
task :note_sources do
  puts <<-WOK

  SiSU project:
      <http://sisudoc.org>
      <http://www.jus.uio.no/sisu>
  sisu source code is available at:
      <http://sources.sisudoc.org>
      <http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
  sisu markup samples are provided/packaged separately as sisu-markup-samples:
      <http://sources.sisudoc.org/gitweb/?p=doc/sisu-markup-samples.git;a=summary>
  WOK
end
task :note_installation do
  puts <<-WOK
  alternative 0: distribution install, rather than this Rakefile
    a distribution install pulls in the many dependencies used by sisu after
    initial processing to generate and store output, significant amongst these are
    XeTeX & databases (sqlite3 and postgresql)

  alternative 1: gem install, you need to:
    create the gemspec; build the gem (from the gemspec); install the gem
  which can be done with the single command:
    rake gem_create_build_install   # (to build and install sisu v4 & sisu v5, alias gemcbi)
  separate gems are made/installed for sisu v4 & sisu v5 contained in source:
    rake gem_create_build_install_stable   # (to build and install sisu v4, alias gem4cbi)
    rake gem_create_build_install_unstable   # (to build and install sisu v5, alias gem5cbi)
  for individual steps (create, build, install) see rake options, rake -T
  to specify sisu version for sisu installed via gem
    sisu _#{Version_info::Current.setting_stable[:version]}_ --version
    sisu _#{Version_info::Current.setting_unstable[:version]}_ --version
  to uninstall sisu installed via gem
    sudo gem uninstall --verbose sisu
  WOK
end
task :note_developer do
  puts <<-WOK

  changelogheaders

  sisuversion
  sisuversionset

  gemcsn gem4csn gem5csn
  gembn gem4bn gem5bn
  gemin gem4in gem5in
  gembin gem4bin gem5bin
  gemcbin gem4cbin gem5cbin
  WOK
end
                                                           #%% help & system info
task :system_info do
  Project_details.system_info
end
task :system_param_ do
  Project_details.env.each {|c| puts c.inspect }
end
task :gem_env_ do
  Project_details.gem_env
end
task :project_help do
  Help.project_help
end
task :tasks do
  Help.tasks
end