diff -Nru gem2deb-0.3.0/Rakefile gem2deb-0.4.1~ubuntu13.04.1~ppa2/Rakefile --- gem2deb-0.3.0/Rakefile 2012-06-19 22:54:36.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/Rakefile 2013-05-30 20:19:15.000000000 +0000 @@ -36,12 +36,24 @@ end desc "Builds a git snapshot package" -task :snapshot do +task :snapshot => ['snapshot:build', 'snapshot:clean'] + +task 'snapshot:build' do sh 'cp debian/changelog debian/changelog.git' date = `date --iso=seconds |sed 's/+.*//' |sed 's/[-T:]//g'`.chomp sh "sed -i '1 s/)/~git#{date})/' debian/changelog" sh 'ls debian/changelog.git' sh 'dpkg-buildpackage -us -uc' +end + +desc 'Build and install a git snapshot' +task 'snapshot:install' do + Rake::Task['snapshot:build'].invoke + sh 'sudo debi' + Rake::Task['snapshot:clean'].invoke +end + +task 'snapshot:clean' do sh 'ls debian/changelog.git' sh 'mv debian/changelog.git debian/changelog' end diff -Nru gem2deb-0.3.0/bin/dh_ruby gem2deb-0.4.1~ubuntu13.04.1~ppa2/bin/dh_ruby --- gem2deb-0.3.0/bin/dh_ruby 2012-05-17 12:08:01.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/bin/dh_ruby 2013-06-02 01:40:26.000000000 +0000 @@ -17,12 +17,11 @@ require 'gem2deb' require 'gem2deb/dh_ruby' -require 'gem2deb/dh_ruby_setuprb' +require 'gem2deb/setup_rb_installer' require 'optparse' include Gem2Deb -cls = DhRuby - +engine = Gem2Deb::DhRuby.new optparse = OptionParser.new do |opts| opts.on('-h', '--help', 'show help') do @@ -31,7 +30,7 @@ end opts.on('', '--setuprb', 'use setup.rb for installation') do - cls = DhRubySetupRb + engine.installer_class = Gem2Deb::SetupRbInstaller end opts.on('-v', '--version', 'show dh_ruby version') do @@ -40,27 +39,27 @@ end opts.on('', '--clean', 'debhelper clean helper') do - cls.new.clean + engine.clean exit(0) end opts.on('', '--configure', 'debhelper configure helper') do - cls.new.configure + engine.configure exit(0) end opts.on('', '--build', 'debhelper build helper') do - cls.new.build + engine.build exit(0) end opts.on('', '--test', 'debhelper test helper') do - cls.new.test + engine.test exit(0) end opts.on('', '--install', 'debhelper install helper') do - cls.new.install(ARGV) + engine.install(ARGV) exit(0) end end @@ -90,6 +89,97 @@ See dh_ruby --help for details. +=head1 SOURCE PACKAGE LAYOUT + +B supports two different source package styles: single-binary source +packages, and multi-binary source packages. + +=head2 Single-binary layout + +The default layout is the B layout. This is the layout used by +most Ruby packages upstream, i.e. Ruby code in I/, executable programs in +I/, etc. Packages imported from Rubygems using B will have +this layout. + +When using this layout, B will install files (Ruby code, +executables, gemspecs) to the I listed in +I. + +=head2 Multi-binary layout + +B version I<0.4.0> introduced support for the B +layout. This layout should be used when you have a set of different Ruby +packages maintained upstream in a single VCS, and you decide that you +also want to maintain a single source package in Debian having the +different components as separate binary packages. + +In this layout, the source package contains the separate components in +subdirectories where each of them will use the standard Ruby layout +(I/, I/, etc). + +This layout does not support creating separate binary packages from the same +root directory. For those cases, see the documentation on +I below. + +To indicate that you want to use a multi-binary layout, we have to 1) +list your multiple binary packages in I as usual, and +add an extra-field called I to each binary package +stanza, indicating which directory has to be used as the root for that +binary package. + +An example: + + Source: mymultibinarypackage + [...] + + Package: ruby-foo + X-DhRuby-Root: path/to/foo + [...] + + Package: ruby-bar + X-DhRuby-Root: path/to/bar + +The corresponding source package should be layed out like this: + + foo/ + foo.gemspec + lib/ + foo.rb + bin/foo + bar/ + bar.gemspec + lib/ + bar.rb + bin/ + bar + +Important notes about multi-binary packages and the usage of +I: + +=over + +=item + +If your package uses the multi-binary layout, it must include +`I (>= 0.4.0~)` in I. + +B in +multi-binary packages, so if your package uses the multi-binary feature +and at least one of the sub-components has native extensions, you must +use `I (>= 0.4.1~)` in I instead. + +=item + +The path indicated in I, as you have probably guessed by +now, must be relative to the root of the source package. + +=item + +If any binary package declares a I field, all other +binary packages that don't have one will be ignored by B. + +=back + =head1 OPTIONS =over @@ -134,15 +224,21 @@ install files to debian/I, where I is the first binary package listed in debian/control. -This is useful for multi-binary source packages, where you will have all files -installed to I, and can them split the files into separate packages -by using debian/I.install. +This is useful for multi-binary source packages that don't conform to +the supported layout (i.e. separate subdirectories each with I/, +I/ etc). Using this, all files will be installed to I, and +you can them distribute them into separate binary packages by using +I files or explicit shell calls in +I. + +Mixing I and multi-binary layout is +not supported. =item I Determines which file contain the gem specification with package metadata. By default, dh_ruby will read metadata from a .gemspec file in the root of source -package directory. You can use this variable to override that if want to +package directory. You can use this variable to override that if you want to provide custom metadata for the Debian package. In the case there are more than one .gemspec in the source package root, you @@ -202,7 +298,7 @@ actually `require "rubygems"`, you can use this file as a whitelist of files allowed to have `require "rubygems"`. -This file is expect to contain a YAML document with a list of files that must +This file is expected to contain a YAML document with a list of files that must be ignored when checking for `require "rubygems"` lines. Example: --- diff -Nru gem2deb-0.3.0/bin/gem2deb gem2deb-0.4.1~ubuntu13.04.1~ppa2/bin/gem2deb --- gem2deb-0.3.0/bin/gem2deb 2012-03-06 00:20:38.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/bin/gem2deb 2013-05-15 23:33:05.000000000 +0000 @@ -189,7 +189,7 @@ =item Metadata -It contains the gem metadata ends up in a file named ``metadata.yml`` inside +It contains the gem metadata in a file named ``metadata.yml`` inside the I directory. =back diff -Nru gem2deb-0.3.0/debian/changelog gem2deb-0.4.1~ubuntu13.04.1~ppa2/debian/changelog --- gem2deb-0.3.0/debian/changelog 2012-06-22 12:43:57.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/debian/changelog 2013-09-30 16:33:40.000000000 +0000 @@ -1,3 +1,53 @@ +gem2deb (0.4.1~ubuntu13.04.1~ppa2) raring; urgency=low + + * No-change backport to raring + + -- Neil Wilson Mon, 30 Sep 2013 16:33:40 +0000 + +gem2deb (0.4.1) unstable; urgency=low + + * Give up on deprecating DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR + * Improve documentation on multi-binary packages + * Make extension buidler honor DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR + (Closes: #701716) + * Fix native extensions support for multi-binary packages + * Update docs on Build-Depends for multi-binary source packages. + For multi-binary packages with native extensions, gem2deb (>= 0.4.1~) is + required. + * Bump standards version to 3.9.4; no changes needed. + + -- Antonio Terceiro Sat, 01 Jun 2013 22:46:10 -0300 + +gem2deb (0.4.0) unstable; urgency=low + + [ Cédric Boutillier ] + * debian/control: remove obsolete DM-Upload-Allowed flag + * use canonical URI in Vcs-* fields + * fix typos in gem2deb and dh_ruby manpages. + Thanks Francesco Poli (Closes: #691132, #691133) + * filter out non Ruby files when creating test-ruby-files.yaml + (Closes: #691236) + * dh-make-ruby: suggest same copyright as original package in generated + debian/copyright + + [ Antonio Terceiro ] + * Added support for multi-binary source packages. See dh_ruby(1) for + details. + * Install CHANGELOG* as upstream changelog (Closes: #702160) + + -- Antonio Terceiro Thu, 30 May 2013 18:25:25 -0300 + +gem2deb (0.3.1) unstable; urgency=low + + [ Antonio Terceiro ] + * remove unused constant + * Remove DM-Upload-Allowed from d/control template (Closes: #692152) + + [ Cédric Boutillier ] + * d/control template: bump Standards-Version; point VCS fields to anonscm.d.o + + -- Antonio Terceiro Tue, 07 May 2013 19:15:17 -0300 + gem2deb (0.3.0) unstable; urgency=low * Fix debug test mode diff -Nru gem2deb-0.3.0/debian/control gem2deb-0.4.1~ubuntu13.04.1~ppa2/debian/control --- gem2deb-0.3.0/debian/control 2012-06-03 15:00:35.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/debian/control 2013-06-02 01:46:06.000000000 +0000 @@ -6,11 +6,10 @@ Antonio Terceiro , Vincent Fourmond , Gunnar Wolf -DM-Upload-Allowed: yes Build-Depends: debhelper (>= 7.0.50~), rake, ruby-shoulda-context, ruby-mocha, rubygems (>= 1.8.12-1~), ruby1.8, ruby1.8-dev, ruby1.9.1 (>= 1.9.3.0-1~), ruby1.9.1-dev (>= 1.9.3.0-1~), devscripts, ruby-setup, lintian -Standards-Version: 3.9.3 -Vcs-Git: git://git.debian.org/pkg-ruby-extras/gem2deb.git -Vcs-Browser: http://git.debian.org/?p=pkg-ruby-extras/gem2deb.git;a=summary +Standards-Version: 3.9.4 +Vcs-Git: git://anonscm.debian.org/pkg-ruby-extras/gem2deb.git +Vcs-Browser: http://anonscm.debian.org/gitweb?p=pkg-ruby-extras/gem2deb.git;a=summary Package: gem2deb Architecture: all diff -Nru gem2deb-0.3.0/debian/gem2deb.lintian-overrides gem2deb-0.4.1~ubuntu13.04.1~ppa2/debian/gem2deb.lintian-overrides --- gem2deb-0.3.0/debian/gem2deb.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/debian/gem2deb.lintian-overrides 2013-06-02 01:51:18.000000000 +0000 @@ -0,0 +1 @@ +script-not-executable usr/lib/ruby/vendor_ruby/gem2deb/dh_make_ruby/template/debian/rules diff -Nru gem2deb-0.3.0/lib/gem2deb/dh_make_ruby/template/debian/control gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/dh_make_ruby/template/debian/control --- gem2deb-0.3.0/lib/gem2deb/dh_make_ruby/template/debian/control 2012-03-02 21:16:23.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/dh_make_ruby/template/debian/control 2013-02-12 17:03:21.000000000 +0000 @@ -3,11 +3,10 @@ Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: <%= maintainer['DEBFULLNAME'] %> <<%= maintainer['DEBEMAIL'] %>> -DM-Upload-Allowed: yes Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= <%= Gem2Deb::VERSION %>~) -Standards-Version: 3.9.3 -#Vcs-Git: git://git.debian.org/pkg-ruby-extras/<%= source_package_name %>.git -#Vcs-Browser: http://git.debian.org/?p=pkg-ruby-extras/<%= source_package_name %>.git;a=summary +Standards-Version: 3.9.4 +#Vcs-Git: git://anonscm.debian.org/pkg-ruby-extras/<%= source_package_name %>.git +#Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-ruby-extras/<%= source_package_name %>.git;a=summary Homepage: <%= homepage ? homepage : 'FIXME'%> XS-Ruby-Versions: <%= ruby_versions %> diff -Nru gem2deb-0.3.0/lib/gem2deb/dh_make_ruby/template/debian/copyright gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/dh_make_ruby/template/debian/copyright --- gem2deb-0.3.0/lib/gem2deb/dh_make_ruby/template/debian/copyright 2012-03-06 00:20:37.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/dh_make_ruby/template/debian/copyright 2013-05-24 22:43:35.000000000 +0000 @@ -6,6 +6,13 @@ Copyright: License: GPL-2+ (FIXME) + +Files: debian/* +Copyright: <%= Date.today.year %> <%= maintainer['DEBFULLNAME'] %> <<%= maintainer['DEBEMAIL'] %>> +License: GPL-2+ (FIXME) +Comment: the Debian packaging is licensed under the same terms as the original package. + +License: GPL-2+ (FIXME) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either @@ -26,8 +33,3 @@ On Debian systems, the full text of the GNU General Public License version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. - -Files: debian/* -Copyright: <%= Date.today.year %> <%= maintainer['DEBFULLNAME'] %> <<%= maintainer['DEBEMAIL'] %>> -License: - [LICENSE TEXT] diff -Nru gem2deb-0.3.0/lib/gem2deb/dh_ruby.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/dh_ruby.rb --- gem2deb-0.3.0/lib/gem2deb/dh_ruby.rb 2012-06-19 23:00:45.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/dh_ruby.rb 2013-05-30 18:28:01.000000000 +0000 @@ -14,7 +14,7 @@ # along with this program. If not, see . require 'gem2deb' -require 'gem2deb/metadata' +require 'gem2deb/installer' require 'find' require 'fileutils' @@ -22,40 +22,24 @@ class DhRuby - SUPPORTED_RUBY_VERSIONS = { - #name Ruby binary - #--------------- ------------------- - 'ruby1.8' => '/usr/bin/ruby1.8', - 'ruby1.9.1' => '/usr/bin/ruby1.9.1', - } - - RUBY_CONFIG_VERSION = { - 'ruby1.8' => '1.8', - 'ruby1.9.1' => '1.9.1', - } - - RUBY_SHEBANG_CALL = '/usr/bin/env ruby' - - DEFAULT_RUBY_VERSION = 'ruby1.8' - - RUBY_CODE_DIR = '/usr/lib/ruby/vendor_ruby' - include Gem2Deb attr_accessor :verbose - - attr_reader :metadata + attr_accessor :installer_class def initialize @verbose = true - @bindir = '/usr/bin' @skip_checks = nil - @metadata = Gem2Deb::Metadata.new('.') + @installer_class = Gem2Deb::Installer end - + def clean puts " Entering dh_ruby --clean" if @verbose - run_make_clean_on_extensions + + installers.each do |installer| + installer.run_make_clean_on_extensions + end + puts " Leaving dh_ruby --clean" if @verbose end @@ -74,165 +58,42 @@ # puts " Leaving dh_ruby --test" if @verbose end - EXTENSION_BUILDER = File.expand_path(File.join(File.dirname(__FILE__),'extension_builder.rb')) TEST_RUNNER = File.expand_path(File.join(File.dirname(__FILE__),'test_runner.rb')) - LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - attr_accessor :dh_auto_install_destdir def install(argv) puts " Entering dh_ruby --install" if @verbose - self.dh_auto_install_destdir = argv.first - - supported_versions = - if all_ruby_versions_supported? - SUPPORTED_RUBY_VERSIONS.keys.clone - else - ruby_versions.clone - end - - package = packages.first - - install_files_and_build_extensions(package, supported_versions) - - update_shebangs(package) - - run_tests(supported_versions) - - install_substvars(package, supported_versions) - - install_gemspec(package, supported_versions) - - check_rubygems - - puts " Leaving dh_ruby --install" if @verbose - end - - protected - - # This function returns the installation path for the given - # package and the given "component", which is one of: - # * :bindir - # * :libdir - # * :archdir - # * :prefix - # - # _rubyver_ is the ruby version, needed only for :archdir for now. - def destdir(package, which, rubyver = nil) - case which - when :bindir - return File.join(destdir_for(package), @bindir) - when :libdir - return File.join(destdir_for(package), RUBY_CODE_DIR) - when :archdir - return File.join(destdir_for(package), `#{SUPPORTED_RUBY_VERSIONS[rubyver]} -rrbconfig -e "puts RbConfig::CONFIG['vendorarchdir']"`.chomp) - when :prefix - return File.join(destdir_for(package), "usr/") - end - end - - - def install_files_and_build_extensions(package, supported_versions) - install_files('bin', destdir(package, :bindir), 755) if File::directory?('bin') - - install_files('lib', destdir(package, :libdir), 644) if File::directory?('lib') - - if metadata.has_native_extensions? - supported_versions.each do |rubyver| - puts "Building extension for #{rubyver} ..." if @verbose - run("#{SUPPORTED_RUBY_VERSIONS[rubyver]} -I#{LIBDIR} #{EXTENSION_BUILDER} #{package}") - - # Remove duplicate files installed by rubygems in the arch dir - # This is a hack to workaround a problem in rubygems - vendor_dir = destdir(package, :libdir) - vendor_arch_dir = destdir(package, :archdir, rubyver) - if File::exists?(vendor_dir) and File::exists?(vendor_arch_dir) - remove_duplicate_files(vendor_dir, vendor_arch_dir) - end - end + installers.each do |installer| + installer.dh_auto_install_destdir = argv.first + installer.install_files_and_build_extensions + installer.update_shebangs end - install_symlinks(package, supported_versions) - end - - def install_symlinks(package, supported_versions) - supported_versions.select { |v| v == 'ruby1.8' }.each do |rubyver| - archdir = destdir(package, :archdir, rubyver) - vendordir = destdir(package, :libdir, rubyver) - vendorlibdir = File.dirname(archdir) - Dir.glob(File.join(archdir, '*.so')).each do |so| - rb = File.basename(so).gsub(/\.so$/, '.rb') - if File.exists?(File.join(vendordir, rb)) - Dir.chdir(vendorlibdir) do - file_handler.ln_s "../#{rb}", rb - end - end - end + run_tests + + installers.each do |installer| + installer.install_substvars + installer.install_gemspec + check_rubygems(installer) end - end - def remove_duplicate_files(src, dst) - candidates = Dir::entries(src) - ['.', '..'] - candidates.each do |cand| - file1 = File.join(src, cand) - file2 = File.join(dst, cand) - if File.file?(file1) and File.file?(file2) and (File.read(file1) == File.read(file2)) - file_handler.rm(file2) - elsif File.directory?(file1) and File.directory?(file2) - remove_duplicate_files(file1, file2) - end - end - if (Dir.entries(dst) - ['.', '..']).empty? - file_handler.rmdir(dst) - end + puts " Leaving dh_ruby --install" if @verbose end - def file_handler - @verbose ? FileUtils::Verbose : FileUtils - end + protected - def check_rubygems + def check_rubygems(installer) if skip_checks? return end - found = false - if File::exists?('debian/require-rubygems.overrides') - overrides = YAML::load_file('debian/require-rubygems.overrides') - else - overrides = [] - end - packages.each do |pkg| - pkg.chomp! - ruby_source_files_in_package(pkg).each do |f| - lines = readlines(f) - rglines = lines.select { |l| l =~ /require.*rubygems/ && l !~ /^\s*#/ } - rglines.each do |l| - if not overrides.include?(f) - puts "#{f}: #{l}" if @verbose - found = true - end - end - end - end - if found - puts "Found some 'require rubygems' without overrides (see above)." if @verbose - handle_test_failure('require-rubygems') - end - end - def readlines(filename) - if String.instance_methods.include?(:valid_encoding?) - File.readlines(filename).select { |l| l.valid_encoding? } - else - File.readlines(filename) + begin + installer.check_rubygems + rescue Gem2Deb::Installer::RequireRubygemsFound + handle_test_failure("require-rubygems") end end - def ruby_source_files_in_package(pkg) - Dir["debian/#{pkg}/usr/lib/ruby/vendor_ruby/**/*.rb"] - end - def handle_test_failure(test) if ENV['DH_RUBY_IGNORE_TESTS'] if ENV['DH_RUBY_IGNORE_TESTS'].split.include?('all') @@ -258,16 +119,14 @@ exit(1) end else - puts "ERROR: Test \"#{test}\" failed. Exiting." - exit(1) + puts "ERROR: Test \"#{test}\" failed. Exiting." + exit(1) end end - def run_tests(supported_versions) - supported_versions.dup.each do |rubyver| - if !run_tests_for_version(rubyver) - supported_versions.delete(rubyver) - end + def run_tests + ruby_versions.each do |rubyver| + run_tests_for_version(rubyver) end end @@ -282,15 +141,6 @@ if $?.exitstatus != 0 handle_test_failure(rubyver) - return false - else - return true - end - end - - def install_substvars(package, supported_versions) - File.open("debian/#{package}.substvars", "a") do |fd| - fd.puts "ruby:Versions=#{supported_versions.join(' ')}" end end @@ -306,87 +156,46 @@ @skip_checks end - JUNK_FILES = %w( RCSLOG tags TAGS .make.state .nse_depinfo ) - HOOK_FILES = %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - JUNK_PATTERNS = [ /^#/, /^\.#/, /^cvslog/, /^,/, /^\.del-*/, /\.olb$/, - /~$/, /\.(old|bak|BAK|orig|rej)$/, /^_\$/, /\$$/, /\.org$/, /\.in$/, /^\./ ] - - DO_NOT_INSTALL = (JUNK_FILES + HOOK_FILES).map { |file| /^#{file}$/ } + JUNK_PATTERNS - - def install_files(src, dest, mode) - run "install -d #{dest}" - files_to_install = Dir.chdir(src) do - Dir.glob('**/*').reject do |file| - filename = File.basename(file) - File.directory?(file) || DO_NOT_INSTALL.any? { |pattern| filename =~ pattern } - end - end - files_to_install.each do |file| - from = File.join(src, file) - to = File.join(dest, file) - run "install -D -m#{mode} #{from} #{to}" - end - end - - def destdir_for(package) - destdir = - if ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] - self.dh_auto_install_destdir - else - File.join('debian', package) - end - File.expand_path(destdir) - end - - def update_shebangs(package) - ruby_binary = - if all_ruby_versions_supported? - RUBY_SHEBANG_CALL - else - SUPPORTED_RUBY_VERSIONS[ruby_versions.first] - end - rewrite_shebangs(package, ruby_binary) - end - - def rewrite_shebangs(package, ruby_binary) - Dir.glob(File.join(destdir_for(package), @bindir, '**/*')).each do |path| - next if File.directory?(path) - atomic_rewrite(path) do |input, output| - old = input.gets - if old =~ /ruby/ or old !~ /^#!/ - puts "Rewriting shebang line of #{path}" if @verbose - output.puts "#!#{ruby_binary}" - unless old =~ /#!/ - output.puts old + def packages + @packages ||= + begin + packages = [] + multibinary = false + File.readlines('debian/control').select do |line| + if line =~ /^Package:\s*(\S*)\s*$/ + package = $1 + packages.push({ :binary_package => package }) + elsif line =~ /^X-DhRuby-Root:\s*(\S*)\s*$/ + root = $1 + if packages.last + packages.last[:root] = root + end + multibinary = true end + end + if multibinary + packages.select { |p| p[:root] } else - puts "Not rewriting shebang line of #{path}" if @verbose - output.puts old + package = packages.first + package[:root] = '.' + [package] end - output.print input.read end - File.chmod(0755, path) - end end - def atomic_rewrite(path, &block) - tmpfile = path + '.tmp' - begin - File.open(tmpfile, 'wb') do |output| - File.open(path, 'rb') do |input| - yield(input, output) + def installers + @installers ||= + begin + packages.map do |package| + installer_class.new( + package[:binary_package], + package[:root], + ruby_versions + ).tap do |installer| + installer.verbose = self.verbose + end end end - File.rename tmpfile, path - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - def packages - @packages ||= `dh_listpackages`.split end def ruby_versions @@ -398,39 +207,14 @@ puts "No XS-Ruby-Versions: field found in source!" if @verbose exit(1) else - lines.first.split[1..-1] - end - end - end - - def all_ruby_versions_supported? - ruby_versions.include?('all') - end - - def run_make_clean_on_extensions - if metadata.has_native_extensions? - metadata.native_extensions.each do |extension| - extension_dir = File.dirname(extension) - if File.exists?(File.join(extension_dir, 'Makefile')) - puts "Running 'make distclean || make clean' in #{extension_dir}..." - Dir.chdir(extension_dir) do - run 'make distclean || make clean' + list = lines.first.split[1..-1] + if list.include?('all') + SUPPORTED_RUBY_VERSIONS.keys + else + list end end end - end - end - - def install_gemspec(package, versions) - if metadata.gemspec - versions.each do |version| - target = File.join(destdir_for(package), "/usr/share/rubygems-integration/#{RUBY_CONFIG_VERSION[version]}/specifications/#{metadata.name}-#{metadata.version}.gemspec") - FileUtils.mkdir_p(File.dirname(target)) - File.open(target, 'w') do |file| - file.write(metadata.gemspec.to_ruby) - end - end - end end end diff -Nru gem2deb-0.3.0/lib/gem2deb/dh_ruby_setuprb.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/dh_ruby_setuprb.rb --- gem2deb-0.3.0/lib/gem2deb/dh_ruby_setuprb.rb 2011-06-06 17:30:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/dh_ruby_setuprb.rb 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -# Copyright © 2011, Vincent Fourmond -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -require 'gem2deb/dh_ruby' - -module Gem2Deb - - class DhRubySetupRb < DhRuby - - def install_files_and_build_extensions(package, supported_versions) - for rubyver in supported_versions - ruby = SUPPORTED_RUBY_VERSIONS[rubyver] - siteruby = destdir(package, :libdir, rubyver) - bindir = destdir(package, :bindir, rubyver) - archdir = destdir(package, :archdir, rubyver) - prefix = destdir(package, :prefix, rubyver) - - # First configure - run("#{ruby} setup.rb config --prefix=#{prefix} --bindir=#{bindir} --siteruby=#{siteruby} --siterubyver=#{siteruby} --siterubyverarch=#{archdir}") - - # Then setup - run("#{ruby} setup.rb setup") - - # Then install - run("#{ruby} setup.rb install") - - # Then clean - run("#{ruby} setup.rb distclean") - - end - end - - - def run_tests(supported_versions) - # Todo: we should first check for setup-rb specific tests. - super - end - - - end - -end diff -Nru gem2deb-0.3.0/lib/gem2deb/extension_builder.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/extension_builder.rb --- gem2deb-0.3.0/lib/gem2deb/extension_builder.rb 2012-06-15 00:59:26.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/extension_builder.rb 2013-06-02 01:05:15.000000000 +0000 @@ -24,12 +24,10 @@ include Gem2Deb attr_reader :extension - attr_reader :package attr_reader :directory - def initialize(extension, pkg) + def initialize(extension) @extension = extension - @package = pkg @directory = File.dirname(extension) end @@ -41,7 +39,7 @@ end end - def build_and_install + def build_and_install(destdir) clean results = [] rubygems_builder = @@ -57,7 +55,7 @@ exit(1) end begin - target = File.expand_path(File.join('debian', package, RbConfig::CONFIG['vendorarchdir'])) + target = File.expand_path(File.join(destdir, RbConfig::CONFIG['vendorarchdir'])) Dir.chdir(directory) do rubygems_builder.build(extension, '.', target, results) puts results @@ -68,26 +66,26 @@ end end - def self.build_all_extensions(package) - all_extensions.each do |extension| - ext = new(extension, package) + def self.build_all_extensions(root, destdir) + all_extensions(root).each do |extension| + ext = new(extension) ext.clean - ext.build_and_install + ext.build_and_install(destdir) end end - def self.all_extensions - @metadata ||= Gem2Deb::Metadata.new('.') + def self.all_extensions(root) + @metadata ||= Gem2Deb::Metadata.new(root) @metadata.native_extensions end end end if $PROGRAM_NAME == __FILE__ - if ARGV.length == 1 - Gem2Deb::ExtensionBuilder.build_all_extensions(ARGV.first) + if ARGV.length == 2 + Gem2Deb::ExtensionBuilder.build_all_extensions(*ARGV) else - puts "usage: #{File.basename($PROGRAM_NAME)} PKGNAME" + puts "usage: #{File.basename($PROGRAM_NAME)} ROOT DESTDIR" exit(1) end end diff -Nru gem2deb-0.3.0/lib/gem2deb/installer.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/installer.rb --- gem2deb-0.3.0/lib/gem2deb/installer.rb 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/installer.rb 2013-06-01 21:52:55.000000000 +0000 @@ -0,0 +1,282 @@ +require 'gem2deb/metadata' + +module Gem2Deb + + class Installer + + class RequireRubygemsFound < Exception; end + + include Gem2Deb + + EXTENSION_BUILDER = File.expand_path(File.join(File.dirname(__FILE__),'extension_builder.rb')) + + attr_reader :binary_package + attr_reader :root + attr_reader :metadata + + attr_reader :ruby_versions + attr_accessor :verbose + attr_accessor :dh_auto_install_destdir + + def initialize(binary_package, root, ruby_versions = SUPPORTED_RUBY_VERSIONS.keys) + @binary_package = binary_package + @root = File.expand_path(root) + @ruby_versions = ruby_versions + @metadata = Gem2Deb::Metadata.new(@root) + end + + def install_files_and_build_extensions + install_files(bindir, destdir(:bindir), 755) if File::directory?(bindir) + + install_files(libdir, destdir(:libdir), 644) if File::directory?(libdir) + + if metadata.has_native_extensions? + ruby_versions.each do |rubyver| + puts "Building extension for #{rubyver} ..." if verbose + run("#{SUPPORTED_RUBY_VERSIONS[rubyver]} -I#{LIBDIR} #{EXTENSION_BUILDER} #{root} #{destdir_base}") + + # Remove duplicate files installed by rubygems in the arch dir + # This is a hack to workaround a problem in rubygems + vendor_dir = destdir(:libdir) + vendor_arch_dir = destdir(:archdir, rubyver) + if File::exists?(vendor_dir) and File::exists?(vendor_arch_dir) + remove_duplicate_files(vendor_dir, vendor_arch_dir) + end + end + end + + install_symlinks + install_changelog + end + + def update_shebangs + ruby_binary = + if all_ruby_versions_supported? + RUBY_SHEBANG_CALL + else + SUPPORTED_RUBY_VERSIONS[ruby_versions.first] + end + rewrite_shebangs(ruby_binary) + end + + def install_substvars + File.open("debian/#{binary_package}.substvars", "a") do |fd| + fd.puts "ruby:Versions=#{ruby_versions.join(' ')}" + end + end + + def install_gemspec + if metadata.gemspec + ruby_versions.each do |version| + target = File.join(destdir(:root), "/usr/share/rubygems-integration/#{RUBY_CONFIG_VERSION[version]}/specifications/#{metadata.name}-#{metadata.version}.gemspec") + FileUtils.mkdir_p(File.dirname(target)) + File.open(target, 'w') do |file| + file.write(metadata.gemspec.to_ruby) + end + end + end + end + + def check_rubygems + found = false + if File::exists?('debian/require-rubygems.overrides') + overrides = YAML::load_file('debian/require-rubygems.overrides') + else + overrides = [] + end + installed_ruby_files.each do |f| + lines = readlines(f) + rglines = lines.select { |l| l =~ /require.*rubygems/ && l !~ /^\s*#/ } + rglines.each do |l| + if not overrides.include?(f) + puts "#{f}: #{l}" if verbose + found = true + end + end + end + if found + puts "Found some 'require rubygems' without overrides (see above)." if verbose + raise RequireRubygemsFound + end + end + + def run_make_clean_on_extensions + if metadata.has_native_extensions? + metadata.native_extensions.each do |extension| + extension_dir = File.dirname(extension) + if File.exists?(File.join(extension_dir, 'Makefile')) + puts "Running 'make distclean || make clean' in #{extension_dir}..." + Dir.chdir(extension_dir) do + run 'make distclean || make clean' + end + end + end + end + end + + protected + + def all_ruby_versions_supported? + ruby_versions == SUPPORTED_RUBY_VERSIONS.keys + end + + def bindir + @bindir ||= File.join(self.root, 'bin') + end + + def libdir + @libdir ||= File.join(self.root, 'lib') + end + + # This function returns the installation path for the given + # package and the given target, which is one of: + # * :bindir + # * :libdir + # * :archdir + # * :prefix + # + # _rubyver_ is the ruby version, needed only for :archdir for now. + def destdir(target, rubyver = nil) + dir = File.expand_path(destdir_base) + + case target + when :root + return dir + when :bindir + return File.join(dir, BIN_DIR) + when :libdir + return File.join(dir, RUBY_CODE_DIR) + when :archdir + return File.join(dir, `#{SUPPORTED_RUBY_VERSIONS[rubyver]} -rrbconfig -e "puts RbConfig::CONFIG['vendorarchdir']"`.chomp) + when :prefix + return File.join(dir, "usr/") + end + end + + def destdir_base + if ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] + self.dh_auto_install_destdir + else + File.join('debian', binary_package) + end + end + + JUNK_FILES = %w( RCSLOG tags TAGS .make.state .nse_depinfo ) + HOOK_FILES = %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| + %w( config setup install clean ).map {|t| sprintf(fmt, t) } + }.flatten + JUNK_PATTERNS = [ /^#/, /^\.#/, /^cvslog/, /^,/, /^\.del-*/, /\.olb$/, + /~$/, /\.(old|bak|BAK|orig|rej)$/, /^_\$/, /\$$/, /\.org$/, /\.in$/, /^\./ ] + + DO_NOT_INSTALL = (JUNK_FILES + HOOK_FILES).map { |file| /^#{file}$/ } + JUNK_PATTERNS + + + def install_files(src, dest, mode) + run "install -d #{dest}" + files_to_install = Dir.chdir(src) do + Dir.glob('**/*').reject do |file| + filename = File.basename(file) + File.directory?(file) || DO_NOT_INSTALL.any? { |pattern| filename =~ pattern } + end + end + files_to_install.each do |file| + from = File.join(src, file) + to = File.join(dest, file) + run "install -D -m#{mode} #{from} #{to}" + end + end + + + def install_symlinks + ruby_versions.select { |v| v == 'ruby1.8' }.each do |rubyver| + archdir = destdir(:archdir, rubyver) + vendordir = destdir(:libdir, rubyver) + vendorlibdir = File.dirname(archdir) + Dir.glob(File.join(archdir, '*.so')).each do |so| + rb = File.basename(so).gsub(/\.so$/, '.rb') + if File.exists?(File.join(vendordir, rb)) + Dir.chdir(vendorlibdir) do + file_handler.ln_s "../#{rb}", rb + end + end + end + end + end + + def remove_duplicate_files(src, dst) + candidates = Dir::entries(src) - ['.', '..'] + candidates.each do |cand| + file1 = File.join(src, cand) + file2 = File.join(dst, cand) + if File.file?(file1) and File.file?(file2) and (File.read(file1) == File.read(file2)) + file_handler.rm(file2) + elsif File.directory?(file1) and File.directory?(file2) + remove_duplicate_files(file1, file2) + end + end + if (Dir.entries(dst) - ['.', '..']).empty? + file_handler.rmdir(dst) + end + end + + def file_handler + @verbose ? FileUtils::Verbose : FileUtils + end + + def rewrite_shebangs(ruby_binary) + Dir.glob(File.join(destdir(:bindir), '**/*')).each do |path| + next if File.directory?(path) + atomic_rewrite(path) do |input, output| + old = input.gets + if old =~ /ruby/ or old !~ /^#!/ + puts "Rewriting shebang line of #{path}" if @verbose + output.puts "#!#{ruby_binary}" + unless old =~ /#!/ + output.puts old + end + else + puts "Not rewriting shebang line of #{path}" if @verbose + output.puts old + end + output.print input.read + end + File.chmod(0755, path) + end + end + + def atomic_rewrite(path, &block) + tmpfile = path + '.tmp' + begin + File.open(tmpfile, 'wb') do |output| + File.open(path, 'rb') do |input| + yield(input, output) + end + end + File.rename tmpfile, path + ensure + File.unlink tmpfile if File.exist?(tmpfile) + end + end + + def readlines(filename) + if String.instance_methods.include?(:valid_encoding?) + File.readlines(filename).select { |l| l.valid_encoding? } + else + File.readlines(filename) + end + end + + def installed_ruby_files + Dir["debian/#{binary_package}/usr/lib/ruby/vendor_ruby/**/*.rb"] + end + + def install_changelog + changelog = Dir.glob(File.join(root, 'CHANGELOG*')).first + if changelog + run("dh_installchangelogs -p#{binary_package} #{changelog} upstream") + end + end + + end + +end diff -Nru gem2deb-0.3.0/lib/gem2deb/metadata.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/metadata.rb --- gem2deb-0.3.0/lib/gem2deb/metadata.rb 2012-06-15 00:59:17.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/metadata.rb 2013-06-02 01:06:23.000000000 +0000 @@ -21,18 +21,14 @@ class Metadata attr_reader :gemspec + attr_reader :source_dir + attr_reader :root - attr_reader :native_extensions - - def initialize(directory) - @source_dir = File.expand_path(directory) - Dir.chdir(directory) do + def initialize(root) + @source_dir = File.expand_path(root) + @root = root + Dir.chdir(source_dir) do load_gemspec - if gemspec - initialize_from_gemspec - else - initialize_without_gemspec - end end end @@ -40,6 +36,20 @@ native_extensions.size > 0 end + def native_extensions + @native_extensions ||= + if gemspec + gemspec.extensions + else + Dir.chdir(source_dir) do + list = [] + list += Dir.glob('**/extconf.rb') + list += Dir.glob('ext/**/{configure,Rakefile}') + list + end + end.map { |ext| File.join(root, ext) } + end + def name @name ||= gemspec && gemspec.name || read_name_from(source_dir) end @@ -65,13 +75,11 @@ end def test_files - gemspec ? gemspec.test_files : [] + gemspec ? gemspec.test_files.select { |filename| filename =~ /\.rb$/ } : [] end protected - attr_reader :source_dir - def load_gemspec if File.exists?('metadata.yml') @gemspec = YAML.load_file('metadata.yml') @@ -89,14 +97,6 @@ end end - def initialize_from_gemspec - @native_extensions = gemspec.extensions - end - - def initialize_without_gemspec - @native_extensions = Dir.glob('**/extconf.rb') + Dir.glob('ext/**/{configure,Rakefile}') - end - # FIXME duplicated logic (see below) def read_name_from(directory) return nil if directory.nil? diff -Nru gem2deb-0.3.0/lib/gem2deb/setup_rb_installer.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/setup_rb_installer.rb --- gem2deb-0.3.0/lib/gem2deb/setup_rb_installer.rb 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/setup_rb_installer.rb 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1,47 @@ +# Copyright © 2011, Vincent Fourmond +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +require 'gem2deb/dh_ruby' + +module Gem2Deb + + class SetupRbInstaller < Installer + + def install_files_and_build_extensions + ruby_versions.each do |rubyver| + ruby = SUPPORTED_RUBY_VERSIONS[rubyver] + siteruby = destdir(:libdir, rubyver) + bindir = destdir(:bindir, rubyver) + archdir = destdir(:archdir, rubyver) + prefix = destdir(:prefix, rubyver) + + # First configure + run("#{ruby} setup.rb config --prefix=#{prefix} --bindir=#{bindir} --siteruby=#{siteruby} --siterubyver=#{siteruby} --siterubyverarch=#{archdir}") + + # Then setup + run("#{ruby} setup.rb setup") + + # Then install + run("#{ruby} setup.rb install") + + # Then clean + run("#{ruby} setup.rb distclean") + + end + end + + end + +end diff -Nru gem2deb-0.3.0/lib/gem2deb/version.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/version.rb --- gem2deb-0.3.0/lib/gem2deb/version.rb 2012-06-19 23:42:39.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb/version.rb 2013-06-02 01:47:29.000000000 +0000 @@ -1,3 +1,3 @@ module Gem2Deb - VERSION = '0.3.0' + VERSION = '0.4.1' end diff -Nru gem2deb-0.3.0/lib/gem2deb.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb.rb --- gem2deb-0.3.0/lib/gem2deb.rb 2012-06-15 01:02:10.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/lib/gem2deb.rb 2013-05-30 18:28:01.000000000 +0000 @@ -22,6 +22,26 @@ class CommandFailed < Exception end + SUPPORTED_RUBY_VERSIONS = { + #name Ruby binary + #--------------- ------------------- + 'ruby1.8' => '/usr/bin/ruby1.8', + 'ruby1.9.1' => '/usr/bin/ruby1.9.1', + } + + RUBY_CONFIG_VERSION = { + 'ruby1.8' => '1.8', + 'ruby1.9.1' => '1.9.1', + } + + RUBY_SHEBANG_CALL = '/usr/bin/env ruby' + + BIN_DIR = '/usr/bin' + + RUBY_CODE_DIR = '/usr/lib/ruby/vendor_ruby' + + LIBDIR = File.expand_path(File.dirname(__FILE__)) + def run(cmd) puts(cmd) if $VERBOSE system(cmd) diff -Nru gem2deb-0.3.0/test/integration/gem2deb_test.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/integration/gem2deb_test.rb --- gem2deb-0.3.0/test/integration/gem2deb_test.rb 2011-11-07 00:40:34.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/integration/gem2deb_test.rb 2013-06-01 21:47:37.000000000 +0000 @@ -27,16 +27,58 @@ assert_match /E: ruby-simplegem: helper-templates-in-copyright/, `lintian #{changes_file}` end - should 'not compress *.rb files installed as examples' do - examples_package = File.join(GEM2DEB_ROOT_SOURCE_DIR, 'test/sample/examples') - tmpdir = Dir.mktmpdir - FileUtils.cp_r(examples_package, tmpdir) - Dir.chdir(File.join(tmpdir, 'examples')) do - run_command('dpkg-buildpackage -d -us -uc') - assert_no_file_exists 'debian/ruby-examples/usr/share/doc/ruby-examples/examples/test.rb.gz' - assert_file_exists 'debian/ruby-examples/usr/share/doc/ruby-examples/examples/test.rb' + def self.build_tree(directory) + FileUtils.cp_r(directory, tmpdir) + dir = File.join(tmpdir, File.basename(directory)) + yield(dir) + puts "Building #{directory} ..." + Dir.chdir(dir) do + run_command('fakeroot debian/rules install') + end + end + + self.build_tree('test/sample/examples') do |dir| + + should 'not compress *.rb files installed as examples' do + assert_no_file_exists "#{dir}/debian/ruby-examples/usr/share/doc/ruby-examples/examples/test.rb.gz" + assert_file_exists "#{dir}/debian/ruby-examples/usr/share/doc/ruby-examples/examples/test.rb" + end + + should 'install CHANGELOG.rdoc as upstream changelog' do + changelog = "#{dir}/debian/ruby-examples/usr/share/doc/ruby-examples/changelog.gz" + assert_file_exists changelog + end + + end + + self.build_tree('test/sample/multibinary') do |dir| + context "multibinary source package" do + should "install foo in ruby-foo" do + assert_file_exists "#{dir}/debian/ruby-foo/usr/bin/foo" + end + should 'install foo.rb in ruby-foo' do + assert_file_exists "#{dir}/debian/ruby-foo/usr/lib/ruby/vendor_ruby/foo.rb" + end + should 'install bar in ruby-bar' do + assert_file_exists "#{dir}/debian/ruby-bar/usr/bin/bar" + end + should 'install bar.rb ruby-bar' do + assert_file_exists "#{dir}/debian/ruby-bar/usr/lib/ruby/vendor_ruby/bar.rb" + end + should 'support installing upstream CHANGELOG in multibinary package' do + assert_file_exists "#{dir}/debian/ruby-bar/usr/share/doc/ruby-bar/changelog.gz" + end + + should 'support native extensions' do + assert Dir.glob("#{dir}/debian/ruby-baz/**/baz.so").size > 0, 'baz.so not found!!!' + end + end + end + + self.build_tree('test/sample/simpleextension_dh_auto_install_destdir') do |dir| + should 'honor DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR when building extensions' do + assert Dir.glob("#{dir}/debian/tmp/usr/lib/ruby/vendor_ruby/**/*.so").size > 0, 'no .so files found in debian/tmp/' end - FileUtils.rm_rf(tmpdir) end end diff -Nru gem2deb-0.3.0/test/sample/examples/CHANGELOG.rdoc gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/examples/CHANGELOG.rdoc --- gem2deb-0.3.0/test/sample/examples/CHANGELOG.rdoc 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/examples/CHANGELOG.rdoc 2013-05-30 18:57:07.000000000 +0000 @@ -0,0 +1 @@ +upstream changelog here diff -Nru gem2deb-0.3.0/test/sample/examples/debian/changelog gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/examples/debian/changelog --- gem2deb-0.3.0/test/sample/examples/debian/changelog 2011-11-06 22:44:06.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/examples/debian/changelog 2013-05-30 19:03:11.000000000 +0000 @@ -1,4 +1,4 @@ -ruby-examples (0.1) UNRELEASED; urgency=low +ruby-examples (0.1-1) UNRELEASED; urgency=low * Initial release (Closes: #nnnn) diff -Nru gem2deb-0.3.0/test/sample/multibinary/bar/CHANGELOG.md gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/bar/CHANGELOG.md --- gem2deb-0.3.0/test/sample/multibinary/bar/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/bar/CHANGELOG.md 2013-05-30 20:30:48.000000000 +0000 @@ -0,0 +1 @@ +upstream changelog here diff -Nru gem2deb-0.3.0/test/sample/multibinary/bar/bar.gemspec gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/bar/bar.gemspec --- gem2deb-0.3.0/test/sample/multibinary/bar/bar.gemspec 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/bar/bar.gemspec 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1,12 @@ +spec = Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY + s.summary = "Simple bar library" + s.name = 'bar' + s.version = '0.0.1' + s.requirements << 'none' + s.require_path = 'lib' + s.files = Dir.glob('lib/**') + Dir.glob('bin/*') + s.description = < Sun, 26 May 2013 18:05:37 -0300 diff -Nru gem2deb-0.3.0/test/sample/multibinary/debian/compat gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/compat --- gem2deb-0.3.0/test/sample/multibinary/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/compat 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1 @@ +7 diff -Nru gem2deb-0.3.0/test/sample/multibinary/debian/control gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/control --- gem2deb-0.3.0/test/sample/multibinary/debian/control 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/control 2013-06-01 21:46:00.000000000 +0000 @@ -0,0 +1,35 @@ +Source: multibinary +Section: ruby +Priority: optional +Maintainer: Debian Ruby Extras Maintainers +Uploaders: Antonio Terceiro +Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.3.1~) +Standards-Version: 3.9.4 +#Vcs-Git: git://anonscm.debian.org/pkg-ruby-extras/ruby-multibinary.git +#Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-ruby-extras/ruby-multibinary.git;a=summary +Homepage: FIXME +XS-Ruby-Versions: all + +Package: ruby-foo +X-DhRuby-Root: foo +Architecture: all +XB-Ruby-Versions: ${ruby:Versions} +Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter +Description: FIXME + + +Package: ruby-bar +X-DhRuby-Root: bar +Architecture: all +XB-Ruby-Versions: ${ruby:Versions} +Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter +Description: FIXME + + +Package: ruby-baz +X-DhRuby-Root: baz +Architecture: all +XB-Ruby-Versions: ${ruby:Versions} +Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter +Description: FIXME + diff -Nru gem2deb-0.3.0/test/sample/multibinary/debian/copyright gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/copyright --- gem2deb-0.3.0/test/sample/multibinary/debian/copyright 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/copyright 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1,33 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: multibinary +Source: FIXME + +Files: * +Copyright: + +License: GPL-2+ (FIXME) + This program is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later + version. + . + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more + details. + . + You should have received a copy of the GNU General Public + License along with this package; if not, write to the Free + Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301 USA + . + On Debian systems, the full text of the GNU General Public + License version 2 can be found in the file + `/usr/share/common-licenses/GPL-2'. + +Files: debian/* +Copyright: 2013 Antonio Terceiro +License: + [LICENSE TEXT] diff -Nru gem2deb-0.3.0/test/sample/multibinary/debian/rules gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/rules --- gem2deb-0.3.0/test/sample/multibinary/debian/rules 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/rules 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1,15 @@ +#!/usr/bin/make -f +#export DH_VERBOSE=1 +# +# Uncomment to ignore all test failures (but the tests will run anyway) +#export DH_RUBY_IGNORE_TESTS=all +# +# Uncomment to ignore some test failures (but the tests will run anyway). +# Valid values: +#export DH_RUBY_IGNORE_TESTS=ruby1.8 ruby1.9.1 require-rubygems +# +# If you need to specify the .gemspec (eg there is more than one) +#export DH_RUBY_GEMSPEC=gem.gemspec + +%: + dh $@ --buildsystem=ruby --with ruby diff -Nru gem2deb-0.3.0/test/sample/multibinary/debian/source/format gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/source/format --- gem2deb-0.3.0/test/sample/multibinary/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/source/format 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru gem2deb-0.3.0/test/sample/multibinary/debian/watch gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/watch --- gem2deb-0.3.0/test/sample/multibinary/debian/watch 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/debian/watch 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1,2 @@ +version=3 +http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/multibinary .*/multibinary-(.*).tar.gz diff -Nru gem2deb-0.3.0/test/sample/multibinary/foo/bin/foo gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/foo/bin/foo --- gem2deb-0.3.0/test/sample/multibinary/foo/bin/foo 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/foo/bin/foo 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1,3 @@ +#!/usr/ruby/ruby + +puts "foo" diff -Nru gem2deb-0.3.0/test/sample/multibinary/foo/foo.gemspec gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/foo/foo.gemspec --- gem2deb-0.3.0/test/sample/multibinary/foo/foo.gemspec 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/multibinary/foo/foo.gemspec 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1,12 @@ +spec = Gem::Specification.new do |s| + s.platform = Gem::Platform::RUBY + s.summary = "Simple foo library" + s.name = 'foo' + s.version = '0.0.1' + s.requirements << 'none' + s.require_path = 'lib' + s.files = Dir.glob('lib/**') + Dir.glob('bin/*') + s.description = < Sat, 01 Jun 2013 16:52:32 -0300 diff -Nru gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/compat gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/compat --- gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/compat 2013-06-01 19:52:32.000000000 +0000 @@ -0,0 +1 @@ +7 diff -Nru gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/control gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/control --- gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/control 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/control 2013-06-01 20:15:35.000000000 +0000 @@ -0,0 +1,24 @@ +Source: ruby-simpleextension-dh-auto-install-destdir +Section: ruby +Priority: optional +Maintainer: Debian Ruby Extras Maintainers +Uploaders: Antonio Terceiro +Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.4.0~) +Standards-Version: 3.9.4 +#Vcs-Git: git://anonscm.debian.org/pkg-ruby-extras/ruby-simpleextension-dh-auto-install-destdir.git +#Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-ruby-extras/ruby-simpleextension-dh-auto-install-destdir.git;a=summary +Homepage: FIXME +XS-Ruby-Versions: all + +Package: ruby-simpleextension-dh-auto-install-destdir +Architecture: any +XB-Ruby-Versions: ${ruby:Versions} +Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter +Description: FIXME + + +Package: ruby-simpleextension-dh-auto-install-destdir-doc +Architecture: all +Description: dummy package + The existance of this package will make dh_auto_install call dh_ruby with + debian/tmp as destdir diff -Nru gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/copyright gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/copyright --- gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/copyright 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/copyright 2013-06-01 19:52:32.000000000 +0000 @@ -0,0 +1,35 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: simpleextension_dh_auto_install_destdir +Source: FIXME + +Files: * +Copyright: + +License: GPL-2+ (FIXME) + +Files: debian/* +Copyright: 2013 Antonio Terceiro +License: GPL-2+ (FIXME) +Comment: the Debian packaging is licensed under the same terms as the original package. + +License: GPL-2+ (FIXME) + This program is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later + version. + . + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more + details. + . + You should have received a copy of the GNU General Public + License along with this package; if not, write to the Free + Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301 USA + . + On Debian systems, the full text of the GNU General Public + License version 2 can be found in the file + `/usr/share/common-licenses/GPL-2'. diff -Nru gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/rules gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/rules --- gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/rules 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/rules 2013-06-01 19:53:04.000000000 +0000 @@ -0,0 +1,6 @@ +#!/usr/bin/make -f + +export DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR=1 + +%: + dh $@ --buildsystem=ruby --with ruby diff -Nru gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/source/format gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/source/format --- gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/debian/source/format 2013-06-01 19:52:32.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/ext/simpleextension_dh_auto_install_destdir/extconf.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/ext/simpleextension_dh_auto_install_destdir/extconf.rb --- gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/ext/simpleextension_dh_auto_install_destdir/extconf.rb 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/ext/simpleextension_dh_auto_install_destdir/extconf.rb 2013-06-01 19:51:37.000000000 +0000 @@ -0,0 +1,2 @@ +require 'mkmf' +create_makefile('simpleextension_dh_auto_install_destdir') diff -Nru gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/ext/simpleextension_dh_auto_install_destdir/simpleextension_dh_auto_install_destdir.c gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/ext/simpleextension_dh_auto_install_destdir/simpleextension_dh_auto_install_destdir.c --- gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/ext/simpleextension_dh_auto_install_destdir/simpleextension_dh_auto_install_destdir.c 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/ext/simpleextension_dh_auto_install_destdir/simpleextension_dh_auto_install_destdir.c 2013-06-01 19:50:55.000000000 +0000 @@ -0,0 +1,13 @@ +#include "ruby.h" + +VALUE method_answer42(VALUE module, VALUE self); + +void Init_simpleextension() { + VALUE SimpleExtension = rb_define_module("SimpleExtension"); + rb_define_module_function(SimpleExtension, "answer42", method_answer42, 0); + rb_define_const(SimpleExtension, "Hello_world", rb_str_new2("Hello World")); +} + +VALUE method_answer42(VALUE module, VALUE self) { + return INT2NUM(42); +} diff -Nru gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/test/test_simpleextension.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/test/test_simpleextension.rb --- gem2deb-0.3.0/test/sample/simpleextension_dh_auto_install_destdir/test/test_simpleextension.rb 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/sample/simpleextension_dh_auto_install_destdir/test/test_simpleextension.rb 2013-06-01 19:50:55.000000000 +0000 @@ -0,0 +1,11 @@ +require 'test/unit' +require 'simpleextension' + +class SimpleExtensionTest < Test::Unit::TestCase + def test_answer + assert_equal(42, SimpleExtension.answer42) + end + def test_const + assert_equal("Hello World", SimpleExtension::Hello_world) + end +end diff -Nru gem2deb-0.3.0/test/test_helper.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/test_helper.rb --- gem2deb-0.3.0/test/test_helper.rb 2012-06-19 23:36:41.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/test_helper.rb 2013-05-30 18:28:01.000000000 +0000 @@ -1,6 +1,6 @@ require 'test/unit' require 'shoulda-context' -require 'mocha' +require 'mocha/setup' require 'fileutils' require 'tmpdir' require 'tempfile' @@ -103,12 +103,13 @@ # Installation-related functions - def installed_file_path(gem_dirname, package, path) - File.join(self.class.tmpdir, 'ruby-' + gem_dirname, 'debian', package, path) + def installed_file_path(gem_dirname, package, path, convert_gem_name = true) + source_package_name = convert_gem_name ? 'ruby-' + gem_dirname : gem_dirname + File.join(self.class.tmpdir, source_package_name, 'debian', package, path) end - def assert_installed(gem_dirname, package, path) - assert_file_exists installed_file_path(gem_dirname, package, path) + def assert_installed(gem_dirname, package, path, convert_gem_name = true) + assert_file_exists installed_file_path(gem_dirname, package, path, convert_gem_name) end def self.silence_stream(stream) @@ -161,4 +162,15 @@ self.class.run_command(cmd) end + # Utility method to fake contents in debian/control in the scope of a + # test. + def debian_control + @debian_control ||= + begin + lines = [] + File.expects(:readlines).with('debian/control').returns(lines) + lines + end + end + end diff -Nru gem2deb-0.3.0/test/unit/dh_ruby_test.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/dh_ruby_test.rb --- gem2deb-0.3.0/test/unit/dh_ruby_test.rb 2012-06-19 23:14:42.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/dh_ruby_test.rb 2013-05-30 20:37:38.000000000 +0000 @@ -60,15 +60,6 @@ end end - context 'installing Ruby files' do - should 'not crash when directories to be installed have names in the exclusion list' do - Dir.chdir('test/sample/install_files/') do - dh_ruby = Gem2Deb::DhRuby.new - dh_ruby.send(:install_files, 'lib', File.join(tmpdir, 'install_files_destdir'), 644) - end - end - end - context 'skipping checks' do setup do @dh_ruby = Gem2Deb::DhRuby.new @@ -104,92 +95,10 @@ end should 'read supported versions from debian/control' do File.expects(:readlines).with('debian/control').returns(["XS-Ruby-Versions: all\n"]) - assert_equal ['all'], @dh_ruby.send(:ruby_versions) - end - should 'known when all versions are supported' do - @dh_ruby.stubs(:ruby_versions).returns(['all']) - assert_equal true, @dh_ruby.send(:all_ruby_versions_supported?) - end - should 'known when not all versions are supported' do - @dh_ruby.stubs(:ruby_versions).returns(['ruby1.8']) - assert_equal false, @dh_ruby.send(:all_ruby_versions_supported?) - end - should 'rewrite shebang to use `/usr/bin/env ruby` if all versions are supported' do - @dh_ruby.stubs(:all_ruby_versions_supported?).returns(true) - @dh_ruby.expects(:rewrite_shebangs).with(anything, '/usr/bin/env ruby') - @dh_ruby.send(:update_shebangs, 'foo') - end - should 'rewrite shebang to usr /usr/bin/ruby1.8 if only 1.8 is supported' do - @dh_ruby.stubs(:ruby_versions).returns(['ruby1.8']) - @dh_ruby.expects(:rewrite_shebangs).with(anything, '/usr/bin/ruby1.8') - @dh_ruby.send(:update_shebangs, 'foo') + assert_equal SUPPORTED_RUBY_VERSIONS.keys, @dh_ruby.send(:ruby_versions) end end - context 'rewriting shebangs' do - setup do - @dh_ruby = Gem2Deb::DhRuby.new - @dh_ruby.verbose = false - - FileUtils.cp_r('test/sample/rewrite_shebangs', self.class.tmpdir) - @dh_ruby.expects(:destdir_for).returns(self.class.tmpdir + '/rewrite_shebangs') - - # The fact that this call does not crash means we won't crash when - # /usr/bin has subdirectories - @dh_ruby.send(:rewrite_shebangs, 'ruby-foo', '/usr/bin/env ruby') - end - teardown do - FileUtils.rm_f(self.class.tmpdir + '/rewrite_shebangs') - end - - should 'rewrite shebangs of programs directly under bin/' do - assert_match %r{/usr/bin/env ruby}, File.read(self.class.tmpdir + '/rewrite_shebangs/usr/bin/prog') - end - should 'rewrite shebangs in subdirs of bin/' do - assert_match %r{/usr/bin/env ruby}, File.read(self.class.tmpdir + '/rewrite_shebangs/usr/bin/subdir/prog') - end - should 'add a shebang when there is none' do - lines = File.readlines(self.class.tmpdir + '/rewrite_shebangs/usr/bin/no-shebang') - assert_match %r{/usr/bin/env ruby}, lines[0] - assert_match /puts/, lines[1] - end - should 'not rewrite shebangs non-Ruby scripts' do - lines = File.readlines(self.class.tmpdir + '/rewrite_shebangs/usr/bin/shell-script') - assert_match %r{/bin/sh}, lines[0] - end - should 'leave programs with correct permissions after rewriting shebangs' do - assert_equal '100755', '%o' % File.stat(self.class.tmpdir + '/rewrite_shebangs/usr/bin/no-shebang').mode - end - end - - context 'checking for require "rubygems"' do - setup do - @dh_ruby = Gem2Deb::DhRuby.new - @dh_ruby.verbose = false - end - should 'detect require "rubygems"' do - @dh_ruby.stubs(:ruby_source_files_in_package).returns(['test/sample/check_rubygems/bad.rb']) - @dh_ruby.expects(:handle_test_failure).once - @dh_ruby.send(:check_rubygems) - end - should 'not complain about commented require "rubygems"' do - @dh_ruby.stubs(:ruby_source_files_in_package).returns(['test/sample/check_rubygems/good.rb']) - @dh_ruby.expects(:handle_test_failure).never - @dh_ruby.send(:check_rubygems) - end - - %w[ - utf8 - latin1 - ].each do |encoding| - should "handle #{encoding}" do - @dh_ruby.stubs(:ruby_source_files_in_package).returns(["test/encondings/#{encoding}.rb"]) - @dh_ruby.send(:check_rubygems) - end - end - - end - context 'libraries with name clash (between foo.rb and foo.so)' do should "install symlinks for foo.rb in Ruby 1.8 vendorlibdir" do symlink = installed_file_path(SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME, 'ruby-simpleextension-with-name-clash', "/usr/lib/ruby/vendor_ruby/1.8/simpleextension_with_name_clash.rb") @@ -213,70 +122,33 @@ end end - context 'using DESTDIR supplied by dh_auto_install' do - setup do - @dh_ruby = Gem2Deb::DhRuby.new - @dh_ruby.dh_auto_install_destdir = '/path/to/source-package/debian/tmp' - end - should 'normally install to debian/${package}' do - assert_match /\/debian\/foo$/, @dh_ruby.send(:destdir_for, 'foo') - end - should 'install to debian/tmp when DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR is set' do - saved_env = ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] - ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] = 'yes' - - assert_equal '/path/to/source-package/debian/tmp', @dh_ruby.send(:destdir_for, 'foo') - - ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] = saved_env + context 'installing gemspec' do + should 'install gemspec for simplegem' do + assert_installed SIMPLE_GEM_DIRNAME, 'ruby-simplegem', '/usr/share/rubygems-integration/1.9.1/specifications/simplegem-0.0.1.gemspec' end end - context 'run_tests' do - setup do - @dh_ruby = Gem2Deb::DhRuby.new - end - should 'not skip tests after one that fails' do - @dh_ruby.stubs(:run_tests_for_version).with('rubyX').returns(false) - @dh_ruby.expects(:run_tests_for_version).with('rubyY') - @dh_ruby.send(:run_tests, ['rubyX', 'rubyY']) - end - end + context "selecting package layout" do - context 'finding duplicate files' do setup do @dh_ruby = Gem2Deb::DhRuby.new @dh_ruby.verbose = false - @tmpdir = Dir.mktmpdir - end - teardown do - FileUtils.rm_rf(@tmpdir) end - should 'actually remove duplicates' do - Dir.chdir(@tmpdir) do - FileUtils.mkdir('dir1') - FileUtils.mkdir('dir2') - ['dir1','dir2'].each do |d| - File.open(File.join(d, 'test.rb'), 'w') { |f| f.puts "# Nice File"} - end - @dh_ruby.send(:remove_duplicate_files, 'dir1', 'dir2') - assert !File.exists?('dir2') - end - end - should 'not crash with duplicates in subdirectories' do - Dir.chdir(@tmpdir) do - FileUtils.mkdir_p('dir1/subdir') - FileUtils.touch('dir1/subdir/test.rb') - FileUtils.mkdir_p('dir2/subdir') - FileUtils.touch('dir2/subdir/test.rb') - @dh_ruby.send(:remove_duplicate_files, 'dir1', 'dir2') - assert !File.exists?('dir2') - end + + should 'default to single-binary' do + debian_control << 'Package: ruby-foo' + debian_control << 'Package: ruby-bar' + ruby_foo = { :binary_package => 'ruby-foo', :root => '.' } + assert_equal [ruby_foo], @dh_ruby.send(:packages) end - end - context 'installing gemspec' do - should 'install gemspec for simplegem' do - assert_installed SIMPLE_GEM_DIRNAME, 'ruby-simplegem', '/usr/share/rubygems-integration/1.9.1/specifications/simplegem-0.0.1.gemspec' + should 'ignore packages without X-DhRuby-Root when one of them has it' do + debian_control << 'Package: ruby-foo' + debian_control << 'Package: ruby-bar' + debian_control << 'X-DhRuby-Root: bar' + + ruby_bar = { :binary_package => 'ruby-bar', :root => 'bar' } + assert_equal [ruby_bar], @dh_ruby.send(:packages) end end diff -Nru gem2deb-0.3.0/test/unit/dh_rubysetuprb_test.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/dh_rubysetuprb_test.rb --- gem2deb-0.3.0/test/unit/dh_rubysetuprb_test.rb 2011-09-11 23:50:53.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/dh_rubysetuprb_test.rb 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -require 'test_helper' -require 'gem2deb/gem2tgz' -require 'gem2deb/dh_make_ruby' -require 'gem2deb/dh_ruby' -require 'gem2deb/dh_ruby_setuprb' -require 'rbconfig' - -class DhRubySetuprbTest < Gem2DebTestCase - - one_time_setup do - build(SIMPLE_SETUPRB_NAME, SIMPLE_SETUPRB_DIRNAME) - end - - dirname = SIMPLE_SETUPRB_DIRNAME - package = "ruby-simplesetuprb" - - context 'installing native extension with setuprb' do - [ - '1.8', - '1.9.1', - ].each do |version_number| - vendorarchdir = VENDOR_ARCH_DIRS['ruby' + version_number] - target_so = "#{vendorarchdir}/simplesetuprb.so" - should "install native extension for Ruby #{version_number} for #{package}" do - assert_installed dirname, package, target_so - end - should "link #{target_so} against libruby#{version_number} for #{package}" do - installed_so = installed_file_path(dirname, package, target_so) - assert_match /libruby-?#{version_number}/, `ldd #{installed_so}` - end - end - end - - context 'test pre-install.rb hook' do - target_file = "/usr/lib/ruby/vendor_ruby/simplesetuprb/generated.rb" - should "install file generated by pre-install.rb hook" do - assert_installed dirname, package, target_file - end - end - - protected - - def self.build(pkgname, source_package) - package_path = File.join(tmpdir, 'ruby-' + source_package) - tarball = File.join(tmpdir, source_package + '.tar.gz') - source_dir = File.join(tmpdir, source_package) - - FileUtils.cp_r("test/sample/#{pkgname}", source_dir) - # Here, copy setup.rb to the source dir. - FileUtils.cp("/usr/lib/ruby/vendor_ruby/setup.rb", - source_dir) - system("tar czf #{tarball} -C#{tmpdir} #{source_package}") - FileUtils.rm_rf(File.join(tmpdir, source_dir)) - Gem2Deb::DhMakeRuby.new(tarball).build - - dh_ruby = Gem2Deb::DhRubySetupRb.new - dh_ruby.verbose = false - - silence_stream(STDOUT) do - silence_stream(STDERR) do - Dir.chdir(package_path) do - # This sequence tries to imitate what dh will actually do - dh_ruby.clean - dh_ruby.configure - dh_ruby.build - dh_ruby.install([File.join(package_path, 'debian', 'tmp')]) - end - end - end - end - -end diff -Nru gem2deb-0.3.0/test/unit/extension_builder_test.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/extension_builder_test.rb --- gem2deb-0.3.0/test/unit/extension_builder_test.rb 2011-07-03 22:01:28.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/extension_builder_test.rb 2013-06-02 01:12:36.000000000 +0000 @@ -12,7 +12,7 @@ FileUtils.cp_r(File.join('test/sample/', gem), target_dir) Dir.chdir(target_dir) do silence_stream STDOUT do - Gem2Deb::ExtensionBuilder.build_all_extensions(package) + Gem2Deb::ExtensionBuilder.build_all_extensions('.', "debian/#{package}") end end end diff -Nru gem2deb-0.3.0/test/unit/installer_test.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/installer_test.rb --- gem2deb-0.3.0/test/unit/installer_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/installer_test.rb 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1,178 @@ +require 'test_helper' +require 'gem2deb/installer' + +class InstallerTest < Gem2DebTestCase + + MULTIBINARY = 'test/sample/multibinary' + FOO = File.join(MULTIBINARY, 'foo') + BAR = File.join(MULTIBINARY, 'foo') + + context 'constructor' do + + setup do + @foo_installer = Gem2Deb::Installer.new('ruby-foo', FOO) + end + + should 'store binary package name' do + assert_equal 'ruby-foo', @foo_installer.binary_package + end + + should 'expand and store root directory' do + assert_match %r{.+#{FOO}$}, @foo_installer.root + end + + should 'read metadata' do + assert @foo_installer.metadata.is_a?(Gem2Deb::Metadata) + end + + end + + context 'finding duplicate files' do + setup do + @installer = Gem2Deb::Installer.new('ruby-foo', FOO) + @installer.verbose = false + @tmpdir = Dir.mktmpdir + end + teardown do + FileUtils.rm_rf(@tmpdir) + end + should 'remove duplicates' do + Dir.chdir(@tmpdir) do + FileUtils.mkdir('dir1') + FileUtils.mkdir('dir2') + ['dir1','dir2'].each do |d| + File.open(File.join(d, 'test.rb'), 'w') { |f| f.puts "# Nice File"} + end + @installer.send(:remove_duplicate_files, 'dir1', 'dir2') + assert !File.exists?('dir2') + end + end + should 'not crash with duplicates in subdirectories' do + Dir.chdir(@tmpdir) do + FileUtils.mkdir_p('dir1/subdir') + FileUtils.touch('dir1/subdir/test.rb') + FileUtils.mkdir_p('dir2/subdir') + FileUtils.touch('dir2/subdir/test.rb') + @installer.send(:remove_duplicate_files, 'dir1', 'dir2') + assert !File.exists?('dir2') + end + end + end + + context 'installing Ruby files' do + should 'not crash when directories to be installed have names in the exclusion list' do + installer = Gem2Deb::Installer.new('ruby-foo', FOO) + Dir.chdir('test/sample/install_files/') do + installer.send(:install_files, 'lib', File.join(tmpdir, 'install_files_destdir'), 644) + end + end + end + + context 'rewriting shebangs' do + setup do + @installer = Gem2Deb::Installer.new('ruby-foo', FOO) + @installer.verbose = false + + FileUtils.cp_r('test/sample/rewrite_shebangs', self.class.tmpdir) + @installer.stubs(:destdir).with(:bindir).returns(self.class.tmpdir + '/rewrite_shebangs') + + # The fact that this call does not crash means we won't crash when + # /usr/bin has subdirectories + @installer.send(:rewrite_shebangs, '/usr/bin/env ruby') + end + teardown do + FileUtils.rm_f(self.class.tmpdir + '/rewrite_shebangs') + end + + should 'rewrite shebangs of programs directly under bin/' do + assert_match %r{/usr/bin/env ruby}, File.read(self.class.tmpdir + '/rewrite_shebangs/usr/bin/prog') + end + should 'rewrite shebangs in subdirs of bin/' do + assert_match %r{/usr/bin/env ruby}, File.read(self.class.tmpdir + '/rewrite_shebangs/usr/bin/subdir/prog') + end + should 'add a shebang when there is none' do + lines = File.readlines(self.class.tmpdir + '/rewrite_shebangs/usr/bin/no-shebang') + assert_match %r{/usr/bin/env ruby}, lines[0] + assert_match /puts/, lines[1] + end + should 'not rewrite shebangs non-Ruby scripts' do + lines = File.readlines(self.class.tmpdir + '/rewrite_shebangs/usr/bin/shell-script') + assert_match %r{/bin/sh}, lines[0] + end + should 'leave programs with correct permissions after rewriting shebangs' do + assert_equal '100755', '%o' % File.stat(self.class.tmpdir + '/rewrite_shebangs/usr/bin/no-shebang').mode + end + should 'rewrite shebang to use `/usr/bin/env ruby` if all versions are supported' do + @installer.stubs(:all_ruby_versions_supported?).returns(true) + @installer.expects(:rewrite_shebangs).with('/usr/bin/env ruby') + @installer.send(:update_shebangs) + end + should 'rewrite shebang to usr /usr/bin/ruby1.8 if only 1.8 is supported' do + @installer.stubs(:ruby_versions).returns(['ruby1.8']) + @installer.expects(:rewrite_shebangs).with('/usr/bin/ruby1.8') + @installer.send(:update_shebangs) + end + end + + context 'checking for require "rubygems"' do + setup do + @installer = Gem2Deb::Installer.new("ruby-foo", FOO) + @installer.verbose = false + end + should 'detect require "rubygems"' do + @installer.stubs(:installed_ruby_files).returns(['test/sample/check_rubygems/bad.rb']) + assert_raises(Gem2Deb::Installer::RequireRubygemsFound) do + @installer.check_rubygems + end + end + should 'not complain about commented require "rubygems"' do + @installer.stubs(:installed_ruby_files).returns(['test/sample/check_rubygems/good.rb']) + @installer.check_rubygems + end + + %w[ + utf8 + latin1 + ].each do |encoding| + should "handle #{encoding}" do + @installer.stubs(:installed_ruby_files).returns(["test/encondings/#{encoding}.rb"]) + @installer.check_rubygems + end + end + + end + + context 'DESTDIR' do + setup do + @installer = Gem2Deb::Installer.new('ruby-foo', FOO) + @installer.dh_auto_install_destdir = '/path/to/source-package/debian/tmp' + end + should 'be debian/${binary_package} by default' do + assert_match /\/debian\/ruby-foo$/, @installer.send(:destdir, :root) + end + should 'install to debian/tmp when DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR is set' do + saved_env = ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] + ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] = 'yes' + + assert_equal '/path/to/source-package/debian/tmp', @installer.send(:destdir, :root) + + ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] = saved_env + end + end + + context "Ruby versions supported" do + setup do + @installer = Gem2Deb::Installer.new('ruby-foo', FOO) + end + should 'know when all versions are supported' do + # ruby_versions contains all supported versions by default + assert_equal true, @installer.send(:all_ruby_versions_supported?) + end + should 'know when not all versions are supported' do + @installer.stubs(:ruby_versions).returns(['ruby1.8']) + assert_equal false, @installer.send(:all_ruby_versions_supported?) + end + end + +end + diff -Nru gem2deb-0.3.0/test/unit/metadata_test.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/metadata_test.rb --- gem2deb-0.3.0/test/unit/metadata_test.rb 2011-06-20 02:48:32.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/metadata_test.rb 2013-06-02 01:17:07.000000000 +0000 @@ -95,11 +95,32 @@ end should 'obtain test files list from gemspec' do - @gemspec.stubs(:test_files).returns(['test/class1_test.rb', 'test/class2_test.rb']) + @gemspec.stubs(:test_files).returns(['test/class1_test.rb', 'test/class2_test.rb', 'test/not_a_test.txt']) assert_equal ['test/class1_test.rb', 'test/class2_test.rb'], @metadata.test_files end end + context 'on multi-binary source packages' do + + setup do + Dir.chdir('test/sample/multibinary') do + @metadata = Gem2Deb::Metadata.new('baz') + end + end + + should 'get the right path for extensions without a gemspec' do + assert_equal ['baz/ext/baz/extconf.rb'], @metadata.native_extensions + end + + should 'get the right path to extensions with a gemspec' do + @gemspec = mock + @metadata.stubs(:gemspec).returns(@gemspec) + @gemspec.expects(:extensions).returns(['path/to/extconf.rb']) + assert_equal ['baz/path/to/extconf.rb'], @metadata.native_extensions + end + + end + end diff -Nru gem2deb-0.3.0/test/unit/setup_rb_installer_test.rb gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/setup_rb_installer_test.rb --- gem2deb-0.3.0/test/unit/setup_rb_installer_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ gem2deb-0.4.1~ubuntu13.04.1~ppa2/test/unit/setup_rb_installer_test.rb 2013-05-30 18:28:01.000000000 +0000 @@ -0,0 +1,73 @@ +require 'test_helper' +require 'gem2deb/gem2tgz' +require 'gem2deb/dh_make_ruby' +require 'gem2deb/dh_ruby' +require 'gem2deb/setup_rb_installer' +require 'rbconfig' + +class SetupRbInstallerTest < Gem2DebTestCase + + one_time_setup do + build(SIMPLE_SETUPRB_NAME, SIMPLE_SETUPRB_DIRNAME) + end + + dirname = SIMPLE_SETUPRB_DIRNAME + package = "ruby-simplesetuprb" + + context 'installing native extension with setuprb' do + [ + '1.8', + '1.9.1', + ].each do |version_number| + vendorarchdir = VENDOR_ARCH_DIRS['ruby' + version_number] + target_so = "#{vendorarchdir}/simplesetuprb.so" + should "install native extension for Ruby #{version_number} for #{package}" do + assert_installed dirname, package, target_so + end + should "link #{target_so} against libruby#{version_number} for #{package}" do + installed_so = installed_file_path(dirname, package, target_so) + assert_match /libruby-?#{version_number}/, `ldd #{installed_so}` + end + end + end + + context 'test pre-install.rb hook' do + target_file = "/usr/lib/ruby/vendor_ruby/simplesetuprb/generated.rb" + should "install file generated by pre-install.rb hook" do + assert_installed dirname, package, target_file + end + end + + protected + + def self.build(pkgname, source_package) + package_path = File.join(tmpdir, 'ruby-' + source_package) + tarball = File.join(tmpdir, source_package + '.tar.gz') + source_dir = File.join(tmpdir, source_package) + + FileUtils.cp_r("test/sample/#{pkgname}", source_dir) + # Here, copy setup.rb to the source dir. + FileUtils.cp("/usr/lib/ruby/vendor_ruby/setup.rb", + source_dir) + system("tar czf #{tarball} -C#{tmpdir} #{source_package}") + FileUtils.rm_rf(File.join(tmpdir, source_dir)) + Gem2Deb::DhMakeRuby.new(tarball).build + + dh_ruby = Gem2Deb::DhRuby.new + dh_ruby.installer_class = Gem2Deb::SetupRbInstaller + dh_ruby.verbose = false + + silence_stream(STDOUT) do + silence_stream(STDERR) do + Dir.chdir(package_path) do + # This sequence tries to imitate what dh will actually do + dh_ruby.clean + dh_ruby.configure + dh_ruby.build + dh_ruby.install([File.join(package_path, 'debian', 'tmp')]) + end + end + end + end + +end