Merge tag 'sisu_5.8.0' into debian/sid
[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 :is => :boolean
55 def setup
56 unless options.length >= 1 \
57 and not (options[:bin] \
58 or options[:lib] \
59 or options[:conf] \
60 or options[:data] \
61 or options[:share] \
62 or options[:man] \
63 or options[:vim])
64 puts 'setup --all --bin --lib --conf --data --share --man --vim'
65 end
66 act=(options[:dryrun]) ? (:dryrun) : (:action)
67 if options[:is]
68 puts Version_info.version_number_info_stable
69 puts Version_info.version_number_info_unstable
70 end
71 if not options[:alt]
72 if options[:all] \
73 or options[:bin]
74 exclude_files=['sisugem']
75 Install.setup_find_create(
76 'bin',
77 Project_details.dir.bin,
78 exclude_files,
79 act
80 ) if File.directory?('bin')
81 end
82 if options[:all] \
83 or options[:lib]
84 Install.setup_find_create(
85 'lib',
86 Project_details.dir.lib,
87 act
88 ) if File.directory?('lib')
89 end
90 if options[:all] \
91 or options[:conf]
92 Install.setup_find_create(
93 'conf',
94 Project_details.dir.conf,
95 act
96 ) if File.directory?('conf')
97 end
98 if options[:all] \
99 or options[:data]
100 Install.setup_find_create(
101 'data',
102 Project_details.dir.data,
103 act
104 ) if File.directory?('data')
105 end
106 if options[:all] \
107 or options[:share]
108 Install.setup_find_create(
109 'data/sisu',
110 Project_details.dir.share,
111 act
112 ) if File.directory?('data/sisu')
113 end
114 if options[:all] \
115 or options[:man]
116 Install.setup_find_create(
117 'man',
118 Project_details.dir.man,
119 act
120 ) if File.directory?('man')
121 end
122 if options[:all] \
123 or options[:vim]
124 Install.setup_find_create(
125 'data/vim',
126 Project_details.dir.vim,
127 act
128 ) if File.directory?('data/vim')
129 end
130 else
131 if options[:all] \
132 or options[:bin]
133 Install.setup_find_cp_r(
134 'bin',
135 Project_details.dir.bin,
136 act
137 ) if File.directory?('bin')
138 end
139 if options[:all] \
140 or options[:bin]
141 Install.setup_find_cp_r(
142 'lib',
143 Project_details.dir.lib,
144 act
145 ) if File.directory?('lib')
146 end
147 if options[:all] \
148 or options[:conf]
149 Install.setup_find_cp_r(
150 'conf',
151 Project_details.dir.conf,
152 act
153 ) if File.directory?('conf')
154 end
155 if options[:all] \
156 or options[:data]
157 Install.setup_find_cp_r(
158 'data',
159 Project_details.dir.data,
160 act
161 ) if File.directory?('data')
162 end
163 if options[:all] \
164 or options[:share]
165 Install.setup_find_cp_r(
166 'data/sisu',
167 Project_details.dir.share,
168 act
169 ) if File.directory?('data/sisu') #
170 end
171 if options[:all] \
172 or options[:man]
173 Install.setup_find_cp_r(
174 'man',
175 Project_details.dir.man,
176 act
177 ) if File.directory?('man')
178 end
179 #if options[:all] \
180 #or options[:vim]
181 # Install.setup_find_cp_r('data/vim',"#{Project_details.dir.data}/vim") \
182 # if File.directory?('data/vim')
183 #end
184 end
185 end
186 desc 'gem --create --build --install --stable --unstable',
187 'gem create build and install'
188 options \
189 :stable => :boolean,
190 :unstable => :boolean,
191 :create => :boolean,
192 :build => :boolean,
193 :install => :boolean,
194 :is => :boolean
195 def gem
196 if options[:unstable]
197 if options[:is]
198 puts Version_info.version_number_info_unstable
199 end
200 if options[:create]
201 Gemspecs::Current.create_unstable
202 #Gemspecs::Next.create_unstable
203 puts 'created gemspec, version: unstable' \
204 if options[:verbose]
205 end
206 if options[:build]
207 Gemspecs::Current.build_unstable
208 #Gemspecs::Next.build_unstable
209 puts 'built gem, version: unstable' \
210 if options[:verbose]
211 end
212 if options[:install]
213 Gemspecs::Current.install_unstable
214 #Gemspecs::Next.install_unstable
215 puts 'installed gem, version: unstable' \
216 if options[:verbose]
217 end
218 end
219 if options[:stable] \
220 or not options[:unstable]
221 if options[:is]
222 puts Version_info.version_number_info_stable
223 end
224 if options[:create]
225 Gemspecs::Current.create_stable
226 #Gemspecs::Current.create_unstable
227 puts 'created gemspec, version: stable' \
228 if options[:verbose]
229 end
230 if options[:build]
231 Gemspecs::Current.build_stable
232 #Gemspecs::Next.build_stable
233 puts 'built gem, version: stable' \
234 if options[:verbose]
235 end
236 if options[:install]
237 Gemspecs::Current.install_stable
238 #Gemspecs::Next.install_stable
239 puts 'installed gem, version: stable' \
240 if options[:verbose]
241 end
242 end
243 if options.length < 2
244 system("#{$called_as} help gem")
245 end
246 end
247 desc 'pkg',
248 'package maintenance tasks, ' \
249 + 'of no general interest ' \
250 + '(maintainer specific for package maintainer\'s convenience)'
251 options \
252 :open_version=> :boolean,
253 :version_and_tag_for_release=> :boolean,
254 :tip => :boolean,
255 :is => :boolean
256 def pkg
257 if options[:is]
258 puts Version_info.version_number_info_stable
259 puts Version_info.version_number_info_unstable
260 end
261 if options[:tip]
262 Package.sequence
263 end
264 if options[:open_version]
265 Version_info::Update.update_stable(:pre_release)
266 Version_info::Update.update_unstable(:pre_release)
267 Version_info::Update.changelog_header_stable_pre_release
268 Version_info::Update.changelog_header_unstable_pre_release
269 Version_info::Update.changelog_header_commit(:pre_release)
270 end
271 if options[:version_and_tag_for_release]
272 Version_info::Update.update_stable(:release)
273 Version_info::Update.update_unstable(:release)
274 Version_info::Update.changelog_header_stable
275 Version_info::Update.changelog_header_unstable
276 Version_info::Update.changelog_header_commit_tag_upstream(:release)
277 end
278 if options.length == 0
279 system("#{$called_as} help pkg")
280 system("#{$called_as} pkg --tip")
281 end
282 end
283 end
284 end
285 begin
286 $called_as,$argv=$0,$*
287 SiSUconf::Configure.start(ARGV)
288 rescue
289 end
290 __END__