def output(output_path)
self.provides = self.provides.collect { |p| fix_provides(p) }
output_check(output_path)
File.write(build_path("debian-binary"), "2.0\n")
if attributes[:deb_shlibs]
if !script?(:after_install)
logger.info("You gave --deb-shlibs but no --after-install, so " \
"I am adding an after-install script that runs " \
"ldconfig to update the system library cache")
scripts[:after_install] = template("deb/ldconfig.sh.erb").result(binding)
end
if !script?(:after_remove)
logger.info("You gave --deb-shlibs but no --after-remove, so " \
"I am adding an after-remove script that runs " \
"ldconfig to update the system library cache")
scripts[:after_remove] = template("deb/ldconfig.sh.erb").result(binding)
end
end
if script?(:before_upgrade) or script?(:after_upgrade)
if script?(:before_install) or script?(:before_upgrade)
scripts[:before_install] = template("deb/preinst_upgrade.sh.erb").result(binding)
end
if script?(:before_remove)
scripts[:before_remove] = template("deb/prerm_upgrade.sh.erb").result(binding)
end
if script?(:after_install) or script?(:after_upgrade)
scripts[:after_install] = template("deb/postinst_upgrade.sh.erb").result(binding)
end
if script?(:after_remove)
scripts[:after_remove] = template("deb/postrm_upgrade.sh.erb").result(binding)
end
end
write_control_tarball
case self.attributes[:deb_compression]
when "gz", nil
datatar = build_path("data.tar.gz")
compression = "-z"
when "bzip2"
datatar = build_path("data.tar.bz2")
compression = "-j"
when "xz"
datatar = build_path("data.tar.xz")
compression = "-J"
else
raise FPM::InvalidPackageConfiguration,
"Unknown compression type '#{self.attributes[:deb_compression]}'"
end
dest_changelog = File.join(staging_path, "usr/share/doc/#{name}/changelog.Debian.gz")
FileUtils.mkdir_p(File.dirname(dest_changelog))
File.new(dest_changelog, "wb", 0644).tap do |changelog|
Zlib::GzipWriter.new(changelog, Zlib::BEST_COMPRESSION).tap do |changelog_gz|
if attributes[:deb_changelog]
logger.info("Writing user-specified changelog", :source => attributes[:deb_changelog])
File.new(attributes[:deb_changelog]).tap do |fd|
chunk = nil
changelog_gz.write(chunk) while chunk = fd.read(16384)
end.close
else
logger.info("Creating boilerplate changelog file")
changelog_gz.write(template("deb/changelog.erb").result(binding))
end
end.close
end
attributes.fetch(:deb_init_list, []).each do |init|
name = File.basename(init, ".init")
dest_init = File.join(staging_path, "etc/init.d/#{name}")
FileUtils.mkdir_p(File.dirname(dest_init))
FileUtils.cp init, dest_init
File.chmod(0755, dest_init)
end
attributes.fetch(:deb_default_list, []).each do |default|
name = File.basename(default, ".default")
dest_default = File.join(staging_path, "etc/default/#{name}")
FileUtils.mkdir_p(File.dirname(dest_default))
FileUtils.cp default, dest_default
File.chmod(0644, dest_default)
end
attributes.fetch(:deb_upstart_list, []).each do |upstart|
name = File.basename(upstart, ".upstart")
dest_upstart = staging_path("etc/init/#{name}.conf")
FileUtils.mkdir_p(File.dirname(dest_upstart))
FileUtils.cp(upstart, dest_upstart)
File.chmod(0644, dest_upstart)
dest_init = staging_path("/etc/init.d/#{name}")
FileUtils.mkdir_p(File.dirname(dest_init))
FileUtils.ln_s("/lib/init/upstart-job", dest_init)
end
args = [ tar_cmd, "-C", staging_path, compression ] + data_tar_flags + [ "-cf", datatar, "." ]
safesystem(*args)
with(File.expand_path(output_path)) do |output_path|
::Dir.chdir(build_path) do
safesystem("ar", "-qc", output_path, "debian-binary", "control.tar.gz", datatar)
end
end
end