c&d: po4a (& git) revisited, revisit
[software/sisu] / qi
1 #!/usr/bin/env ruby
2 =begin
3
4 ** Description:
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 - 2015 Ralph Amissah
11
12 ** License:
13
14 ** Ralph Amissah <ralph@amissah.com>
15 Ralph Amissah <ralph.amissah@gmail.com>
16
17 =end
18 #% manual settings, edit/update as required (note current default settings are obtained from sisu version yml file)
19 begin
20 require 'thor'
21 rescue LoadError
22 puts 'thor (package ruby-thor) not found'
23 end
24 begin
25 require './setup/sisu_version' # ./setup/sisu_version.rb
26 include SiSUversion
27 rescue LoadError
28 puts 'this does not appear to be a SiSU development directory'
29 exit
30 end
31 require_relative 'setup/qi_libs' # setup/qi_libs.rb
32 require 'find'
33 require 'fileutils'
34 include FileUtils
35 require 'pathname'
36 require 'rbconfig.rb'
37 require 'yaml'
38 module SiSUconf
39 class Configure < Thor
40 class_option :verbose, :type => :boolean
41 desc 'setup --all --bin --lib --conf --data --alt --dryrun',
42 'setup sisu'
43 options \
44 :all => :boolean,
45 :bin => :boolean,
46 :lib => :boolean,
47 :conf => :boolean,
48 :data => :boolean,
49 :share => :boolean,
50 :man => :boolean,
51 :vim => :boolean,
52 :alt => :boolean,
53 :dryrun => :boolean
54 def setup
55 unless options.length >= 1 \
56 and not (options[:bin] \
57 or options[:lib] \
58 or options[:conf] \
59 or options[:data] \
60 or options[:share] \
61 or options[:man] \
62 or options[:vim])
63 puts 'setup --all --bin --lib --conf --data --share --man --vim'
64 end
65 act=(options[:dryrun]) ? (:dryrun) : (:action)
66 if not options[:alt]
67 if options[:all] \
68 or options[:bin]
69 exclude_files=['sisugem']
70 Install.setup_find_create('bin',Project_details.dir.bin,exclude_files,act) \
71 if File.directory?('bin')
72 end
73 if options[:all] \
74 or options[:lib]
75 Install.setup_find_create('lib',Project_details.dir.lib,act) \
76 if File.directory?('lib')
77 end
78 if options[:all] \
79 or options[:conf]
80 Install.setup_find_create('conf',Project_details.dir.conf,act) \
81 if File.directory?('conf')
82 end
83 if options[:all] \
84 or options[:data]
85 Install.setup_find_create('data',Project_details.dir.data,act) \
86 if File.directory?('data')
87 end
88 if options[:all] \
89 or options[:share]
90 Install.setup_find_create('data/sisu',Project_details.dir.share,act) \
91 if File.directory?('data/sisu')
92 end
93 if options[:all] \
94 or options[:man]
95 Install.setup_find_create('man',Project_details.dir.man,act) \
96 if File.directory?('man')
97 end
98 if options[:all] \
99 or options[:vim]
100 Install.setup_find_create('data/vim',Project_details.dir.vim,act) \
101 if File.directory?('data/vim')
102 end
103 else
104 if options[:all] \
105 or options[:bin]
106 Install.setup_find_cp_r('bin',Project_details.dir.bin,act) \
107 if File.directory?('bin')
108 end
109 if options[:all] \
110 or options[:bin]
111 Install.setup_find_cp_r('lib',Project_details.dir.lib,act) \
112 if File.directory?('lib')
113 end
114 if options[:all] \
115 or options[:conf]
116 Install.setup_find_cp_r('conf',Project_details.dir.conf,act) \
117 if File.directory?('conf')
118 end
119 if options[:all] \
120 or options[:data]
121 Install.setup_find_cp_r('data',Project_details.dir.data,act) \
122 if File.directory?('data')
123 end
124 if options[:all] \
125 or options[:share]
126 Install.setup_find_cp_r('data/sisu',Project_details.dir.share,act) \
127 if File.directory?('data/sisu') #
128 end
129 if options[:all] \
130 or options[:man]
131 Install.setup_find_cp_r('man',Project_details.dir.man,act) \
132 if File.directory?('man')
133 end
134 #if options[:all] \
135 #or options[:vim]
136 # Install.setup_find_cp_r('data/vim',"#{Project_details.dir.data}/vim") \
137 # if File.directory?('data/vim')
138 #end
139 end
140 end
141 desc 'gem --create --build --install --stable --unstable',
142 'gem create build and install'
143 options \
144 :stable => :boolean,
145 :unstable => :boolean,
146 :create => :boolean,
147 :build => :boolean,
148 :install => :boolean
149 def gem
150 if options[:unstable]
151 if options[:create]
152 Gemspecs::Current.create_unstable
153 #Gemspecs::Next.create_unstable
154 puts 'created gemspec, version: unstable' \
155 if options[:verbose]
156 end
157 if options[:build]
158 Gemspecs::Current.build_unstable
159 #Gemspecs::Next.build_unstable
160 puts 'built gem, version: unstable' \
161 if options[:verbose]
162 end
163 if options[:install]
164 Gemspecs::Current.install_unstable
165 #Gemspecs::Next.install_unstable
166 puts 'installed gem, version: unstable' \
167 if options[:verbose]
168 end
169 end
170 if options[:stable] \
171 or not options[:unstable]
172 if options[:create]
173 Gemspecs::Current.create_stable
174 #Gemspecs::Current.create_unstable
175 puts 'created gemspec, version: stable' \
176 if options[:verbose]
177 end
178 if options[:build]
179 Gemspecs::Current.build_stable
180 #Gemspecs::Next.build_stable
181 puts 'built gem, version: stable' \
182 if options[:verbose]
183 end
184 if options[:install]
185 Gemspecs::Current.install_stable
186 #Gemspecs::Next.install_stable
187 puts 'installed gem, version: stable' \
188 if options[:verbose]
189 end
190 end
191 if options.length < 2
192 system("#{$called_as} help gem")
193 end
194 end
195 desc 'pkg',
196 'package maintenance tasks, of no general interest (maintainer specific for package maintainer\'s convenience)'
197 options \
198 :open_version=> :boolean,
199 :version_and_tag_for_release=> :boolean,
200 :tip => :boolean
201 def pkg
202 if options[:tip]
203 Package.sequence
204 end
205 if options[:open_version]
206 Version_info::Update.update_stable(:pre_release)
207 Version_info::Update.update_unstable(:pre_release)
208 Version_info::Update.changelog_header_stable_pre_release
209 Version_info::Update.changelog_header_unstable_pre_release
210 Version_info::Update.changelog_header_commit(:pre_release)
211 end
212 if options[:version_and_tag_for_release]
213 Version_info::Update.update_stable(:release)
214 Version_info::Update.update_unstable(:release)
215 Version_info::Update.changelog_header_stable
216 Version_info::Update.changelog_header_unstable
217 Version_info::Update.changelog_header_commit_tag_upstream(:release)
218 end
219 if options.length == 0
220 system("#{$called_as} help pkg")
221 system("#{$called_as} pkg --tip")
222 end
223 end
224 end
225 end
226 begin
227 $called_as,$argv=$0,$*
228 SiSUconf::Configure.start(ARGV)
229 rescue
230 end
231 __END__