daemon_controller 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.asc CHANGED
@@ -2,11 +2,11 @@
2
2
  Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
3
3
  Comment: GPGTools - http://gpgtools.org
4
4
 
5
- iQEcBAABAgAGBQJSYaWbAAoJECrHRaUKISqMPEgH/2vbmBzw53ORHQDt0mJR/Loy
6
- zR3mV9jOWSep8Ia5T2i3MNs/eHJoZR+77YOJGvZa3qESN9g/2pZZYiWa3URBCc4D
7
- +nZcCMwHIhzwQzs6IHCEON1LhI1tvzdwe8LNu0uNFM6k9Q6oASMmqw9kF6gySOxA
8
- rwVxmYwR30eVM5E44D7KQx/OgTq69fVhlQmqlWTkjJej8o+AUQZ++ulD1eMS3uYF
9
- LOm1yDM2bOckjMQEb4BHmldIOP2quvnSqI7UsGK4UsrKGGZ4ILa/3TfS/OCSPZbY
10
- HiEFG9z3MkXKF6VXdbfiFHtMnYI9T2fuFYJ/Z9sDup1FrVbYH3nPl81N8aIXfcg=
11
- =7qth
5
+ iQEcBAABAgAGBQJSqv2ZAAoJECrHRaUKISqMXUcH/A7ahkIB32CsvC2z7Aa+rVXD
6
+ wjRUtm8fKxsz2SlFRa4RiVAwC6KFwbaRCAPMvXci1uEUecGeMdigBSYB5LFJx2em
7
+ AGjZefD46oosv5+2L+B+/JOyMtox2dDKDrP841+mciDFSj4h28tCtFZIxtWt/5g1
8
+ loxbFASHS23rb/N5sMuNwUEgkzDNmz2wwwGPVsWC8HEsYCBK+talACGAQEKoj93c
9
+ JsSI226pFF7FsFbzUa2yj972tYl+77j6dDGaP2NDnFw7haeDJCIIb3px0RbRe8Qv
10
+ KBzw5YiDCfSV7Lp/30hmpZd/Zk4mbaL3eJAjkBMBMyCOSLDX5cKuA15kAWZ37tY=
11
+ =kYLp
12
12
  -----END PGP SIGNATURE-----
@@ -51,6 +51,22 @@ Our Ubuntu Lucid packages are compatible with Debian 6.
51
51
  sudo apt-get update
52
52
  sudo apt-get install ruby-daemon-controller
53
53
 
54
+ ## Installation on RHEL, CentOS and Amazon Linux
55
+
56
+ Enable our YUM repository:
57
+
58
+ # RHEL 6, CentOS 6
59
+ curl -L https://oss-binaries.phusionpassenger.com/yumgems/phusion-misc/el.repo | \
60
+ sudo tee /etc/yum.repos.d/phusion-misc.repo
61
+
62
+ # Amazon Linux
63
+ curl -L https://oss-binaries.phusionpassenger.com/yumgems/phusion-misc/amazon.repo | \
64
+ sudo tee /etc/yum.repos.d/phusion-misc.repo
65
+
66
+ Install our package:
67
+
68
+ sudo yum install rubygem-daemon_controller
69
+
54
70
  ## Resources
55
71
 
