Class: Ploy::LocalPackage::DebBuilder
- Inherits:
-
Object
- Object
- Ploy::LocalPackage::DebBuilder
- Defined in:
- lib/ploy/localpackage/debbuilder.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#dist_dir ⇒ Object
Returns the value of attribute dist_dir.
-
#name ⇒ Object
Returns the value of attribute name.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#sha ⇒ Object
Returns the value of attribute sha.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#upstart_files ⇒ Object
Returns the value of attribute upstart_files.
Instance Method Summary collapse
- #build_deb ⇒ Object
- #fpm_optlist(dir) ⇒ Object
-
#initialize(opts = {}) ⇒ DebBuilder
constructor
A new instance of DebBuilder.
- #mirror_dist(dir) ⇒ Object
- #mirror_dist_target(topdir) ⇒ Object
- #write_metadata(dir) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ DebBuilder
Returns a new instance of DebBuilder.
15 16 17 18 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 15 def initialize(opts = {}) @metadata_dir = "/etc/ploy/metadata.d" opts.each { |k,v| instance_variable_set("@#{k}", v) } # maybe? end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
9 10 11 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 9 def branch @branch end |
#dist_dir ⇒ Object
Returns the value of attribute dist_dir.
12 13 14 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 12 def dist_dir @dist_dir end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 7 def name @name end |
#prefix ⇒ Object
Returns the value of attribute prefix.
13 14 15 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 13 def prefix @prefix end |
#sha ⇒ Object
Returns the value of attribute sha.
8 9 10 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 8 def sha @sha end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
10 11 12 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 10 def @timestamp end |
#upstart_files ⇒ Object
Returns the value of attribute upstart_files.
11 12 13 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 11 def upstart_files @upstart_files end |
Instance Method Details
#build_deb ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 20 def build_deb info = nil Dir.mktmpdir do |dir| mirror_dist(dir) (dir) info = eval(`fpm #{fpm_optlist(dir).as_string} .`) end return info[:path] end |
#fpm_optlist(dir) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 30 def fpm_optlist(dir) optlist = Ploy::LocalPackage::DebBuilderOptlist.new [ { "-n" => @name }, { "-s" => "dir" }, { "-t" => "deb" }, { "-a" => "all" }, { "-C" => dir }, { "--deb-field" => "'gitrev: #{@sha}'" }, "-f", { "-v" => @timestamp + '.' + @branch }, ] if @upstart_files then @upstart_files.each do | upstart | optlist.add("--deb-upstart", upstart) end end return optlist end |
#mirror_dist(dir) ⇒ Object
51 52 53 54 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 51 def mirror_dist(dir) FileUtils.mkpath mirror_dist_target(dir) system("rsync -aC #{@dist_dir}/* #{mirror_dist_target(dir)}") end |
#mirror_dist_target(topdir) ⇒ Object
56 57 58 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 56 def mirror_dist_target(topdir) return @prefix ? File.join(topdir, @prefix) : topdir end |
#write_metadata(dir) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ploy/localpackage/debbuilder.rb', line 60 def (dir) base = File.join(dir, @metadata_dir) FileUtils.mkpath(base) path = File.join(base, "#{@name}.yml") info = { "name" => @name, "sha" => @sha, "timestamp" => @timestamp, "branch" => @branch, } File.open(path, 'w') do | out | YAML.dump(info, out) end end |