software_smithy 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/README.rdoc +114 -0
  2. data/bin/smithy +586 -0
  3. data/etc/completion/smithy-completion.bash +266 -0
  4. data/etc/completion/zsh/_smithy +130 -0
  5. data/etc/smithyrc +36 -0
  6. data/etc/templates/build/.owners +1 -0
  7. data/etc/templates/build/build-notes +0 -0
  8. data/etc/templates/build/dependencies +0 -0
  9. data/etc/templates/build/rebuild +13 -0
  10. data/etc/templates/build/relink +2 -0
  11. data/etc/templates/build/remodule.erb +21 -0
  12. data/etc/templates/build/retest +6 -0
  13. data/etc/templates/build/status +0 -0
  14. data/etc/templates/modulefile.erb +30 -0
  15. data/etc/templates/package/.check4newver +2 -0
  16. data/etc/templates/package/.exceptions +3 -0
  17. data/etc/templates/package/description +18 -0
  18. data/etc/templates/package/description.markdown +17 -0
  19. data/etc/templates/package/support +1 -0
  20. data/etc/templates/package/versions +3 -0
  21. data/etc/templates/web/all.html.erb +19 -0
  22. data/etc/templates/web/alphabetical.html.erb +12 -0
  23. data/etc/templates/web/category.html.erb +74 -0
  24. data/etc/templates/web/machine_version_table.html.erb +35 -0
  25. data/etc/templates/web/package.html.erb +53 -0
  26. data/etc/templates/web/version_list.html.erb +7 -0
  27. data/etc/templates/web/version_table.html.erb +24 -0
  28. data/lib/smithy/config.rb +167 -0
  29. data/lib/smithy/description.rb +276 -0
  30. data/lib/smithy/file_operations.rb +234 -0
  31. data/lib/smithy/format.rb +134 -0
  32. data/lib/smithy/helpers.rb +159 -0
  33. data/lib/smithy/module_file.rb +224 -0
  34. data/lib/smithy/package.rb +647 -0
  35. data/lib/smithy.rb +45 -0
  36. data/lib/smithy_version.rb +40 -0
  37. data/man/man1/smithy.1 +262 -0
  38. data/smithy.rdoc +281 -0
  39. metadata +230 -0
