[DRE-commits] [gem2deb] 02/03: dh-make-ruby: add -w/--overwrite option to overwrite files under debian/
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun May 17 02:16:58 UTC 2015
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to branch master
in repository gem2deb.
commit e43fd09d9fa5d27322bffdd87632a6643208906c
Author: Antonio Terceiro <terceiro at debian.org>
Date: Sat May 16 23:08:48 2015 -0300
dh-make-ruby: add -w/--overwrite option to overwrite files under debian/
---
bin/dh-make-ruby | 9 +++++++++
debian/changelog | 1 +
lib/gem2deb/dh_make_ruby.rb | 25 ++++++++++++++-----------
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/bin/dh-make-ruby b/bin/dh-make-ruby
index a050b77..5e56387 100755
--- a/bin/dh-make-ruby
+++ b/bin/dh-make-ruby
@@ -39,6 +39,10 @@ optparse = OptionParser.new do |opts|
options[:source_package_name] = package_name
end
+ opts.on('-w', '--overwrite', 'overwrite existing files (default: don\'t)') do
+ options[:overwrite] = true
+ end
+
opts.on('', '--ruby-versions VERSIONS', 'ruby versions to use (default: all)') do |versions|
options[:ruby_versions] = versions
end
@@ -90,6 +94,11 @@ library, then it should use the default. On the other hand, if the packages is
mainly used as an application, then you should drop the ruby- prefix by using
this option an explicit package u.
+=item B<-w>, B<--overwrite>
+
+Overwrites packaging files that already exists but would be created by
+dh-make-ruby if they didn't.
+
=item B<--ruby-versions VERSIONS>
Ruby versions to build the package for. This is used to generate the
diff --git a/debian/changelog b/debian/changelog
index b8ea8ff..f7c63ef 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
gem2deb (0.17) UNRELEASED; urgency=medium
* dh-make-ruby: fix call to wrap-and-sort
+ * dh-make-ruby: add -w/--overwrite option to overwrite files under debian/
-- Antonio Terceiro <terceiro at debian.org> Sat, 16 May 2015 22:51:18 -0300
diff --git a/lib/gem2deb/dh_make_ruby.rb b/lib/gem2deb/dh_make_ruby.rb
index a76debd..a033ee5 100644
--- a/lib/gem2deb/dh_make_ruby.rb
+++ b/lib/gem2deb/dh_make_ruby.rb
@@ -60,6 +60,8 @@ module Gem2Deb
attr_accessor :extra_build_dependencies
+ attr_accessor :overwrite
+
def initialize(input, options = {})
generate_or_update_gem_to_package_data
@@ -266,10 +268,11 @@ module Gem2Deb
end
end
- def write_if_missing(filename)
- unless File.exist? filename
- File.open(filename, 'w') { |f| yield f }
+ def maybe_create(filename)
+ if File.exist?(filename) && !overwrite
+ return
end
+ File.open(filename, 'w') { |f| yield f }
end
def create_debian_boilerplates
@@ -281,7 +284,7 @@ module Gem2Deb
end
templates.each do |template|
FileUtils.mkdir_p(template.directory)
- write_if_missing(template.filename) do |f|
+ maybe_create(template.filename) do |f|
f.puts ERB.new(template.data, nil, '<>').result(binding)
end
end
@@ -365,7 +368,7 @@ module Gem2Deb
def test_suite_rspec
if File::directory?("spec")
extra_build_dependencies << 'ruby-rspec' << 'rake'
- write_if_missing("debian/ruby-tests.rake") do |f|
+ maybe_create("debian/ruby-tests.rake") do |f|
f.puts <<-EOF
require 'rspec/core/rake_task'
@@ -385,7 +388,7 @@ task :default => :spec
def test_suite_yaml
if !metadata.test_files.empty?
- write_if_missing("debian/ruby-test-files.yaml") do |f|
+ maybe_create("debian/ruby-test-files.yaml") do |f|
YAML::dump(metadata.test_files, f)
end
true
@@ -397,7 +400,7 @@ task :default => :spec
def test_suite_rb
if File::directory?("test")
extra_build_dependencies << 'rake'
- write_if_missing("debian/ruby-tests.rake") do |f|
+ maybe_create("debian/ruby-tests.rake") do |f|
f.puts <<-EOF
require 'gem2deb/rake/testtask'
@@ -432,7 +435,7 @@ end
docs << "# #{r}\n"
end
if docs != ""
- write_if_missing("debian/#{source_package_name}.docs") do |f|
+ maybe_create("debian/#{source_package_name}.docs") do |f|
f.puts docs
end
end
@@ -449,7 +452,7 @@ end
end
end
if examples != ""
- write_if_missing("debian/#{source_package_name}.examples") do |f|
+ maybe_create("debian/#{source_package_name}.examples") do |f|
f.puts examples
end
end
@@ -471,7 +474,7 @@ end
EOF
end
if installs != ""
- write_if_missing("debian/#{source_package_name}.install") do |f|
+ maybe_create("debian/#{source_package_name}.install") do |f|
f.puts installs
end
end
@@ -481,7 +484,7 @@ end
manpages = Dir.glob("man/**/*.[1-8]")
manpages_header = "# FIXME: man/ dir found in source. Consider installing manpages"
- write_if_missing("debian/#{source_package_name}.manpages") do |f|
+ maybe_create("debian/#{source_package_name}.manpages") do |f|
f.puts manpages_header
manpages.each do |m|
f.puts "# " + m
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/gem2deb.git
More information about the Pkg-ruby-extras-commits
mailing list