qi (quick installer) minor
[software/sisu] / qi
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 begin
41 require 'thor'
42 rescue LoadError
43 puts 'thor (package ruby-thor) not found'
44 end
45 begin
46 require './setup/sisu_version' # ./setup/sisu_version.rb
47 include SiSUversion
48 rescue LoadError
49 puts 'this does not appear to be a SiSU development directory'
50 exit
51 end
52 require_relative 'setup/qi_libs' # setup/qi_libs.rb
53 require 'find'
54 require 'fileutils'
55 include FileUtils
56 require 'pathname'
57 require 'rbconfig.rb'
58 require 'yaml'
59 module SiSUconf
60 class Configure < Thor
61 class_option :verbose, :type => :boolean
62 desc 'setup --all --bin --lib --conf --data --alt',
63 'setup sisu'
64 options \
65 :all => :boolean,
66 :bin => :boolean,
67 :lib => :boolean,
68 :conf => :boolean,
69 :data => :boolean,
70 :share => :boolean,
71 :man => :boolean,
72 :vim => :boolean,
73 :alt => :boolean
74 def setup
75 unless options.length >= 1 \
76 and not (options[:bin] \
77 or options[:lib] \
78 or options[:conf] \
79 or options[:data] \
80 or options[:share] \
81 or options[:man] \
82 or options[:vim])
83 puts 'setup --all --bin --lib --conf --data --share --man --vim'
84 end
85 if not options[:alt]
86 if options[:all] \
87 or options[:bin]
88 exclude_files=['sisugem']
89 Install.setup_find_create('bin',Project_details.dir.bin,exclude_files) \
90 if File.directory?('bin')
91 end
92 if options[:all] \
93 or options[:lib]
94 Install.setup_find_create('lib',Project_details.dir.lib) \
95 if File.directory?('lib')
96 end
97 if options[:all] \
98 or options[:conf]
99 Install.setup_find_create('conf',Project_details.dir.conf) \
100 if File.directory?('conf')
101 end
102 if options[:all] \
103 or options[:data]
104 Install.setup_find_create('data',Project_details.dir.data) \
105 if File.directory?('data')
106 end
107 if options[:all] \
108 or options[:share]
109 Install.setup_find_create('data/sisu',Project_details.dir.share) \
110 if File.directory?('data/sisu')
111 end
112 if options[:all] \
113 or options[:man]
114 Install.setup_find_create('man',Project_details.dir.man) \
115 if File.directory?('man')
116 end
117 if options[:all] \
118 or options[:vim]
119 Install.setup_find_create('data/vim',Project_details.dir.vim) \
120 if File.directory?('data/vim')
121 end
122 else
123 if options[:all] \
124 or options[:bin]
125 Install.setup_find_cp_r('bin',Project_details.dir.bin) \
126 if File.directory?('bin')
127 end
128 if options[:all] \
129 or options[:bin]
130 Install.setup_find_cp_r('lib',Project_details.dir.lib) \
131 if File.directory?('lib')
132 end
133 if options[:all] \
134 or options[:conf]
135 Install.setup_find_cp_r('conf',Project_details.dir.conf) \
136 if File.directory?('conf')
137 end
138 if options[:all] \
139 or options[:data]
140 Install.setup_find_cp_r('data',Project_details.dir.data) \
141 if File.directory?('data')
142 end
143 if options[:all] \
144 or options[:share]
145 Install.setup_find_cp_r('data/sisu',Project_details.dir.share) \
146 if File.directory?('data/sisu') #
147 end
148 if options[:all] \
149 or options[:man]
150 Install.setup_find_cp_r('man',Project_details.dir.man) \
151 if File.directory?('man')
152 end
153 #if options[:all] \
154 #or options[:vim]
155 # Install.setup_find_cp_r('data/vim',"#{Project_details.dir.data}/vim") \
156 # if File.directory?('data/vim')
157 #end
158 end
159 end
160 desc 'gem --create --build --install --stable --unstable',
161 'gem create build and install'
162 options \
163 :stable => :boolean,
164 :unstable => :boolean,
165 :create => :boolean,
166 :build => :boolean,
167 :install => :boolean
168 def gem
169 if options[:unstable]
170 if options[:create]
171 Gemspecs::Current.create_unstable
172 #Gemspecs::Next.create_unstable
173 puts 'created gemspec, version: unstable' \
174 if options[:verbose]
175 end
176 if options[:build]
177 Gemspecs::Current.build_unstable
178 #Gemspecs::Next.build_unstable
179 puts 'built gem, version: unstable' \
180 if options[:verbose]
181 end
182 if options[:install]
183 Gemspecs::Current.install_unstable
184 #Gemspecs::Next.install_unstable
185 puts 'installed gem, version: unstable' \
186 if options[:verbose]
187 end
188 end
189 if options[:stable] \
190 or not options[:unstable]
191 if options[:create]
192 Gemspecs::Current.create_stable
193 #Gemspecs::Current.create_unstable
194 puts 'created gemspec, version: stable' \
195 if options[:verbose]
196 end
197 if options[:build]
198 Gemspecs::Current.build_stable
199 #Gemspecs::Next.build_stable
200 puts 'built gem, version: stable' \
201 if options[:verbose]
202 end
203 if options[:install]
204 Gemspecs::Current.install_stable
205 #Gemspecs::Next.install_stable
206 puts 'installed gem, version: stable' \
207 if options[:verbose]
208 end
209 end
210 if options.length < 2
211 system("#{$called_as} help gem")
212 end
213 end
214 desc 'pkg',
215 'package maintenance tasks, of no general interest (maintainer specific for package maintainer\'s convenience)'
216 options \
217 :update_version=> :boolean,
218 :tip => :boolean
219 def pkg
220 if options[:tip]
221 Package.sequence
222 end
223 if options[:update_version]
224 Version_info::Update.update_stable
225 Version_info::Update.update_unstable
226 puts "\n" + Version_info::Update.changelog_header_stable
227 puts "\n" + Version_info::Update.changelog_header_unstable
228 end
229 if options.length == 0
230 system("#{$called_as} help pkg")
231 system("#{$called_as} pkg --tip")
232 end
233 end
234 end
235 end
236 begin
237 $called_as,$argv=$0,$*
238 SiSUconf::Configure.start(ARGV)
239 rescue
240 end
241 __END__