56
72
  * [Website](https://github.com/FooBarWidget/daemon_controller)
@@ -0,0 +1,580 @@
1
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/lib"))
2
+ require 'daemon_controller/version'
3
+
4
+ PACKAGE_NAME = "daemon_controller"
5
+ PACKAGE_VERSION = DaemonController::VERSION_STRING
6
+ PACKAGE_SIGNING_KEY = "0x0A212A8C"
7
+ MAINTAINER_NAME = "Hongli Lai"
8
+ MAINTAINER_EMAIL = "hongli@phusion.nl"
9
+
10
+ desc "Run the unit tests"
11
+ task :test do
12
+ sh "rspec -f s -c spec/*_spec.rb"
13
+ end
14
+
15
+ desc "Build, sign & upload gem"
16
+ task 'package:release' do
17
+ sh "git tag -s release-#{PACKAGE_VERSION}"
18
+ sh "gem build #{PACKAGE_NAME}.gemspec --sign --key #{PACKAGE_SIGNING_KEY}"
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
26
+ end
27
+
28
+
29
+ ##### Utilities #####
30
+
31
+ def string_option(name, default_value = nil)
32
+ value = ENV[name]
33
+ if value.nil? || value.empty?
34
+ return default_value
35
+ else
36
+ return value
37
+ end
38
+ end
39
+
40
+ def boolean_option(name, default_value = false)
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
47
+ end
48
+
49
+
50
+ ##### Debian packaging support #####
51
+
52
+ PKG_DIR = string_option('PKG_DIR', "pkg")
53
+ DEBIAN_NAME = "ruby-daemon-controller"
54
+ DEBIAN_PACKAGE_REVISION = 1
55
+ ALL_DISTRIBUTIONS = string_option('DEBIAN_DISTROS', 'saucy precise lucid').split(/[ ,]/)
56
+ ORIG_TARBALL_FILES = lambda do
57
+ require 'daemon_controller/packaging'
58
+ Dir[*DAEMON_CONTROLLER_FILES] - Dir[*DAEMON_CONTROLLER_DEBIAN_EXCLUDE_FILES]
59
+ end
60
+
61
+ # Implements a simple preprocessor language which combines elements in the C
62
+ # preprocessor with ERB:
63
+ #
64
+ # Today
65
+ # #if @today == :fine
66
+ # is a fine day.
67
+ # #elif @today == :good
68
+ # is a good day.
69
+ # #else
70
+ # is a sad day.
71
+ # #endif
72
+ # Let's go walking.
73
+ # Today is <%= Time.now %>.
74
+ #
75
+ # When run with...
76
+ #
77
+ # Preprocessor.new.start('input.txt', 'output.txt', :today => :fine)
78
+ #
79
+ # ...will produce:
80
+ #
81
+ # Today
82
+ # is a fine day.
83
+ # Let's go walking.
84
+ # Today is 2013-08-11 22:37:06 +0200.
85
+ #
86
+ # Highlights:
87
+ #
88
+ # * #if blocks can be nested.
89
+ # * Expressions are Ruby expressions, evaluated within the binding of a
90
+ # Preprocessor::Evaluator object.
91
+ # * Text inside #if/#elif/#else are automatically unindented.
92
+ # * ERB compatible.
93
+ class Preprocessor
94
+ def initialize
95
+ require 'erb' if !defined?(ERB)
96
+ @indentation_size = 4
97
+ @debug = boolean_option('DEBUG')
98
+ end
99
+
100
+ def start(filename, output_filename, variables = {})
101
+ if output_filename
102
+ temp_output_filename = "#{output_filename}._new"
103
+ output = File.open(temp_output_filename, 'w')
104
+ else
105
+ output = STDOUT
106
+ end
107
+ the_binding = create_binding(variables)
108
+ context = []
109
+ @filename = filename
110
+ @lineno = 1
111
+ @indentation = 0
112
+
113
+ each_line(filename, the_binding) do |line|
114
+ debug("context=#{context.inspect}, line=#{line.inspect}")
115
+
116
+ name, args_string, cmd_indentation = recognize_command(line)
117
+ case name
118
+ when "if"
119
+ case context.last
120
+ when nil, :if_true, :else_true
121
+ check_indentation(cmd_indentation)
122
+ result = the_binding.eval(args_string, filename, @lineno)
123
+ context.push(result ? :if_true : :if_false)
124
+ inc_indentation
125
+ when :if_false, :else_false, :if_ignore
126
+ check_indentation(cmd_indentation)
127
+ inc_indentation
128
+ context.push(:if_ignore)
129
+ else
130
+ terminate "#if is not allowed in this context"
131
+ end
132
+ when "elif"
133
+ case context.last
134
+ when :if_true
135
+ dec_indentation
136
+ check_indentation(cmd_indentation)
137
+ inc_indentation
138
+ context[-1] = :if_false
139
+ when :if_false
140
+ dec_indentation
141
+ check_indentation(cmd_indentation)
142
+ inc_indentation
143
+ result = the_binding.eval(args_string, filename, @lineno)
144
+ context[-1] = result ? :if_true : :if_false
145
+ when :else_true, :else_false
146
+ terminate "#elif is not allowed after #else"
147
+ when :if_ignore
148
+ dec_indentation
149
+ check_indentation(cmd_indentation)
150
+ inc_indentation
151
+ else
152
+ terminate "#elif is not allowed outside #if block"
153
+ end
154
+ when "else"
155
+ case context.last
156
+ when :if_true
157
+ dec_indentation
158
+ check_indentation(cmd_indentation)
159
+ inc_indentation
160
+ context[-1] = :else_false
161
+ when :if_false
162
+ dec_indentation
163
+ check_indentation(cmd_indentation)
164
+ inc_indentation
165
+ context[-1] = :else_true
166
+ when :else_true, :else_false
167
+ terminate "it is not allowed to have multiple #else clauses in one #if block"
168
+ when :if_ignore
169
+ dec_indentation
170
+ check_indentation(cmd_indentation)
171
+ inc_indentation
172
+ else
173
+ terminate "#else is not allowed outside #if block"
174
+ end
175
+ when "endif"
176
+ case context.last
177
+ when :if_true, :if_false, :else_true, :else_false, :if_ignore
178
+ dec_indentation
179
+ check_indentation(cmd_indentation)
180
+ context.pop
181
+ else
182
+ terminate "#endif is not allowed outside #if block"
183
+ end
184
+ when "DEBHELPER"
185
+ output.puts(line)
186
+ when "", nil
187
+ # Either a comment or not a preprocessor command.
188
+ case context.last
189
+ when nil, :if_true, :else_true
190
+ output.puts(unindent(line))
191
+ else
192
+ # Check indentation but do not output.
193
+ unindent(line)
194
+ end
195
+ else
196
+ terminate "Unrecognized preprocessor command ##{name.inspect}"
197
+ end
198
+
199
+ @lineno += 1
200
+ end
201
+ ensure
202
+ if output_filename && output
203
+ output.close
204
+ stat = File.stat(filename)
205
+ File.chmod(stat.mode, temp_output_filename)
206
+ File.chown(stat.uid, stat.gid, temp_output_filename) rescue nil
207
+ File.rename(temp_output_filename, output_filename)
208
+ end
209
+ end
210
+
211
+ private
212
+ UBUNTU_DISTRIBUTIONS = {
213
+ "lucid" => "10.04",
214
+ "maverick" => "10.10",
215
+ "natty" => "11.04",
216
+ "oneiric" => "11.10",
217
+ "precise" => "12.04",
218
+ "quantal" => "12.10",
219
+ "raring" => "13.04",
220
+ "saucy" => "13.10",
221
+ "trusty" => "14.04"
222
+ }
223
+ DEBIAN_DISTRIBUTIONS = {
224
+ "squeeze" => "20110206",
225
+ "wheezy" => "20130504"
226
+ }
227
+ REDHAT_ENTERPRISE_DISTRIBUTIONS = {
228
+ "el6" => "el6.0"
229
+ }
230
+ AMAZON_DISTRIBUTIONS = {
231
+ "amazon" => "amazon"
232
+ }
233
+
234
+ # Provides the DSL that's accessible within.
235
+ class Evaluator
236
+ def _infer_distro_table(name)
237
+ if UBUNTU_DISTRIBUTIONS.has_key?(name)
238
+ return UBUNTU_DISTRIBUTIONS
239
+ elsif DEBIAN_DISTRIBUTIONS.has_key?(name)
240
+ return DEBIAN_DISTRIBUTIONS
241
+ elsif REDHAT_ENTERPRISE_DISTRIBUTIONS.has_key?(name)
242
+ return REDHAT_ENTERPRISE_DISTRIBUTIONS
243
+ elsif AMAZON_DISTRIBUTIONS.has_key?(name)
244
+ return AMAZON_DISTRIBUTIONS
245
+ end
246
+ end
247
+
248
+ def is_distribution?(expr)
249
+ if @distribution.nil?
250
+ raise "The :distribution variable must be set"
251
+ else
252
+ if expr =~ /^(>=|>|<=|<|==|\!=)[\s]*(.+)/
253
+ comparator = $1
254
+ name = $2
255
+ else
256
+ raise "Invalid expression #{expr.inspect}"
257
+ end
258
+
259
+ table1 = _infer_distro_table(@distribution)
260
+ table2 = _infer_distro_table(name)
261
+ raise "Distribution name #{@distribution.inspect} not recognized" if !table1
262
+ raise "Distribution name #{name.inspect} not recognized" if !table2
263
+ return false if table1 != table2
264
+ v1 = table1[@distribution]
265
+ v2 = table2[name]
266
+
267
+ case comparator
268
+ when ">"
269
+ return v1 > v2
270
+ when ">="
271
+ return v1 >= v2
272
+ when "<"
273
+ return v1 < v2
274
+ when "<="
275
+ return v1 <= v2
276
+ when "=="
277
+ return v1 == v2
278
+ when "!="
279
+ return v1 != v2
280
+ else
281
+ raise "BUG"
282
+ end
283
+ end
284
+ end
285
+ end
286
+
287
+ def each_line(filename, the_binding)
288
+ data = File.open(filename, 'r') do |f|
289
+ erb = ERB.new(f.read, nil, "-")
290
+ erb.filename = filename
291
+ erb.result(the_binding)
292
+ end
293
+ data.each_line do |line|
294
+ yield line.chomp
295
+ end
296
+ end
297
+
298
+ def recognize_command(line)
299
+ if line =~ /^([\s\t]*)#(.+)/
300
+ indentation_str = $1
301
+ command = $2
302
+
303
+ # Declare tabs as equivalent to 4 spaces. This is necessary for
304
+ # Makefiles in which the use of tabs is required.
305
+ indentation_str.gsub!("\t", " ")
306
+
307
+ name = command.scan(/^\w+/).first
308
+ # Ignore shebangs and comments.
309
+ return if name.nil?
310
+
311
+ args_string = command.sub(/^#{Regexp.escape(name)}[\s\t]*/, '')
312
+ return [name, args_string, indentation_str.to_s.size]
313
+ else
314
+ return nil
315
+ end
316
+ end
317
+
318
+ def create_binding(variables)
319
+ object = Evaluator.new
320
+ variables.each_pair do |key, val|
321
+ object.send(:instance_variable_set, "@#{key}", val)
322
+ end
323
+ return object.instance_eval do
324
+ binding
325
+ end
326
+ end
327
+
328
+ def inc_indentation
329
+ @indentation += @indentation_size
330
+ end
331
+
332
+ def dec_indentation
333
+ @indentation -= @indentation_size
334
+ end
335
+
336
+ def check_indentation(expected)
337
+ if expected != @indentation
338
+ terminate "wrong indentation: found #{expected} characters, should be #{@indentation}"
339
+ end
340
+ end
341
+
342
+ def unindent(line)
343
+ line =~ /^([\s\t]*)/
344
+ # Declare tabs as equivalent to 4 spaces. This is necessary for
345
+ # Makefiles in which the use of tabs is required.
346
+ found = $1.to_s.gsub("\t", " ").size
347
+
348
+ if found >= @indentation
349
+ # Tab-friendly way to remove indentation.
350
+ remaining = @indentation
351
+ line = line.dup
352
+ while remaining > 0
353
+ if line[0..0] == " "
354
+ remaining -= 1
355
+ else
356
+ # This is a tab.
357
+ remaining -= 4
358
+ end
359
+ line.slice!(0, 1)
360
+ end
361
+ return line
362
+ else
363
+ terminate "wrong indentation: found #{found} characters, should be at least #{@indentation}"
364
+ end
365
+ end
366
+
367
+ def debug(message)
368
+ puts "DEBUG:#{@lineno}: #{message}" if @debug
369
+ end
370
+
371
+ def terminate(message)
372
+ abort "*** ERROR: #{@filename} line #{@lineno}: #{message}"
373
+ end
374
+ end
375
+
376
+ def recursive_copy_files(files, destination_dir, preprocess = false, variables = {})
377
+ require 'fileutils' if !defined?(FileUtils)
378
+ files.each_with_index do |filename, i|
379
+ dir = File.dirname(filename)
380
+ if !File.exist?("#{destination_dir}/#{dir}")
381
+ FileUtils.mkdir_p("#{destination_dir}/#{dir}")
382
+ end
383
+ if !File.directory?(filename)
384
+ if preprocess && filename =~ /\.template$/
385
+ real_filename = filename.sub(/\.template$/, '')
386
+ FileUtils.install(filename, "#{destination_dir}/#{real_filename}")
387
+ Preprocessor.new.start(filename, "#{destination_dir}/#{real_filename}",
388
+ variables)
389
+ else
390
+ FileUtils.install(filename, "#{destination_dir}/#{filename}")
391
+ end
392
+ end
393
+ printf "\r[%5d/%5d] [%3.0f%%] Copying files...", i + 1, files.size, i * 100.0 / files.size
394
+ STDOUT.flush
395
+ end
396
+ printf "\r[%5d/%5d] [%3.0f%%] Copying files...\n", files.size, files.size, 100
397
+ end
398
+
399
+ def create_debian_package_dir(distribution)
400
+ require 'time'
401
+
402
+ variables = {
403
+ :distribution => distribution
404
+ }
405
+
406
+ root = "#{PKG_DIR}/#{distribution}"
407
+ sh "rm -rf #{root}"
408
+ sh "mkdir -p #{root}"
409
+ recursive_copy_files(ORIG_TARBALL_FILES.call, root)
410
+ recursive_copy_files(Dir["debian.template/**/*"], root,
411
+ true, variables)
412
+ sh "mv #{root}/debian.template #{root}/debian"
413
+ changelog = File.read("#{root}/debian/changelog")
414
+ changelog =
415
+ "#{DEBIAN_NAME} (#{PACKAGE_VERSION}-#{DEBIAN_PACKAGE_REVISION}~#{distribution}1) #{distribution}; urgency=low\n" +
416
+ "\n" +
417
+ " * Package built.\n" +
418
+ "\n" +
419
+ " -- #{MAINTAINER_NAME} <#{MAINTAINER_EMAIL}> #{Time.now.rfc2822}\n\n" +
420
+ changelog
421
+ File.open("#{root}/debian/changelog", "w") do |f|
422
+ f.write(changelog)
423
+ end
424
+ end
425
+
426
+ task 'debian:orig_tarball' do
427
+ if File.exist?("#{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz")
428
+ puts "Debian orig tarball #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz already exists."
429
+ else
430
+ sh "rm -rf #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}"
431
+ sh "mkdir -p #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}"
432
+ recursive_copy_files(ORIG_TARBALL_FILES.call, "#{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}")
433
+ sh "cd #{PKG_DIR} && find #{DEBIAN_NAME}_#{PACKAGE_VERSION} -print0 | xargs -0 touch -d '2013-10-27 00:00:00 UTC'"
434
+ sh "cd #{PKG_DIR} && tar -c #{DEBIAN_NAME}_#{PACKAGE_VERSION} | gzip --no-name --best > #{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz"
435
+ end
436
+ end
437
+
438
+ desc "Build Debian source and binary package(s) for local testing"
439
+ task 'debian:dev' do
440
+ sh "rm -f #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz"
441
+ Rake::Task["debian:clean"].invoke
442
+ Rake::Task["debian:orig_tarball"].invoke
443
+ case distro = string_option('DISTRO', 'current')
444
+ when 'current'
445
+ distributions = [File.read("/etc/lsb-release").scan(/^DISTRIB_CODENAME=(.+)/).first.first]
446
+ when 'all'
447
+ distributions = ALL_DISTRIBUTIONS
448
+ else
449
+ distributions = distro.split(',')
450
+ end
451
+ distributions.each do |distribution|
452
+ create_debian_package_dir(distribution)
453
+ sh "cd #{PKG_DIR}/#{distribution} && dpkg-checkbuilddeps"
454
+ end
455
+ distributions.each do |distribution|
456
+ sh "cd #{PKG_DIR}/#{distribution} && debuild -F -us -uc"
457
+ end
458
+ end
459
+
460
+ desc "Build Debian source packages"
461
+ task 'debian:source_packages' => 'debian:orig_tarball' do
462
+ ALL_DISTRIBUTIONS.each do |distribution|
463
+ create_debian_package_dir(distribution)
464
+ end
465
+ ALL_DISTRIBUTIONS.each do |distribution|
466
+ sh "cd #{PKG_DIR}/#{distribution} && debuild -S -us -uc"
467
+ end
468
+ end
469
+
470
+ desc "Build Debian source packages to be uploaded to Launchpad"
471
+ task 'debian:launchpad' => 'debian:orig_tarball' do
472
+ ALL_DISTRIBUTIONS.each do |distribution|
473
+ create_debian_package_dir(distribution)
474
+ sh "cd #{PKG_DIR}/#{distribution} && dpkg-checkbuilddeps"
475
+ end
476
+ ALL_DISTRIBUTIONS.each do |distribution|
477
+ sh "cd #{PKG_DIR}/#{distribution} && debuild -S -sa -k#{PACKAGE_SIGNING_KEY}"
478
+ end
479
+ end
480
+
481
+ desc "Clean Debian packaging products, except for orig tarball"
482
+ task 'debian:clean' do
483
+ files = Dir["#{PKG_DIR}/*.{changes,build,deb,dsc,upload}"]
484
+ sh "rm -f #{files.join(' ')}"
485
+ sh "rm -rf #{PKG_DIR}/dev"
486
+ ALL_DISTRIBUTIONS.each do |distribution|
487
+ sh "rm -rf #{PKG_DIR}/#{distribution}"
488
+ end
489
+ sh "rm -rf #{PKG_DIR}/*.debian.tar.gz"
490
+ end
491
+
492
+
493
+ ##### RPM packaging support #####
494
+
495
+ RPM_NAME = "rubygem-daemon_controller"
496
+ RPMBUILD_ROOT = File.expand_path("~/rpmbuild")
497
+ MOCK_OFFLINE = boolean_option('MOCK_OFFLINE', false)
498
+ ALL_RPM_DISTROS = {
499
+ "el6" => { :mock_chroot_name => "epel-6", :distro_name => "Enterprise Linux 6" },
500
+ "amazon" => { :mock_chroot_name => "epel-6", :distro_name => "Amazon Linux" }
501
+ }
502
+
503
+ desc "Build gem for use in RPM building"
504
+ task 'rpm:gem' do
505
+ rpm_source_dir = "#{RPMBUILD_ROOT}/SOURCES"
506
+ sh "gem build #{PACKAGE_NAME}.gemspec"
507
+ sh "cp #{PACKAGE_NAME}-#{PACKAGE_VERSION}.gem #{rpm_source_dir}/"
508
+ end
509
+
510
+ desc "Build RPM for local machine"
511
+ task 'rpm:local' => 'rpm:gem' do
512
+ distro_id = `./rpm/get_distro_id.py`.strip
513
+ rpm_spec_dir = "#{RPMBUILD_ROOT}/SPECS"
514
+ spec_target_dir = "#{rpm_spec_dir}/#{distro_id}"
515
+ spec_target_file = "#{spec_target_dir}/#{RPM_NAME}.spec"
516
+
517
+ sh "mkdir -p #{spec_target_dir}"
518
+ puts "Generating #{spec_target_file}"
519
+ Preprocessor.new.start("rpm/#{RPM_NAME}.spec.template",
520
+ spec_target_file,
521
+ :distribution => distro_id)
522
+
523
+ sh "rpmbuild -ba #{spec_target_file}"
524
+ end
525
+
526
+ def create_rpm_build_task(distro_id, mock_chroot_name, distro_name)
527
+ desc "Build RPM for #{distro_name}"
528
+ task "rpm:#{distro_id}" => 'rpm:gem' do
529
+ rpm_spec_dir = "#{RPMBUILD_ROOT}/SPECS"
530
+ spec_target_dir = "#{rpm_spec_dir}/#{distro_id}"
531
+ spec_target_file = "#{spec_target_dir}/#{RPM_NAME}.spec"
532
+ maybe_offline = MOCK_OFFLINE ? "--offline" : nil
533
+
534
+ sh "mkdir -p #{spec_target_dir}"
535
+ puts "Generating #{spec_target_file}"
536
+ Preprocessor.new.start("rpm/#{RPM_NAME}.spec.template",
537
+ spec_target_file,
538
+ :distribution => distro_id)
539
+
540
+ sh "rpmbuild -bs #{spec_target_file}"
541
+ sh "mock --verbose #{maybe_offline} " +
542
+ "-r #{mock_chroot_name}-x86_64 " +
543
+ "--resultdir '#{PKG_DIR}/#{distro_id}' " +
544
+ "rebuild #{RPMBUILD_ROOT}/SRPMS/#{RPM_NAME}-#{PACKAGE_VERSION}-1#{distro_id}.src.rpm"
545
+ end
546
+ end
547
+
548
+ ALL_RPM_DISTROS.each_pair do |distro_id, info|
549
+ create_rpm_build_task(distro_id, info[:mock_chroot_name], info[:distro_name])
550
+ end
551
+
552
+ desc "Build RPMs for all distributions"
553
+ task "rpm:all" => ALL_RPM_DISTROS.keys.map { |x| "rpm:#{x}" }
554
+
555
+ desc "Publish RPMs for all distributions"
556
+ task "rpm:publish" do
557
+ server = "juvia-helper.phusion.nl"
558
+ remote_dir = "/srv/oss_binaries_passenger/yumgems/phusion-misc"
559
+ rsync = "rsync -z -r --delete --progress"
560
+
561
+ ALL_RPM_DISTROS.each_key do |distro_id|
562
+ if !File.exist?("#{PKG_DIR}/#{distro_id}")
563
+ abort "No packages built for #{distro_id}. Please run 'rake rpm:all' first."
564
+ end
565
+ end
566
+ ALL_RPM_DISTROS.each_key do |distro_id|
567
+ sh "rpm --resign --define '%_signature gpg' --define '%_gpg_name #{PACKAGE_SIGNING_KEY}' #{PKG_DIR}/#{distro_id}/*.rpm"
568
+ end
569
+ sh "#{rsync} #{server}:#{remote_dir}/latest/ #{PKG_DIR}/yumgems/"
570
+ ALL_RPM_DISTROS.each_key do |distro_id|
571
+ distro_dir = "#{PKG_DIR}/#{distro_id}"
572
+ repo_dir = "#{PKG_DIR}/yumgems/#{distro_id}"
573
+ sh "mkdir -p #{repo_dir}"
574
+ sh "cp #{distro_dir}/#{RPM_NAME}*.rpm #{repo_dir}/"
575
+ sh "createrepo #{repo_dir}"
576
+ end
577
+ sh "ssh #{server} 'rm -rf #{remote_dir}/new && cp -dpR #{remote_dir}/latest #{remote_dir}/new'"
578
+ sh "#{rsync} #{PKG_DIR}/yumgems/ #{server}:#{remote_dir}/new/"
579
+ sh "ssh #{server} 'rm -rf #{remote_dir}/previous && mv #{remote_dir}/latest #{remote_dir}/previous && mv #{remote_dir}/new #{remote_dir}/latest'"
580
+ end
@@ -12,4 +12,4 @@ Package: ruby-daemon-controller
12
12
  Architecture: all
13
13
  Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter
14
14
  Description: Library for robust daemon management
15
- Library which implementing daemon management capabilities.
15
+ Library which implements daemon management capabilities.
@@ -20,11 +20,16 @@
20
20
  # THE SOFTWARE.
21
21
 
22
22
  DAEMON_CONTROLLER_FILES = [
23
- "README.markdown", "LICENSE.txt", "daemon_controller.gemspec",
23
+ "README.markdown", "LICENSE.txt", "Rakefile", "daemon_controller.gemspec",
24
24
  "lib/**/*.rb",
25
25
  "debian.template/**/*",
26
+ "rpm/**/*",
26
27
  "spec/*.rb",
27
28
  "spec/run_echo_server"
28
29
  ]
29
30
 
30
- DAEMON_CONTROLLER_DEBIAN_EXCLUDE_FILES = []
31
+ DAEMON_CONTROLLER_DEBIAN_EXCLUDE_FILES = [
32
+ "Rakefile",
33
+ "debian.template/**/*",
34
+ "rpm/**/*"
35
+ ]
@@ -22,6 +22,6 @@
22
22
  class DaemonController
23
23
  MAJOR = 1
24
24
  MINOR = 1
25
- TINY = 7
25
+ TINY = 8
26
26
  VERSION_STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
27
27
  end # class DaemonController
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env python
2
+ vars = { 'config_opts': {} }
3
+ execfile("/etc/mock/default.cfg", vars)
4
+ print(vars['config_opts']['dist'])
@@ -0,0 +1,102 @@
1
+ %global gem_name daemon_controller
2
+ %global gem_version <%= PACKAGE_VERSION %>
3
+
4
+ %if 0%{?fc18}
5
+ %global rubyabi 1.9.1
6
+ %endif
7
+
8
+ %if 0%{?el6}
9
+ %global rubyabi 1.8
10
+ %endif
11
+
12
+ Name: rubygem-%{gem_name}
13
+ Version: %{gem_version}
14
+ Release: 1<%= @distribution %>
15
+ Summary: Library for robust daemon management
16
+ License: MIT
17
+ Group: Development/Libraries
18
+ URL: https://github.com/FooBarWidget/daemon_controller
19
+ Source0: https://rubygems.org/gems/%{gem_name}-%{gem_version}.gem
20
+
21
+ %if 0%{?fedora} >= 19
22
+ Requires: ruby(release)
23
+ %else
24
+ Requires: ruby(abi) = %{rubyabi}
25
+ %endif
26
+ Requires: ruby(rubygems)
27
+
28
+ %if 0%{?fedora} >= 19
29
+ BuildRequires: ruby(release)
30
+ %else
31
+ BuildRequires: ruby(abi) = %{rubyabi}
32
+ %endif
33
+ %if 0%{?el6}
34
+ BuildRequires: ruby(rubygems)
35
+ %else
36
+ BuildRequires: rubygems-devel
37
+ %endif
38
+
39
+ BuildArch: noarch
40
+ Provides: rubygem(%{gem_name}) = %{gem_version}-%{release}
41
+
42
+ # macros for RHEL6 compatibility:
43
+ %{!?gem_dir: %global gem_dir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)}
44
+ %{!?gem_instdir: %global gem_instdir %{gem_dir}/gems/%{gem_name}-%{gem_version}}
45
+ %{!?gem_libdir: %global gem_libdir %{gem_instdir}/lib}
46
+ %{!?gem_cache: %global gem_cache %{gem_dir}/cache/%{gem_name}-%{gem_version}.gem}
47
+ %{!?gem_spec: %global gem_spec %{gem_dir}/specifications/%{gem_name}-%{gem_version}.gemspec}
48
+ %{!?gem_docdir: %global gem_docdir %{gem_dir}/doc/%{gem_name}-%{gem_version}}
49
+ %{!?ruby_sitearch: %global ruby_sitearch %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["sitearchdir"]')}
50
+
51
+
52
+ %description
53
+ Library which implements daemon management capabilities.
54
+
55
+ %prep
56
+ %setup -q -c -T
57
+
58
+ %build
59
+ %if 0%{?el6}
60
+ mkdir -p .%{gem_dir}
61
+ gem install \
62
+ --local \
63
+ --install-dir .%{gem_dir} \
64
+ --bindir .%{_bindir} \
65
+ --no-rdoc --no-ri \
66
+ --force \
67
+ --backtrace \
68
+ %{SOURCE0}
69
+ %else
70
+ %gem_install -n %{SOURCE0} --no-rdoc --no-ri
71
+ %endif
72
+
73
+ %install
74
+ rm -rf %{buildroot}
75
+ mkdir -p %{buildroot}%{gem_dir}
76
+ cp -a .%{_prefix}/* %{buildroot}%{_prefix}/
77
+
78
+ %check
79
+ pushd %{buildroot}%{gem_instdir}
80
+ ruby -Ilib -rdaemon_controller -e ''
81
+ popd
82
+
83
+ %clean
84
+ rm -rf %{buildroot}
85
+
86
+ %files
87
+ %defattr(-,root,root,-)
88
+ %dir %{gem_instdir}
89
+ %doc %{gem_instdir}/LICENSE.txt
90
+ %doc %{gem_instdir}/README.markdown
91
+ %{gem_instdir}/daemon_controller.gemspec
92
+ %{gem_instdir}/spec
93
+ %{gem_libdir}
94
+ %exclude %{gem_instdir}/Rakefile
95
+ %exclude %{gem_instdir}/debian.template
96
+ %exclude %{gem_instdir}/rpm
97
+ %exclude %{gem_cache}
98
+ %{gem_spec}
99
+
100
+ %changelog
101
+ * Wed Dec 11 2013 Hongli Lai <hongli@phusion.nl> - 1.1.7-1<%= @distribution %>
102
+ - Initial packaging
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemon_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.8
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Hongli Lai
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-10-18 00:00:00.000000000 Z
12
+ date: 2013-12-13 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: A library for robust daemon management.
14
15
  email: software-signing@phusion.nl
@@ -18,6 +19,7 @@ extra_rdoc_files: []
18
19
  files:
19
20
  - README.markdown
20
21
  - LICENSE.txt
22
+ - Rakefile
21
23
  - daemon_controller.gemspec
22
24
  - lib/daemon_controller/lock_file.rb
23
25
  - lib/daemon_controller/packaging.rb
@@ -31,6 +33,8 @@ files:
31
33
  - debian.template/ruby-daemon-controller.install
32
34
  - debian.template/rules
33
35
  - debian.template/source/format
36
+ - rpm/get_distro_id.py
37
+ - rpm/rubygem-daemon_controller.spec.template
34
38
  - spec/daemon_controller_spec.rb
35
39
  - spec/echo_server.rb
36
40
  - spec/test_helper.rb
@@ -39,25 +43,26 @@ files:
39
43
  homepage: https://github.com/FooBarWidget/daemon_controller
40
44
  licenses:
41
45
  - MIT
42
- metadata: {}
43
46
  post_install_message:
44
47
  rdoc_options: []
45
48
  require_paths:
46
49
  - lib
47
50
  required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
48
52
  requirements:
49
53
  - - ! '>='
50
54
  - !ruby/object:Gem::Version
51
55
  version: '0'
52
56
  required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
53
58
  requirements:
54
59
  - - ! '>='
55
60
  - !ruby/object:Gem::Version
56
61
  version: '0'
57
62
  requirements: []
58
63
  rubyforge_project:
59
- rubygems_version: 2.1.5
64
+ rubygems_version: 1.8.23
60
65
  signing_key:
61
- specification_version: 4
66
+ specification_version: 3
62
67
  summary: A library for implementing daemon management capabilities
63
68
  test_files: []
metadata.gz.asc CHANGED
@@ -2,11 +2,11 @@
2
2
  Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
3
3
  Comment: GPGTools - http://gpgtools.org
4
4
 
5
- iQEcBAABAgAGBQJSYaWbAAoJECrHRaUKISqM7AYH/1X7PiV32w0NzEZIBYvyXjW6
6
- EbUzb0FjoROwXRCMiIbdrRoNoS15xdH6qjvqO6cvInyv0RBfLmr9N1ME8mRhxX7F
7
- 7Iqyuqv2K8hqOeKNR14e+CerHvSr6pY9EdQ/CYBPz1rnjOXcpiXk74n3bYVkUClp
8
- VTtiJd/PqxobCDRDL6a0awCKC1aUgUIaQrfLPLmN6gvXzOJGZ0vOUxapbJsM+QtC
9
- RznkJ+acZUxQ+wicbG3HlTUwghg6rt73w37RRX3kyVXXlyim2dI8wA8MEVweG7Ic
10
- hcpkDLrfjnuGfU5ZXMBaJis45eLyM04PhMkgy7tN38eFhDpkVDBntmzDssn2IR0=
11
- =R5Ld
5
+ iQEcBAABAgAGBQJSqv2ZAAoJECrHRaUKISqMUggH/2RSYFWz4Ar/hVc3hNiFT6/g
6
+ /FwS91uvTfaT+dXH8Ce6S5pG+YpfHED4AE0sauPqA2Y6PUrWRBHqrokk+XOhPaGe
7
+ ONNBrikL1yzQDwuPYdEN09g+XTrQwVfD7d/wbh1PySUeZ3+ccmxe1DCtHB0DIDtz
8
+ 7yBGbbfbcZsdnx43wzaGKIS8jLxsLip3Ui9XPxhyJVcfJd/8Q9Tp7d9/Zd+wKMt6
9
+ Ii2pjXB99Dx2KfUOWetIeFIANrxj9HkKgPaVqp5uWVSfZUkknKytaHJMNDIdQixA
10
+ OB/CaYOurmEkhn9dUml72D0cWlD4wN1wcATa8bnxp8ii+566wt1tab/GQi/5llU=
11
+ =I4R2
12
12
  -----END PGP SIGNATURE-----
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDkzOTZlNWZlMDlmODNlODZhYTBjZGZhN2MyZGRjZjczYjJkOGExNg==
5
- data.tar.gz: !binary |-
6
- YTI4ZjVkZThmODZkNTM1MmFmNjAyZDVkOTVlMTdmNzEwZWNkMThmYg==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- MmFhNTNhZWE0OTk5NWZmMTAwOThmMDQ1MDI3MzgyMTI2ZWMyN2Q3ZWYxYzg0
10
- NDhkZjRhOWJkZGI1MTUyZWVkODNlYTcxMGZkMjg5NWNlOTEwMTY1NzcyZmJk
11
- MTRlMmQ2NDBiMjdlNGEzNDZjNTUxNWEyODc2NGQ1ODM2OGQxYWI=
12
- data.tar.gz: !binary |-
13
- NmI1MGE0MjM4MjliOTYwNDg5NmI4NDExZDQyZDEyYTkzMDBiYmY1OGYwMzcw
14
- ZTcwMjBlM2VkNjg2MzgxMDlhODFhOTBjMjdlNDUzZjFlOTQ4MWZjNjdjNjVk
15
- MzE2NzE2YmU1ZTA5NzEzMmU1MWU0ODQ2YWU2Yzg0ZTYzNDZkYjY=
@@ -1,12 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
3
- Comment: GPGTools - http://gpgtools.org
4
-
5
- iQEcBAABAgAGBQJSYaWbAAoJECrHRaUKISqM+nUH/3EL1ONzC4dtX9mDaRVIPXJN
6
- t5GpAP8t0eu9/C4WGUUKoaix6vmVMQCBIDooAFsvxuS4G/d9PB4GKwJl5y9cPIxi
7
- QCu9vseOn81cuOTwVUPioeXEyCP3zqpO0Gipb5awLC2YcHxAu7L3BnUeIVBD8oW9
8
- oqIkbOcaaxBW0yKSzsmGoeshAJcD/dBIvkudnm4lQjeYTycgyfEKwhePRWU52tML
9
- stSxMEbjn9XysBzhPqYI4B33beAglRJbl7g4TbO871IgbvK9l0bue/XurO4Y5tee
10
- fS4f3fAlXBeGLJZOcYrXDDdsVimOU0xZ8sMiSFoGRc9hEDmCDtxC7ZrOayQz+3A=
11
- =2wsI
12
- -----END PGP SIGNATURE-----