software_smithy 1.1 → 1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/smithy +140 -33
- data/etc/completion/smithy-completion.bash +106 -7
- data/etc/completion/zsh/_smithy +121 -27
- data/etc/templates/formula.rb.erb +11 -0
- data/etc/templates/web/machine_version_table.html.erb +0 -7
- data/etc/templates/web/version_table.html.erb +2 -2
- data/lib/smithy/config.rb +70 -13
- data/lib/smithy/description.rb +4 -4
- data/lib/smithy/download_cache.rb +120 -0
- data/lib/smithy/file_operations.rb +13 -6
- data/lib/smithy/formula.rb +203 -0
- data/lib/smithy/formula_command.rb +198 -0
- data/lib/smithy/helpers.rb +83 -37
- data/lib/smithy/module_file.rb +21 -10
- data/lib/smithy/package.rb +111 -86
- data/lib/smithy.rb +3 -0
- data/lib/smithy_version.rb +1 -1
- data/man/man1/smithy.1 +240 -53
- data/smithy.rdoc +107 -7
- metadata +84 -39
- data/README.rdoc +0 -114
- data/etc/smithyrc +0 -36
data/lib/smithy/helpers.rb
CHANGED
@@ -35,61 +35,41 @@
|
|
35
35
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36
36
|
# }}}
|
37
37
|
|
38
|
-
# try and blank? methods borrowed from rails
|
39
|
-
# See: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/try.rb
|
40
|
-
class Object
|
41
|
-
def try(method, *args, &block)
|
42
|
-
send(method, *args, &block)
|
43
|
-
end
|
44
|
-
remove_method :try
|
45
|
-
alias_method :try, :__send__
|
46
|
-
|
47
|
-
def blank?
|
48
|
-
respond_to?(:empty?) ? empty? : !self
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class NilClass #:nodoc:
|
53
|
-
def try(*args)
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
|
57
|
-
def blank?
|
58
|
-
true
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
38
|
module Smithy
|
63
39
|
def notice(message)
|
64
|
-
STDOUT.puts "==> ".color(:blue).bright+message.bright if STDOUT.tty?
|
40
|
+
STDOUT.puts "==> ".color(:blue).bright+message.bright #if STDOUT.tty?
|
65
41
|
end
|
66
42
|
|
67
43
|
def notice_warn(message)
|
68
|
-
STDOUT.puts ("==> "+message).color(:yellow) if STDOUT.tty?
|
44
|
+
STDOUT.puts ("==> "+message).color(:yellow) #if STDOUT.tty?
|
69
45
|
end
|
70
46
|
|
71
47
|
def notice_info(message)
|
72
|
-
STDOUT.puts (message).color(:blue) if STDOUT.tty?
|
48
|
+
STDOUT.puts (message).color(:blue) #if STDOUT.tty?
|
73
49
|
end
|
74
50
|
|
75
51
|
def notice_command(command, comment, width=40)
|
76
|
-
STDOUT.puts command.bright.ljust(width)+comment.color(:blue) if STDOUT.tty?
|
52
|
+
STDOUT.puts command.bright.ljust(width)+comment.color(:blue) #if STDOUT.tty?
|
77
53
|
end
|
78
54
|
|
79
55
|
def notice_success(message)
|
80
|
-
if STDOUT.tty?
|
81
|
-
STDOUT.puts
|
82
|
-
else
|
83
|
-
|
84
|
-
end
|
56
|
+
# if STDOUT.tty?
|
57
|
+
STDOUT.puts "==> ".color(:green).bright + message.color(:green)
|
58
|
+
# else
|
59
|
+
# STDOUT.puts message
|
60
|
+
# end
|
85
61
|
end
|
86
62
|
|
87
63
|
def notice_fail(message)
|
88
|
-
if STDOUT.tty?
|
64
|
+
# if STDOUT.tty?
|
89
65
|
STDOUT.puts ("==> "+message).color(:red)
|
90
|
-
else
|
91
|
-
|
92
|
-
end
|
66
|
+
# else
|
67
|
+
# STDOUT.puts message
|
68
|
+
# end
|
69
|
+
end
|
70
|
+
|
71
|
+
def notice_exception(message)
|
72
|
+
STDERR.puts "==> ERROR: ".color(:red).bright + message
|
93
73
|
end
|
94
74
|
|
95
75
|
def process_ouput(stdout, stderr, suppress_stdout = false, log_file = nil)
|
@@ -156,4 +136,70 @@ module Smithy
|
|
156
136
|
# end
|
157
137
|
end
|
158
138
|
|
139
|
+
def operating_system
|
140
|
+
b = `uname -m`.chomp
|
141
|
+
redhat = "/etc/redhat-release"
|
142
|
+
suse = "/etc/SuSE-release"
|
143
|
+
if File.exists? redhat
|
144
|
+
# Red Hat Enterprise Linux Server release 6.3 (Santiago)
|
145
|
+
# CentOS release 5.9 (Final)
|
146
|
+
content = File.read(redhat)
|
147
|
+
content =~ /([\d\.]+)/
|
148
|
+
version = $1
|
149
|
+
b = "rhel" if content =~ /Red Hat/
|
150
|
+
b = "centos" if content =~ /CentOS/
|
151
|
+
b += version
|
152
|
+
elsif File.exists? suse
|
153
|
+
# SUSE Linux Enterprise Server 11 (x86_64)
|
154
|
+
# VERSION = 11
|
155
|
+
# PATCHLEVEL = 1
|
156
|
+
content = File.read(suse)
|
157
|
+
content =~ /VERSION = (\d+)/
|
158
|
+
version = $1
|
159
|
+
content =~ /PATCHLEVEL = (\d+)/
|
160
|
+
patch = $1
|
161
|
+
b = "sles#{version}.#{patch}"
|
162
|
+
end
|
163
|
+
|
164
|
+
if `gcc --version` =~ /gcc \((.*)\) ([\d\.]+)/
|
165
|
+
b << "_gnu#{$2}"
|
166
|
+
end
|
167
|
+
return b
|
168
|
+
end
|
169
|
+
|
170
|
+
def url_filename(url)
|
171
|
+
File.basename(URI(url).path)
|
172
|
+
end
|
173
|
+
|
174
|
+
def url_filename_version_number(url)
|
175
|
+
version = url_filename(url)
|
176
|
+
version = $1 if version =~ /([\d\.]+[\d])/
|
177
|
+
version
|
178
|
+
end
|
179
|
+
|
180
|
+
def url_filename_basename(url)
|
181
|
+
name = url_filename(url)
|
182
|
+
name = $1 if name =~ /(.*?)-([\d\.]+[\d])/
|
183
|
+
name
|
184
|
+
end
|
185
|
+
|
186
|
+
def log_exception(e, argv, config)
|
187
|
+
logfile = Smithy::Config.global[:"global-error-log"]
|
188
|
+
if logfile.present?
|
189
|
+
exception = {
|
190
|
+
"time" => DateTime.now,
|
191
|
+
"user" => `whoami`.chomp,
|
192
|
+
"hostname" => `hostname`.chomp,
|
193
|
+
"working_dir" => Dir.getwd,
|
194
|
+
"argv" => argv,
|
195
|
+
"config" => config,
|
196
|
+
"exception" => e,
|
197
|
+
"backtrace" => e.backtrace
|
198
|
+
}
|
199
|
+
File.open(logfile, "a") do |f|
|
200
|
+
f.write(exception.to_yaml)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
159
205
|
end
|
data/lib/smithy/module_file.rb
CHANGED
@@ -54,6 +54,10 @@ module Smithy
|
|
54
54
|
]
|
55
55
|
#{:prg_env => "PrgEnv-pathscale", :compiler_name => "pathscale", :human_name => "pathscale", :regex => /(pathscale)(.*)/}
|
56
56
|
|
57
|
+
def self.compilers
|
58
|
+
Smithy::Config.compilers || Environments
|
59
|
+
end
|
60
|
+
|
57
61
|
def initialize(args = {})
|
58
62
|
@package = args[:package]
|
59
63
|
@builds = @package.alternate_builds
|
@@ -88,9 +92,14 @@ module Smithy
|
|
88
92
|
|
89
93
|
FileUtils.mkdir_p(File.join(module_path, package.name), options)
|
90
94
|
|
91
|
-
|
92
|
-
|
93
|
-
|
95
|
+
if args[:existing]
|
96
|
+
existing_modulefile = File.join(args[:existing], "../modulefile", package.name, package.version)
|
97
|
+
FileOperations.install_file(existing_modulefile, module_file, options) if File.exists?(existing_modulefile)
|
98
|
+
else
|
99
|
+
FileOperations.render_erb :destination => module_file,
|
100
|
+
:erb => File.join(@@smithy_bin_root, "/etc/templates/modulefile.erb"),
|
101
|
+
:binding => get_binding, :options => options
|
102
|
+
end
|
94
103
|
|
95
104
|
FileOperations.make_group_writable(module_path, options.merge(:recursive => true))
|
96
105
|
FileOperations.set_group(module_path, package.group, options.merge(:recursive => true))
|
@@ -123,9 +132,11 @@ module Smithy
|
|
123
132
|
|
124
133
|
def module_build_list(package, builds, args = {})
|
125
134
|
output = ""
|
126
|
-
|
127
|
-
|
128
|
-
|
135
|
+
|
136
|
+
|
137
|
+
notice "Multiple Builds Found" if Smithy::Config.global[:verbose]
|
138
|
+
notice_info "Build Name".rjust(25)+" Required Modules" if Smithy::Config.global[:verbose]
|
139
|
+
ModuleFile::compilers.each_with_index do |e,i|
|
129
140
|
if i == 0
|
130
141
|
output << "if "
|
131
142
|
else
|
@@ -146,14 +157,14 @@ module Smithy
|
|
146
157
|
end
|
147
158
|
output << "[ is-loaded #{name}/#{version} ] {\n"
|
148
159
|
output << " set BUILD #{b}\n"
|
149
|
-
notice_info b.rjust(25) + " #{e[:prg_env]} + #{name}/#{version}"
|
160
|
+
notice_info b.rjust(25) + " #{e[:prg_env]} + #{name}/#{version}" if Smithy::Config.global[:verbose]
|
150
161
|
end
|
151
162
|
output << " } else {\n"
|
152
163
|
output << " set BUILD #{sub_builds.last}\n"
|
153
164
|
output << " }\n"
|
154
165
|
else
|
155
166
|
output << " set BUILD #{builds[j]}\n"
|
156
|
-
notice_info builds[j].rjust(25) + " #{e[:prg_env]}"
|
167
|
+
notice_info builds[j].rjust(25) + " #{e[:prg_env]}" if Smithy::Config.global[:verbose]
|
157
168
|
end
|
158
169
|
else
|
159
170
|
output << " puts stderr \"Not implemented for the #{e[:human_name]} compiler\"\n"
|
@@ -214,8 +225,8 @@ module Smithy
|
|
214
225
|
system_module_defaults += module_files_defaults
|
215
226
|
end
|
216
227
|
|
217
|
-
|
218
|
-
|
228
|
+
# desired_modules = %w{ ^cce ^pgi ^intel ^gcc ^hdf5 ^netcdf ^fftw ^petsc ^trilinos ^chapel ^java ^ntk ^papi ^stat ^gdb ^perftools ^tpsl ^ga\/ ^libsci_acc ^acml }
|
229
|
+
# stub_packages = system_module_names.select{|m| m =~ /(#{desired_modules.join('|')})/}
|
219
230
|
|
220
231
|
return system_module_names, system_module_defaults
|
221
232
|
end
|
data/lib/smithy/package.rb
CHANGED
@@ -40,19 +40,15 @@ module Smithy
|
|
40
40
|
attr_accessor :arch, :root, :name, :version, :build_name
|
41
41
|
attr_accessor :group
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
p.gsub! /\/?#{root}\/?/, ''
|
54
|
-
p.gsub! /\/?#{arch}\/?/, ''
|
55
|
-
return p
|
43
|
+
def self.normalize_name(name)
|
44
|
+
name = Dir.pwd if name == "."
|
45
|
+
name_split = name.split('/')
|
46
|
+
name_version_build = []
|
47
|
+
name_version_build << name_split[-3]
|
48
|
+
name_version_build << name_split[-2]
|
49
|
+
name_version_build << name_split[-1]
|
50
|
+
name_version_build.compact!
|
51
|
+
return File.join(name_version_build)
|
56
52
|
end
|
57
53
|
|
58
54
|
def initialize(args = {})
|
@@ -62,7 +58,7 @@ module Smithy
|
|
62
58
|
if args[:path].try(:downcase) == 'last'
|
63
59
|
@path = Smithy::Config.last_prefix
|
64
60
|
else
|
65
|
-
@path = Package.normalize_name(
|
61
|
+
@path = Package.normalize_name(args[:path])
|
66
62
|
end
|
67
63
|
@path =~ /(.*)\/(.*)\/(.*)$/
|
68
64
|
@name = $1
|
@@ -70,7 +66,8 @@ module Smithy
|
|
70
66
|
@build_name = $3
|
71
67
|
@group = Smithy::Config.file_group
|
72
68
|
|
73
|
-
@
|
69
|
+
@group_writable = Smithy::Config.group_writable?
|
70
|
+
@group_writable = args[:group_writable] if args.has_key?(:group_writable)
|
74
71
|
end
|
75
72
|
|
76
73
|
def get_binding
|
@@ -108,18 +105,24 @@ module Smithy
|
|
108
105
|
BuildFileERBs = [
|
109
106
|
BuildFileNames[:env] ]
|
110
107
|
|
111
|
-
def build_support_files
|
108
|
+
def build_support_files(alternate_source)
|
112
109
|
file_list = []
|
113
110
|
BuildFileNames.each do |name, file|
|
114
111
|
src = File.join(@@smithy_bin_root, "etc/templates/build", file)
|
115
112
|
src += ".erb" if BuildFileERBs.include?(file)
|
113
|
+
|
114
|
+
if alternate_source && Dir.exists?(alternate_source)
|
115
|
+
alt_src = File.join(alternate_source, file)
|
116
|
+
src = alt_src if File.exists? alt_src
|
117
|
+
end
|
118
|
+
|
116
119
|
file_list << { :name => name, :src => src, :dest => File.join(prefix, file) }
|
117
120
|
end
|
118
121
|
return file_list
|
119
122
|
end
|
120
123
|
|
121
|
-
def
|
122
|
-
@
|
124
|
+
def group_writable?
|
125
|
+
@group_writable
|
123
126
|
end
|
124
127
|
|
125
128
|
def valid?
|
@@ -131,7 +134,7 @@ module Smithy
|
|
131
134
|
|
132
135
|
# If good, save as last prefix
|
133
136
|
Smithy::Config.save_last_prefix(qualified_name)
|
134
|
-
|
137
|
+
return true
|
135
138
|
end
|
136
139
|
|
137
140
|
def qualified_name
|
@@ -148,6 +151,10 @@ module Smithy
|
|
148
151
|
raise "The package #{prefix} does not exist!" unless prefix_exists?
|
149
152
|
end
|
150
153
|
|
154
|
+
def source_directory
|
155
|
+
File.join(prefix,"source")
|
156
|
+
end
|
157
|
+
|
151
158
|
def rebuild_script
|
152
159
|
File.join(prefix, BuildFileNames[:build])
|
153
160
|
end
|
@@ -205,7 +212,7 @@ module Smithy
|
|
205
212
|
else
|
206
213
|
FileUtils.touch(lock_file)
|
207
214
|
FileOperations.set_group(lock_file, group)
|
208
|
-
FileOperations.make_group_writable(lock_file) if
|
215
|
+
FileOperations.make_group_writable(lock_file) if group_writable?
|
209
216
|
return true
|
210
217
|
end
|
211
218
|
end
|
@@ -214,6 +221,23 @@ module Smithy
|
|
214
221
|
FileUtils.rm_f(lock_file)
|
215
222
|
end
|
216
223
|
|
224
|
+
def valid_build_file
|
225
|
+
File.join(prefix, ".valid")
|
226
|
+
end
|
227
|
+
|
228
|
+
def create_valid_build_file
|
229
|
+
unless File.exists? valid_build_file
|
230
|
+
FileUtils.touch(valid_build_file)
|
231
|
+
FileOperations.set_group(valid_build_file, group)
|
232
|
+
FileOperations.make_group_writable(valid_build_file) if group_writable?
|
233
|
+
return true
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def delete_valid_build_file
|
238
|
+
FileUtils.rm_f(valid_build_file)
|
239
|
+
end
|
240
|
+
|
217
241
|
def run_script(args ={})
|
218
242
|
case args[:script]
|
219
243
|
when :build
|
@@ -239,7 +263,7 @@ module Smithy
|
|
239
263
|
log_file = File.open(log_file_path, 'w') unless args[:dry_run]
|
240
264
|
|
241
265
|
FileOperations.set_group(log_file, group)
|
242
|
-
FileOperations.make_group_writable(log_file) if
|
266
|
+
FileOperations.make_group_writable(log_file) if group_writable?
|
243
267
|
end
|
244
268
|
if args[:dry_run] || log_file != nil
|
245
269
|
notice "Logging to #{log_file_path}"
|
@@ -281,11 +305,7 @@ module Smithy
|
|
281
305
|
|
282
306
|
case args[:script]
|
283
307
|
when :build
|
284
|
-
if exit_status == 0
|
285
|
-
notice "Setting permissions on installed files"
|
286
|
-
FileOperations.set_group prefix, @group, :recursive => true
|
287
|
-
FileOperations.make_group_writable prefix, :recursive => true if group_writeable?
|
288
|
-
end
|
308
|
+
set_file_permissions_recursive if exit_status == 0
|
289
309
|
when :test
|
290
310
|
end
|
291
311
|
|
@@ -293,47 +313,26 @@ module Smithy
|
|
293
313
|
end
|
294
314
|
end
|
295
315
|
|
296
|
-
def
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
downloaded_tarball = "#{prefix}/#{File.basename(URI(url).path)}"
|
302
|
-
if File.exist?(downloaded_tarball)
|
303
|
-
puts "downloaded ".rjust(12).color(:green).bright + downloaded_tarball
|
304
|
-
return downloaded_tarball
|
305
|
-
else
|
306
|
-
puts "download ".rjust(12).color(:green).bright + url
|
307
|
-
end
|
308
|
-
|
309
|
-
args = ['-qf#L']
|
310
|
-
args << "--silent" unless $stdout.tty?
|
311
|
-
args << '-o'
|
312
|
-
args << downloaded_tarball
|
313
|
-
args << url
|
314
|
-
|
315
|
-
if system(curl, *args)
|
316
|
-
FileOperations.set_group(downloaded_tarball, group)
|
317
|
-
FileOperations.make_group_writable(downloaded_tarball) if group_writeable?
|
318
|
-
return downloaded_tarball
|
319
|
-
else
|
320
|
-
return false
|
316
|
+
def set_file_permissions_recursive
|
317
|
+
if group_writable?
|
318
|
+
notice "Setting permissions on installed files"
|
319
|
+
FileOperations.set_group prefix, @group, :recursive => true
|
320
|
+
FileOperations.make_group_writable prefix, :recursive => true if group_writable?
|
321
321
|
end
|
322
322
|
end
|
323
323
|
|
324
324
|
def extract(args = {})
|
325
325
|
archive = args[:archive]
|
326
326
|
temp_dir = File.join(prefix,"tmp")
|
327
|
-
source_dir = File.join(prefix,"source")
|
328
327
|
|
329
|
-
notice "Extracting
|
328
|
+
notice "Extracting to #{source_directory}"
|
330
329
|
|
331
330
|
return if args[:dry_run]
|
332
331
|
|
333
|
-
overwrite =
|
334
|
-
overwrite =
|
335
|
-
if File.exists?(
|
336
|
-
while overwrite
|
332
|
+
overwrite = Smithy::Config.global.try(:[], :force) ? true : "unknown"
|
333
|
+
overwrite = true if args[:overwrite]
|
334
|
+
if File.exists?(source_directory)
|
335
|
+
while overwrite == "unknown" do
|
337
336
|
prompt = Readline.readline(" "*FILE_NOTICE_COLUMNS+"Overwrite? (enter \"h\" for help) [ynh] ")
|
338
337
|
case prompt.downcase
|
339
338
|
when "y"
|
@@ -355,7 +354,7 @@ module Smithy
|
|
355
354
|
|
356
355
|
if overwrite
|
357
356
|
FileUtils.rm_rf temp_dir
|
358
|
-
FileUtils.rm_rf
|
357
|
+
FileUtils.rm_rf source_directory
|
359
358
|
FileUtils.mkdir temp_dir
|
360
359
|
FileUtils.cd temp_dir
|
361
360
|
|
@@ -372,17 +371,33 @@ module Smithy
|
|
372
371
|
|
373
372
|
extracted_files = Dir.glob('*')
|
374
373
|
if extracted_files.count == 1
|
375
|
-
FileUtils.mv extracted_files.first,
|
374
|
+
FileUtils.mv extracted_files.first, source_directory
|
376
375
|
else
|
377
376
|
FileUtils.cd prefix
|
378
|
-
FileUtils.mv temp_dir,
|
377
|
+
FileUtils.mv temp_dir, source_directory
|
379
378
|
end
|
380
379
|
|
381
380
|
FileUtils.rm_rf temp_dir
|
382
381
|
|
383
|
-
FileOperations.set_group
|
384
|
-
FileOperations.make_group_writable
|
382
|
+
FileOperations.set_group source_directory, @group, :recursive => true
|
383
|
+
FileOperations.make_group_writable source_directory, :recursive => true if group_writable?
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
def update_version_table_file(options)
|
388
|
+
version_table_file = File.join(application_directory, ".versions")
|
389
|
+
version_table = YAML.load_file(version_table_file).stringify_keys rescue {}
|
390
|
+
if version_table[version].is_a? String
|
391
|
+
version_table[version] = [ build_name.encode('UTF-8') ]
|
392
|
+
elsif version_table[version].is_a? Array
|
393
|
+
version_table[version] << build_name.encode('UTF-8') unless version_table[version].include?(build_name.encode('UTF-8'))
|
394
|
+
else
|
395
|
+
version_table.merge!({version.encode('UTF-8') => build_name.encode('UTF-8')})
|
385
396
|
end
|
397
|
+
|
398
|
+
FileOperations.install_from_string version_table.to_yaml, version_table_file, options.merge({:force => true})
|
399
|
+
FileOperations.set_group version_table_file, group, options
|
400
|
+
FileOperations.make_group_writable version_table_file, options if group_writable?
|
386
401
|
end
|
387
402
|
|
388
403
|
def create(args = {})
|
@@ -395,27 +410,26 @@ module Smithy
|
|
395
410
|
[application_directory].each do |dir|
|
396
411
|
FileOperations.make_directory dir, options
|
397
412
|
FileOperations.set_group dir, group, options
|
398
|
-
FileOperations.make_group_writable dir, options if
|
413
|
+
FileOperations.make_group_writable dir, options if group_writable?
|
399
414
|
end
|
400
415
|
|
401
|
-
|
402
|
-
version_table = YAML.load_file(version_table_file).stringify_keys rescue {}
|
403
|
-
version_table.merge!({version => build_name})
|
404
|
-
|
405
|
-
FileOperations.install_from_string version_table.to_yaml, version_table_file, options.merge({:force => true})
|
406
|
-
FileOperations.set_group version_table_file, group, options
|
407
|
-
FileOperations.make_group_writable version_table_file, options if group_writeable?
|
416
|
+
update_version_table_file(options)
|
408
417
|
else
|
409
418
|
|
410
419
|
directories.each do |dir|
|
411
420
|
#if dir == prefix
|
412
421
|
FileOperations.make_directory dir, options
|
413
422
|
FileOperations.set_group dir, group, options
|
414
|
-
FileOperations.make_group_writable dir, options if
|
423
|
+
FileOperations.make_group_writable dir, options if group_writable?
|
415
424
|
#end
|
416
425
|
end
|
417
426
|
|
418
|
-
|
427
|
+
if args[:formula]
|
428
|
+
update_version_table_file(options)
|
429
|
+
return
|
430
|
+
end
|
431
|
+
|
432
|
+
all_files = build_support_files(args[:existing])
|
419
433
|
all_files = package_support_files + all_files if args[:web] || args[:stub]
|
420
434
|
|
421
435
|
all_files.each do |file|
|
@@ -433,7 +447,7 @@ module Smithy
|
|
433
447
|
end
|
434
448
|
|
435
449
|
FileOperations.set_group file[:dest], group, options
|
436
|
-
FileOperations.make_group_writable file[:dest], options if
|
450
|
+
FileOperations.make_group_writable file[:dest], options if group_writable?
|
437
451
|
FileOperations.make_executable file[:dest], options if file[:dest] =~ /(#{ExecutableBuildFileNames.join('|')})/
|
438
452
|
end
|
439
453
|
|
@@ -442,7 +456,7 @@ module Smithy
|
|
442
456
|
|
443
457
|
def module_load_prgenv
|
444
458
|
output = ""
|
445
|
-
ModuleFile::
|
459
|
+
ModuleFile::compilers.each do |e|
|
446
460
|
if build_name =~ e[:regex]
|
447
461
|
output = "module load #{e[:prg_env]}"
|
448
462
|
break
|
@@ -486,7 +500,7 @@ module Smithy
|
|
486
500
|
if missing_package.include?(file[:name])
|
487
501
|
FileOperations.install_file file[:src], file[:dest], options
|
488
502
|
FileOperations.set_group file[:dest], group, options
|
489
|
-
FileOperations.make_group_writable file[:dest], options if
|
503
|
+
FileOperations.make_group_writable file[:dest], options if group_writable?
|
490
504
|
end
|
491
505
|
end
|
492
506
|
end
|
@@ -496,7 +510,7 @@ module Smithy
|
|
496
510
|
if missing_build.include?(file[:name])
|
497
511
|
FileOperations.install_file file[:src], file[:dest], options
|
498
512
|
FileOperations.set_group file[:dest], group, options
|
499
|
-
FileOperations.make_group_writable file[:dest], options if
|
513
|
+
FileOperations.make_group_writable file[:dest], options if group_writable?
|
500
514
|
end
|
501
515
|
end
|
502
516
|
end
|
@@ -504,11 +518,11 @@ module Smithy
|
|
504
518
|
notice "Setting permissions for #{prefix}"
|
505
519
|
|
506
520
|
FileOperations.set_group prefix, group, options.merge(:recursive => true)
|
507
|
-
FileOperations.make_group_writable prefix, options.merge(:recursive => true) if
|
521
|
+
FileOperations.make_group_writable prefix, options.merge(:recursive => true) if group_writable?
|
508
522
|
|
509
523
|
[version_directory, application_directory].each do |dir|
|
510
524
|
FileOperations.set_group dir, group, options
|
511
|
-
FileOperations.make_group_writable dir, options if
|
525
|
+
FileOperations.make_group_writable dir, options if group_writable?
|
512
526
|
end
|
513
527
|
end
|
514
528
|
|
@@ -527,7 +541,7 @@ module Smithy
|
|
527
541
|
|
528
542
|
stubbed_builds = YAML.load_file(File.join(File.dirname(version_directory), ".versions")).stringify_keys rescue {}
|
529
543
|
if stubbed_builds[version]
|
530
|
-
if stubbed_builds[version].
|
544
|
+
if stubbed_builds[version].is_a? String
|
531
545
|
builds += [ stubbed_builds[version] ]
|
532
546
|
else
|
533
547
|
builds += stubbed_builds[version]
|
@@ -560,12 +574,23 @@ module Smithy
|
|
560
574
|
Description.publishable?(application_directory)
|
561
575
|
end
|
562
576
|
|
577
|
+
def self.search(query = '')
|
578
|
+
Package.all.select{|s| s =~ /#{query}/}
|
579
|
+
end
|
580
|
+
|
581
|
+
def self.search_by_name(name)
|
582
|
+
Package.all(:name => name)
|
583
|
+
end
|
584
|
+
|
563
585
|
def self.all(args = {})
|
586
|
+
name = args[:name] || '*'
|
587
|
+
version = args[:version] || '*'
|
588
|
+
build = args[:build] || '*'
|
564
589
|
# Array of full paths to rebuild scripts
|
565
|
-
software =
|
590
|
+
software = Dir.glob(Smithy::Config.full_root+"/#{name}/#{version}/#{build}/#{BuildFileNames[:build]}")
|
591
|
+
software += Dir.glob(Smithy::Config.full_root+"/#{name}/#{version}/#{build}/.valid")
|
566
592
|
# Remove rebuild from each path
|
567
|
-
software.collect!{|s| s.gsub(
|
568
|
-
#TODO allow sorting?
|
593
|
+
software.collect!{|s| s.gsub(/\/(#{BuildFileNames[:build]}|\.valid)$/, '')}
|
569
594
|
software.sort!
|
570
595
|
end
|
571
596
|
|
@@ -582,15 +607,15 @@ module Smithy
|
|
582
607
|
software.reject! do |s|
|
583
608
|
! Description.publishable?(s)
|
584
609
|
end
|
585
|
-
|
610
|
+
software.sort!
|
586
611
|
return software
|
587
612
|
end
|
588
613
|
|
589
614
|
def self.create_stubs_from_modules(stub_packages, system_module_defaults, options = {})
|
590
615
|
notice "Generating stubs for the following modules:"
|
591
616
|
Format.print_column_list(stub_packages)
|
592
|
-
proceed =
|
593
|
-
while proceed
|
617
|
+
proceed = "no"
|
618
|
+
while proceed == "no" do
|
594
619
|
prompt = Readline.readline("Generate the above packages? [yn] ")
|
595
620
|
case prompt.downcase
|
596
621
|
when "y"
|
@@ -639,7 +664,7 @@ The following information is available by running `module help #{name}`
|
|
639
664
|
ops = {:noop => options[:"dry-run"] ? true : false}
|
640
665
|
FileOperations.install_from_string(help_content, help_dest, ops)
|
641
666
|
FileOperations.set_group help_dest, p.group, ops
|
642
|
-
FileOperations.make_group_writable help_dest, ops if p.
|
667
|
+
FileOperations.make_group_writable help_dest, ops if p.group_writable?
|
643
668
|
end
|
644
669
|
end
|
645
670
|
|