Class: OpenmsxBuilder
- Inherits:
-
Object
- Object
- OpenmsxBuilder
- Defined in:
- lib/openmsx_builder.rb
Defined Under Namespace
Classes: NotConfigured
Constant Summary collapse
- CONFIG_FILENAME =
File.('~/.openMSX-builder.yaml')
- DEFAULTS =
{ :projects => { :openmsx_univ => { :source_dir => File.("~/Development/openMSX"), :builds_subdir => 'derived/univ-darwin-opt-3rd', :report_bcc => [], :report_from => "openMSX auto-builder by FiXato <[email protected]>", :nice_name => 'openMSX Universal Mac OS X (ppc/i386/x86_64)', :publish_location => 'ssh_host:path/to/existing/publish/dir', :site_path => 'http://your.host.example/publish/dir', :target_cpu => 'univ', }, :openmsx_x86 => { :source_dir => File.("~/Development/openMSX"), :builds_subdir => 'derived/x86-darwin-opt-3rd', :report_bcc => [], :report_from => "openMSX auto-builder by FiXato <[email protected]>", :nice_name => 'openMSX for 32-bit Mac OS X', :publish_location => 'ssh_host:path/to/existing/publish/dir', :site_path => 'http://your.host.example/publish/dir', :target_cpu => 'x86', }, :openmsx_x86_64 => { :source_dir => File.("~/Development/openMSX"), :builds_subdir => 'derived/x86_64-darwin-opt-3rd', :report_bcc => [], :report_from => "openMSX auto-builder by FiXato <[email protected]>", :nice_name => 'openMSX for 64-bit Mac OS X', :publish_location => 'ssh_host:path/to/existing/publish/dir', :site_path => 'http://your.host.example/publish/dir', :target_cpu => 'x86_64', }, :openmsx_ppc => { :source_dir => File.("~/Development/openMSX"), :builds_subdir => 'derived/ppc-darwin-ppc-3rd', :report_bcc => [], :report_from => "openMSX auto-builder by FiXato <[email protected]>", :nice_name => 'openMSX for PowerPC Mac OS', :publish_location => 'ssh_host:path/to/existing/publish/dir', :site_path => 'http://your.host.example/publish/dir', :target_cpu => 'ppc', }, :openmsx_debugger => { :source_dir => File.("~/Development/openmsx-debugger"), :builds_subdir => 'derived', :report_bcc => [], :report_from => "openMSX auto-builder by FiXato <[email protected]>", :nice_name => 'openMSX Debugger, 32-Bit Mac OS X', :publish_location => 'ssh_host:path/to/existing/publish/dir', :site_path => 'http://your.host.example/publish/dir', :target_cpu => 'x86', }, :openmsx_debugger_x86 => { :source_dir => File.("~/Development/openmsx-debugger"), :builds_subdir => 'derived', :report_bcc => [], :report_from => "openMSX auto-builder by FiXato <[email protected]>", :nice_name => 'openMSX Debugger, 32-Bit Mac OS X', :publish_location => 'ssh_host:path/to/existing/publish/dir', :site_path => 'http://your.host.example/publish/dir', :target_cpu => 'x86', }, :openmsx_debugger_x86_64 => { :source_dir => File.("~/Development/openmsx-debugger"), :builds_subdir => 'derived', :report_bcc => [], :report_from => "openMSX auto-builder by FiXato <[email protected]>", :nice_name => 'openMSX Debugger, 64-Bit Mac OS X', :publish_location => 'ssh_host:path/to/existing/publish/dir', :site_path => 'http://your.host.example/publish/dir', :target_cpu => 'x86_64', }, }, :smtp_settings => { :address => "mail.example", :port => 25, :domain => 'mail.example', :user_name => '[email protected]', :password => '', :authentication => :plain, :enable_starttls_auto => true }, }
Instance Attribute Summary collapse
-
#build_outputs ⇒ Object
Returns the value of attribute build_outputs.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #config ⇒ Object
- #create_default_config ⇒ Object
-
#initialize(options, type = :openmsx_univ) ⇒ OpenmsxBuilder
constructor
A new instance of OpenmsxBuilder.
- #publish_all ⇒ Object
- #publish_revision(revision, archive_name = nil) ⇒ Object
- #run ⇒ Object
- #setting(key) ⇒ Object
- #update_svn ⇒ Object
Constructor Details
#initialize(options, type = :openmsx_univ) ⇒ OpenmsxBuilder
Returns a new instance of OpenmsxBuilder.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/openmsx_builder.rb', line 94 def initialize(,type=:openmsx_univ) @options = @type = type @log = Logger.new(STDOUT) @log.level = Logger::FATAL @log.level = Logger::ERROR if @options.include?('--log-errors') @log.level = Logger::WARN if @options.include?('--warn') @log.level = Logger::INFO if @options.include?('--verbose') @log.level = Logger::DEBUG if @options.include?('--debug') @log.debug("Logger created with level #{@log.level}") @current_revision = `svnversion -cn #{setting(:source_dir)}`.split(':').last.to_i @fails = 0 @build_outputs = [] config rescue NotConfigured => e @log.fatal e. exit end |
Instance Attribute Details
#build_outputs ⇒ Object
Returns the value of attribute build_outputs.
93 94 95 |
# File 'lib/openmsx_builder.rb', line 93 def build_outputs @build_outputs end |
#type ⇒ Object
Returns the value of attribute type.
93 94 95 |
# File 'lib/openmsx_builder.rb', line 93 def type @type end |
Instance Method Details
#config ⇒ Object
113 114 115 116 117 118 |
# File 'lib/openmsx_builder.rb', line 113 def config create_default_config unless File.exist?(CONFIG_FILENAME) @config ||= YAML.load_file(CONFIG_FILENAME) raise NotConfigured.new("You need to set up your config file at #{CONFIG_FILENAME} first") if @config == DEFAULTS @config end |
#create_default_config ⇒ Object
120 121 122 123 124 125 |
# File 'lib/openmsx_builder.rb', line 120 def create_default_config system("mkdir -p #{File.dirname(CONFIG_FILENAME)}") File.open(CONFIG_FILENAME,'w') do |f| f.write DEFAULTS.to_yaml end end |
#publish_all ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/openmsx_builder.rb', line 127 def publish_all @log.info "Publishing all #{@type} builds found" if openmsx? regexp = /openmsx-.+-(\d+)-mac-#{setting(:target_cpu)}-bin.dmg$/ elsif openmsx_debugger? regexp = /openMSX-debugger-(\d+)-mac-#{setting(:target_cpu)}.tbz$/ end Dir.glob(filemask_for_revision('*')).sort.each do |file| publish_revision($1,file) if file =~ regexp end nil end |
#publish_revision(revision, archive_name = nil) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/openmsx_builder.rb', line 140 def publish_revision(revision,archive_name=nil) if archive_name.nil? if openmsx? archive_name = Dir.glob(filemask_for_revision(revision)).first elsif openmsx_debugger? archive_name = filemask_for_revision(revision) archive(File.join(setting(:source_dir),setting(:builds_subdir),'openMSX_Debugger.app'),File.basename(archive_name)) end if archive_name.nil? @log.error "No archive could be found for revision #{revision} in '#{File.join(setting(:source_dir),setting(:builds_subdir))}' for target_cpu #{setting(:target_cpu)}" return nil end end destination = File.join(setting(:publish_location),File.basename(archive_name)) @log.info "Publishing '#{archive_name}' to '#{destination}'." @log.debug `scp -p "#{archive_name}" #{destination}` return nil unless @options.include?('--tweet') url = File.join(setting(:site_path),File.basename(archive_name)) = "[#{setting(:nice_name)}] Revision #{revision} added: \r\n#{url}" tweetmsx.update() rescue TweetMsx::NotConfigured => e @log.error e. end |
#run ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/openmsx_builder.rb', line 170 def run return publish_all if @options.include?('--publish-all') return publish_revision(@current_revision) if @options.include?('--publish-current') if @options.include?('--dont-update') @new_revision = @current_revision @log.info "Update skipped. Still at revision #{@new_revision}" else update_svn end if @new_revision >= @current_revision @log.info "Revision #{@new_revision} is not older than #{@current_revision}. Proceeding with build." build unless already_built?(@new_revision) end end |
#setting(key) ⇒ Object
166 167 168 |
# File 'lib/openmsx_builder.rb', line 166 def setting(key) config[:projects][type][key] end |
#update_svn ⇒ Object
186 187 188 189 190 191 192 |
# File 'lib/openmsx_builder.rb', line 186 def update_svn @log.info "openMSX is currently at #{@current_revision}. Proceeding with `svn update`" @log.debug `cd #{setting(:source_dir)} && svn up` @new_revision = `svnversion -nc #{setting(:source_dir)}`.split(':').last.to_i @log.info "Now at revision #{@new_revision}" nil end |