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
@@ -0,0 +1,224 @@
|
|
1
|
+
# Smithy is freely available under the terms of the BSD license given below. {{{
|
2
|
+
#
|
3
|
+
# Copyright (c) 2012. UT-BATTELLE, LLC. All rights reserved.
|
4
|
+
#
|
5
|
+
# Produced by the National Center for Computational Sciences at Oak Ridge
|
6
|
+
# National Laboratory. Smithy is a based on SWTools, more information on SWTools
|
7
|
+
# can be found at: http://www.olcf.ornl.gov/center-projects/swtools/
|
8
|
+
#
|
9
|
+
# This product includes software produced by UT-Battelle, LLC under Contract No.
|
10
|
+
# DE-AC05-00OR22725 with the Department of Energy.
|
11
|
+
#
|
12
|
+
# Redistribution and use in source and binary forms, with or without
|
13
|
+
# modification, are permitted provided that the following conditions are met:
|
14
|
+
#
|
15
|
+
# - Redistributions of source code must retain the above copyright notice, this
|
16
|
+
# list of conditions and the following disclaimer.
|
17
|
+
#
|
18
|
+
# - Redistributions in binary form must reproduce the above copyright notice, this
|
19
|
+
# list of conditions and the following disclaimer in the documentation and/or
|
20
|
+
# other materials provided with the distribution.
|
21
|
+
#
|
22
|
+
# - Neither the name of the UT-BATTELLE nor the names of its contributors may
|
23
|
+
# be used to endorse or promote products derived from this software without
|
24
|
+
# specific prior written permission.
|
25
|
+
#
|
26
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
27
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
28
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
29
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
30
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
31
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
32
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
33
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
34
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
35
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36
|
+
# }}}
|
37
|
+
|
38
|
+
module Smithy
|
39
|
+
class ModuleFile
|
40
|
+
attr_accessor :package, :builds
|
41
|
+
|
42
|
+
PackageModulePathName = "modulefile"
|
43
|
+
SystemModulePathName = "modulefiles"
|
44
|
+
|
45
|
+
Environments = [
|
46
|
+
{:prg_env => "PrgEnv-gnu", :compiler_name => "gcc", :human_name => "gnu", :regex => /(gnu|gcc)(.*)/,
|
47
|
+
:build_name_regex => /(gnu|gcc)([\d\.]+)/ },
|
48
|
+
{:prg_env => "PrgEnv-pgi", :compiler_name => "pgi", :human_name => "pgi", :regex => /(pgi)(.*)/,
|
49
|
+
:build_name_regex => /(pgi)([\d\.]+)/ },
|
50
|
+
{:prg_env => "PrgEnv-intel", :compiler_name => "intel", :human_name => "intel", :regex => /(intel)(.*)/,
|
51
|
+
:build_name_regex => /(intel)([\d\.]+)/ },
|
52
|
+
{:prg_env => "PrgEnv-cray", :compiler_name => "cce", :human_name => "cray", :regex => /(cce|cray)(.*)/,
|
53
|
+
:build_name_regex => /(cce|cray)([\d\.]+)/ }
|
54
|
+
]
|
55
|
+
#{:prg_env => "PrgEnv-pathscale", :compiler_name => "pathscale", :human_name => "pathscale", :regex => /(pathscale)(.*)/}
|
56
|
+
|
57
|
+
def initialize(args = {})
|
58
|
+
@package = args[:package]
|
59
|
+
@builds = @package.alternate_builds
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_binding
|
63
|
+
binding
|
64
|
+
end
|
65
|
+
|
66
|
+
def module_path
|
67
|
+
File.join(package.version_directory, PackageModulePathName)
|
68
|
+
end
|
69
|
+
|
70
|
+
def module_file
|
71
|
+
File.join(module_path, package.name, package.version)
|
72
|
+
end
|
73
|
+
|
74
|
+
def system_module_path
|
75
|
+
File.join(package.software_root, SystemModulePathName)
|
76
|
+
end
|
77
|
+
|
78
|
+
def system_module_file
|
79
|
+
File.join(system_module_path, package.name, package.version)
|
80
|
+
end
|
81
|
+
|
82
|
+
def create(args = {})
|
83
|
+
notice "Creating Modulefile for #{package.prefix}"
|
84
|
+
notice_warn "Dry Run! (no files will be created or changed)" if args[:dry_run]
|
85
|
+
|
86
|
+
options = {:noop => false, :verbose => false}
|
87
|
+
options[:noop] = true if args[:dry_run]
|
88
|
+
|
89
|
+
FileUtils.mkdir_p(File.join(module_path, package.name), options)
|
90
|
+
|
91
|
+
FileOperations.render_erb :destination => module_file,
|
92
|
+
:erb => File.join(@@smithy_bin_root, "/etc/templates/modulefile.erb"),
|
93
|
+
:binding => get_binding, :options => options
|
94
|
+
|
95
|
+
FileOperations.make_group_writable(module_path, options.merge(:recursive => true))
|
96
|
+
FileOperations.set_group(module_path, package.group, options.merge(:recursive => true))
|
97
|
+
end
|
98
|
+
|
99
|
+
def deploy(args = {})
|
100
|
+
options = {:noop => false, :verbose => false}
|
101
|
+
options[:noop] = true if args[:dry_run]
|
102
|
+
|
103
|
+
g = system_module_path+"/*#{package.name}*/*#{package.version}*"
|
104
|
+
module_matches = Dir.glob(g)
|
105
|
+
if module_matches.size > 1
|
106
|
+
notice_warn "Warning - multiple existing modulefiles found:"
|
107
|
+
puts module_matches
|
108
|
+
end
|
109
|
+
|
110
|
+
if module_matches.empty?
|
111
|
+
destination = system_module_file
|
112
|
+
else
|
113
|
+
destination = module_matches.first
|
114
|
+
end
|
115
|
+
|
116
|
+
notice "Deploying modulefile #{destination}"
|
117
|
+
install_dir = File.join(system_module_path, package.name)
|
118
|
+
FileOperations.make_directory install_dir, options
|
119
|
+
FileOperations.install_file module_file, destination, options
|
120
|
+
FileOperations.make_group_writable(install_dir, options.merge(:recursive => true))
|
121
|
+
FileOperations.set_group(install_dir, package.group, options.merge(:recursive => true))
|
122
|
+
end
|
123
|
+
|
124
|
+
def module_build_list(package, builds, args = {})
|
125
|
+
output = ""
|
126
|
+
notice "Multiple Builds Found"
|
127
|
+
notice_info "Build Name".rjust(25)+" Required Modules"
|
128
|
+
Environments.each_with_index do |e,i|
|
129
|
+
if i == 0
|
130
|
+
output << "if "
|
131
|
+
else
|
132
|
+
output << "} elseif "
|
133
|
+
end
|
134
|
+
output << "[ is-loaded #{e[:prg_env]} ] {\n"
|
135
|
+
if j=builds.index{|b|b=~e[:regex]}
|
136
|
+
sub_builds = builds.select{|b|b=~e[:regex]}
|
137
|
+
if sub_builds.size > 1
|
138
|
+
sub_builds.each_with_index do |b,k|
|
139
|
+
b =~ e[:build_name_regex]
|
140
|
+
name = e[:compiler_name]
|
141
|
+
version = $2
|
142
|
+
if k == 0
|
143
|
+
output << " if "
|
144
|
+
else
|
145
|
+
output << " } elseif "
|
146
|
+
end
|
147
|
+
output << "[ is-loaded #{name}/#{version} ] {\n"
|
148
|
+
output << " set BUILD #{b}\n"
|
149
|
+
notice_info b.rjust(25) + " #{e[:prg_env]} + #{name}/#{version}"
|
150
|
+
end
|
151
|
+
output << " } else {\n"
|
152
|
+
output << " set BUILD #{sub_builds.last}\n"
|
153
|
+
output << " }\n"
|
154
|
+
else
|
155
|
+
output << " set BUILD #{builds[j]}\n"
|
156
|
+
notice_info builds[j].rjust(25) + " #{e[:prg_env]}"
|
157
|
+
end
|
158
|
+
else
|
159
|
+
output << " puts stderr \"Not implemented for the #{e[:human_name]} compiler\"\n"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
output << "}\n"
|
164
|
+
output << "if {![info exists BUILD]} {\n"
|
165
|
+
output << " puts stderr \"[module-info name] is only available for the following environments:\"\n"
|
166
|
+
builds.each do |build|
|
167
|
+
output << " puts stderr \"#{build}\"\n"
|
168
|
+
end
|
169
|
+
output << " break\n}\n"
|
170
|
+
|
171
|
+
return output
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.get_module_names(options = {})
|
175
|
+
if options[:only]
|
176
|
+
module_dirs = options[:only].split(':')
|
177
|
+
raise "No module directories could be found" if module_dirs.empty?
|
178
|
+
else
|
179
|
+
raise "$MODULEPATH is not set" unless ENV.has_key?('MODULEPATH')
|
180
|
+
module_dirs = ENV['MODULEPATH'].split(':')
|
181
|
+
raise "$MODULEPATH is empty" if module_dirs.empty?
|
182
|
+
end
|
183
|
+
|
184
|
+
system_module_names = []
|
185
|
+
system_module_defaults = []
|
186
|
+
if options[:except]
|
187
|
+
module_dirs.delete_if{|p| options[:except].split(":").include?(p)}
|
188
|
+
end
|
189
|
+
module_dirs.each do |p|
|
190
|
+
module_files = Dir.glob(p+"/*/*").sort
|
191
|
+
module_files_defaults = module_files.dup
|
192
|
+
version_files = Dir.glob(p+"/*/.version").sort
|
193
|
+
|
194
|
+
version_files.each do |version_file|
|
195
|
+
module_name = File.basename(File.dirname(version_file))
|
196
|
+
file_content = ""
|
197
|
+
File.open(version_file).readlines.each { |line| file_content << line.chomp }
|
198
|
+
|
199
|
+
if file_content =~ /ModulesVersion "(.*?)"/
|
200
|
+
version = $1
|
201
|
+
module_files_defaults.collect! do |m|
|
202
|
+
if m =~ /#{module_name}\/#{version}$/
|
203
|
+
m+"(default)"
|
204
|
+
else
|
205
|
+
m
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
module_files.collect!{|s| s.gsub(p+"/", '')}
|
213
|
+
system_module_names += module_files
|
214
|
+
system_module_defaults += module_files_defaults
|
215
|
+
end
|
216
|
+
|
217
|
+
# desired_modules = %w{ ^cce ^pgi ^intel ^gcc ^hdf5 ^netcdf ^fftw ^petsc ^trilinos ^chapel ^java ^ntk ^papi ^stat ^gdb ^perftools ^tpsl ^ga\/ ^libsci_acc ^acml }
|
218
|
+
# stub_packages = system_module_names.select{|m| m =~ /(#{desired_modules.join('|')})/}
|
219
|
+
|
220
|
+
return system_module_names, system_module_defaults
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
end
|