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