openMSX-builder 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +11 -5
- data/VERSION +1 -1
- data/bin/build_openmsx +11 -4
- data/lib/openmsx_builder.rb +40 -34
- data/lib/tweet_msx.rb +16 -8
- data/openMSX-builder.gemspec +1 -2
- metadata +2 -3
- data/lib/debug_tools.rb +0 -9
data/README.markdown
CHANGED
@@ -25,9 +25,8 @@ Set up of the oauth info has to be done manually at the moment, for more informa
|
|
25
25
|
|
26
26
|
### Commandline Arguments
|
27
27
|
|
28
|
-
Currently `build_openmsx` supports the following
|
28
|
+
Currently `build_openmsx` supports the following command-line arguments:
|
29
29
|
|
30
|
-
* --debug => Generate debug output.
|
31
30
|
* --publish => Publish the created build
|
32
31
|
* --publish-current => Only publish the current build and exit
|
33
32
|
* --publish-all => Only publish all previously created builds and exit
|
@@ -35,13 +34,21 @@ Currently `build_openmsx` supports the following commandline arguments:
|
|
35
34
|
* --dont-update => Don't update the SVN repository
|
36
35
|
* --report-build-failure => If an error occurs during build, report failure via e-mail
|
37
36
|
|
37
|
+
By default only fatal errors will be output via STDOUT.
|
38
|
+
However, the following command-line arguments are available to set the verbosity:
|
39
|
+
|
40
|
+
* --log-errors => Fatal and non-fatal errors.
|
41
|
+
* --warn => Logs warnings besides the (non-)fatal errors.
|
42
|
+
* --verbose => Besides the --warn output, also outputs info.
|
43
|
+
* --debug => Most verbose form. --verbose plus debug info.
|
44
|
+
|
38
45
|
### Examples
|
39
46
|
|
40
47
|
Simplest way to run it would usually be:
|
41
|
-
`build_openmsx --
|
48
|
+
`build_openmsx --verbose --publish --tweet --report-build-failure`
|
42
49
|
|
43
50
|
Or by adding a cronjob for:
|
44
|
-
`0 3 * * * build_openmsx --publish --tweet --report-build-failure`
|
51
|
+
`0 3 * * * build_openmsx --publish --tweet --report-build-failure --log-errors`
|
45
52
|
to have it run daily at 3 at night.
|
46
53
|
(Remember to add either `source ~/.profile` or the right PATH to your cron.)
|
47
54
|
|
@@ -50,7 +57,6 @@ to have it run daily at 3 at night.
|
|
50
57
|
******************************************************************************
|
51
58
|
Current list of tasks is:
|
52
59
|
|
53
|
-
+ Replace DebugTools with Log4r
|
54
60
|
+ Integrate with CIA.vc / Ruby-Rbot
|
55
61
|
+ Add tests
|
56
62
|
+ Refactor `#archive_for_revision` and `#dmg_for_revision` into a single method
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.1
|
data/bin/build_openmsx
CHANGED
@@ -16,9 +16,16 @@ if ARGV.include?('--version')
|
|
16
16
|
exit
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
# TODO: Refactor this into OpenmsxBuilder; perhaps make @options a class variable.
|
20
|
+
log = Logger.new(STDOUT)
|
21
|
+
log.level = Logger::FATAL
|
22
|
+
log.level = Logger::ERROR if ARGV.include?('--log-errors')
|
23
|
+
log.level = Logger::WARN if ARGV.include?('--warn')
|
24
|
+
log.level = Logger::INFO if ARGV.include?('--verbose')
|
25
|
+
log.level = Logger::DEBUG if ARGV.include?('--debug')
|
26
|
+
log.info('-'*50)
|
27
|
+
log.info("Starting with openMSX")
|
21
28
|
OpenmsxBuilder.new(ARGV,:openmsx).run
|
22
|
-
|
23
|
-
|
29
|
+
log.info('-'*50)
|
30
|
+
log.info("Proceeding with openMSX-Debugger")
|
24
31
|
OpenmsxBuilder.new(ARGV,:openmsx_debugger).run
|
data/lib/openmsx_builder.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'mail'
|
3
3
|
require 'yaml'
|
4
|
-
require 'twitter_oauth'
|
5
4
|
require 'tweet_msx'
|
6
|
-
|
7
|
-
include DebugTools
|
5
|
+
require 'logger'
|
8
6
|
class OpenmsxBuilder
|
9
|
-
include DebugTools
|
10
7
|
class NotConfigured < RuntimeError;end
|
11
8
|
CONFIG_FILENAME = File.expand_path('~/.openMSX-builder.yaml')
|
12
9
|
DEFAULTS = {
|
@@ -47,9 +44,16 @@ class OpenmsxBuilder
|
|
47
44
|
@current_revision = `svnversion -n #{setting(:source_dir)}`.to_i
|
48
45
|
@options = options
|
49
46
|
@fails = 0
|
47
|
+
@log = Logger.new(STDOUT)
|
48
|
+
@log.level = Logger::FATAL
|
49
|
+
@log.level = Logger::ERROR if @options.include?('--log-errors')
|
50
|
+
@log.level = Logger::WARN if @options.include?('--warn')
|
51
|
+
@log.level = Logger::INFO if @options.include?('--verbose')
|
52
|
+
@log.level = Logger::DEBUG if @options.include?('--debug')
|
53
|
+
@log.debug("Logger created with level #{@log.level}")
|
50
54
|
config
|
51
55
|
rescue NotConfigured => e
|
52
|
-
|
56
|
+
@log.fatal e.message
|
53
57
|
exit
|
54
58
|
end
|
55
59
|
|
@@ -80,10 +84,10 @@ class OpenmsxBuilder
|
|
80
84
|
publish_current
|
81
85
|
return
|
82
86
|
end
|
83
|
-
|
87
|
+
@log.info "openMSX is currently at #{@current_revision}."
|
84
88
|
update_svn
|
85
89
|
if @new_revision >= @current_revision
|
86
|
-
|
90
|
+
@log.info "Revision #{@new_revision} is not older than #{@current_revision}. Proceeding with build."
|
87
91
|
build
|
88
92
|
end
|
89
93
|
end
|
@@ -96,30 +100,30 @@ private
|
|
96
100
|
def dmg_for_revision?(revision)
|
97
101
|
return false unless openmsx?
|
98
102
|
files = Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-#{revision}-mac-x86-bin.dmg"))
|
99
|
-
debug files.to_yaml unless files.size == 0
|
103
|
+
@log.debug files.to_yaml unless files.size == 0
|
100
104
|
files.size > 0
|
101
105
|
end
|
102
106
|
|
103
107
|
def archive_for_revision?(revision)
|
104
108
|
return false unless openmsx_debugger?
|
105
109
|
filename = File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{revision}-mac-x86.tbz")
|
106
|
-
debug filename
|
110
|
+
@log.debug filename
|
107
111
|
File.exist?(filename)
|
108
112
|
end
|
109
113
|
|
110
114
|
def publish_build(revision,infile,outfile='',location=setting(:publish_location))
|
111
|
-
debug ""
|
115
|
+
@log.debug "\n#publish_build"
|
112
116
|
outfile = File.basename(infile) if outfile == ''
|
113
117
|
destination = File.join(location,outfile)
|
114
|
-
|
118
|
+
@log.info "Will publish #{infile} to #{setting(:publish_location)} now."
|
115
119
|
publish_output = `scp -p "#{infile}" #{destination}`
|
116
|
-
debug publish_output unless publish_output.nil? || publish_output.strip == ''
|
120
|
+
@log.debug publish_output unless publish_output.nil? || publish_output.strip == ''
|
117
121
|
url = File.join(setting(:site_path),File.basename(destination))
|
118
122
|
twitter_update = tweetmsx.update("[#{setting(:nice_name)}] Revision #{revision} is now available:\r\n #{url}") if @options.include?('--tweet')
|
119
|
-
|
123
|
+
@log.info(twitter_update) unless twitter_update.nil?
|
120
124
|
nil
|
121
125
|
rescue TweetMsx::NotConfigured => e
|
122
|
-
|
126
|
+
@log.error e.message
|
123
127
|
end
|
124
128
|
|
125
129
|
def publish
|
@@ -134,7 +138,7 @@ private
|
|
134
138
|
end
|
135
139
|
|
136
140
|
def publish_all
|
137
|
-
|
141
|
+
@log.info "Publishing all #{@type} builds found"
|
138
142
|
if openmsx?
|
139
143
|
files = Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-mac-x86-bin.dmg")).sort.map do |f|
|
140
144
|
if f =~ /openmsx-.+-(\d+)-mac-x86-bin.dmg$/
|
@@ -175,38 +179,38 @@ private
|
|
175
179
|
if @options.include?('--dont-update')
|
176
180
|
update = 'Update skipped'
|
177
181
|
else
|
178
|
-
|
182
|
+
@log.info "Proceeding with update."
|
179
183
|
update = `cd #{setting(:source_dir)} && svn up`
|
180
184
|
end
|
181
185
|
@new_revision = `svnversion -n #{setting(:source_dir)}`.to_i
|
182
|
-
debug update
|
183
|
-
|
186
|
+
@log.debug update
|
187
|
+
@log.info "Now at revision #{@new_revision}"
|
184
188
|
nil
|
185
189
|
end
|
186
190
|
|
187
191
|
def tweetmsx
|
188
|
-
@tweetmsx ||= TweetMsx.new
|
192
|
+
@tweetmsx ||= TweetMsx.new(@log.level)
|
189
193
|
end
|
190
194
|
|
191
195
|
def build
|
192
196
|
if openmsx?
|
193
197
|
if dmg_for_revision?(@new_revision)
|
194
|
-
|
198
|
+
@log.info "Revision already build as #{Dir.glob(File.join(setting(:source_dir),setting(:builds_subdir),"openmsx-*-#{@new_revision}-mac-x86-bin.dmg")).first}"
|
195
199
|
return nil
|
196
200
|
end
|
197
201
|
cleanup_dmg_locks
|
198
202
|
elsif openmsx_debugger?
|
199
203
|
if archive_for_revision?(@new_revision)
|
200
|
-
|
204
|
+
@log.info "Revision already build as #{File.join(setting(:source_dir),setting(:builds_subdir),"openMSX-debugger-#{@new_revision}-mac-x86.tbz")}"
|
201
205
|
return nil
|
202
206
|
end
|
203
207
|
end
|
204
|
-
|
208
|
+
@log.info("Will attempt to build revision #{@new_revision}.")
|
205
209
|
build_output = `cd #{setting(:source_dir)} && make clean && make #{'staticbindist' if openmsx?} 2>&1`
|
206
210
|
if $?.success?
|
207
|
-
|
211
|
+
@log.info "++++++SUCCESS++++++"
|
208
212
|
build_output.each_line do |line|
|
209
|
-
debug " %s" % line
|
213
|
+
@log.debug " %s" % line
|
210
214
|
end
|
211
215
|
publish if @options.include?('--publish')
|
212
216
|
nil
|
@@ -214,17 +218,18 @@ private
|
|
214
218
|
#Capture the weird random build error that seems to be more OSX related than openMSX related.
|
215
219
|
if build_output.include?('hdiutil: create failed - error 49168')
|
216
220
|
@fails += 1
|
217
|
-
|
218
|
-
|
221
|
+
@log.error build_output
|
222
|
+
@log.error "Weird bug (attempt #{@fails}/3)"
|
219
223
|
if @fails == 3
|
224
|
+
@log.fatal "Encountered the weird 'hdiutil error 49168'-bug #{@fails} times; failing."
|
220
225
|
exit
|
221
226
|
else
|
222
227
|
return build
|
223
228
|
end
|
224
229
|
end
|
225
|
-
|
230
|
+
@log.error "!!!!!!FAILED!!!!!!"
|
226
231
|
build_output.each_line do |line|
|
227
|
-
|
232
|
+
@log.error " %s" % line
|
228
233
|
end
|
229
234
|
if @options.include?('--report-build-failure')
|
230
235
|
report_build_failure(build_output)
|
@@ -234,13 +239,14 @@ private
|
|
234
239
|
end
|
235
240
|
|
236
241
|
def cleanup_dmg_locks
|
237
|
-
|
242
|
+
@log.info("Checking for existing filelocks on DMGs.")
|
238
243
|
locks = `/usr/sbin/lsof | grep #{@new_revision}-mac-x86-bin.dmg`
|
239
|
-
debug locks
|
244
|
+
@log.debug locks
|
240
245
|
locks.each_line do |lock_line|
|
241
246
|
pid = lock_line.split[1].to_i
|
242
|
-
|
243
|
-
`kill -9 #{pid}`
|
247
|
+
@log.info "Killing pid #{pid} from lock '#{lock_line}'"
|
248
|
+
kill_output = `kill -9 #{pid}`
|
249
|
+
@log.debug kill_output
|
244
250
|
end
|
245
251
|
end
|
246
252
|
|
@@ -251,10 +257,10 @@ private
|
|
251
257
|
smtp_settings = config[:smtp_settings]
|
252
258
|
mail_from = setting(:report_from)
|
253
259
|
mail_bcc = setting(:report_bcc)
|
254
|
-
Mail.defaults do
|
260
|
+
@log.debug Mail.defaults do
|
255
261
|
delivery_method :smtp, smtp_settings
|
256
262
|
end
|
257
|
-
Mail.deliver do
|
263
|
+
@log.debug Mail.deliver do
|
258
264
|
from mail_from
|
259
265
|
to mail_from
|
260
266
|
bcc mail_bcc.join(', ')
|
data/lib/tweet_msx.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'logger'
|
2
|
+
require 'twitter_oauth'
|
3
|
+
require 'yaml'
|
2
4
|
# Patch for Ruby 1.9.2
|
3
5
|
module Net
|
4
6
|
module HTTPHeader
|
@@ -10,7 +12,6 @@ module Net
|
|
10
12
|
end
|
11
13
|
end
|
12
14
|
class TweetMsx
|
13
|
-
include DebugTools
|
14
15
|
class NotConfigured < RuntimeError;end
|
15
16
|
CONFIG_FILENAME = File.expand_path('~/.openMSX-builder-TweetMSX.yaml')
|
16
17
|
DEFAULTS = {
|
@@ -22,35 +23,42 @@ class TweetMsx
|
|
22
23
|
}
|
23
24
|
}
|
24
25
|
attr_reader :client, :twitter_down
|
25
|
-
def initialize
|
26
|
+
def initialize(log_level=Logger::FATAL)
|
26
27
|
@client = TwitterOAuth::Client.new(config[:client])
|
28
|
+
@log = Logger.new(STDOUT)
|
29
|
+
@log.level = log_level
|
27
30
|
end
|
28
31
|
|
29
32
|
def config
|
30
33
|
create_default_config unless File.exist?(CONFIG_FILENAME)
|
31
34
|
@config ||= YAML.load_file(CONFIG_FILENAME)
|
32
|
-
|
35
|
+
@log.debug @config.to_yaml
|
36
|
+
if @config == DEFAULTS
|
37
|
+
@log.error "TweetMSX config at #{CONFIG_FILENAME} matches DEFAULTS"
|
38
|
+
raise NotConfigured.new("You need to set up your config file at #{CONFIG_FILENAME} first")
|
39
|
+
end
|
33
40
|
@config
|
34
41
|
end
|
35
42
|
|
36
43
|
def create_default_config
|
37
44
|
system("mkdir -p #{File.dirname(CONFIG_FILENAME)}")
|
45
|
+
@log.debug "Creating default config at #{CONFIG_FILENAME}"
|
38
46
|
File.open(CONFIG_FILENAME,'w') do |f|
|
39
47
|
f.write DEFAULTS.to_yaml
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
43
51
|
def update(message)
|
44
|
-
|
52
|
+
@log.info "Tweeting message:\n #{message}"
|
53
|
+
@log.debug "[#{message.size} characters]"
|
45
54
|
if @client.rate_limit_status == 0
|
46
|
-
|
55
|
+
@log.error "You've exceeded your rate limit"
|
47
56
|
return nil
|
48
57
|
end
|
49
|
-
puts message.to_yaml
|
50
58
|
@client.update(message.to_s)
|
51
59
|
nil
|
52
60
|
rescue SocketError
|
53
|
-
|
61
|
+
@log.error "Could not send '#{message}'. Twitter or your connection might be down."
|
54
62
|
nil
|
55
63
|
end
|
56
64
|
end
|
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.3.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"]
|
@@ -26,7 +26,6 @@ Gem::Specification.new do |s|
|
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"bin/build_openmsx",
|
29
|
-
"lib/debug_tools.rb",
|
30
29
|
"lib/openmsx_builder.rb",
|
31
30
|
"lib/tweet_msx.rb",
|
32
31
|
"openMSX-builder.gemspec",
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 1
|
9
|
-
version: 1.
|
9
|
+
version: 1.3.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Filip H.F. "FiXato" Slagter
|
@@ -77,7 +77,6 @@ files:
|
|
77
77
|
- Rakefile
|
78
78
|
- VERSION
|
79
79
|
- bin/build_openmsx
|
80
|
-
- lib/debug_tools.rb
|
81
80
|
- lib/openmsx_builder.rb
|
82
81
|
- lib/tweet_msx.rb
|
83
82
|
- openMSX-builder.gemspec
|