Skip to content

Commit

Permalink
deb: Always provide a "changes" file
Browse files Browse the repository at this point in the history
lintian in Ubuntu 14.04 now errors when a file
/usr/share/NAME/changelog.Debian.gz doesn't exist.

In the spirit of respecting lintian's meaningful errors, this commit
fixes that error.

The new behavior is that a changelog file is *always* provided. If the
--deb-changelog flag is not given, then fpm will produce a default one
based on the package being built in hope that it satisfies lintian.

With this commit, the lintian rspec test passes on Ubuntu 14.04.

Fixes #784
  • Loading branch information
jordansissel committed Oct 25, 2014
1 parent d03fae0 commit 045e73e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/fpm/package/deb.rb
Expand Up @@ -378,13 +378,24 @@ def output(output_path)
"Unknown compression type '#{self.attributes[:deb_compression]}'"
end

if attributes[:deb_changelog]
dest_changelog = File.join(staging_path, "usr/share/doc/#{name}/changelog.Debian")
FileUtils.mkdir_p(File.dirname(dest_changelog))
FileUtils.cp attributes[:deb_changelog], dest_changelog
File.chmod(0644, dest_changelog)
safesystem("gzip", dest_changelog)
end
# Write the changelog file
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
# Ruby 1.8.7 doesn't have IO#copy_stream
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 # No need to close, GzipWriter#close will close it.

attributes.fetch(:deb_init_list, []).each do |init|
name = File.basename(init, ".init")
Expand Down
5 changes: 5 additions & 0 deletions templates/deb/changelog.erb
@@ -0,0 +1,5 @@
<%= name %> (<%= "#{epoch}:" if epoch %><%= version %><%= "-" + iteration.to_s if iteration %>) whatever; urgency=medium

* Package created with FPM.

-- <%= maintainer %>[two spaces] <%= Time.now.strftime("%a, %d %b %Y %T %z") %>

0 comments on commit 045e73e

Please sign in to comment.