software_smithy 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +114 -0
- data/bin/smithy +586 -0
- data/etc/completion/smithy-completion.bash +266 -0
- data/etc/completion/zsh/_smithy +130 -0
- data/etc/smithyrc +36 -0
- data/etc/templates/build/.owners +1 -0
- data/etc/templates/build/build-notes +0 -0
- data/etc/templates/build/dependencies +0 -0
- data/etc/templates/build/rebuild +13 -0
- data/etc/templates/build/relink +2 -0
- data/etc/templates/build/remodule.erb +21 -0
- data/etc/templates/build/retest +6 -0
- data/etc/templates/build/status +0 -0
- data/etc/templates/modulefile.erb +30 -0
- data/etc/templates/package/.check4newver +2 -0
- data/etc/templates/package/.exceptions +3 -0
- data/etc/templates/package/description +18 -0
- data/etc/templates/package/description.markdown +17 -0
- data/etc/templates/package/support +1 -0
- data/etc/templates/package/versions +3 -0
- data/etc/templates/web/all.html.erb +19 -0
- data/etc/templates/web/alphabetical.html.erb +12 -0
- data/etc/templates/web/category.html.erb +74 -0
- data/etc/templates/web/machine_version_table.html.erb +35 -0
- data/etc/templates/web/package.html.erb +53 -0
- data/etc/templates/web/version_list.html.erb +7 -0
- data/etc/templates/web/version_table.html.erb +24 -0
- data/lib/smithy/config.rb +167 -0
- data/lib/smithy/description.rb +276 -0
- data/lib/smithy/file_operations.rb +234 -0
- data/lib/smithy/format.rb +134 -0
- data/lib/smithy/helpers.rb +159 -0
- data/lib/smithy/module_file.rb +224 -0
- data/lib/smithy/package.rb +647 -0
- data/lib/smithy.rb +45 -0
- data/lib/smithy_version.rb +40 -0
- data/man/man1/smithy.1 +262 -0
- data/smithy.rdoc +281 -0
- metadata +230 -0
data/README.rdoc
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
Smithy is a tool that aims to replicate and improve upon functionality of
|
2
|
+
{SWTools}[http://www.olcf.ornl.gov/center-projects/swtools/].
|
3
|
+
|
4
|
+
Smithy's goals are:
|
5
|
+
|
6
|
+
* Provide a simplified and intuitive command line interface for installing software.
|
7
|
+
* Reduce the number of steps necessary for each function
|
8
|
+
|
9
|
+
= Installation
|
10
|
+
|
11
|
+
== Installing ruby
|
12
|
+
|
13
|
+
Smithy requires ruby 1.9.2 or later. Most distrubutions only ship version 1.8.7
|
14
|
+
and you may need build your own copy. The simplest way is using the excellent
|
15
|
+
{ruby-build}[https://github.com/sstephenson/ruby-build] script. As an example,
|
16
|
+
this will install ruby with a prefix of <tt>/sw/xk6/ruby/1.9.3-p286/sles11.1_gnu4.3.4</tt>
|
17
|
+
|
18
|
+
curl -L https://github.com/sstephenson/ruby-build/archive/master.zip -o ruby-build.zip
|
19
|
+
unzip ruby-build.zip
|
20
|
+
cd ruby-build-master
|
21
|
+
./bin/ruby-build -h
|
22
|
+
./bin/ruby-build --definitions
|
23
|
+
./bin/ruby-build 1.9.3-p286 /sw/xk6/ruby/1.9.3-p286/sles11.1_gnu4.3.4
|
24
|
+
|
25
|
+
Many sites use {Environment Modules}[http://modules.sourceforge.net/] to allow
|
26
|
+
users to load and unload software into their environment. Here is sample
|
27
|
+
modulefile for ruby installed in the previous example.
|
28
|
+
|
29
|
+
#%Module1.0
|
30
|
+
proc ModulesHelp { } {
|
31
|
+
puts stderr "Ruby 1.9.3 patch 286"
|
32
|
+
puts stderr "The gem command will install gems to the ~/.gem directory."
|
33
|
+
}
|
34
|
+
module-whatis "Ruby 1.9.3-p286"
|
35
|
+
|
36
|
+
set PREFIX /sw/xk6/ruby/1.9.3-p286/sles11.1_gnu4.3.4
|
37
|
+
prepend-path PATH $PREFIX/bin
|
38
|
+
prepend-path LD_LIBRARY_PATH $PREFIX/lib
|
39
|
+
prepend-path MANPATH $PREFIX/share/man
|
40
|
+
setenv GEM_HOME $env(HOME)/.gem/ruby/1.9.1
|
41
|
+
setenv GEM_PATH $env(HOME)/.gem/ruby/1.9.1:$PREFIX/lib/ruby/gems/1.9.1
|
42
|
+
prepend-path PATH $env(HOME)/.gem/ruby/1.9.1/bin:$PREFIX/lib/ruby/gems/1.9.1/bin
|
43
|
+
|
44
|
+
This file should be saved to <tt>$MODULEPATH/ruby/1.9.3</tt>
|
45
|
+
|
46
|
+
== Installing smithy
|
47
|
+
|
48
|
+
=== Choosting an install location
|
49
|
+
|
50
|
+
There are two ways to install smithy. The simplest is by simply installing the
|
51
|
+
<tt>software_smithy</tt> gem. This will install smithy and it's required gems in
|
52
|
+
your home directory:
|
53
|
+
|
54
|
+
gem install software_smithy
|
55
|
+
|
56
|
+
If you are installing in production for all users you will want to install
|
57
|
+
smithy somewhere everyone can access. There are two places you might want to do
|
58
|
+
this:
|
59
|
+
|
60
|
+
==== Ruby's default GEM_PATH
|
61
|
+
|
62
|
+
If you installed manually using the examples above, this will be something like
|
63
|
+
<tt>PREFIX/lib/ruby/gems/1.9.1</tt> This will give access to smithy whenever
|
64
|
+
ruby is loaded into a users environment using the modulefile above. To install
|
65
|
+
to ruby's default GEM_PATH (following the above example):
|
66
|
+
|
67
|
+
export GEM_HOME=/sw/xk6/ruby/1.9.3-p286/sles11.1_gnu4.3.4/lib/ruby/gems/1.9.1
|
68
|
+
gem install software_smithy --no-rdoc --no-ri
|
69
|
+
|
70
|
+
==== A different location of your choosing.
|
71
|
+
|
72
|
+
This is useful if you want a single smithy install location for more than one
|
73
|
+
install of ruby (typically on separate machines). This method is a bit more
|
74
|
+
complicated and requires users to load smithy into their environment manually in
|
75
|
+
addition to ruby.
|
76
|
+
|
77
|
+
Assuming you use environment modules you can install smithy to a separate
|
78
|
+
directory e.g. <tt>/sw/tools/smithy</tt> with the install_smithy script. This
|
79
|
+
will setup a folder containing the smithy gem, a modulefile and a script that
|
80
|
+
sets up shell completion. Users can load smithy into their environment by
|
81
|
+
running:
|
82
|
+
|
83
|
+
source /sw/tools/smithy/environment.sh
|
84
|
+
|
85
|
+
=== Loading smithy into your environment
|
86
|
+
|
87
|
+
Smithy depends on a config file to define it's behavior. For an example see
|
88
|
+
{etc/smithyrc}[https://github.com/AnthonyDiGirolamo/smithy/blob/master/etc/smithyrc]
|
89
|
+
This can be set via the <tt>$SMITHY_CONFIG</tt> environment variable.
|
90
|
+
|
91
|
+
You may wish to set this using a modulefile or a shell script. Examples are
|
92
|
+
provided in
|
93
|
+
{modulefiles/smithy/1.0}[https://github.com/AnthonyDiGirolamo/smithy/blob/master/modulefiles/smithy/1.0]
|
94
|
+
and
|
95
|
+
{environment.sh}[https://github.com/AnthonyDiGirolamo/smithy/blob/master/environment.sh]
|
96
|
+
|
97
|
+
= License
|
98
|
+
|
99
|
+
Smithy is based on the ideas created in SWTools and uses a BSD license. See
|
100
|
+
LICENSE for the exact text.
|
101
|
+
|
102
|
+
= Contributing and Support
|
103
|
+
|
104
|
+
The smithy {github repo}[https://github.com/AnthonyDiGirolamo/smithy] contains
|
105
|
+
all development files. Please fork and send me a pull request with any additions
|
106
|
+
or changes.
|
107
|
+
|
108
|
+
If you encounter any issues please {open an
|
109
|
+
issue}[https://github.com/AnthonyDiGirolamo/smithy/issues] on github. Or send me
|
110
|
+
an email.
|
111
|
+
|
112
|
+
= smithy command line usage
|
113
|
+
|
114
|
+
:include:smithy.rdoc
|
data/bin/smithy
ADDED
@@ -0,0 +1,586 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Smithy is freely available under the terms of the BSD license given below. {{{
|
3
|
+
#
|
4
|
+
# Copyright (c) 2012. UT-BATTELLE, LLC. All rights reserved.
|
5
|
+
#
|
6
|
+
# Produced by the National Center for Computational Sciences at Oak Ridge
|
7
|
+
# National Laboratory. Smithy is a based on SWTools, more information on SWTools
|
8
|
+
# can be found at: http://www.olcf.ornl.gov/center-projects/swtools/
|
9
|
+
#
|
10
|
+
# This product includes software produced by UT-Battelle, LLC under Contract No.
|
11
|
+
# DE-AC05-00OR22725 with the Department of Energy.
|
12
|
+
#
|
13
|
+
# Redistribution and use in source and binary forms, with or without
|
14
|
+
# modification, are permitted provided that the following conditions are met:
|
15
|
+
#
|
16
|
+
# - Redistributions of source code must retain the above copyright notice, this
|
17
|
+
# list of conditions and the following disclaimer.
|
18
|
+
#
|
19
|
+
# - Redistributions in binary form must reproduce the above copyright notice, this
|
20
|
+
# list of conditions and the following disclaimer in the documentation and/or
|
21
|
+
# other materials provided with the distribution.
|
22
|
+
#
|
23
|
+
# - Neither the name of the UT-BATTELLE nor the names of its contributors may
|
24
|
+
# be used to endorse or promote products derived from this software without
|
25
|
+
# specific prior written permission.
|
26
|
+
#
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
28
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
29
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
30
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
31
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
33
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
34
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
35
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
36
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
37
|
+
# }}}
|
38
|
+
|
39
|
+
# Absolute path to the smithy gem prefix
|
40
|
+
@@smithy_bin_root = File.expand_path(File.dirname(File.realpath(__FILE__))+ '/../')
|
41
|
+
# Add the smithy lib dir to the ruby library search path
|
42
|
+
$: << File.expand_path(@@smithy_bin_root + '/lib')
|
43
|
+
|
44
|
+
require 'English'
|
45
|
+
require 'fileutils'
|
46
|
+
|
47
|
+
require 'rubygems'
|
48
|
+
require 'open4'
|
49
|
+
require 'rainbow'
|
50
|
+
require 'readline'
|
51
|
+
require 'terminal-table'
|
52
|
+
require 'erb'
|
53
|
+
require 'uri'
|
54
|
+
require 'kramdown'
|
55
|
+
require 'active_support/core_ext/hash'
|
56
|
+
require 'active_support/core_ext/string'
|
57
|
+
# require 'debugger' #XXX
|
58
|
+
# require 'awesome_print' #XXX
|
59
|
+
|
60
|
+
require 'gli'
|
61
|
+
include GLI::App
|
62
|
+
|
63
|
+
require 'smithy'
|
64
|
+
include Smithy
|
65
|
+
|
66
|
+
version Smithy::VERSION
|
67
|
+
|
68
|
+
program_desc "Smithy will help you build, test, and install software with ease."
|
69
|
+
|
70
|
+
desc "Machine architecure to operate on"
|
71
|
+
arg_name "NAME"
|
72
|
+
flag [:arch]
|
73
|
+
|
74
|
+
desc "Group name for files created by smithy"
|
75
|
+
arg_name "GROUP"
|
76
|
+
flag ["file-group-name"]
|
77
|
+
|
78
|
+
desc "Disable group writable file creation"
|
79
|
+
switch ["disable-group-writable"], :negatable => false
|
80
|
+
|
81
|
+
desc "The root level directory for software"
|
82
|
+
arg_name "PATH"
|
83
|
+
flag ["software-root"]
|
84
|
+
|
85
|
+
desc "The prefix of programming environments for this machine"
|
86
|
+
arg_name "NAME"
|
87
|
+
flag ["prgenv-prefix"]
|
88
|
+
|
89
|
+
desc "The root level directory for published web files"
|
90
|
+
arg_name "PATH"
|
91
|
+
flag ["web-root"]
|
92
|
+
|
93
|
+
desc "The root level directory global description files"
|
94
|
+
arg_name "PATH"
|
95
|
+
flag ["descriptions-root"]
|
96
|
+
|
97
|
+
desc "Disable or enable color output (default: enabled)"
|
98
|
+
switch "colors"
|
99
|
+
|
100
|
+
desc "Alternate config file, also set by $SMITHY_CONFIG"
|
101
|
+
arg_name "FILE"
|
102
|
+
flag [:"config-file"]
|
103
|
+
|
104
|
+
desc "Always overwrite existing files"
|
105
|
+
switch [:f, :force], :negatable => false
|
106
|
+
|
107
|
+
desc "Search currently installed software"
|
108
|
+
arg_name "PATTERN"
|
109
|
+
command ['search'] do |c|
|
110
|
+
output_formats = {
|
111
|
+
'path' => Format::Path.new,
|
112
|
+
'name' => Format::Name.new,
|
113
|
+
'table' => Format::Table.new,
|
114
|
+
'csv' => Format::CSV.new,
|
115
|
+
'dokuwiki' => Format::Doku.new
|
116
|
+
}
|
117
|
+
c.desc 'Format of the output'
|
118
|
+
c.arg_name output_formats.keys.join('|')
|
119
|
+
c.default_value output_formats.keys.first
|
120
|
+
c.flag :format
|
121
|
+
|
122
|
+
#c.desc 'Only search packages ready for web publishing'
|
123
|
+
#c.switch [:w, "web-enabled"]
|
124
|
+
|
125
|
+
#sorting = %w{name date user}
|
126
|
+
#c.desc 'Field to sort in ascending order'
|
127
|
+
#c.arg_name sorting.join('|')
|
128
|
+
#c.default_value sorting.first
|
129
|
+
#c.flag :sort
|
130
|
+
|
131
|
+
c.action do |global_options,options,args|
|
132
|
+
swroot = Smithy::Config.full_root
|
133
|
+
|
134
|
+
formatter = output_formats[options[:format]]
|
135
|
+
raise "Unknow format \"#{options[:format]}\" valid formats include: #{output_formats.keys.join(',')}" if formatter.nil?
|
136
|
+
|
137
|
+
notice "Searching in #{swroot}" unless formatter.class == Format::Doku
|
138
|
+
|
139
|
+
software = Package.all :root => swroot
|
140
|
+
|
141
|
+
count = 0
|
142
|
+
formatter.before
|
143
|
+
if args.empty?
|
144
|
+
formatter.format(software, swroot)
|
145
|
+
count += software.count
|
146
|
+
else
|
147
|
+
args.each do |a|
|
148
|
+
result = software.select { |s| s =~ /#{a}/ }
|
149
|
+
formatter.format(result, swroot)
|
150
|
+
count += result.count
|
151
|
+
end
|
152
|
+
end
|
153
|
+
formatter.after
|
154
|
+
|
155
|
+
notice "#{count} Found" unless formatter.class == Format::Doku
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
desc "Test software"
|
160
|
+
command ['test'] do |c|
|
161
|
+
c.desc 'Test log file name located within the software prefix.'
|
162
|
+
c.arg_name 'FILE'
|
163
|
+
c.default_value 'test.log'
|
164
|
+
c.flag ["log-name"]
|
165
|
+
|
166
|
+
c.desc "Disable logging"
|
167
|
+
c.switch ["disable-log"], :negatable => false
|
168
|
+
|
169
|
+
c.desc 'Suppress messages from STDOUT.'
|
170
|
+
c.switch [:s, "suppress-stdout"], :negatable => false
|
171
|
+
|
172
|
+
c.desc 'Ignore .lock file and run anyway'
|
173
|
+
c.switch [:f, "force"], :negatable => false
|
174
|
+
|
175
|
+
c.desc 'See what scripts will be run without running them'
|
176
|
+
c.switch [:n, "dry-run"], :negatable => false
|
177
|
+
|
178
|
+
c.action do |global_options,options,args|
|
179
|
+
packages = args.dup
|
180
|
+
if args.empty?
|
181
|
+
notice "Reading package names from STDIN..."
|
182
|
+
packages = STDIN.readlines.map{|p| p.chomp}
|
183
|
+
end
|
184
|
+
|
185
|
+
raise "You must supply at least one package to test" if packages.empty?
|
186
|
+
|
187
|
+
packages.each do |package|
|
188
|
+
p = Package.new :path => package
|
189
|
+
p.valid?
|
190
|
+
p.run_script :script => :test,
|
191
|
+
:dry_run => options[:"dry-run"],
|
192
|
+
:disable_logging => options[:"disable-log"],
|
193
|
+
:log_name => options[:"log-name"],
|
194
|
+
:suppress_stdout => options[:"suppress-stdout"],
|
195
|
+
:force => options[:"force"]
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
desc "Build software"
|
202
|
+
long_desc "The software to build may be either the absolute path or the full name of the software. The full name includes version numbers and build names using the format: NAME/VERSION/BUILD."
|
203
|
+
arg_name "PATH"
|
204
|
+
command ['build'] do |c|
|
205
|
+
c.desc 'Build log file name located within the software prefix.'
|
206
|
+
c.arg_name 'FILE'
|
207
|
+
c.default_value 'build.log'
|
208
|
+
c.flag ["log-name"]
|
209
|
+
|
210
|
+
c.desc "Disable logging"
|
211
|
+
c.switch ["disable-log"], :negatable => false
|
212
|
+
|
213
|
+
c.desc 'Suppress messages from STDOUT.'
|
214
|
+
c.switch [:s, "suppress-stdout"], :negatable => false
|
215
|
+
|
216
|
+
c.desc 'Ignore .lock file and run anyway'
|
217
|
+
c.switch [:f, "force"], :negatable => false
|
218
|
+
|
219
|
+
c.desc 'See what scripts will be run without running them'
|
220
|
+
c.switch [:n, "dry-run"], :negatable => false
|
221
|
+
|
222
|
+
c.action do |global_options,options,args|
|
223
|
+
packages = args.dup
|
224
|
+
if args.empty?
|
225
|
+
notice "Reading package names from STDIN..."
|
226
|
+
packages = STDIN.readlines.map{|p| p.chomp}
|
227
|
+
end
|
228
|
+
|
229
|
+
raise "You must supply at least one package to build" if packages.empty?
|
230
|
+
|
231
|
+
packages.each do |package|
|
232
|
+
p = Package.new :path => package
|
233
|
+
p.valid?
|
234
|
+
p.run_script :script => :build,
|
235
|
+
:dry_run => options[:"dry-run"],
|
236
|
+
:disable_logging => options[:"disable-log"],
|
237
|
+
:log_name => options[:"log-name"],
|
238
|
+
:suppress_stdout => options[:"suppress-stdout"],
|
239
|
+
:force => options[:"force"]
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
desc "Generate a new build and all necessary files"
|
245
|
+
long_desc <<-EOS
|
246
|
+
The new command will create all necessary files needed to add a new software package. Some care should be given to naming new packages. Some considerations are package names, version numbers, and build names. New package names should be of the format NAME/VERSION/BUILD
|
247
|
+
|
248
|
+
- NAME of the package should be all lower case and one word. If multiple words are necessary separate them with dashes '-'.
|
249
|
+
|
250
|
+
- VERSION numbers should be standard numbers separated by periods. If another format is necessary ensure that the numbers can be lexigraphically sorted in order of oldest release to newest.
|
251
|
+
|
252
|
+
- BUILD names should consist of two pieces of information separated by an underscore '_', the package's intended operating system and compiler.
|
253
|
+
|
254
|
+
EXAMPLES:
|
255
|
+
|
256
|
+
silo/4.8/sles11.1_gnu4.5.3
|
257
|
+
fftw/3.2.2/cle4.0_pgi11.10.0
|
258
|
+
EOS
|
259
|
+
arg_name "NAME"
|
260
|
+
command ['new'] do |c|
|
261
|
+
c.desc "Create description file for website"
|
262
|
+
c.switch ["web-description"], :negatable => false
|
263
|
+
|
264
|
+
c.desc "See what files will be created when running new without creating them"
|
265
|
+
c.switch [:n, "dry-run"], :negatable => false
|
266
|
+
|
267
|
+
c.desc "Skip modulefile generation"
|
268
|
+
c.switch ["skip-modulefile"], :negatable => false
|
269
|
+
|
270
|
+
c.desc "Provide a tarball to unpack, either a file or URL (optional)"
|
271
|
+
c.arg_name "FILE|URL"
|
272
|
+
c.flag [:t, :tarball]
|
273
|
+
c.action do |global_options,options,args|
|
274
|
+
raise "You must supply a name to create new packages" if args.empty?
|
275
|
+
|
276
|
+
p = Package.new :path => args.first
|
277
|
+
|
278
|
+
p.valid?
|
279
|
+
|
280
|
+
if options[:tarball] =~ URI::ABS_URI
|
281
|
+
url = options[:tarball]
|
282
|
+
elsif options[:tarball]
|
283
|
+
archive = File.absolute_path options[:tarball]
|
284
|
+
raise "The archive #{archive} does not exist" unless File.exists? archive
|
285
|
+
end
|
286
|
+
p.create :dry_run => options[:"dry-run"],
|
287
|
+
:web => options[:"web-description"]
|
288
|
+
|
289
|
+
if options[:tarball]
|
290
|
+
downloaded = p.download(url) if url
|
291
|
+
archive = downloaded if downloaded
|
292
|
+
p.extract :archive => archive, :dry_run => options[:"dry-run"]
|
293
|
+
end
|
294
|
+
|
295
|
+
unless options[:"skip-modulefile"]
|
296
|
+
m = ModuleFile.new :package => p
|
297
|
+
m.create :dry_run => options[:"dry-run"]
|
298
|
+
end
|
299
|
+
|
300
|
+
notice "Next Steps"
|
301
|
+
notice_command " smithy edit last" , "Edit build scripts or modulefile"
|
302
|
+
notice_command " smithy build last" , "Run build script"
|
303
|
+
notice_command " smithy module create" , "Generate a modulefile" if options[:"skip-modulefile"]
|
304
|
+
notice_command " smithy module deploy last" , "Install modulefile"
|
305
|
+
notice_command " smithy publish last" , "Publish web description"
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
desc "Edit package support files"
|
310
|
+
arg_name "build|test|env|modulefile NAME"
|
311
|
+
command ['edit'] do |c|
|
312
|
+
c.desc "Editor for opening script files"
|
313
|
+
c.arg_name "BINARY"
|
314
|
+
c.flag [:e, :editor]
|
315
|
+
|
316
|
+
c.desc "Split editing window with requested file and the environment (remodule) file"
|
317
|
+
c.switch [:s, :split], :negatable => false
|
318
|
+
|
319
|
+
c.action do |global_options,options,args|
|
320
|
+
operations = [:build, :environment, :modulefile, :test, :config]
|
321
|
+
arguments = args.dup
|
322
|
+
operation = nil
|
323
|
+
operations.each do |o|
|
324
|
+
if arguments.include? o.to_s
|
325
|
+
operation = o
|
326
|
+
arguments.delete o.to_s
|
327
|
+
break
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
raise "You must supply a package name to edit" if arguments.empty?
|
332
|
+
|
333
|
+
if operation == :config
|
334
|
+
file_name = @smithy_config_file
|
335
|
+
status = Kernel::system(editor, file_name)
|
336
|
+
else
|
337
|
+
p = Package.new :path => arguments.first
|
338
|
+
p.valid?
|
339
|
+
p.prefix_exists!
|
340
|
+
p.rebuild_script_exists!
|
341
|
+
|
342
|
+
# if no file, prompt
|
343
|
+
if operation.nil?
|
344
|
+
puts "Edit which file? (default is build)"
|
345
|
+
width = 25
|
346
|
+
notice_command "(b)uild", p.rebuild_script, width
|
347
|
+
notice_command "(e)nvironment", p.remodule_script, width
|
348
|
+
notice_command "(m)odulefile", ModuleFile.new(:package => p).module_file, width
|
349
|
+
notice_command "(t)est", p.retest_script, width
|
350
|
+
|
351
|
+
while operation.nil? do
|
352
|
+
prompt = Readline.readline("> ")
|
353
|
+
prompt.downcase!
|
354
|
+
|
355
|
+
if prompt =~ /(1|b|build)/
|
356
|
+
operation = :build
|
357
|
+
elsif prompt =~ /(2|e|environment)/
|
358
|
+
operation = :environment
|
359
|
+
elsif prompt =~ /(3|m|modulefile)/
|
360
|
+
operation = :modulefile
|
361
|
+
elsif prompt =~ /(4|t|test)/
|
362
|
+
operation = :test
|
363
|
+
else
|
364
|
+
operation = :build
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
file_names = []
|
370
|
+
case operation
|
371
|
+
when :build
|
372
|
+
file_names << p.rebuild_script
|
373
|
+
when :test
|
374
|
+
file_names << p.retest_script
|
375
|
+
when :environment
|
376
|
+
file_names << p.remodule_script
|
377
|
+
when :modulefile
|
378
|
+
file_names << ModuleFile.new(:package => p).module_file
|
379
|
+
else
|
380
|
+
file_names << p.rebuild_script
|
381
|
+
end
|
382
|
+
|
383
|
+
case operation
|
384
|
+
when :build || :test
|
385
|
+
file_names << p.remodule_script if options[:split]
|
386
|
+
end
|
387
|
+
|
388
|
+
launch_editor :editor => options[:editor],
|
389
|
+
:split => options[:split],
|
390
|
+
:files => file_names
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
desc "Repair a package"
|
396
|
+
long_desc "Repair permissions and check that files exist"
|
397
|
+
arg_name "NAME"
|
398
|
+
command ['repair'] do |c|
|
399
|
+
c.desc "Verify permissions only"
|
400
|
+
c.switch [:n, "dry-run"], :negatable => false
|
401
|
+
|
402
|
+
c.action do |global_options,options,args|
|
403
|
+
packages = args.dup
|
404
|
+
if args.empty?
|
405
|
+
notice "Reading package names from STDIN..."
|
406
|
+
packages = STDIN.readlines.map{|p| p.chomp}
|
407
|
+
end
|
408
|
+
|
409
|
+
raise "You must supply at least one package to repair" if packages.empty?
|
410
|
+
|
411
|
+
packages.each do |package|
|
412
|
+
p = Package.new :path => package
|
413
|
+
p.valid?
|
414
|
+
p.repair :dry_run => options[:"dry-run"]
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
desc "Publish packages to web"
|
420
|
+
arg_name "NAME"
|
421
|
+
command ['publish'] do |c|
|
422
|
+
c.desc "See what files will be created without creating them"
|
423
|
+
c.switch [:n, "dry-run"], :negatable => false
|
424
|
+
|
425
|
+
c.action do |global_options,options,args|
|
426
|
+
www_root = Smithy::Config.web_root
|
427
|
+
raise """Cannot determine where to publish web descriptions.\n Please add a 'web-root: PATH' entry to the smithy config file.""" if www_root.nil?
|
428
|
+
|
429
|
+
packages = args.dup
|
430
|
+
if args.empty?
|
431
|
+
notice "Reading package names from STDIN..."
|
432
|
+
packages = STDIN.readlines.map{|p| p.chomp}
|
433
|
+
end
|
434
|
+
|
435
|
+
raise "You must supply at least one package to publish" if packages.empty?
|
436
|
+
|
437
|
+
packages = Package.all_web if packages.include?("all")
|
438
|
+
|
439
|
+
notice "Publishing #{packages.size} package#{'s' if packages.size>1}#{' (dry-run)' if options[:"dry-run"]}"
|
440
|
+
|
441
|
+
descriptions = []
|
442
|
+
|
443
|
+
packages.each do |package|
|
444
|
+
d = Description.new :package => package
|
445
|
+
if d.valid? && d.publishable?
|
446
|
+
d.deploy :dry_run => options[:"dry-run"]
|
447
|
+
descriptions << d
|
448
|
+
else
|
449
|
+
notice_fail "Flagged for no publishing, remove 'noweb' from #{d.exceptions_file} and re-publish."
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
["alphabetical","all"].each do |p|
|
454
|
+
Description.update_page p,
|
455
|
+
:descriptions => descriptions,
|
456
|
+
:dry_run => options[:"dry-run"]
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
|
462
|
+
desc "Manage modulefiles for a package"
|
463
|
+
arg_name "NAME"
|
464
|
+
command ['module'] do |c|
|
465
|
+
c.desc "See what files will be created without creating them"
|
466
|
+
c.switch [:n, "dry-run"], :negatable => false
|
467
|
+
|
468
|
+
c.desc "Run the proper module command to add a package's modulefile to the MODULEPATH. This allows you to edit and test a modulefile in isolation. By adding the correct directory to MODULEPATH you may run module commands as you normally would."
|
469
|
+
c.command :use do |use|
|
470
|
+
use.action do |global_options,options,args|
|
471
|
+
raise "You must supply a package name" if args.empty?
|
472
|
+
p = Package.new :path => args.first
|
473
|
+
p.valid?
|
474
|
+
m = ModuleFile.new :package => p
|
475
|
+
|
476
|
+
mp = m.module_path
|
477
|
+
if Dir.exist?(mp)
|
478
|
+
puts "module use #{mp}"
|
479
|
+
else
|
480
|
+
raise "No modulefiles found in #{mp}"
|
481
|
+
end
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
c.desc "Generate a modulefile for a given package. This operation normally happens after creating a new package. It is provided separately here for use with existing packages."
|
486
|
+
c.command :create do |create|
|
487
|
+
create.action do |global_options,options,args|
|
488
|
+
raise "You must supply a package name" if args.empty?
|
489
|
+
p = Package.new :path => args.first
|
490
|
+
p.valid?
|
491
|
+
m = ModuleFile.new :package => p
|
492
|
+
|
493
|
+
m.create :dry_run => options[:"dry-run"]
|
494
|
+
notice "Next Steps"
|
495
|
+
notice_command " smithy edit modulefile last" , "Edit generated modulefile"
|
496
|
+
notice_command " smithy module deploy last" , "Install modulefile"
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
c.desc "Copy a package's modulefile to the system module path. This is typically done after you have tested a new module in isolation."
|
501
|
+
c.command :deploy do |deploy|
|
502
|
+
deploy.action do |global_options,options,args|
|
503
|
+
raise "You must supply a package name" if args.empty?
|
504
|
+
p = Package.new :path => args.first
|
505
|
+
p.valid?
|
506
|
+
m = ModuleFile.new :package => p
|
507
|
+
|
508
|
+
m.deploy :dry_run => options[:"dry-run"]
|
509
|
+
end
|
510
|
+
end
|
511
|
+
|
512
|
+
c.desc "alias for 'smithy edit modulefile'"
|
513
|
+
c.command :edit do |edit|
|
514
|
+
edit.action do |global_options,options,args|
|
515
|
+
raise "You must supply a package name" if args.empty?
|
516
|
+
p = Package.new :path => args.first
|
517
|
+
p.valid?
|
518
|
+
m = ModuleFile.new :package => p
|
519
|
+
|
520
|
+
launch_editor :files => [m.module_file]
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
524
|
+
end
|
525
|
+
|
526
|
+
desc "Display internal smithy values"
|
527
|
+
command ['show'] do |c|
|
528
|
+
c.desc "Display the package name used in the last smithy command. This is stored in the '~/.smithyrc' file."
|
529
|
+
c.command :last do |last|
|
530
|
+
last.action do
|
531
|
+
puts Smithy::Config.last_prefix
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
c.desc "List all architectures know to smithy."
|
536
|
+
c.command :arch do |arch|
|
537
|
+
arch.action do
|
538
|
+
Smithy::Config.architectures
|
539
|
+
end
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
# command ['publish_cray'] do |c|
|
544
|
+
# c.desc "See what files will be created without creating them"
|
545
|
+
# c.switch [:n, "dry-run"], :negatable => false
|
546
|
+
|
547
|
+
# c.desc "Exclude directories specified in $MODULEPATH"
|
548
|
+
# c.flag [:except]
|
549
|
+
|
550
|
+
# c.desc "Parse given directories only, $MODULEPATH is not checked"
|
551
|
+
# c.flag [:only]
|
552
|
+
|
553
|
+
# c.action do |global_options,options,args|
|
554
|
+
# packages, default_names = ModuleFile.get_module_names(options)
|
555
|
+
# Package.create_stubs_from_modules(packages, default_names, options)
|
556
|
+
# end
|
557
|
+
# end
|
558
|
+
|
559
|
+
pre do |global,command,options,args|
|
560
|
+
# ap global #XXX
|
561
|
+
Sickill::Rainbow.enabled = false if global[:"colors"] == false
|
562
|
+
|
563
|
+
Smithy::Config.config_file_name = File.join(@@smithy_bin_root,"etc/smithyrc")
|
564
|
+
Smithy::Config.load_configuration(global)
|
565
|
+
|
566
|
+
# Pre logic here
|
567
|
+
# Return true to proceed; false to abort and not call the chosen command
|
568
|
+
# Use skips_pre before a command to skip this block on that command only
|
569
|
+
true
|
570
|
+
end
|
571
|
+
|
572
|
+
post do |global,command,options,args|
|
573
|
+
# Post logic here
|
574
|
+
# Use skips_post before a command to skip this
|
575
|
+
# block on that command only
|
576
|
+
end
|
577
|
+
|
578
|
+
on_error do |exception|
|
579
|
+
# Error logic here
|
580
|
+
# return false to skip default error handling
|
581
|
+
true
|
582
|
+
end
|
583
|
+
|
584
|
+
exit run(ARGV)
|
585
|
+
|
586
|
+
# vim: ft=ruby
|