crash-watch 1.1.12 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a7605a58edde59c3c6e329dc0e9bef448ffb25c8
4
+ data.tar.gz: c20d2e5b85718f321f7678303b60edd348827e14
5
+ SHA512:
6
+ metadata.gz: bc25dd08bf114c1cc6679b2b34732d0f4e2bc77f5b410bea92f35bc5302d1180dbe9c44550e6d2e4cdc523ddf5bae786ca9aac6f092f1bb359d04289061b699f
7
+ data.tar.gz: 4f47118b83193ab32388f23a44bb05247264d053162c5e6126933e20bee42bebf0262af993623b2763f55cf3d372c5f7d9de20ad175f1c9134fcb2be450724e6
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2013 Phusion
1
+ Copyright (c) 2010-2016 Phusion Holding B.V.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -13,50 +13,11 @@ Run:
13
13
 
14
14
  gem install crash-watch
15
15
 
16
- You must also have GDB installed. Mac OS X already has it by default. If you're on Linux, try one of these:
16
+ You must also have GDB installed. macOS already has it by default. If you're on Linux, try one of these:
17
17
 
18
18
  apt-get install gdb
19
19
  yum install gdb
20
20
 
21
- This gem is signed using PGP with the [Phusion Software Signing key](http://www.phusion.nl/about/gpg). That key in turn is signed by [the rubygems-openpgp Certificate Authority](http://www.rubygems-openpgp-ca.org/).
22
-
23
- You can verify the authenticity of the gem by following [The Complete Guide to Verifying Gems with rubygems-openpgp](http://www.rubygems-openpgp-ca.org/blog/the-complete-guide-to-verifying-gems-with-rubygems-openpgp.html).
24
-
25
- ## Installation on Ubuntu
26
-
27
- Use our [PPA](https://launchpad.net/~phusion.nl/+archive/misc):
28
-
29
- sudo add-apt-repository ppa:phusion.nl/misc
30
- sudo apt-get update
31
- sudo apt-get install crash-watch
32
-
33
- ## Installation on Debian
34
-
35
- Our Ubuntu Lucid packages are compatible with Debian 6.
36
-
37
- sudo sh -c 'echo deb http://ppa.launchpad.net/phusion.nl/misc/ubuntu lucid main > /etc/apt/sources.list.d/phusion-misc.list'
38
- sudo sh -c 'echo deb-src http://ppa.launchpad.net/phusion.nl/misc/ubuntu lucid main >> /etc/apt/sources.list.d/phusion-misc.list'
39
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 2AC745A50A212A8C
40
- sudo apt-get update
41
- sudo apt-get install crash-watch
42
-
43
- ## Installation on RHEL, CentOS and Amazon Linux
44
-
45
- 1. Enable EPEL: [RHEL](https://fedoraproject.org/wiki/EPEL), [CentOS](http://www.centosblog.com/enable-epel-repo-on-centos-5-and-centos-6/), [Amazon Linux](http://aws.amazon.com/amazon-linux-ami/faqs/#epel).
46
- 2. Enable our YUM repository:
47
-
48
- # RHEL 6, CentOS 6
49
- curl -L https://oss-binaries.phusionpassenger.com/yumgems/phusion-misc/el.repo | \
50
- sudo tee /etc/yum.repos.d/phusion-misc.repo
51
-
52
- # Amazon Linux
53
- curl -L https://oss-binaries.phusionpassenger.com/yumgems/phusion-misc/amazon.repo | \
54
- sudo tee /etc/yum.repos.d/phusion-misc.repo
55
-
56
- 3. Install our package:
57
-
58
- sudo yum install rubygem-crash-watch
59
-
60
21
  ## Sample usage
61
22
 
62
23
  $ crash-watch <PID>
@@ -99,7 +60,7 @@ Instantiate with:
99
60
  require 'crash_watch/gdb_controller'
100
61
  gdb = CrashWatch::GdbController.new
101
62
 
102
- This will spawn a new GDB process. Use `#execute` to execute arbitary GDB commands. Whatever the command prints to stdout and stderr will be available in the result string.
63
+ This will spawn a new GDB process. Use `#execute` to execute arbitrary GDB commands. Whatever the command prints to stdout and stderr will be available in the result string.
103
64
 
104
65
  gdb.execute("bt") # => backtrace string
105
66
  gdb.execute("p 1 + 2") # => "$1 = 3\n"
data/Rakefile CHANGED
@@ -4,579 +4,44 @@ require 'tmpdir'
4
4
 
5
5
  PACKAGE_NAME = "crash-watch"
6
6
  PACKAGE_VERSION = CrashWatch::VERSION_STRING
7
- PACKAGE_SIGNING_KEY = "0x0A212A8C"
8
7
  MAINTAINER_NAME = "Hongli Lai"
9
8
  MAINTAINER_EMAIL = "hongli@phusion.nl"
10
9
 
11
10
  desc "Run unit tests"
12
11
  task :test do
13
- ruby "-S rspec -f s -c test/*_spec.rb"
12
+ ruby "-S rspec -f documentation -c test/*_spec.rb"
14
13
  end
15
14
 
16
15
  desc "Build, sign & upload gem"
17
16
  task 'package:release' do
18
- sh "git tag -s release-#{PACKAGE_VERSION}"
19
- sh "gem build #{PACKAGE_NAME}.gemspec --sign --key #{PACKAGE_SIGNING_KEY}"
20
- puts "Proceed with pushing tag to Github and uploading the gem? [y/n]"
21
- if STDIN.readline == "y\n"
22
- sh "git push origin release-#{PACKAGE_VERSION}"
23
- sh "gem push #{PACKAGE_NAME}-#{PACKAGE_VERSION}.gem"
24
- else
25
- puts "Did not upload the gem."
26
- end
17
+ sh "git tag -s release-#{PACKAGE_VERSION}"
18
+ sh "gem build #{PACKAGE_NAME}.gemspec"
19
+ puts "Proceed with pushing tag to Github and uploading the gem? [y/n]"
20
+ if STDIN.readline == "y\n"
21
+ sh "git push origin release-#{PACKAGE_VERSION}"
22
+ sh "gem push #{PACKAGE_NAME}-#{PACKAGE_VERSION}.gem"
23
+ else
24
+ puts "Did not upload the gem."
25
+ end
27
26
  end
28
27
 
29
28
 
30
29
  ##### Utilities #####
31
30
 
32
31
  def string_option(name, default_value = nil)
33
- value = ENV[name]
34
- if value.nil? || value.empty?
35
- return default_value
36
- else
37
- return value
38
- end
32
+ value = ENV[name]
33
+ if value.nil? || value.empty?
34
+ return default_value
35
+ else
36
+ return value
37
+ end
39
38
  end
40
39
 
41
40
  def boolean_option(name, default_value = false)
42
- value = ENV[name]
43
- if value.nil? || value.empty?
44
- return default_value
45
- else
46
- return value == "yes" || value == "on" || value == "true" || value == "1"
47
- end
48
- end
49
-
50
-
51
- ##### Debian packaging support #####
52
-
53
- PKG_DIR = string_option('PKG_DIR', "pkg")
54
- DEBIAN_NAME = PACKAGE_NAME
55
- DEBIAN_PACKAGE_REVISION = 2
56
- ALL_DISTRIBUTIONS = string_option('DEBIAN_DISTROS', 'saucy precise lucid').split(/[ ,]/)
57
- ORIG_TARBALL_FILES = lambda do
58
- require 'crash_watch/packaging'
59
- Dir[*CRASH_WATCH_FILES] - Dir[*CRASH_WATCH_EXCLUDE_FILES]
60
- end
61
-
62
- # Implements a simple preprocessor language which combines elements in the C
63
- # preprocessor with ERB:
64
- #
65
- # Today
66
- # #if @today == :fine
67
- # is a fine day.
68
- # #elif @today == :good
69
- # is a good day.
70
- # #else
71
- # is a sad day.
72
- # #endif
73
- # Let's go walking.
74
- # Today is <%= Time.now %>.
75
- #
76
- # When run with...
77
- #
78
- # Preprocessor.new.start('input.txt', 'output.txt', :today => :fine)
79
- #
80
- # ...will produce:
81
- #
82
- # Today
83
- # is a fine day.
84
- # Let's go walking.
85
- # Today is 2013-08-11 22:37:06 +0200.
86
- #
87
- # Highlights:
88
- #
89
- # * #if blocks can be nested.
90
- # * Expressions are Ruby expressions, evaluated within the binding of a
91
- # Preprocessor::Evaluator object.
92
- # * Text inside #if/#elif/#else are automatically unindented.
93
- # * ERB compatible.
94
- class Preprocessor
95
- def initialize
96
- require 'erb' if !defined?(ERB)
97
- @indentation_size = 4
98
- @debug = boolean_option('DEBUG')
99
- end
100
-
101
- def start(filename, output_filename, variables = {})
102
- if output_filename
103
- temp_output_filename = "#{output_filename}._new"
104
- output = File.open(temp_output_filename, 'w')
105
- else
106
- output = STDOUT
107
- end
108
- the_binding = create_binding(variables)
109
- context = []
110
- @filename = filename
111
- @lineno = 1
112
- @indentation = 0
113
-
114
- each_line(filename, the_binding) do |line|
115
- debug("context=#{context.inspect}, line=#{line.inspect}")
116
-
117
- name, args_string, cmd_indentation = recognize_command(line)
118
- case name
119
- when "if"
120
- case context.last
121
- when nil, :if_true, :else_true
122
- check_indentation(cmd_indentation)
123
- result = the_binding.eval(args_string, filename, @lineno)
124
- context.push(result ? :if_true : :if_false)
125
- inc_indentation
126
- when :if_false, :else_false, :if_ignore
127
- check_indentation(cmd_indentation)
128
- inc_indentation
129
- context.push(:if_ignore)
130
- else
131
- terminate "#if is not allowed in this context"
132
- end
133
- when "elif"
134
- case context.last
135
- when :if_true
136
- dec_indentation
137
- check_indentation(cmd_indentation)
138
- inc_indentation
139
- context[-1] = :if_false
140
- when :if_false
141
- dec_indentation
142
- check_indentation(cmd_indentation)
143
- inc_indentation
144
- result = the_binding.eval(args_string, filename, @lineno)
145
- context[-1] = result ? :if_true : :if_false
146
- when :else_true, :else_false
147
- terminate "#elif is not allowed after #else"
148
- when :if_ignore
149
- dec_indentation
150
- check_indentation(cmd_indentation)
151
- inc_indentation
152
- else
153
- terminate "#elif is not allowed outside #if block"
154
- end
155
- when "else"
156
- case context.last
157
- when :if_true
158
- dec_indentation
159
- check_indentation(cmd_indentation)
160
- inc_indentation
161
- context[-1] = :else_false
162
- when :if_false
163
- dec_indentation
164
- check_indentation(cmd_indentation)
165
- inc_indentation
166
- context[-1] = :else_true
167
- when :else_true, :else_false
168
- terminate "it is not allowed to have multiple #else clauses in one #if block"
169
- when :if_ignore
170
- dec_indentation
171
- check_indentation(cmd_indentation)
172
- inc_indentation
173
- else
174
- terminate "#else is not allowed outside #if block"
175
- end
176
- when "endif"
177
- case context.last
178
- when :if_true, :if_false, :else_true, :else_false, :if_ignore
179
- dec_indentation
180
- check_indentation(cmd_indentation)
181
- context.pop
182
- else
183
- terminate "#endif is not allowed outside #if block"
184
- end
185
- when "DEBHELPER"
186
- output.puts(line)
187
- when "", nil
188
- # Either a comment or not a preprocessor command.
189
- case context.last
190
- when nil, :if_true, :else_true
191
- output.puts(unindent(line))
192
- else
193
- # Check indentation but do not output.
194
- unindent(line)
195
- end
196
- else
197
- terminate "Unrecognized preprocessor command ##{name.inspect}"
198
- end
199
-
200
- @lineno += 1
201
- end
202
- ensure
203
- if output_filename && output
204
- output.close
205
- stat = File.stat(filename)
206
- File.chmod(stat.mode, temp_output_filename)
207
- File.chown(stat.uid, stat.gid, temp_output_filename) rescue nil
208
- File.rename(temp_output_filename, output_filename)
209
- end
210
- end
211
-
212
- private
213
- UBUNTU_DISTRIBUTIONS = {
214
- "lucid" => "10.04",
215
- "maverick" => "10.10",
216
- "natty" => "11.04",
217
- "oneiric" => "11.10",
218
- "precise" => "12.04",
219
- "quantal" => "12.10",
220
- "raring" => "13.04",
221
- "saucy" => "13.10",
222
- "trusty" => "14.04"
223
- }
224
- DEBIAN_DISTRIBUTIONS = {
225
- "squeeze" => "20110206",
226
- "wheezy" => "20130504"
227
- }
228
- REDHAT_ENTERPRISE_DISTRIBUTIONS = {
229
- "el6" => "el6.0"
230
- }
231
- AMAZON_DISTRIBUTIONS = {
232
- "amazon" => "amazon"
233
- }
234
-
235
- # Provides the DSL that's accessible within.
236
- class Evaluator
237
- def _infer_distro_table(name)
238
- if UBUNTU_DISTRIBUTIONS.has_key?(name)
239
- return UBUNTU_DISTRIBUTIONS
240
- elsif DEBIAN_DISTRIBUTIONS.has_key?(name)
241
- return DEBIAN_DISTRIBUTIONS
242
- elsif REDHAT_ENTERPRISE_DISTRIBUTIONS.has_key?(name)
243
- return REDHAT_ENTERPRISE_DISTRIBUTIONS
244
- elsif AMAZON_DISTRIBUTIONS.has_key?(name)
245
- return AMAZON_DISTRIBUTIONS
246
- end
247
- end
248
-
249
- def is_distribution?(expr)
250
- if @distribution.nil?
251
- raise "The :distribution variable must be set"
252
- else
253
- if expr =~ /^(>=|>|<=|<|==|\!=)[\s]*(.+)/
254
- comparator = $1
255
- name = $2
256
- else
257
- raise "Invalid expression #{expr.inspect}"
258
- end
259
-
260
- table1 = _infer_distro_table(@distribution)
261
- table2 = _infer_distro_table(name)
262
- raise "Distribution name #{@distribution.inspect} not recognized" if !table1
263
- raise "Distribution name #{name.inspect} not recognized" if !table2
264
- return false if table1 != table2
265
- v1 = table1[@distribution]
266
- v2 = table2[name]
267
-
268
- case comparator
269
- when ">"
270
- return v1 > v2
271
- when ">="
272
- return v1 >= v2
273
- when "<"
274
- return v1 < v2
275
- when "<="
276
- return v1 <= v2
277
- when "=="
278
- return v1 == v2
279
- when "!="
280
- return v1 != v2
281
- else
282
- raise "BUG"
283
- end
284
- end
285
- end
286
- end
287
-
288
- def each_line(filename, the_binding)
289
- data = File.open(filename, 'r') do |f|
290
- erb = ERB.new(f.read, nil, "-")
291
- erb.filename = filename
292
- erb.result(the_binding)
293
- end
294
- data.each_line do |line|
295
- yield line.chomp
296
- end
297
- end
298
-
299
- def recognize_command(line)
300
- if line =~ /^([\s\t]*)#(.+)/
301
- indentation_str = $1
302
- command = $2
303
-
304
- # Declare tabs as equivalent to 4 spaces. This is necessary for
305
- # Makefiles in which the use of tabs is required.
306
- indentation_str.gsub!("\t", " ")
307
-
308
- name = command.scan(/^\w+/).first
309
- # Ignore shebangs and comments.
310
- return if name.nil?
311
-
312
- args_string = command.sub(/^#{Regexp.escape(name)}[\s\t]*/, '')
313
- return [name, args_string, indentation_str.to_s.size]
314
- else
315
- return nil
316
- end
317
- end
318
-
319
- def create_binding(variables)
320
- object = Evaluator.new
321
- variables.each_pair do |key, val|
322
- object.send(:instance_variable_set, "@#{key}", val)
323
- end
324
- return object.instance_eval do
325
- binding
326
- end
327
- end
328
-
329
- def inc_indentation
330
- @indentation += @indentation_size
331
- end
332
-
333
- def dec_indentation
334
- @indentation -= @indentation_size
335
- end
336
-
337
- def check_indentation(expected)
338
- if expected != @indentation
339
- terminate "wrong indentation: found #{expected} characters, should be #{@indentation}"
340
- end
341
- end
342
-
343
- def unindent(line)
344
- line =~ /^([\s\t]*)/
345
- # Declare tabs as equivalent to 4 spaces. This is necessary for
346
- # Makefiles in which the use of tabs is required.
347
- found = $1.to_s.gsub("\t", " ").size
348
-
349
- if found >= @indentation
350
- # Tab-friendly way to remove indentation.
351
- remaining = @indentation
352
- line = line.dup
353
- while remaining > 0
354
- if line[0..0] == " "
355
- remaining -= 1
356
- else
357
- # This is a tab.
358
- remaining -= 4
359
- end
360
- line.slice!(0, 1)
361
- end
362
- return line
363
- else
364
- terminate "wrong indentation: found #{found} characters, should be at least #{@indentation}"
365
- end
366
- end
367
-
368
- def debug(message)
369
- puts "DEBUG:#{@lineno}: #{message}" if @debug
370
- end
371
-
372
- def terminate(message)
373
- abort "*** ERROR: #{@filename} line #{@lineno}: #{message}"
374
- end
375
- end
376
-
377
- def recursive_copy_files(files, destination_dir, preprocess = false, variables = {})
378
- require 'fileutils' if !defined?(FileUtils)
379
- files.each_with_index do |filename, i|
380
- dir = File.dirname(filename)
381
- if !File.exist?("#{destination_dir}/#{dir}")
382
- FileUtils.mkdir_p("#{destination_dir}/#{dir}")
383
- end
384
- if !File.directory?(filename)
385
- if preprocess && filename =~ /\.template$/
386
- real_filename = filename.sub(/\.template$/, '')
387
- FileUtils.install(filename, "#{destination_dir}/#{real_filename}")
388
- Preprocessor.new.start(filename, "#{destination_dir}/#{real_filename}",
389
- variables)
390
- else
391
- FileUtils.install(filename, "#{destination_dir}/#{filename}")
392
- end
393
- end
394
- printf "\r[%5d/%5d] [%3.0f%%] Copying files...", i + 1, files.size, i * 100.0 / files.size
395
- STDOUT.flush
396
- end
397
- printf "\r[%5d/%5d] [%3.0f%%] Copying files...\n", files.size, files.size, 100
398
- end
399
-
400
- def create_debian_package_dir(distribution)
401
- require 'time'
402
-
403
- variables = {
404
- :distribution => distribution
405
- }
406
-
407
- root = "#{PKG_DIR}/#{distribution}"
408
- sh "rm -rf #{root}"
409
- sh "mkdir -p #{root}"
410
- recursive_copy_files(ORIG_TARBALL_FILES.call, root)
411
- recursive_copy_files(Dir["debian.template/**/*"], root,
412
- true, variables)
413
- sh "mv #{root}/debian.template #{root}/debian"
414
- changelog = File.read("#{root}/debian/changelog")
415
- changelog =
416
- "#{DEBIAN_NAME} (#{PACKAGE_VERSION}-#{DEBIAN_PACKAGE_REVISION}~#{distribution}1) #{distribution}; urgency=low\n" +
417
- "\n" +
418
- " * Package built.\n" +
419
- "\n" +
420
- " -- #{MAINTAINER_NAME} <#{MAINTAINER_EMAIL}> #{Time.now.rfc2822}\n\n" +
421
- changelog
422
- File.open("#{root}/debian/changelog", "w") do |f|
423
- f.write(changelog)
424
- end
425
- end
426
-
427
- task 'debian:orig_tarball' do
428
- if File.exist?("#{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz")
429
- puts "Debian orig tarball #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz already exists."
430
- else
431
- sh "rm -rf #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}"
432
- sh "mkdir -p #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}"
433
- recursive_copy_files(ORIG_TARBALL_FILES.call, "#{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}")
434
- sh "cd #{PKG_DIR} && find #{DEBIAN_NAME}_#{PACKAGE_VERSION} -print0 | xargs -0 touch -d '2013-10-27 00:00:00 UTC'"
435
- sh "cd #{PKG_DIR} && tar -c #{DEBIAN_NAME}_#{PACKAGE_VERSION} | gzip --no-name --best > #{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz"
436
- end
437
- end
438
-
439
- desc "Build Debian source and binary package(s) for local testing"
440
- task 'debian:dev' do
441
- sh "rm -f #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz"
442
- Rake::Task["debian:clean"].invoke
443
- Rake::Task["debian:orig_tarball"].invoke
444
- case distro = string_option('DISTRO', 'current')
445
- when 'current'
446
- distributions = [File.read("/etc/lsb-release").scan(/^DISTRIB_CODENAME=(.+)/).first.first]
447
- when 'all'
448
- distributions = ALL_DISTRIBUTIONS
449
- else
450
- distributions = distro.split(',')
451
- end
452
- distributions.each do |distribution|
453
- create_debian_package_dir(distribution)
454
- sh "cd #{PKG_DIR}/#{distribution} && dpkg-checkbuilddeps"
455
- end
456
- distributions.each do |distribution|
457
- sh "cd #{PKG_DIR}/#{distribution} && debuild -F -us -uc"
458
- end
459
- end
460
-
461
- desc "Build Debian source packages"
462
- task 'debian:source_packages' => 'debian:orig_tarball' do
463
- ALL_DISTRIBUTIONS.each do |distribution|
464
- create_debian_package_dir(distribution)
465
- end
466
- ALL_DISTRIBUTIONS.each do |distribution|
467
- sh "cd #{PKG_DIR}/#{distribution} && debuild -S -us -uc"
468
- end
469
- end
470
-
471
- desc "Build Debian source packages to be uploaded to Launchpad"
472
- task 'debian:launchpad' => 'debian:orig_tarball' do
473
- ALL_DISTRIBUTIONS.each do |distribution|
474
- create_debian_package_dir(distribution)
475
- sh "cd #{PKG_DIR}/#{distribution} && dpkg-checkbuilddeps"
476
- end
477
- ALL_DISTRIBUTIONS.each do |distribution|
478
- sh "cd #{PKG_DIR}/#{distribution} && debuild -S -sa -k#{PACKAGE_SIGNING_KEY}"
479
- end
480
- end
481
-
482
- desc "Clean Debian packaging products, except for orig tarball"
483
- task 'debian:clean' do
484
- files = Dir["#{PKG_DIR}/*.{changes,build,deb,dsc,upload}"]
485
- sh "rm -f #{files.join(' ')}"
486
- sh "rm -rf #{PKG_DIR}/dev"
487
- ALL_DISTRIBUTIONS.each do |distribution|
488
- sh "rm -rf #{PKG_DIR}/#{distribution}"
489
- end
490
- sh "rm -rf #{PKG_DIR}/*.debian.tar.gz"
491
- end
492
-
493
-
494
- ##### RPM packaging support #####
495
-
496
- RPM_NAME = "rubygem-crash-watch"
497
- RPM_PACKAGE_REVISION = 1
498
- RPMBUILD_ROOT = File.expand_path("~/rpmbuild")
499
- MOCK_OFFLINE = boolean_option('MOCK_OFFLINE', false)
500
- ALL_RPM_DISTROS = {
501
- "el6" => { :mock_chroot_name => "epel-6", :distro_name => "Enterprise Linux 6" },
502
- "amazon" => { :mock_chroot_name => "epel-6", :distro_name => "Amazon Linux" }
503
- }
504
-
505
- desc "Build gem for use in RPM building"
506
- task 'rpm:gem' do
507
- rpm_source_dir = "#{RPMBUILD_ROOT}/SOURCES"
508
- sh "gem build #{PACKAGE_NAME}.gemspec"
509
- sh "cp #{PACKAGE_NAME}-#{PACKAGE_VERSION}.gem #{rpm_source_dir}/"
510
- end
511
-
512
- desc "Build RPM for local machine"
513
- task 'rpm:local' => 'rpm:gem' do
514
- distro_id = `./rpm/get_distro_id.py`.strip
515
- rpm_spec_dir = "#{RPMBUILD_ROOT}/SPECS"
516
- spec_target_dir = "#{rpm_spec_dir}/#{distro_id}"
517
- spec_target_file = "#{spec_target_dir}/#{RPM_NAME}.spec"
518
-
519
- sh "mkdir -p #{spec_target_dir}"
520
- puts "Generating #{spec_target_file}"
521
- Preprocessor.new.start("rpm/#{RPM_NAME}.spec.template",
522
- spec_target_file,
523
- :distribution => distro_id)
524
-
525
- sh "rpmbuild -ba #{spec_target_file}"
526
- end
527
-
528
- def create_rpm_build_task(distro_id, mock_chroot_name, distro_name)
529
- desc "Build RPM for #{distro_name}"
530
- task "rpm:#{distro_id}" => 'rpm:gem' do
531
- rpm_spec_dir = "#{RPMBUILD_ROOT}/SPECS"
532
- spec_target_dir = "#{rpm_spec_dir}/#{distro_id}"
533
- spec_target_file = "#{spec_target_dir}/#{RPM_NAME}.spec"
534
- maybe_offline = MOCK_OFFLINE ? "--offline" : nil
535
-
536
- sh "mkdir -p #{spec_target_dir}"
537
- puts "Generating #{spec_target_file}"
538
- Preprocessor.new.start("rpm/#{RPM_NAME}.spec.template",
539
- spec_target_file,
540
- :distribution => distro_id)
541
-
542
- sh "rpmbuild -bs #{spec_target_file}"
543
- sh "mock --verbose #{maybe_offline} " +
544
- "-r #{mock_chroot_name}-x86_64 " +
545
- "--resultdir '#{PKG_DIR}/#{distro_id}' " +
546
- "rebuild #{RPMBUILD_ROOT}/SRPMS/#{RPM_NAME}-#{PACKAGE_VERSION}-#{RPM_PACKAGE_REVISION}#{distro_id}.src.rpm"
547
- end
548
- end
549
-
550
- ALL_RPM_DISTROS.each_pair do |distro_id, info|
551
- create_rpm_build_task(distro_id, info[:mock_chroot_name], info[:distro_name])
552
- end
553
-
554
- desc "Build RPMs for all distributions"
555
- task "rpm:all" => ALL_RPM_DISTROS.keys.map { |x| "rpm:#{x}" }
556
-
557
- desc "Publish RPMs for all distributions"
558
- task "rpm:publish" do
559
- server = "juvia-helper.phusion.nl"
560
- remote_dir = "/srv/oss_binaries_passenger/yumgems/phusion-misc"
561
- rsync = "rsync -z -r --delete --progress"
562
-
563
- ALL_RPM_DISTROS.each_key do |distro_id|
564
- if !File.exist?("#{PKG_DIR}/#{distro_id}")
565
- abort "No packages built for #{distro_id}. Please run 'rake rpm:all' first."
566
- end
567
- end
568
- ALL_RPM_DISTROS.each_key do |distro_id|
569
- sh "rpm --resign --define '%_signature gpg' --define '%_gpg_name #{PACKAGE_SIGNING_KEY}' #{PKG_DIR}/#{distro_id}/*.rpm"
570
- end
571
- sh "#{rsync} #{server}:#{remote_dir}/latest/ #{PKG_DIR}/yumgems/"
572
- ALL_RPM_DISTROS.each_key do |distro_id|
573
- distro_dir = "#{PKG_DIR}/#{distro_id}"
574
- repo_dir = "#{PKG_DIR}/yumgems/#{distro_id}"
575
- sh "mkdir -p #{repo_dir}"
576
- sh "cp #{distro_dir}/#{RPM_NAME}*.rpm #{repo_dir}/"
577
- sh "createrepo #{repo_dir}"
578
- end
579
- sh "ssh #{server} 'rm -rf #{remote_dir}/new && cp -dpR #{remote_dir}/latest #{remote_dir}/new'"
580
- sh "#{rsync} #{PKG_DIR}/yumgems/ #{server}:#{remote_dir}/new/"
581
- sh "ssh #{server} 'rm -rf #{remote_dir}/previous && mv #{remote_dir}/latest #{remote_dir}/previous && mv #{remote_dir}/new #{remote_dir}/latest'"
41
+ value = ENV[name]
42
+ if value.nil? || value.empty?
43
+ return default_value
44
+ else
45
+ return value == "yes" || value == "on" || value == "true" || value == "1"
46
+ end
582
47
  end