software_smithy 1.6.2 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/smithy CHANGED
@@ -43,6 +43,7 @@ $: << File.expand_path(@@smithy_bin_root + '/lib')
43
43
 
44
44
  require 'English'
45
45
  require 'fileutils'
46
+ require 'etc'
46
47
 
47
48
  require 'rubygems'
48
49
  require 'open4'
@@ -57,7 +58,7 @@ require 'active_support/core_ext/string'
57
58
  require 'active_support/inflector'
58
59
 
59
60
  # require 'debugger' #XXX
60
- # require 'awesome_print' #XXX
61
+ # require 'pp' #XXX
61
62
  # require 'pry'
62
63
  # require 'pry-doc'
63
64
 
@@ -1,8 +1,8 @@
1
1
  #compdef smithy
2
2
 
3
3
  _smithy_packages() {
4
- cache_file=$HOME/.smithy/completion_packages
5
- if [[ -e $cache_file ]]
4
+ cache_file=$HOME/.smithy/completion_packages
5
+ if [[ -e $cache_file ]]
6
6
  then
7
7
  packages=(`cat $cache_file`)
8
8
  else
@@ -13,7 +13,7 @@ _smithy_packages() {
13
13
 
14
14
  _smithy_formulas() {
15
15
  cache_file=$HOME/.smithy/completion_formulas
16
- if [[ -e $cache_file ]]
16
+ if [[ -e $cache_file ]]
17
17
  then
18
18
  formulas=(`cat $cache_file`)
19
19
  else
@@ -24,7 +24,7 @@ _smithy_formulas() {
24
24
 
25
25
  _smithy_architectures() {
26
26
  cache_file=$HOME/.smithy/completion_arches
27
- if [[ -e $cache_file ]]
27
+ if [[ -e $cache_file ]]
28
28
  then
29
29
  arches=(`cat $cache_file`)
30
30
  else
@@ -219,7 +219,7 @@ case "$words[1]" in
219
219
  [[ "$PREFIX" = -* ]] && _arguments \
220
220
  '(--clean)--clean[clean existing install prefix]' \
221
221
  '(--no-clean)--no-clean[leave existing install prefix files intact]' \
222
- '(-f --formula-name)'{-f,--formula-name}'[Formula name]' \
222
+ '(-f --formula-name=)'{-f,--formula-name=}'[Formula name]:formula:_smithy_formulas' \
223
223
  '(-m --modulefile)'{-m,--modulefile}'[Create modulefiles as well]' \
224
224
  '1: :->subcmds' && return 0
225
225
  _smithy_formulas
@@ -230,6 +230,12 @@ case "$words[1]" in
230
230
  display)
231
231
  _smithy_formulas
232
232
  ;;
233
+ new)
234
+ [[ "$PREFIX" = -* ]] && _arguments \
235
+ '(-h --homepage=)'{-h,--homepage=}'[Formula homepage]' \
236
+ '(-n --name=)'{-n,--name=}'[Formula name]' \
237
+ '1: :->subcmds' && return 0
238
+ ;;
233
239
  esac
234
240
 
235
241
  return
data/lib/smithy/config.rb CHANGED
@@ -161,8 +161,13 @@ module Smithy
161
161
  return s
162
162
  end
163
163
 
164
+ def homedir
165
+ @homedir ||= File.join(Dir.home(Etc.getlogin))
166
+ @homedir
167
+ end
168
+
164
169
  def last_prefix
165
- rc_file = File.join(ENV['HOME'], '.smithyrc')
170
+ rc_file = File.join(homedir, '.smithyrc')
166
171
  if File.exists?(rc_file)
167
172
  h = YAML.load_file(rc_file).stringify_keys rescue nil
168
173
  return h["last"]
@@ -172,7 +177,7 @@ module Smithy
172
177
  end
173
178
 
174
179
  def save_last_prefix(prefix)
175
- rc_file = File.join(ENV['HOME'], '.smithyrc')
180
+ rc_file = File.join(homedir, '.smithyrc')
176
181
  h = {:last => prefix.encode('UTF-8')}
177
182
  File.open(rc_file, "w+") do |f|
178
183
  f.write(h.to_yaml)
@@ -185,15 +190,15 @@ module Smithy
185
190
  formulas = FormulaCommand.formula_names
186
191
  packages = Package.all.collect{|s| s.gsub(/#{full_root}\//, '')}
187
192
 
188
- FileUtils.mkdir_p(File.join(ENV["HOME"], ".smithy"))
193
+ FileUtils.mkdir_p(File.join(homedir, ".smithy"))
189
194
 
190
- File.open(File.join(ENV["HOME"], ".smithy", "completion_formulas"), "w+") do |f|
195
+ File.open(File.join(homedir, ".smithy", "completion_formulas"), "w+") do |f|
191
196
  f.puts formulas
192
197
  end
193
- File.open(File.join(ENV["HOME"], ".smithy", "completion_packages"), "w+") do |f|
198
+ File.open(File.join(homedir, ".smithy", "completion_packages"), "w+") do |f|
194
199
  f.puts packages
195
200
  end
196
- File.open(File.join(ENV["HOME"], ".smithy", "completion_arches"), "w+") do |f|
201
+ File.open(File.join(homedir, ".smithy", "completion_arches"), "w+") do |f|
197
202
  f.puts @config_file_hash["hostname-architectures"].values.uniq.sort
198
203
  end
199
204
  end
@@ -22,7 +22,7 @@ module Smithy
22
22
 
23
23
  def download_cache_dir
24
24
  dir = Smithy::Config.global[:"download-cache"]
25
- dir = File.join(ENV['HOME'], '.smithy/cache') if dir.blank?
25
+ dir = File.join(Smithy::Config.homedir, '.smithy/cache') if dir.blank?
26
26
  dir
27
27
  end
28
28
 
@@ -197,7 +197,7 @@ module Smithy
197
197
 
198
198
  def install_from_string(content, dest, options = {})
199
199
  if options[:noop]
200
- updated_file = File.join(ENV["HOME"]+"/.smithy_#{File.basename(dest)}_#{Time.now.to_i}")
200
+ updated_file = File.join(Smithy::Config.homedir+"/.smithy_#{File.basename(dest)}_#{Time.now.to_i}")
201
201
  else
202
202
  updated_file = File.join(File.dirname(dest), ".#{File.basename(dest)}_#{Time.now.to_i}")
203
203
  end
@@ -218,7 +218,7 @@ module Smithy
218
218
  dest = args[:destination]
219
219
 
220
220
  if options[:noop]
221
- rendered_file = ENV["HOME"]+"/.#{File.basename(dest)}_#{Time.now.to_i}"
221
+ rendered_file = Smithy::Config.homedir+"/.#{File.basename(dest)}_#{Time.now.to_i}"
222
222
  else
223
223
  rendered_file = "#{File.dirname(dest)}/.#{File.basename(dest)}_#{Time.now.to_i}"
224
224
  end
@@ -30,6 +30,7 @@ module Smithy
30
30
  @module_commands = nil # re-evaluate module_commands block
31
31
  @module_setup = ""
32
32
  raise "please specify modules OR modules_command, not both" if modules.present? && module_commands.present?
33
+ raise "module_commands method must return an array" if module_commands.present? && module_commands.class != Array
33
34
  if ENV["MODULESHOME"]
34
35
  @modulecmd = "modulecmd sh"
35
36
  @modulecmd = "#{ENV["MODULESHOME"]}/bin/modulecmd sh" if File.exists?("#{ENV["MODULESHOME"]}/bin/modulecmd")
@@ -108,8 +109,8 @@ module Smithy
108
109
  m = ModuleFile.new :package => package
109
110
  FileUtils.mkdir_p(File.dirname(m.module_file))
110
111
  FileOperations.render_erb(:erb_string => modulefile, :binding => m.get_binding, :destination => m.module_file)
111
- FileOperations.make_group_writable(m.module_file)
112
- FileOperations.set_group(m.module_file, package.group)
112
+ FileOperations.make_group_writable(m.module_path, :recursive => true)
113
+ FileOperations.set_group(m.module_path, package.group, :recursive => true)
113
114
  return true
114
115
  end
115
116
 
@@ -131,9 +132,9 @@ module Smithy
131
132
  end
132
133
 
133
134
  def module_environment_variable(mod, var)
134
- module_display = `#{@modulecmd} display #{mod} 2>&1`
135
+ module_display = `#{module_setup} #{@modulecmd} display #{mod} 2>&1`
135
136
  if module_display =~ /(\S+)\s+#{var}\s+(.*)$/
136
- return $2
137
+ return $2.strip
137
138
  else
138
139
  return ""
139
140
  end
@@ -7,7 +7,7 @@ module Smithy
7
7
  # 3. smithy's built in formulas
8
8
  def self.formula_directories
9
9
  unless @formula_directories
10
- @formula_directories = [ File.join(ENV["HOME"], ".smithy/formulas") ]
10
+ @formula_directories = [ File.join(Smithy::Config.homedir, ".smithy/formulas") ]
11
11
  if Smithy::Config.global[:"formula-directories"]
12
12
  Smithy::Config.global[:"formula-directories"].reverse.each do |dir|
13
13
  @formula_directories << dir
@@ -81,15 +81,16 @@ module Smithy
81
81
  raise "unknown formula #{formula_name}" unless formula_names.include?(formula_name)
82
82
 
83
83
  require formula_file_path(formula_name)
84
- f = "#{formula_name.underscore.camelize}Formula".constantize.new
84
+
85
+ formula_class = "#{formula_name.underscore.camelize}Formula".constantize
86
+ version = formula_class.version if version.blank?
87
+ build = operating_system if build.blank?
88
+ p = Package.new :path => [name, version, build].join("/"), :group_writable => !formula_class.disable_group_writable
89
+
90
+ f = "#{formula_name.underscore.camelize}Formula".constantize.new(p)
85
91
  # Set the actual formula file path, otherwise it's just formula.rb
86
92
  f.formula_file = formula_file_path(formula_name)
87
93
 
88
- version = f.version if version.blank?
89
- build = operating_system if build.blank?
90
- p = Package.new :path => [name, version, build].join("/"), :group_writable => f.group_writable?
91
- f.set_package(p) if p.valid?
92
-
93
94
  return f
94
95
  end
95
96
 
@@ -165,7 +166,7 @@ module Smithy
165
166
  @formula_homepage = options[:homepage]
166
167
  @formula_homepage = "#{URI(@formula_url).scheme}://#{URI(@formula_url).host}/" unless options[:homepage]
167
168
 
168
- destination = File.join(ENV["HOME"], ".smithy/formulas")
169
+ destination = File.join(Smithy::Config.homedir, ".smithy/formulas")
169
170
  destination = Smithy::Config.global[:"formula-directories"].first if Smithy::Config.global[:"formula-directories"]
170
171
  FileUtils::mkdir_p(destination)
171
172
 
@@ -133,10 +133,13 @@ module Smithy
133
133
  def module_build_list(package, builds, args = {})
134
134
  output = ""
135
135
 
136
-
137
136
  notice "Multiple Builds Found" if Smithy::Config.global[:verbose]
138
137
  notice_info "Build Name".rjust(25)+" Required Modules" if Smithy::Config.global[:verbose]
139
138
  ModuleFile::compilers.each_with_index do |e,i|
139
+
140
+ prgenv = e[:prg_env]
141
+ prgenv.gsub!(/PrgEnv-/, args.fetch(:prgenv_prefix)) if args[:prgenv_prefix]
142
+
140
143
  if i == 0
141
144
  output << "if "
142
145
  else
@@ -36,5 +36,5 @@
36
36
  # }}}
37
37
 
38
38
  module Smithy
39
- VERSION = '1.6.2'
39
+ VERSION = '1.6.3'
40
40
  end
data/smithy.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  == smithy - Smithy will help you build, test, and install software with ease.
2
2
 
3
- v1.6.2
3
+ v1.6.3
4
4
 
5
5
  === Global Options
6
6
  === --arch NAME
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: software_smithy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-28 00:00:00.000000000 Z
12
+ date: 2013-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: awesome_print
@@ -336,7 +336,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
336
336
  version: '0'
337
337
  segments:
338
338
  - 0
339
- hash: -1093726032562910331
339
+ hash: -3602502256992475544
340
340
  required_rubygems_version: !ruby/object:Gem::Requirement
341
341
  none: false
342
342
  requirements:
@@ -345,7 +345,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
345
345
  version: '0'
346
346
  segments:
347
347
  - 0
348
- hash: -1093726032562910331
348
+ hash: -3602502256992475544
349
349
  requirements: []
350
350
  rubyforge_project:
351
351
  rubygems_version: 1.8.23