@@ -0,0 +1,35 @@
1
+ <h2>Available Versions</h2>
2
+
3
+ <table class="kb-table kb-table-bordered">
4
+ <thead>
5
+ <tr>
6
+ <td style="text-align:center;"><b>System</b></td>
7
+ <td style="text-align:center;"><b>Application/Version</b></td>
8
+ <td style="text-align:center;"><b>Build</b></td>
9
+ <!-- <%# ModuleFile::Environments.reject{|e| e[:human_name]=="pathscale"}.each do |e| %> -->
10
+ <!-- <td style="text-align:center;"> -->
11
+ <!-- <b> -->
12
+ <!-- <%#= e[:human_name].upcase %> -->
13
+ <!-- </b> -->
14
+ <!-- </td> -->
15
+ <!-- <%# end %> -->
16
+ </tr>
17
+ </thead>
18
+
19
+ <tbody>
20
+ <% @machine_table.each do |machine, version_table| %>
21
+ <% version_table.each do |version, builds| %>
22
+ <% builds.each do |build| %>
23
+ <tr>
24
+ <td style="text-align:center;"><%= machine.humanize %></td>
25
+ <td style="text-align:center;"><%= "#{@name}/#{version}" %></td>
26
+ <td style="text-align:center;"><%= build %></td>
27
+ </tr>
28
+ <% end %>
29
+ <% end %>
30
+ <% end %>
31
+ </tbody>
32
+ </table>
33
+
34
+
35
+
@@ -0,0 +1,53 @@
1
+ <h1>Git</h1>
2
+
3
+ <p> Category: Program Dev-Tools
4
+
5
+ <h2>Description</h2>
6
+
7
+ <p> <a href="http://git.or.cz/">Git</a> is an open source version
8
+ control system designed to handle very large projects with speed and
9
+ efficiency, but just as well suited for small personal repositories;
10
+ it is especially popular in the open source community, serving as a
11
+ development platform for projects like the Linux Kernel, Ruby on
12
+ Rails, WINE or X.org.
13
+
14
+ <p>Git falls in the category of distributed source code management tools,
15
+ similar to e.g. Mercurial or Bazaar. Every Git working directory is a
16
+ full-fledged repository with complete history and full revision
17
+ tracking capabilities, not dependent on network access or a central
18
+ server. Still, Git stays extremely fast and space efficient.
19
+
20
+ <h2>Use</h2>
21
+
22
+ <pre>
23
+ module avail git
24
+ module load git
25
+ git
26
+ </pre>
27
+
28
+
29
+ <h2>Support</h2><p>This package has the following support level : Unsupported
30
+ <br>
31
+ <h2>Available Versions</h2>
32
+
33
+ <table class="inline">
34
+ <tr>
35
+ <th rowspan = "2">Version</th>
36
+ <th colspan = "6">Available Builds</th> </tr><tr>
37
+ <th>pgi</th>
38
+ <th>pathscale</th>
39
+ <th>gnu</th>
40
+ <th>intel</th>
41
+ <th>cray</th>
42
+ <th>Other</th>
43
+ <tr>
44
+ <th>1.7.8</th>
45
+ <td></td>
46
+ <td></td>
47
+ <td><table class="inline"><tr><td class="hidden">gnu4.3.4</td><td class="hidden2">?</td></tr></table></td>
48
+ <td></td>
49
+ <td></td>
50
+ <td><table class="inline"></table></td>
51
+ </tr>
52
+
53
+ </table>
@@ -0,0 +1,7 @@
1
+ <h2>Available Versions</h2>
2
+
3
+ <ul>
4
+ <% @version_table.each do |version, builds| %>
5
+ <li><%= "#{@name}/#{version}" %></li>
6
+ <% end %>
7
+ </ul>
@@ -0,0 +1,24 @@
1
+ <h2>Available Versions</h2>
2
+
3
+ Checkmarks indicate a given version is available for the compiler specified in each column.
4
+
5
+ <table class="kb-table kb-table-bordered">
6
+ <thead>
7
+ <tr>
8
+ <td style="text-align:center;"><b>Version</b></td>
9
+ <% ModuleFile::Environments.reject{|e| e[:human_name]=="pathscale"}.each do |e| %>
10
+ <td style="text-align:center;"><b><%= e[:human_name].upcase %></b></td>
11
+ <% end %>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <% @version_table.each do |version, builds| %>
16
+ <tr>
17
+ <td style="text-align:center;"><b><%= "#{@name}/#{version}" %></b></td>
18
+ <% ModuleFile::Environments.reject{|e| e[:human_name]=="pathscale"}.each do |e| %>
19
+ <td style="text-align:center;"><% if builds.select{|b|b=~e[:regex]}.size > 0 %><img width="23" height="18" style="margin:0;" title="checkmark" alt="" src="http://www.olcf.ornl.gov/wp-content/uploads/2011/03/checkmark.png"><% end %></td>
20
+ <% end %>
21
+ </tr>
22
+ <% end %>
23
+ </tbody>
24
+ </table>
@@ -0,0 +1,167 @@
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 Config
40
+ class << self
41
+ attr_accessor :config_file_name, :config_file_hash, :global, :hostname,
42
+ :arch, :root, :full_root, :web_root, :file_group, :descriptions_root,
43
+ :web_architecture_names
44
+
45
+ def group_writeable?
46
+ @global[:"disable-group-writable"] ? false : true
47
+ end
48
+
49
+ def load_configuration(gli_options = {})
50
+ @global = gli_options
51
+ options_to_merge = {}
52
+ load_config_yaml
53
+
54
+ return nil unless @config_file_hash
55
+
56
+ # Pick some values from the config file
57
+ options_to_merge[:"software-root"] = @config_file_hash.try(:[], "software-root")
58
+ options_to_merge[:"web-root"] = @config_file_hash.try(:[], "web-root")
59
+ options_to_merge[:"file-group-name"] = @config_file_hash.try(:[], "file-group-name")
60
+ options_to_merge[:"descriptions-root"] = @config_file_hash.try(:[], "descriptions-root")
61
+ options_to_merge[:"web-architecture-names"] = @config_file_hash.try(:[], "web-architecture-names")
62
+
63
+ set_hostname_and_arch
64
+ options_to_merge[:arch] = @arch
65
+ options_to_merge[:"prgenv-prefix"] = get_prgenv_prefix
66
+
67
+ # Merge the config file values with command line values,
68
+ # options on the command line take precedence.
69
+ @global.merge!(options_to_merge) do |key, values_command_line, values_config|
70
+ if values_command_line.nil?
71
+ values_config
72
+ else
73
+ values_command_line
74
+ end
75
+ end
76
+
77
+ @arch = @global[:arch]
78
+ @root = @global[:"software-root"]
79
+ @file_group = @global[:"file-group-name"]
80
+ @full_root = get_software_root
81
+ @web_root = @global[:"web-root"]
82
+ @descriptions_root = @global[:"descriptions-root"]
83
+ @web_architecture_names = @global[:"web-architecture-names"]
84
+
85
+ # Add new info
86
+ @global[:full_software_root_path] = @full_root
87
+ @global[:"file-group-id"] = Etc.getgrnam(options_to_merge[:"file-group-name"]).try(:gid) if @global[:"file-group-name"]
88
+ end
89
+
90
+ def load_config_yaml
91
+ config_path = File.expand_path(ENV['SMITHY_CONFIG']) if ENV['SMITHY_CONFIG']
92
+ config_path = File.expand_path(global[:"config-file"]) if global[:"config-file"]
93
+ config_path = File.expand_path(@config_file_name) if config_path.blank?
94
+
95
+ if File.exists? config_path
96
+ @config_file_name = config_path
97
+ @config_file_hash = YAML.load_file(config_path).stringify_keys
98
+ else
99
+ raise """warning: Cannot read config file: #{@config_file_name}
100
+ Please update the file or set SMITHY_CONFIG """
101
+ end
102
+ end
103
+
104
+ def architectures
105
+ notice_command "Current Hostname: ", @hostname, 30
106
+ notice_command "Current Architecture: ", @arch, 30
107
+ notice_command "All Architectures: ", @config_file_hash["hostname-architectures"].values.uniq.sort.join(", "), 30
108
+ end
109
+
110
+ def get_prgenv_prefix
111
+ default_prefix = "PrgEnv-"
112
+
113
+ default_prefix_from_config = @config_file_hash.try(:[], "programming-environment-prefix").try(:[], "default")
114
+ default_prefix = default_prefix_from_config unless default_prefix_from_config.blank?
115
+
116
+ prefix_from_config = @config_file_hash.try(:[], "programming-environment-prefix").try(:[], @arch)
117
+
118
+ return prefix_from_config unless prefix_from_config.blank?
119
+
120
+ return default_prefix
121
+ end
122
+
123
+ def set_hostname_and_arch
124
+ @hostname ||= ENV.try(:[], 'HOSTNAME').try(:dup)
125
+ @hostname ||= `hostname -s`.try(:dup)
126
+ @hostname.chomp!
127
+ # Remove trailing numbers (if they exist) and a possible single trailing period
128
+ @hostname.gsub!(/\.?$/,'')
129
+ machine = @hostname.gsub(/(\d*)$/,'')
130
+
131
+ @arch = global[:arch] if @arch.nil?
132
+ @arch = @config_file_hash.try(:[], "hostname-architectures").try(:[], machine) if @arch.nil?
133
+ @arch = @config_file_hash.try(:[], "hostname-architectures").try(:[], @hostname) if @arch.nil?
134
+ end
135
+
136
+ def get_software_root
137
+ if @root.blank? || @arch.blank?
138
+ raise """Cannot determine which architecture we are using.
139
+ Please specify using --arch or add a '#{@hostname}' hostname entry to:
140
+ #{@config_file_name}"""
141
+ end
142
+
143
+ s = File.join(@root, @arch)
144
+ raise "The software-root directory '#{s}' does not exist" unless Dir.exist?(s)
145
+ return s
146
+ end
147
+
148
+ def last_prefix
149
+ rc_file = File.join(ENV['HOME'], '.smithyrc')
150
+ if File.exists?(rc_file)
151
+ h = YAML.load_file(rc_file).stringify_keys rescue nil
152
+ return h["last"]
153
+ else
154
+ return nil
155
+ end
156
+ end
157
+
158
+ def save_last_prefix(prefix)
159
+ rc_file = File.join(ENV['HOME'], '.smithyrc')
160
+ h = {:last => prefix}
161
+ File.open(rc_file, "w+") do |f|
162
+ f.write(h.to_yaml)
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,276 @@
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 Description
40
+ attr_accessor :path, :package, :root, :arch, :www_root, :name, :content,
41
+ :categories, :versions, :builds, :global_description
42
+
43
+ def initialize(args = {})
44
+ @www_root = Smithy::Config.web_root
45
+ @package = args[:package]
46
+ @global_description = true if Smithy::Config.descriptions_root
47
+
48
+ if @package.class == Package
49
+ @root = @package.root
50
+ @arch = @package.arch
51
+ @name = @package.name
52
+ @path = args[:package].application_directory
53
+ @path = File.join(Smithy::Config.descriptions_root, @name) if @global_description
54
+ else
55
+ @root = Smithy::Config.root
56
+ @arch = Smithy::Config.arch
57
+
58
+ if @global_description
59
+ @name = @package.gsub(/#{Smithy::Config.descriptions_root}\/?/, "")
60
+ @path = @package
61
+ else
62
+ if @package == 'last'
63
+ @name = last_prefix.split('/').try(:first)
64
+ else
65
+ @name = Package.normalize_name :name => args[:package], :root => @root, :arch => @arch
66
+ end
67
+ @path = File.join @root, @arch, @name
68
+ end
69
+ end
70
+ @categories = []
71
+ end
72
+
73
+ def description_file_path
74
+ File.join(@path, "description.markdown")
75
+ end
76
+
77
+ def valid?
78
+ raise "Cannot find the package #{@path}" unless Dir.exists? @path
79
+ return true
80
+ end
81
+
82
+ def exceptions_file
83
+ File.join(@path, Package::PackageFileNames[:exception])
84
+ end
85
+
86
+ def self.publishable?(path)
87
+ exceptions_file = File.join(path, Package::PackageFileNames[:exception])
88
+ description_file = File.join(path, "description")
89
+ publishable = true
90
+ if File.exists?(exceptions_file) && ( File.exists?(description_file) || File.exists?(description_file+".markdown") )
91
+ File.open(exceptions_file).readlines.each do |line|
92
+ publishable = false if line =~ /^\s*noweb\s*$/
93
+ end
94
+ end
95
+ return publishable
96
+ end
97
+
98
+ def publishable?
99
+ Description.publishable?(path)
100
+ end
101
+
102
+ def remove_ptag_linebreaks!
103
+ # Find paragraph tag contents
104
+ results = []
105
+ @content.scan(/<p>(.*?)<\/p>/m) {|m| results << [m.first, Regexp.last_match.offset(0)[0]] }
106
+ newlines = []
107
+ # For each paragraph
108
+ results.each do |string, index|
109
+ # Find newlines and save their index
110
+ # index + 3 to accomodate '<p>'
111
+ string.scan(/\n/) {|m| newlines << index+3+Regexp.last_match.offset(0)[0] }
112
+ end
113
+ # Replace the newlines with spaces
114
+ newlines.each {|i| @content[i] = ' '}
115
+ end
116
+
117
+ def sanitize_content!
118
+ # Increment h tags by 2
119
+ @content.gsub!(/<h(\d)>/) {|m| "<h#{$1.to_i+1}>"}
120
+ @content.gsub!(/<\/h(\d)>/) {|m| "</h#{$1.to_i+1}>"}
121
+
122
+ # Don't use <code> inside a <pre>
123
+ @content.gsub!(/<pre(.*?)><code>/) {|m| "<pre#{$1}>"}
124
+ @content.gsub!(/<\/code><\/pre>/, "</pre>")
125
+ end
126
+
127
+ def add_system_info!
128
+ system_string = @machine_table.keys.reject{|m| @machine_table[m].empty?}.collect{|m| m.humanize}.sort.join(', ')
129
+ @content.sub!(/(<h\d>.*?<\/h\d>\n)/) do
130
+ "#{$&}\n<p>Systems: #{system_string}</p>\n"
131
+ end
132
+ end
133
+
134
+ def parse_categories
135
+ if @content =~ /Categor(y|ies):\s+(.*?)(<\/p>)$/i
136
+ @categories = $2.split(',')
137
+ @categories.map do |t|
138
+ t.downcase!
139
+ t.strip!
140
+ end
141
+ end
142
+ end
143
+
144
+ def render_version_table
145
+ if Smithy::Config.descriptions_root
146
+ @machine_table = {}
147
+ web_arches = Smithy::Config.web_architecture_names.keys
148
+ web_arches.each do |a|
149
+ architecture_path = File.join( Smithy::Config.root, a, @name )
150
+ next unless Dir.exists? architecture_path
151
+ web_machine_name = Smithy::Config.web_architecture_names[a]
152
+ @machine_table[web_machine_name] = {}
153
+ Package.alternate_versions(architecture_path).each do |v|
154
+ @machine_table[web_machine_name][v] = Package.alternate_builds(File.join(architecture_path, v))
155
+ end
156
+ end
157
+ erb_file = File.join(@@smithy_bin_root, "/etc/templates/web/machine_version_table.html.erb")
158
+
159
+ else
160
+ @version_table = {}
161
+ universal = false
162
+ Package.alternate_versions(@path).each do |v|
163
+ @version_table[v] = Package.alternate_builds(File.join(@path, v))
164
+ universal = true if @version_table[v].select{|b| b =~ /(universal|binary)/}.size > 0
165
+ end
166
+ if universal
167
+ erb_file = File.join(@@smithy_bin_root, "/etc/templates/web/version_list.html.erb")
168
+ else
169
+ erb_file = File.join(@@smithy_bin_root, "/etc/templates/web/version_table.html.erb")
170
+ end
171
+
172
+ end
173
+
174
+ erb = ERB.new(File.read(erb_file), nil, "<>")
175
+ return erb.result(binding)
176
+ end
177
+
178
+ def deploy(args = {})
179
+ options = {:verbose => false, :noop => false}
180
+ options = {:verbose => true, :noop => true} if args[:dry_run]
181
+
182
+ www_arch = File.join(www_root, "/#{arch.downcase}")
183
+ www_arch = File.join(www_root, "all") if global_description
184
+
185
+ FileUtils.mkdir_p www_root, options unless Dir.exists? www_root
186
+ raise "Cannot access web-root directory #{www_root}" unless Dir.exists? www_root
187
+ FileUtils.mkdir_p www_arch, options unless Dir.exists? www_arch
188
+ raise "Cannot create web-root directory #{www_arch}" unless Dir.exists? www_arch
189
+
190
+ description_file = File.join(path, "description.markdown")
191
+
192
+ begin
193
+ if File.exist? description_file
194
+ f = File.open description_file
195
+ d = Kramdown::Document.new(f.read, :auto_ids => false)
196
+ @content = d.to_html
197
+ remove_ptag_linebreaks!
198
+ else
199
+ description_file = File.join(path, "description")
200
+ f = File.open description_file
201
+ @content = f.read
202
+ end
203
+ rescue => exception
204
+ raise "#{exception}\nCannot read #{description_file}"
205
+ end
206
+
207
+ @content += render_version_table
208
+ sanitize_content!
209
+ parse_categories
210
+ add_system_info! if global_description
211
+
212
+ description_output = File.join(www_arch, "/#{name.downcase}.html")
213
+ unless args[:dry_run]
214
+ d = File.open(description_output, "w+")
215
+ d.write(@content)
216
+ d.close
217
+ end
218
+ puts "updated ".rjust(12).bright + description_output
219
+
220
+ #TODO update category list
221
+
222
+ #notice_success "SUCCESS #{path} published to web"
223
+ end
224
+
225
+ def self.update_page(file = 'alphabetical', args = {})
226
+ root = Smithy::Config.root
227
+ arch = Smithy::Config.arch
228
+ if Smithy::Config.descriptions_root
229
+ www_arch = File.join(Smithy::Config.web_root, "all")
230
+ else
231
+ www_arch = File.join(Smithy::Config.web_root, arch)
232
+ end
233
+
234
+ unless args[:descriptions].nil?
235
+ @descriptions = args[:descriptions]
236
+ @descriptions.sort! {|x,y| x.name <=> y.name}
237
+
238
+ #tags.each do |tag|
239
+ #t = tag.gsub(/^ *| *$|"/, '').downcase
240
+ #@packages[@last_package][:tags] << t
241
+ #@tags[t] = [] unless @tags.has_key?(t)
242
+ #@tags[t] << name
243
+ #end
244
+ #@max_tag_count = 0
245
+ #@min_tag_count = 1000000
246
+ #@tags.each do |tag|
247
+ #@max_tag_count = tag[1].size if tag[1].size > @max_tag_count
248
+ #@min_tag_count = tag[1].size if tag[1].size < @min_tag_count
249
+ #end
250
+ end
251
+
252
+ @packages = Package.all_web :root => File.join(root,arch)
253
+ @packages.collect! do |p|
254
+ if Smithy::Config.descriptions_root
255
+ File.basename(p)
256
+ else
257
+ Package.normalize_name(:name => p, :root => root, :arch => arch)
258
+ end
259
+ end
260
+ @packages.sort!
261
+
262
+ erb_file = File.join(@@smithy_bin_root, "/etc/templates/web/#{file}.html.erb")
263
+ output = File.join(www_arch, "/#{file}.html")
264
+
265
+ erb = ERB.new(File.read(erb_file), nil, "<>")
266
+ unless args[:dry_run]
267
+ File.open(output, "w+") do |f|
268
+ f.write erb.result(binding)
269
+ end
270
+ end
271
+
272
+ puts "updated ".rjust(12).bright + output
273
+ end
274
+
275
+ end
276
+ end