lib/dockly/deb.rb in dockly-1.13.0 vs lib/dockly/deb.rb in dockly-2.0.0
- old
+ new
@@ -5,32 +5,29 @@
include Dockly::Util::Logger::Mixin
logger_prefix '[dockly deb]'
dsl_attribute :package_name, :version, :release, :arch, :build_dir,
:deb_build_dir, :pre_install, :post_install, :pre_uninstall,
- :post_uninstall, :s3_bucket, :files, :app_user, :vendor,
- :package_startup_script
+ :post_uninstall, :s3_bucket, :files, :app_user, :vendor
dsl_class_attribute :docker, Dockly::Docker
- dsl_class_attribute :foreman, Dockly::Foreman, type: Array
+ dsl_class_attribute :foreman, Dockly::Foreman
default_value :version, '0.0'
default_value :release, '0'
default_value :arch, 'x86_64'
default_value :build_dir, 'build'
default_value :deb_build_dir, 'deb'
default_value :files, []
default_value :app_user, 'nobody'
default_value :vendor, 'Dockly'
- default_value :package_startup_script, true
def file(source, destination)
@files << { :source => source, :destination => destination }
end
def create_package!
- info "creating package"
ensure_present! :build_dir, :deb_build_dir
FileUtils.mkdir_p(File.join(build_dir, deb_build_dir))
FileUtils.rm(build_path) if File.exist?(build_path)
debug "exporting #{package_name} to #{build_path}"
build_package
@@ -42,22 +39,16 @@
@dir_package.cleanup if @dir_package
@deb_package.cleanup if @deb_package
end
def build
+ info "creating package"
create_package!
+ info "uploading to s3"
upload_to_s3
end
- def copy_from_s3(sha)
- ensure_present! :s3_bucket
- object = s3_object_name_for(sha)
- info "Copying s3://#{s3_bucket}/#{object} to s3://#{s3_bucket}/#{s3_object_name}"
- Dockly::AWS.s3.copy_object(s3_bucket, object, s3_bucket, s3_object_name)
- info "Successfully copied s3://#{s3_bucket}/#{object} to s3://#{s3_bucket}/#{s3_object_name}"
- end
-
def build_path
ensure_present! :build_dir, :deb_build_dir
File.join(build_dir, deb_build_dir, output_filename)
end
@@ -65,16 +56,16 @@
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}"
+ info "#{name}: could not find package: " +
+ "#{s3_url}"
false
end
def upload_to_s3
- info "uploading to s3"
return if s3_bucket.nil?
raise "Package wasn't created!" 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))
@@ -83,17 +74,13 @@
def s3_url
"s3://#{s3_bucket}/#{s3_object_name}"
end
def s3_object_name
- s3_object_name_for(Dockly::Util::Git.git_sha)
+ "#{package_name}/#{Dockly::Util::Git.git_sha}/#{output_filename}"
end
- def s3_object_name_for(sha)
- "#{package_name}/#{sha}/#{output_filename}"
- end
-
def output_filename
"#{package_name}_#{version}.#{release}_#{arch}.deb"
end
def startup_script
@@ -113,11 +100,11 @@
@dir_package = FPM::Package::Dir.new
add_foreman(@dir_package)
add_files(@dir_package)
add_docker_auth_config(@dir_package)
add_docker(@dir_package)
- add_startup_script(@dir_package) if package_startup_script
+ add_startup_script(@dir_package)
convert_package
@deb_package.scripts[:before_install] = pre_install
@deb_package.scripts[:after_install] = post_install
@@ -138,17 +125,17 @@
debug "converting to deb"
@deb_package = @dir_package.convert(FPM::Package::Deb)
end
def add_foreman(package)
- return if (foreman || []).empty?
- foreman.each do |fore|
- info "adding foreman export '#{fore.name}'"
- fore.create!
- package.attributes[:prefix] = fore.init_dir
- Dir.chdir(fore.build_dir) { package.input('.') }
- package.attributes[:prefix] = nil
+ return if foreman.nil?
+ info "adding foreman export"
+ foreman.create!
+ package.attributes[:prefix] = foreman.init_dir
+ Dir.chdir(foreman.build_dir) do
+ package.input('.')
end
+ package.attributes[:prefix] = nil
end
def add_files(package)
return if files.empty?
info "adding files to package"