openMSX-builder 1.4.2 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +0 -1
- data/VERSION +1 -1
- data/lib/openmsx_builder.rb +138 -147
- data/lib/tweet_msx.rb +2 -1
- data/openMSX-builder.gemspec +1 -1
- metadata +3 -3
data/README.markdown
CHANGED
@@ -60,7 +60,6 @@ Current list of tasks is:
|
|
60
60
|
|
61
61
|
+ Integrate with CIA.vc / Ruby-Rbot
|
62
62
|
+ Add tests
|
63
|
-
+ Refactor `#archive_for_revision` and `#dmg_for_revision` into a single method
|
64
63
|
+ Create a simple Sinatra App for [openMSX.FiXato.net][5]
|
65
64
|
+ Allow for automatic setup of the oAuth tokens.
|
66
65
|
+ Add documentation on the YAML configuration files.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.1
|
data/lib/openmsx_builder.rb
CHANGED
@@ -38,12 +38,10 @@ class OpenmsxBuilder
|
|
38
38
|
},
|
39
39
|
}
|
40
40
|
|
41
|
-
attr_accessor :type
|
41
|
+
attr_accessor :type,:build_outputs
|
42
42
|
def initialize(options,type=:openmsx)
|
43
|
-
@type = type
|
44
|
-
@current_revision = `svnversion -n #{setting(:source_dir)}`.to_i
|
45
43
|
@options = options
|
46
|
-
@
|
44
|
+
@type = type
|
47
45
|
@log = Logger.new(STDOUT)
|
48
46
|
@log.level = Logger::FATAL
|
49
47
|
@log.level = Logger::ERROR if @options.include?('--log-errors')
|
@@ -51,6 +49,9 @@ class OpenmsxBuilder
|
|
51
49
|
@log.level = Logger::INFO if @options.include?('--verbose')
|
52
50
|
@log.level = Logger::DEBUG if @options.include?('--debug')
|
53
51
|
@log.debug("Logger created with level #{@log.level}")
|
52
|
+
@current_revision = `svnversion -n #{setting(:source_dir)}`.to_i
|
53
|
+
@fails = 0
|
54
|
+
@build_outputs = []
|
54
55
|
config
|
55
56
|
rescue NotConfigured => e
|
56
57
|
@log.fatal e.message
|
@@ -71,186 +72,176 @@ class OpenmsxBuilder
|
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
75
|
+
def publish_all
|
76
|
+
@log.info "Publishing all #{@type} builds found"
|
77
|
+
if openmsx?
|
78
|
+
regexp = /openmsx-.+-(\d+)-mac-univ-bin.dmg$/
|
79
|
+
elsif openmsx_debugger?
|
80
|
+
regexp = /openMSX-debugger-(\d+)-mac-x86.tbz$/
|
81
|
+
end
|
82
|
+
Dir.glob(filemask_for_revision('*')).sort.each do |file|
|
83
|
+
publish_revision($1,file) if file =~ regexp
|
84
|
+
end
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
|
88
|
+
def publish_revision(revision,archive_name=nil)
|
89
|
+
if archive_name.nil?
|
90
|
+
if openmsx?
|
91
|
+
archive_name = Dir.glob(filemask_for_revision(revision)).first
|
92
|
+
elsif openmsx_debugger?
|
93
|
+
archive_name = filemask_for_revision(revision)
|
94
|
+
archive(File.join(setting(:source_dir),setting(:builds_subdir),'openMSX_Debugger.app'),File.basename(archive_name))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
destination = File.join(setting(:publish_location),File.basename(archive_name))
|
99
|
+
@log.info "Publishing '#{archive_name}' to '#{destination}'."
|
100
|
+
@log.debug `scp -p "#{archive_name}" #{destination}`
|
101
|
+
|
102
|
+
return nil unless @options.include?('--tweet')
|
103
|
+
url = File.join(setting(:site_path),File.basename(archive_name))
|
104
|
+
message = "[#{setting(:nice_name)}] Revision #{revision} is now available:\r\n #{url}"
|
105
|
+
tweetmsx.update(message)
|
106
|
+
rescue TweetMsx::NotConfigured => e
|
107
|
+
@log.error e.message
|
108
|
+
end
|
109
|
+
|
74
110
|
def setting(key)
|
75
111
|
config[:projects][type][key]
|
76
112
|
end
|
77
113
|
|
78
114
|
def run
|
79
|
-
if @options.include?('--publish-all')
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
publish_current
|
115
|
+
return publish_all if @options.include?('--publish-all')
|
116
|
+
return publish_revision(@current_revision) if @options.include?('--publish-current')
|
117
|
+
if @options.include?('--dont-update')
|
118
|
+
@new_revision = @current_revision
|
119
|
+
@log.info "Update skipped. Still at revision #{@new_revision}"
|
85
120
|
return
|
121
|
+
else
|
122
|
+
update_svn
|
86
123
|
end
|
87
|
-
|
88
|
-
update_svn
|
124
|
+
|
89
125
|
if @new_revision >= @current_revision
|
90
126
|
@log.info "Revision #{@new_revision} is not older than #{@current_revision}. Proceeding with build."
|
91
|
-
build
|
127
|
+
build unless already_built?(@new_revision)
|
92
128
|
end
|
93
129
|
end
|
94
130
|
|
131
|
+
def update_svn
|
132
|
+
@log.info "openMSX is currently at #{@current_revision}. Proceeding with `svn update`"
|
133
|
+
@log.debug `cd #{setting(:source_dir)} && svn up`
|
134
|
+
@new_revision = `svnversion -n #{setting(:source_dir)}`.to_i
|
135
|
+
@log.info "Now at revision #{@new_revision}"
|
136
|
+
nil
|
137
|
+
end
|
138
|
+
|
95
139
|
private
|
140
|
+
def already_built?(revision)
|
141
|
+
if openmsx?
|
142
|
+
files = Dir.glob(filemask_for_revision(revision))
|
143
|
+
if files.size == 0
|
144
|
+
@log.debug "Revision #{revision} has not yet been built."
|
145
|
+
return false
|
146
|
+
end
|
147
|
+
@log.debug "The following file(s) were found for revision #{revision}: #{files.join(",")}"
|
148
|
+
filename = files.first
|
149
|
+
elsif openmsx_debugger?
|
150
|
+
filename = filemask_for_revision(revision)
|
151
|
+
return false unless File.exist?(filename)
|
152
|
+
else
|
153
|
+
@log.fatal "Unsupported config type #{@type}."
|
154
|
+
exit
|
155
|
+
end
|
156
|
+
@log.info "Revision #{revision} already built as: #{filename}"
|
157
|
+
filename
|
158
|
+
end
|
159
|
+
|
96
160
|
def archive(infile,outfile)
|
97
161
|
`cd #{File.dirname(infile)} && tar --bzip2 -cf #{outfile} #{File.basename(infile)}`
|
98
162
|
end
|
99
163
|
|
100
|
-
def
|
101
|
-
|
102
|
-
|
103
|
-
@
|
104
|
-
|
164
|
+
def build
|
165
|
+
cleanup_dmg_locks if openmsx?
|
166
|
+
@log.info("Will attempt to build revision #{@new_revision}.")
|
167
|
+
@build_outputs << `cd #{setting(:source_dir)} && make clean OPENMSX_TARGET_CPU=univ && make #{'staticbindist OPENMSX_TARGET_CPU=univ' if openmsx?} 2>&1`
|
168
|
+
if $?.success?
|
169
|
+
handle_build_success
|
170
|
+
return nil
|
171
|
+
end
|
172
|
+
handle_build_error
|
173
|
+
nil
|
105
174
|
end
|
106
175
|
|
107
|
-
def
|
108
|
-
|
109
|
-
filename = File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{revision}-mac-x86.tbz")
|
110
|
-
@log.debug filename
|
111
|
-
File.exist?(filename)
|
176
|
+
def build_output
|
177
|
+
build_outputs.last
|
112
178
|
end
|
113
179
|
|
114
|
-
def
|
115
|
-
@log.
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
nil
|
125
|
-
rescue TweetMsx::NotConfigured => e
|
126
|
-
@log.error e.message
|
180
|
+
def cleanup_dmg_locks
|
181
|
+
@log.info("Checking for existing filelocks on DMGs.")
|
182
|
+
locks = `/usr/sbin/lsof | grep #{@new_revision}-mac-univ-bin.dmg`
|
183
|
+
@log.debug locks
|
184
|
+
locks.each_line do |lock_line|
|
185
|
+
pid = lock_line.split[1].to_i
|
186
|
+
@log.info "Killing pid #{pid} from lock '#{lock_line}'"
|
187
|
+
kill_output = `kill -9 #{pid}`
|
188
|
+
@log.debug kill_output
|
189
|
+
end
|
127
190
|
end
|
128
191
|
|
129
|
-
def
|
192
|
+
def filemask_for_revision(revision)
|
130
193
|
if openmsx?
|
131
|
-
|
194
|
+
File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-#{revision}-mac-univ-bin.dmg")
|
132
195
|
elsif openmsx_debugger?
|
133
|
-
|
134
|
-
archive(File.join(setting(:source_dir),setting(:builds_subdir),'openMSX_Debugger.app'),File.basename(archive_name))
|
196
|
+
File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{revision}-mac-x86.tbz")
|
135
197
|
end
|
136
|
-
publish_build(@new_revision, archive_name)
|
137
|
-
nil
|
138
198
|
end
|
139
199
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
if f =~ /openmsx-.+-(\d+)-mac-x86-bin.dmg$/
|
145
|
-
rev = $1
|
146
|
-
else
|
147
|
-
rev = 'unknown'
|
148
|
-
end
|
149
|
-
[rev,f]
|
150
|
-
end
|
151
|
-
elsif openmsx_debugger?
|
152
|
-
files = Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),'openMSX-debugger-*-mac-x86.tbz')).sort.map do |f|
|
153
|
-
if f =~ /openMSX-debugger-(\d+)-mac-x86.tbz$/
|
154
|
-
rev = $1
|
155
|
-
else
|
156
|
-
rev = 'unknown'
|
157
|
-
end
|
158
|
-
[rev,f]
|
159
|
-
end
|
160
|
-
end
|
161
|
-
files.each do |rev,file|
|
162
|
-
publish_build(rev,file)
|
200
|
+
def handle_build_error
|
201
|
+
if handle_build_hdiutil_error?
|
202
|
+
build
|
203
|
+
return nil
|
163
204
|
end
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
def publish_current
|
168
|
-
if openmsx?
|
169
|
-
archive_name = Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-#{@current_revision}-mac-univ-bin.dmg")).first
|
170
|
-
elsif openmsx_debugger?
|
171
|
-
archive_name = File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{@current_revision}-mac-x86.tbz")
|
172
|
-
archive(File.join(setting(:source_dir),setting(:builds_subdir),'openMSX_Debugger.app'),File.basename(archive_name))
|
205
|
+
@log.error "!!!!!!FAILED!!!!!!"
|
206
|
+
build_output.each_line do |line|
|
207
|
+
@log.error " %s" % line
|
173
208
|
end
|
174
|
-
|
175
|
-
|
176
|
-
end
|
177
|
-
|
178
|
-
def update_svn
|
179
|
-
if @options.include?('--dont-update')
|
180
|
-
update = 'Update skipped'
|
181
|
-
else
|
182
|
-
@log.info "Proceeding with update."
|
183
|
-
update = `cd #{setting(:source_dir)} && svn up`
|
209
|
+
if @options.include?('--report-build-failure')
|
210
|
+
report_build_failure
|
184
211
|
end
|
185
|
-
@new_revision = `svnversion -n #{setting(:source_dir)}`.to_i
|
186
|
-
@log.debug update
|
187
|
-
@log.info "Now at revision #{@new_revision}"
|
188
|
-
nil
|
189
212
|
end
|
190
213
|
|
191
|
-
|
192
|
-
|
214
|
+
#Capture the weird random build error that seems to be more OSX related than openMSX related.
|
215
|
+
def handle_build_hdiutil_error?
|
216
|
+
return false unless build_output.include?('hdiutil: create failed - error 49168')
|
217
|
+
@fails += 1
|
218
|
+
@log.error build_output
|
219
|
+
@log.error "Weird bug (attempt #{@fails}/3)"
|
220
|
+
return true if @fails < 3
|
221
|
+
@log.fatal "Encountered the weird 'hdiutil error 49168'-bug #{@fails} times; failing."
|
222
|
+
exit
|
193
223
|
end
|
194
224
|
|
195
|
-
def
|
196
|
-
|
197
|
-
|
198
|
-
@log.info "Revision already build as #{Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-#{@new_revision}-mac-univ-bin.dmg")).first}"
|
199
|
-
return nil
|
200
|
-
end
|
201
|
-
cleanup_dmg_locks
|
202
|
-
elsif openmsx_debugger?
|
203
|
-
if archive_for_revision?(@new_revision)
|
204
|
-
@log.info "Revision already build as #{File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{@new_revision}-mac-x86.tbz")}"
|
205
|
-
return nil
|
206
|
-
end
|
207
|
-
end
|
208
|
-
@log.info("Will attempt to build revision #{@new_revision}.")
|
209
|
-
build_output = `cd #{setting(:source_dir)} && make clean OPENMSX_TARGET_CPU=univ && make #{'staticbindist OPENMSX_TARGET_CPU=univ' if openmsx?} 2>&1`
|
210
|
-
if $?.success?
|
211
|
-
@log.info "++++++SUCCESS++++++"
|
225
|
+
def handle_build_success
|
226
|
+
@log.info "++++++SUCCESS++++++"
|
227
|
+
if @log.debug?
|
212
228
|
build_output.each_line do |line|
|
213
229
|
@log.debug " %s" % line
|
214
230
|
end
|
215
|
-
publish if @options.include?('--publish')
|
216
|
-
nil
|
217
|
-
else
|
218
|
-
#Capture the weird random build error that seems to be more OSX related than openMSX related.
|
219
|
-
if build_output.include?('hdiutil: create failed - error 49168')
|
220
|
-
@fails += 1
|
221
|
-
@log.error build_output
|
222
|
-
@log.error "Weird bug (attempt #{@fails}/3)"
|
223
|
-
if @fails == 3
|
224
|
-
@log.fatal "Encountered the weird 'hdiutil error 49168'-bug #{@fails} times; failing."
|
225
|
-
exit
|
226
|
-
else
|
227
|
-
return build
|
228
|
-
end
|
229
|
-
end
|
230
|
-
@log.error "!!!!!!FAILED!!!!!!"
|
231
|
-
build_output.each_line do |line|
|
232
|
-
@log.error " %s" % line
|
233
|
-
end
|
234
|
-
if @options.include?('--report-build-failure')
|
235
|
-
report_build_failure(build_output)
|
236
|
-
end
|
237
231
|
end
|
232
|
+
publish_revision(@new_revision) if @options.include?('--publish')
|
238
233
|
nil
|
239
234
|
end
|
240
235
|
|
241
|
-
def
|
242
|
-
@
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
@log.info "Killing pid #{pid} from lock '#{lock_line}'"
|
248
|
-
kill_output = `kill -9 #{pid}`
|
249
|
-
@log.debug kill_output
|
250
|
-
end
|
236
|
+
def openmsx?
|
237
|
+
@type == :openmsx
|
238
|
+
end
|
239
|
+
|
240
|
+
def openmsx_debugger?
|
241
|
+
@type == :openmsx_debugger
|
251
242
|
end
|
252
243
|
|
253
|
-
def report_build_failure
|
244
|
+
def report_build_failure
|
254
245
|
#TODO: Find out why I have to set these local vars due to problems with scope within Mail
|
255
246
|
revision = @new_revision
|
256
247
|
project_name = setting(:nice_name)
|
@@ -267,15 +258,15 @@ private
|
|
267
258
|
subject "[FAIL] #{project_name} revision #{revision} failed to build"
|
268
259
|
content_type 'text/plain; charset=UTF-8'
|
269
260
|
content_transfer_encoding '8bit'
|
270
|
-
body
|
261
|
+
body <<-EOS
|
262
|
+
While trying to build revision #{revision} of #{project_name}, the daily auto-builder encountered an error.
|
263
|
+
Below you will find the entire build report:\r\n
|
264
|
+
#{build_output}
|
265
|
+
EOS
|
271
266
|
end
|
272
267
|
end
|
273
|
-
|
274
|
-
def openmsx?
|
275
|
-
@type == :openmsx
|
276
|
-
end
|
277
268
|
|
278
|
-
def
|
279
|
-
@
|
269
|
+
def tweetmsx
|
270
|
+
@tweetmsx ||= TweetMsx.new(@log.level)
|
280
271
|
end
|
281
272
|
end
|
data/lib/tweet_msx.rb
CHANGED
@@ -55,7 +55,8 @@ class TweetMsx
|
|
55
55
|
@log.error "You've exceeded your rate limit"
|
56
56
|
return nil
|
57
57
|
end
|
58
|
-
@client.update(message.to_s)
|
58
|
+
ret = @client.update(message.to_s)
|
59
|
+
@log.info(ret.to_yaml) unless ret.nil?
|
59
60
|
nil
|
60
61
|
rescue SocketError
|
61
62
|
@log.error "Could not send '#{message}'. Twitter or your connection might be down."
|
data/openMSX-builder.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{openMSX-builder}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.5.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Filip H.F. \"FiXato\" Slagter"]
|