~cbehrens/openstack-guest-agents/lp764221

« back to all changes in this revision

Viewing changes to src/xenserver/windows/BuildUtils.rb

  • Committer: Antony Messerli
  • Date: 2011-03-02 21:56:51 UTC
  • Revision ID: amesserl@rackspace.com-20110302215651-0clqh49spumg13c6
Initial commit Rackspace Windows Guest Agent

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
def output_dir
 
2
        if ENV.keys.include?('CC_BUILD_ARTIFACTS')
 
3
                dir = ENV['CC_BUILD_ARTIFACTS']
 
4
        else
 
5
                dir = 'results'
 
6
        end
 
7
        Dir.mkdir dir unless File.exists?(dir)
 
8
        return dir
 
9
end
 
10
 
 
11
class ReleaseZipper
 
12
  def create(filename, root, installerBatchFile, excludes=/^$/)
 
13
    root = root + "/" if root[root.length - 1].chr != "/"
 
14
    Zip::ZipFile.open(filename, Zip::ZipFile::CREATE) do |zip|
 
15
      Find.find(root) do |path|
 
16
        next if path =~ excludes
 
17
        zip_path = path.gsub(root, '')
 
18
        zip.add(zip_path, path)
 
19
      end
 
20
      zip.add(installerBatchFile, File.join(Dir.pwd, installerBatchFile))
 
21
    end
 
22
  end
 
23
end
 
24
 
 
25
class AssemblyInfoBuilder
 
26
  attr_accessor :assemblyAttributes
 
27
  def initialize(sourcePath, assemblyAttributes = {})
 
28
    @sourcePath = sourcePath
 
29
    @assemblyAttributes = assemblyAttributes
 
30
  end
 
31
  
 
32
  def do
 
33
    assemblyInfoFiles = FileList["#{@sourcePath}/**/AssemblyInfo.cs"]
 
34
    assemblyInfoFiles.each do |filePath|
 
35
      puts "AssemblyInfo file found at: #{filePath}"
 
36
      assemblyTitleLine = IO.readlines(filePath).grep /AssemblyTitle/
 
37
      AssemblyFile.process(filePath, "w+") do |file|
 
38
        file.puts "using System.Reflection;"
 
39
        file.puts "using System.Runtime.InteropServices;"
 
40
        file.puts ""
 
41
        file.puts assemblyTitleLine
 
42
        file.puts "[assembly: AssemblyDescription(\"#{@assemblyAttributes[:description]}\")]"
 
43
        file.puts "[assembly: AssemblyConfiguration(\"\")]"
 
44
        file.puts "[assembly: AssemblyCompany(\"#{@assemblyAttributes[:company]}\")]"
 
45
        file.puts "[assembly: AssemblyProduct(\"#{@assemblyAttributes[:product]}\")]"
 
46
        file.puts "[assembly: AssemblyCopyright(\"#{@assemblyAttributes[:copyright]}\")]"
 
47
        file.puts "[assembly: AssemblyTrademark(\"\")]"
 
48
        file.puts "[assembly: AssemblyCulture(\"\")]"
 
49
        file.puts "[assembly: ComVisible(false)]"
 
50
        file.puts "[assembly: AssemblyVersion(\"#{@assemblyAttributes[:version]}.#{@assemblyAttributes[:buildNumber]}\")]"
 
51
        file.puts "[assembly: AssemblyFileVersion(\"#{@assemblyAttributes[:version]}.#{@assemblyAttributes[:buildNumber]}\")]"
 
52
      end
 
53
    end
 
54
  end
 
55
end
 
56
  
 
57
class AssemblyFile
 
58
  def AssemblyFile.process(*args)
 
59
    f = File.open(*args)
 
60
    yield f
 
61
    f.close()
 
62
  end
 
63
end