Class: Dockly::Deb
- Inherits:
-
Object
- Object
- Dockly::Deb
- Includes:
- Util::DSL, Util::Logger::Mixin
- Defined in:
- lib/dockly/deb.rb
Instance Method Summary collapse
- #build ⇒ Object
- #build_path ⇒ Object
- #create_package! ⇒ Object
- #exists? ⇒ Boolean
- #file(source, destination) ⇒ Object
- #output_filename ⇒ Object
- #s3_object_name ⇒ Object
- #s3_url ⇒ Object
- #upload_to_s3 ⇒ Object
Instance Method Details
#build ⇒ Object
41 42 43 44 45 46 |
# File 'lib/dockly/deb.rb', line 41 def build info "creating package" create_package! info "uploading to s3" upload_to_s3 end |
#build_path ⇒ Object
48 49 50 51 |
# File 'lib/dockly/deb.rb', line 48 def build_path ensure_present! :build_dir "#{build_dir}/#{output_filename}" end |
#create_package! ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dockly/deb.rb', line 26 def create_package! ensure_present! :build_dir FileUtils.mkdir_p(build_dir) FileUtils.rm(build_path) if File.exist?(build_path) debug "exporting #{package_name} to #{build_path}" build_package if @deb_package @deb_package.output(build_path) info "exported #{package_name} to #{build_path}" end ensure @dir_package.cleanup if @dir_package @deb_package.cleanup if @deb_package end |
#exists? ⇒ Boolean
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dockly/deb.rb', line 53 def exists? debug "#{name}: checking for package: #{s3_url}" Dockly::AWS.s3.head_object(s3_bucket, s3_object_name) info "#{name}: found package: #{s3_url}" true rescue info "#{name}: could not find package: " + "#{s3_url}" false end |
#file(source, destination) ⇒ Object
22 23 24 |
# File 'lib/dockly/deb.rb', line 22 def file(source, destination) @files << { :source => source, :destination => destination } end |
#output_filename ⇒ Object
80 81 82 |
# File 'lib/dockly/deb.rb', line 80 def output_filename "#{package_name}_#{version}.#{release}_#{arch}.deb" end |
#s3_object_name ⇒ Object
76 77 78 |
# File 'lib/dockly/deb.rb', line 76 def s3_object_name "#{package_name}/#{Dockly::Util::Git.git_sha}/#{output_filename}" end |
#s3_url ⇒ Object
72 73 74 |
# File 'lib/dockly/deb.rb', line 72 def s3_url "s3://#{s3_bucket}/#{s3_object_name}" end |
#upload_to_s3 ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/dockly/deb.rb', line 64 def upload_to_s3 return if s3_bucket.nil? create_package! unless File.exist?(build_path) info "uploading package to s3" Dockly::AWS.s3.put_bucket(s3_bucket) rescue nil Dockly::AWS.s3.put_object(s3_bucket, s3_object_name, File.new(build_path)) end |