gem2deb-0.6.1/0000755000000000000000000000000012247473375007727 5ustar gem2deb-0.6.1/TODO0000644000000000000000000000765312200771641010414 0ustar These enhancement ideas are listed in no particular order. do not stop running tests after the first failing test suite ============================================================ Currently dh_ruby will stop after the first test suite fails, i.e. if the test suite fails under ruby 1.9.1, it will not run under ruby 2.0. Instead, dh_ruby should run all tests, and fail if any of them fail, but still run all of them. dh_ruby: solve the --install X the world situation ================================================== Currently, everything that dh_ruby does happens during `dh_ruby --install`. --configure, --build and --test are no-ops. We should either fix this, or remove these actions and leave only --install and --clean (and make --install the default so that we can call just `dh_ruby`). Rubygems integration ==================== It would be nice if Rubygems recognized packages created by gem2deb. For this, we need to install a .gemspec file somewhere, and patch Rubygems to look there for gemspecs as well (Rubygems already supports looking at multiple places for gemspecs). This should probably be discussed with Rubygems developers to reach the better integration possible and avoid noise. Other distributions may be already doing this, we should do some reasearch. autopkgtest support =================== It would ne nice to have some sort of integration with autopkgtest (DEP-8), so that we could automatically run the automated testes of the package against the installed package instead of against the source package. This would probably be done by subclassing the test runner to not mess with the load paths, i.e. when the test code require's something, that something would come from the system libraries. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=637917 syntax/load test ================ This should be a minimal test that would try to check the syntax of every source file against all supported Ruby interpreters to make sure the code is valid everywhere. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=645357 (with the rising usage of http://travis-ci.org/, compatibility should not be an issue for most new packages, but it might be for "legacy", or not very active packages) Support Rubinius ================ This includes both installing stuff to be used by Rubinius, including extensions, and being able to run gem2deb under Rubinius. See the `rake test` lines in debian/rules, we should add one like that for Rubinius. Support JRuby ============= This includes both installing stuff to be used by JRuby, including extensions, and being able to run gem2deb under JRuby. See the `rake test` lines in debian/rules, we should add one like that for JRuby. increase the coverage of the test suite ======================================= We should packages simplecov (http://rubygems.org/gems/simplecov), run it against gem2deb, and find places that are not covered by the test suite. Also, some places might be being run, but not checked at all. One example if the code that handles XS-Ruby-Versions. Make Rubygems extension builders verbose ======================================== Currently Rubygems hides the compilation from users, what makes sense; but we do not want that when we are building Debian packages. If there is any error during the build, we want to be able to stop the error right away instead of looking at log files. Besides, it is fun to watch build log scroll over your a terminal. ;-) To work on this, look at rubygems source, lib/rubygems/ext/builder.rb, you have to make both `make` and `run` commands spit the output from running commands to the terminal. Make the debhelper ruby buildsystem trigger automatically ========================================================= This way we don't need to pass `--buildsystem=ruby --with ruby` to dh in debian/rules. It should build automatically the sources root contains either metadata.yml, *.gemspec. To get full automation, the buildsystem should be included in debhelper. gem2deb-0.6.1/test/0000755000000000000000000000000012247471737010706 5ustar gem2deb-0.6.1/test/test_helper/0000755000000000000000000000000012151002231013171 5ustar gem2deb-0.6.1/test/test_helper/samples.rb0000644000000000000000000000424512150520372015201 0ustar class Gem2DebTestCase module Samples SAMPLE_DIR = File.join(File.dirname(__FILE__), '..', 'sample') TMP_DIR = Dir.mktmpdir(['gem2deb.', '.tmp']) SIMPLE_GEM_NAME = 'simplegem' SIMPLE_GEM_DIRNAME = SIMPLE_GEM_NAME + '-0.0.1' SIMPLE_GEM = File.join(SAMPLE_DIR, "#{SIMPLE_GEM_NAME}/pkg/#{SIMPLE_GEM_DIRNAME}.gem") SIMPLE_PROGRAM_NAME = 'simpleprogram' SIMPLE_PROGRAM_DIRNAME = SIMPLE_PROGRAM_NAME + '-1.2.3' SIMPLE_PROGRAM = File.join(SAMPLE_DIR, "#{SIMPLE_PROGRAM_NAME}/pkg/#{SIMPLE_PROGRAM_DIRNAME}.gem") SIMPLE_EXTENSION_NAME = 'simpleextension' SIMPLE_EXTENSION_DIRNAME = SIMPLE_EXTENSION_NAME + '-1.2.3' SIMPLE_EXTENSION = File.join(SAMPLE_DIR, "#{SIMPLE_EXTENSION_NAME}/pkg/#{SIMPLE_EXTENSION_DIRNAME}.gem") SIMPLE_ROOT_EXTENSION_NAME = 'simpleextension_in_root' SIMPLE_ROOT_EXTENSION_DIRNAME = SIMPLE_ROOT_EXTENSION_NAME.gsub('_', '-') + '-1.2.3' SIMPLE_ROOT_EXTENSION = File.join(SAMPLE_DIR, SIMPLE_ROOT_EXTENSION_NAME, 'pkg', "#{SIMPLE_ROOT_EXTENSION_NAME}-1.2.3.gem") SIMPLE_TGZ_NAME = 'simpletgz' SIMPLE_TGZ_DIRNAME = SIMPLE_TGZ_NAME + '-0.0.1' SIMPLE_TGZ = File.join(SAMPLE_DIR, "#{SIMPLE_TGZ_NAME}/pkg/#{SIMPLE_TGZ_DIRNAME}.tgz") SIMPLE_MIXED_NAME = 'simplemixed' SIMPLE_MIXED_DIRNAME = SIMPLE_MIXED_NAME + '-1.2.3' SIMPLE_MIXED = File.join(SAMPLE_DIR, "#{SIMPLE_MIXED_NAME}/pkg/#{SIMPLE_MIXED_DIRNAME}.gem") SIMPLE_GIT = File.join(SAMPLE_DIR, 'simplegit') SIMPLE_SETUPRB_NAME = "simplesetuprb" SIMPLE_SETUPRB_DIRNAME = SIMPLE_SETUPRB_NAME + "-0.0.1" SIMPLE_EXTENSION_WITH_NAME_CLASH_NAME = 'simpleextension_with_name_clash' SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME = SIMPLE_EXTENSION_WITH_NAME_CLASH_NAME.gsub('_', '-') + '-1.2.3' SIMPLE_EXTENSION_WITH_NAME_CLASH = File.join(SAMPLE_DIR, SIMPLE_EXTENSION_WITH_NAME_CLASH_NAME, 'pkg', SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME + '.gem') FANCY_PACKAGE_NAME = 'Fancy_Package' FANCY_PACKAGE = File.join(SAMPLE_DIR, "#{FANCY_PACKAGE_NAME}/pkg/#{FANCY_PACKAGE_NAME}-0.0.1.gem") end end gem2deb-0.6.1/test/sample/0000755000000000000000000000000012152450237012152 5ustar gem2deb-0.6.1/test/sample/rewrite_shebangs/0000755000000000000000000000000011572214617015512 5ustar gem2deb-0.6.1/test/sample/rewrite_shebangs/usr/0000755000000000000000000000000011572214617016323 5ustar gem2deb-0.6.1/test/sample/rewrite_shebangs/usr/bin/0000755000000000000000000000000011637424507017076 5ustar gem2deb-0.6.1/test/sample/rewrite_shebangs/usr/bin/shell-script0000644000000000000000000000005011637424245021424 0ustar #!/bin/sh set -e echo "Hello, world!" gem2deb-0.6.1/test/sample/rewrite_shebangs/usr/bin/subdir/0000755000000000000000000000000011572213572020362 5ustar gem2deb-0.6.1/test/sample/rewrite_shebangs/usr/bin/subdir/prog0000755000000000000000000000003411572213572021254 0ustar #!/usr/bin/env ruby exit 0 gem2deb-0.6.1/test/sample/rewrite_shebangs/usr/bin/prog0000755000000000000000000000003411572213572017764 0ustar #!/usr/bin/env ruby exit 0 gem2deb-0.6.1/test/sample/rewrite_shebangs/usr/bin/no-shebang0000644000000000000000000000002511633244535021034 0ustar puts 'Hello, world!' gem2deb-0.6.1/test/sample/simplegem/0000755000000000000000000000000011577230724014143 5ustar gem2deb-0.6.1/test/sample/simplegem/pkg/0000755000000000000000000000000011577230724014724 5ustar gem2deb-0.6.1/test/sample/simplegem/pkg/simplegem-0.0.1.gem0000644000000000000000000000600011577230724020026 0ustar data.tar.gz0000644000000000000000000000014100000000000013313 0ustar00wheelwheel00000000000000LL/-IMO+Jb030 4&ȈAA%E@3RSs#$Q0 F(kLmetadata.gz0000644000000000000000000000073000000000000013401 0ustar00wheelwheel00000000000000LSn ӻýwQvHTxlp`\%U?e_ sq >ĩy $aDm:yP@2nأc0| ޸T\rѢJMl¼w)sg6ZE]N@dj!|wVi21g4FzP/VQ\Wy{\*~kS%Ϩ'R-[ѷŤiOIf j54(*S(arpw:el8W |&mв3;j] i(ذ\.lG՗|b 񉔵aJ hf s+p- ;2.qq O,ƻB+"j=?>- ljXܫfF`fxGLO|ɨt蕥93ے.֭D?lNbgem2deb-0.6.1/test/sample/simplegem/Rakefile0000644000000000000000000000076611577230724015621 0ustar require 'rubygems' require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.summary = "Simple gem used to test gem2tgz." s.name = 'simplegem' s.version = '0.0.1' s.requirements << 'none' s.require_path = 'lib' #s.autorequire = 'rake' s.files = Dir.glob('lib/**') s.description = < s&q-Ls8͜f'ɗ :-d>U?~!PBpV.I&;ˍn+g~88g>yENCPUbXohmetadata.gz0000644000000000000000000000103200000000000013375 0ustar00wheelwheel00000000000000QkMTA0 Wx=mP 6Ez4 d$, O?hKUUgc9w~O{WDW4BtY`V4 {CJ\eI=zP ! vm "a9泘ϒKCVd%[獀)Γ,)I{ jmГ)RvA62 y.?k+<mVi\36c N\:\ X]{Ovqȟ K]~CcD 1FCRchՕJ" =6uBzYƩU$WjNx*Ɓ4s~Ozgp]jUq4+mCP aj6sc@qn&_/aiGbRnA-P/U0[pKh;zW[!+O,jUx"T~В//SwW%e;`M gem2deb-0.6.1/test/sample/simplemixed/Rakefile0000644000000000000000000000116311543165110016134 0ustar require 'rubygems' require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.summary = "Simple native extension used to test dh_ruby" s.name = 'simplemixed' s.version = '1.2.3' s.requirements << 'none' s.require_path = 'ext' s.extensions << 'ext/simplemixed/extconf.rb' #s.autorequire = 'rake' s.files = Dir.glob('{bin,ext,lib}/**/*') s.description = <&?ֈ͝}crBD ~ .GλQzҘb> M`")cɏ˵w4wm]ubAFN/ ;ܠgf''|&;j (\6gem2deb-0.6.1/test/sample/simpleprogram-no-shebang/Rakefile0000644000000000000000000000111511633244535020522 0ustar require 'rubygems' require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.summary = "Simple program used to test dh_ruby" s.name = 'simpleprogram-no-shebang' s.version = '1.2.3' s.requirements << 'none' s.require_path = 'lib' #s.autorequire = 'rake' s.files = Dir.glob('{bin,man}/**/*') s.test_files = ['test/runprogram.rb'] s.description = < Sun, 06 Nov 2011 20:36:58 -0200 gem2deb-0.6.1/test/sample/examples/debian/copyright0000644000000000000000000000226611725254125017156 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: examples 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: 2011 Antonio Terceiro License: [LICENSE TEXT] gem2deb-0.6.1/test/sample/examples/debian/control0000644000000000000000000000137011763235317016625 0ustar Source: ruby-examples Section: ruby Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: Antonio Terceiro , Cédric Boutillier DM-Upload-Allowed: yes Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.2.10~) Standards-Version: 3.9.2 #Vcs-Git: git://git.debian.org/pkg-ruby-extras/ruby-examples.git #Vcs-Browser: http://git.debian.org/?p=pkg-ruby-extras/ruby-examples.git;a=summary Homepage: FIXME XS-Ruby-Versions: all Package: ruby-examples Architecture: all XB-Ruby-Versions: ${ruby:Versions} Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter Description: FIXME gem2deb-0.6.1/test/sample/examples/debian/rules0000755000000000000000000000007511655606147016306 0ustar #!/usr/bin/make -f %: dh $@ --buildsystem=ruby --with ruby gem2deb-0.6.1/test/sample/examples/debian/source/0000755000000000000000000000000011655606720016521 5ustar gem2deb-0.6.1/test/sample/examples/debian/source/format0000644000000000000000000000001511655606720017730 0ustar 3.0 (native) gem2deb-0.6.1/test/sample/examples/debian/ruby-examples.examples0000644000000000000000000000001311655606133021546 0ustar examples/* gem2deb-0.6.1/test/sample/simpleextension_in_root/0000755000000000000000000000000011543165110017125 5ustar gem2deb-0.6.1/test/sample/simpleextension_in_root/extconf.rb0000644000000000000000000000007211543165110021117 0ustar require 'mkmf' create_makefile('simpleextension_in_root') gem2deb-0.6.1/test/sample/simpleextension_in_root/simpleextension_in_root.c0000644000000000000000000000015011543165110024244 0ustar #include "ruby.h" void Init_simpleextension_in_root() { rb_define_module("SimpleExtensionInRoot"); } gem2deb-0.6.1/test/sample/simpleextension_in_root/pkg/0000755000000000000000000000000011543165110017706 5ustar gem2deb-0.6.1/test/sample/simpleextension_in_root/pkg/simpleextension_in_root-1.2.3.gem0000644000000000000000000000700011543165110026013 0ustar data.tar.gz0000644000000000000000000000037400000000000013323 0ustar00wheelwheel00000000000000 vM씻 0KICW})w7 R(WȷpNH*e6xxܭ/d< oݪT@@?AF3 mtQ.!U@0r[֬k2)T \}{r+~LI$?`G8L;c#Xf0)M\BpWO¨oN6-,8 metadata.gz0000644000000000000000000000106300000000000013401 0ustar00wheelwheel00000000000000 vMTM0W =l"qݕ d$1$ve+qloU93˛KQ.Ӎ?B86݄ڶVdԈ D;NCBi[Z'Ic`yrWo)`U$V i/b7KalZӺؗӠRjNlыuƆ)4$u[F%U?OaU$>:hpBgikDQ;?.NCp{ W1G4<$L/%%ʞYni)e̷َ~;Lm{`12 !ӚLqq>nRzx|[Ke8IP2ek7j^CTjAIHaF'q }&|LQ Gq> \AN*K&yWvxp:.6<gݗ;2yU[tQޕ j w:F 8cXn* e]~vκNZ8 {Awm/5IJg= v.?HKIgem2deb-0.6.1/test/sample/simpleextension_in_root/Rakefile0000644000000000000000000000136311543165110020575 0ustar require 'rubygems' require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.summary = "Simple native extension with extconf.rb in root directory used to test dh_ruby" s.name = 'simpleextension_in_root' s.version = '1.2.3' s.requirements << 'none' s.require_path = '.' s.extensions << 'extconf.rb' #s.autorequire = 'rake' s.files = ['extconf.rb', 'simpleextension_in_root.c'] s.description = <030 4P0(-$h}yFjju=7D~iq~0)&UYpq+(y*$*$*@4(q G@nb>zԴ`GgQ0 F(%pz metadata.gz0000644000000000000000000000075300000000000013406 0ustar00wheelwheel000000000000001MTM0 WsV"޻^ ` |Iv&| jENpᓟ۷kIFI+Q9 ̢!AIѰC w~ZCF CZN Thu, 11 Aug 2011 11:11:27 -0700 gem2deb-0.6.1/test/sample/name_clash_multiple/debian/copyright0000644000000000000000000000236011725254125021340 0ustar FIXME. fill-in with DEP5 copyright file. http://dep.debian.net/deps/dep5/ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: simpleextension-with-name-clash Source: FIXME (URL where source can be downloaded) Files: * Copyright: Copyright 1998 John Doe License: GPL-2+ 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: Copyright 1998 Jane Smith License: [LICENSE TEXT] gem2deb-0.6.1/test/sample/name_clash_multiple/debian/control0000644000000000000000000000207011626511334021004 0ustar Source: ruby-name-clash Section: ruby Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: Antonio Terceiro DM-Upload-Allowed: yes Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.2.6~) Standards-Version: 3.9.2 #Vcs-Git: git://git.debian.org/pkg-ruby-extras/ruby-simpleextension-with-name-clash.git #Vcs-Browser: http://git.debian.org/?p=pkg-ruby-extras/ruby-simpleextension-with-name-clash.git;a=summary Homepage: FIXME XS-Ruby-Versions: all Package: ruby-name-clash Architecture: any XB-Ruby-Versions: ${ruby:Versions} Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter Description: Simple native extension with .rb/.so name clash used to test dh_ruby simpleextension_with_name_clash is a simple native extension that is used to test dh_ruby. Package: libname-clash-ruby Architecture: any Depends: ruby-name-clash Description: transitional package for ruby-name-clash This packages is a transitional package for ruby-name-clash and can be safely removed. gem2deb-0.6.1/test/sample/name_clash_multiple/debian/rules0000755000000000000000000000070112200775462020463 0ustar #!/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.9.1 ruby2.0 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 gem2deb-0.6.1/test/sample/name_clash_multiple/debian/source/0000755000000000000000000000000011626511334020702 5ustar gem2deb-0.6.1/test/sample/name_clash_multiple/debian/source/format0000644000000000000000000000001511626511334022111 0ustar 3.0 (native) gem2deb-0.6.1/test/sample/name_clash_multiple/lib/0000755000000000000000000000000011626511334016726 5ustar gem2deb-0.6.1/test/sample/name_clash_multiple/lib/name_clash.rb0000644000000000000000000000007711626511334021351 0ustar require 'name_clash.so' module NameClash ANSWER_42 = 42 end gem2deb-0.6.1/test/sample/multibinary/0000755000000000000000000000000012152453572014516 5ustar gem2deb-0.6.1/test/sample/multibinary/baz/0000755000000000000000000000000012152453621015265 5ustar gem2deb-0.6.1/test/sample/multibinary/baz/ext/0000755000000000000000000000000012152453621016065 5ustar gem2deb-0.6.1/test/sample/multibinary/baz/ext/baz/0000755000000000000000000000000012152453731016643 5ustar gem2deb-0.6.1/test/sample/multibinary/baz/ext/baz/extconf.rb0000644000000000000000000000004612152453631020635 0ustar require 'mkmf' create_makefile('baz') gem2deb-0.6.1/test/sample/multibinary/baz/ext/baz/baz.c0000644000000000000000000000051712152453724017570 0ustar #include "ruby.h" VALUE method_answer42(VALUE module, VALUE self); void Init_baz() { VALUE BAZ = rb_define_module("BAZ"); rb_define_module_function(BAZ, "answer42", method_answer42, 0); rb_define_const(BAZ, "Hello_world", rb_str_new2("Hello World")); } VALUE method_answer42(VALUE module, VALUE self) { return INT2NUM(42); } gem2deb-0.6.1/test/sample/multibinary/bar/0000755000000000000000000000000012151733370015256 5ustar gem2deb-0.6.1/test/sample/multibinary/bar/CHANGELOG.md0000644000000000000000000000003012151733370017060 0ustar upstream changelog here gem2deb-0.6.1/test/sample/multibinary/bar/bar.gemspec0000644000000000000000000000044112151715061017363 0ustar 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 gem2deb-0.6.1/test/sample/multibinary/debian/copyright0000644000000000000000000000227112151715061017666 0ustar 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] gem2deb-0.6.1/test/sample/multibinary/debian/control0000644000000000000000000000222712152465630017344 0ustar 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 gem2deb-0.6.1/test/sample/multibinary/debian/rules0000755000000000000000000000070112200775446017017 0ustar #!/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.9.1 ruby2.0 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 gem2deb-0.6.1/test/sample/multibinary/debian/source/0000755000000000000000000000000012151715061017231 5ustar gem2deb-0.6.1/test/sample/multibinary/debian/source/format0000644000000000000000000000001412151715061020437 0ustar 3.0 (quilt) gem2deb-0.6.1/test/sample/multibinary/debian/watch0000644000000000000000000000015312151715061016761 0ustar version=3 http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/multibinary .*/multibinary-(.*).tar.gz gem2deb-0.6.1/test/sample/simplegit/0000755000000000000000000000000011547533701014154 5ustar gem2deb-0.6.1/test/sample/simplegit/simplegit.gemspec0000644000000000000000000000127311547533574017531 0ustar # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "simplegit/version" Gem::Specification.new do |s| s.name = "simplegit" s.version = Simplegit::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Antonio Terceiro"] s.email = ["terceiro@softwarelivre.org"] s.homepage = "" s.summary = %q{Simple gem faking code from git} s.description = %q{This gem is used to test the case where dh-make-ruby is called on a directory} s.rubyforge_project = "simplegit" s.files = %w[ lib lib/simplegit.rb lib/simplegit lib/simplegit/version.rb Rakefile simplegit.gemspec ] s.require_paths = ["lib"] end gem2deb-0.6.1/test/sample/simplegit/lib/0000755000000000000000000000000011547533330014720 5ustar gem2deb-0.6.1/test/sample/simplegit/lib/simplegit.rb0000644000000000000000000000006011547533313017237 0ustar module Simplegit # Your code goes here... end gem2deb-0.6.1/test/sample/simplegit/lib/simplegit/0000755000000000000000000000000011547537735016732 5ustar gem2deb-0.6.1/test/sample/simplegit/lib/simplegit/version.rb0000644000000000000000000000005111547533313020724 0ustar module Simplegit VERSION = "0.0.1" end gem2deb-0.6.1/test/sample/simpleextension_with_name_clash/0000755000000000000000000000000011604167104020604 5ustar gem2deb-0.6.1/test/sample/simpleextension_with_name_clash/ext/0000755000000000000000000000000011604201275021402 5ustar gem2deb-0.6.1/test/sample/simpleextension_with_name_clash/ext/extconf.rb0000644000000000000000000000010211604156077023377 0ustar require 'mkmf' create_makefile('simpleextension_with_name_clash') gem2deb-0.6.1/test/sample/simpleextension_with_name_clash/ext/simpleextension_with_name_clash.c0000644000000000000000000000101111604157264030202 0ustar #include "ruby.h" VALUE method_answer42(VALUE module, VALUE self); void Init_simpleextension_with_name_clash() { VALUE SimpleExtensionWithNameClass = rb_define_module("SimpleExtensionWithNameClash"); rb_define_module_function(SimpleExtensionWithNameClass, "answer42", method_answer42, 0); rb_define_const(SimpleExtensionWithNameClass, "Hello_world", rb_str_new2("Hello World")); } VALUE method_answer42(VALUE module, VALUE self) { VALUE answer = rb_const_get(module, rb_intern("ANSWER_42")); return answer; } gem2deb-0.6.1/test/sample/simpleextension_with_name_clash/test/0000755000000000000000000000000011604157445021572 5ustar ././@LongLink0000644000000000000000000000014712247476172011660 Lustar rootrootgem2deb-0.6.1/test/sample/simpleextension_with_name_clash/test/simpleextension_with_name_clash_test.rbgem2deb-0.6.1/test/sample/simpleextension_with_name_clash/test/simpleextension_with_name_clash_test.0000644000000000000000000000032411604157445031264 0ustar require 'test/unit' require 'simpleextension_with_name_clash' class SimpleExtensionWithNameClashTest < Test::Unit::TestCase def test_simple assert_equal 42, SimpleExtensionWithNameClash.answer42 end end gem2deb-0.6.1/test/sample/simpleextension_with_name_clash/pkg/0000755000000000000000000000000011604167033021366 5ustar ././@LongLink0000644000000000000000000000015012247476172011652 Lustar rootrootgem2deb-0.6.1/test/sample/simpleextension_with_name_clash/pkg/simpleextension-with-name-clash-1.2.3.gemgem2deb-0.6.1/test/sample/simpleextension_with_name_clash/pkg/simpleextension-with-name-clash-1.2.3.0000644000000000000000000001000011604167033030222 0ustar data.tar.gz0000644000000000000000000000106700000000000013323 0ustar00wheelwheel00000000000000NW]k0+.Cz+dC) Fֵy}=&ߵգvF Ft?$Yp$+ORun2.y," x7aض~|ϻ8ﰴ&Rŀxq WB]N+ʤ7rk"kj j0`(veZ<c}{OE 8ZgcwnPʄGRר0KHoQ |#Gɝo"{E41Z\"84LJ ٺCfl RPץ $gmXn7vhJ{θۮvb+wC4HBܸ7s8A8 Nz{ zc`"Xad={:1Y8Zx0G o`?ž סc`WAHMؾwBƭXf_(.Y,n)bѼ_EIĐ&F8REDe8M"Z"i/i#זmetadata.gz0000644000000000000000000000101600000000000013377 0ustar00wheelwheel00000000000000NTM0W ;M[";+q!q&v]IS]HԸ͇߄so>} Uj>m I{I Dm'ż4r8 ޼i0fhǷy: hPL͈Eb18x,):V'6zl9>_22|j@g Cj-N 9ևx}n>'t:q0TE!_DPID W\ is1A7 ʧb &$[sbcJq"WyW Eά 7h[@?/y:)D[@dsēIh4FXq|^dWRM4?.@RyDVlea.OxU,j?֕zmu&p#_e|Wgx#zp ;>eT{tX!Cd;BW|*$jIgem2deb-0.6.1/test/sample/simpleextension_with_name_clash/Rakefile0000644000000000000000000000130711604166763022264 0ustar require 'rubygems' require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.summary = "Simple native extension with .rb/.so name clash used to test dh_ruby" s.name = 'simpleextension-with-name-clash' s.version = '1.2.3' s.requirements << 'none' s.require_path = 'ext' s.extensions << 'ext/extconf.rb' #s.autorequire = 'rake' s.files = Dir.glob('{lib,ext,test}/**/*') s.description = <t~zEs+^ձc1({c P lOmΆdweaM 0oTU[oaJA?0 0 0 0 0 0 0 ü_w(gem2deb-0.6.1/test/sample/simpletgz/Rakefile0000644000000000000000000000076611543165110015642 0ustar require 'rubygems' require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.summary = "Simple gem used to test gem2tgz." s.name = 'simplegem' s.version = '0.0.1' s.requirements << 'none' s.require_path = 'lib' #s.autorequire = 'rake' s.files = Dir.glob('lib/**') s.description = <ni4)2MwnvlnV){{4+PGQgKF%y?73p&;P+J~9C7VrQYgw-jC:,W )αة@Gh|9G0~лx 1p^H0gUB-QcVO ymU0Nұg.71x2K m9VZ2Ez#}>[^'m[JP2U>!vцoGac@◺|cT gFFtL7o &ﱇ1S:t8metadata.gz0000644000000000000000000000076100000000000013405 0ustar00wheelwheel00000000000000MTM +ܹI2j+Ej{J="BnjWꏯ!әΞEĆgc;77GD;Uu?T"(k4">4#^,*(ߓ99t8DF^ >94i<ѸY4Y+٘`~c̍2rЗItPfA"̋x^@Wo MF*\y[ҩ)2~ǒ/[ʃX'P΋a!"f- }vcc\|B9ь[֝!vGU#YҚ.sMD;QʺS;jR8u:+?o'iS8 Sat, 01 Jun 2013 16:52:32 -0300 gem2deb-0.6.1/test/sample/simpleextension_dh_auto_install_destdir/debian/copyright0000644000000000000000000000250512152450400025516 0ustar 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'. gem2deb-0.6.1/test/sample/simpleextension_dh_auto_install_destdir/debian/control0000644000000000000000000000200312152453147025172 0ustar 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 gem2deb-0.6.1/test/sample/simpleextension_dh_auto_install_destdir/debian/rules0000755000000000000000000000015312152450440024644 0ustar #!/usr/bin/make -f export DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR=1 %: dh $@ --buildsystem=ruby --with ruby gem2deb-0.6.1/test/sample/simpleextension_dh_auto_install_destdir/debian/source/0000755000000000000000000000000012152450400025061 5ustar gem2deb-0.6.1/test/sample/simpleextension_dh_auto_install_destdir/debian/source/format0000644000000000000000000000001412152450400026267 0ustar 3.0 (quilt) gem2deb-0.6.1/test/sample/Fancy_Package/0000755000000000000000000000000011631060321014615 5ustar gem2deb-0.6.1/test/sample/Fancy_Package/pkg/0000755000000000000000000000000011631060321015376 5ustar gem2deb-0.6.1/test/sample/Fancy_Package/pkg/Fancy_Package-0.0.1.gem0000644000000000000000000000700011631060321021172 0ustar data.tar.gz0000644000000000000000000000020400000000000013313 0ustar00wheelwheel00000000000000UdNLOKK/HLNLO+Jb2030 贁9 74542aP0C"9xG9 nI\y)\Q0 F(4_Ametadata.gz0000644000000000000000000000111500000000000013377 0ustar00wheelwheel00000000000000UdNTM0W 'vFZ $g&O-3vnWމtEQ3o5Nu!{k4[@9=a 36ݣX `qaw#b $QG5b?㘕Vgʭ 潧MOrWO}[:K5ȯ2HܘA[ ;UmQs:Yuuŕha>6BX q ydlg<9" RuHL"mX:7E#09ba8BӎB7PzqbcDŠe_1tZGY;fP 'mG,ޣY@xRt u4{{F*`>ZĒZ5 Ȃӽ#7R`H>weRΎN] <1`_E睸1wI-`v#bR, pj~aV<^N"G/^zE>{gESκ9QPz#{stdout} 2>#{stderr}") if $?.exitstatus != 0 error = "Command [#{cmd}] failed!\n" error << "Standard output:\n" << File.read(stdout).lines.map { |line| " #{line}"}.join error << "Standard error:\n" << File.read(stderr).lines.map { |line| " #{line}"}.join end FileUtils.rm_f(stdout) FileUtils.rm_f(stderr) if error raise error end end # See above def run_command(cmd) 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 gem2deb-0.6.1/test/integration/0000755000000000000000000000000012152514245013214 5ustar gem2deb-0.6.1/test/integration/gem2deb_test.rb0000644000000000000000000000570312152465771016123 0ustar require 'test_helper' class Gem2DebTest < Gem2DebTestCase def self.build(gem) FileUtils.cp gem, tmpdir gem = File.basename(gem) Dir.chdir(tmpdir) do cmd = "gem2deb -d #{gem}" run_command(cmd) end end Dir.glob('test/sample/*/pkg/*.gem').each do |gem| puts "Building #{gem} ..." self.build(gem) should "build #{gem} correcly" do package_name = 'ruby-' + File.basename(File.dirname(File.dirname(gem))).gsub('_', '-').downcase binary_packages = File.join(self.class.tmpdir, "#{package_name}_*.deb") packages = Dir.glob(binary_packages) assert !packages.empty?, "building #{gem} produced no binary packages! (expected to find #{binary_packages})" end end should 'generate a non-lintian-clean copyright file' do changes_file = File.join(self.class.tmpdir, "ruby-simplegem_*.changes") assert_match /E: ruby-simplegem: helper-templates-in-copyright/, `lintian #{changes_file}` end 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 end end gem2deb-0.6.1/test/integration/dh_make_ruby_integration_test.rb0000644000000000000000000000105011550644435021636 0ustar require 'test_helper' class DhMakeRubyIntegrationTest < Gem2DebTestCase should 'run dh-make against directory with gemspec' do target_dir = File.join(tmpdir, 'withgemspec') FileUtils.cp_r(SIMPLE_GIT, target_dir) run_command("dh-make-ruby #{target_dir}") end should 'run dh-make against directory without gemspec' do target_dir = File.join(tmpdir, 'withoutgemspec') FileUtils.cp_r(SIMPLE_GIT, target_dir) FileUtils.rm(File.join(target_dir, 'simplegit.gemspec')) run_command("dh-make-ruby #{target_dir}") end end gem2deb-0.6.1/test/unit/0000755000000000000000000000000012247472736011665 5ustar gem2deb-0.6.1/test/unit/setup_rb_installer_test.rb0000644000000000000000000000435012200777673017150 0ustar 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 SUPPORTED_VERSION_NUMBERS.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 gem2deb-0.6.1/test/unit/metadata_test.rb0000644000000000000000000000745212200777673015036 0ustar require 'test_helper' require 'gem2deb/metadata' require 'yaml' class MetaDataTest < Gem2DebTestCase { 'simpleextension' => true, 'simpleextension_in_root' => true, 'simplegem' => false, 'simplemixed' => true, 'simpleprogram' => false, 'simpletgz' => false, }.each do |source_package, has_extensions| should "correctly detect native extensions for #{source_package}" do assert_equal has_extensions, Gem2Deb::Metadata.new(File.join('test/sample', source_package)).has_native_extensions? end end def setup FileUtils.mkdir_p('test/tmp') end def teardown FileUtils.rmdir('test/tmp') end context 'without gemspec' do setup do @metadata = Gem2Deb::Metadata.new('test/tmp') end should 'have no homepage' do assert_nil @metadata.homepage end should 'have no short description' do assert_nil @metadata.short_description end should 'have no long description' do assert_nil @metadata.long_description end should 'have no dependencies' do assert_equal [], @metadata.dependencies end should 'have no test files' do assert_equal [], @metadata.test_files end should 'provide a gem name from source dir' do assert_equal 'tmp', @metadata.name end should 'provide a fallback version number' do assert_not_nil @metadata.version end should 'read version number from source dir name when available' do @metadata.stubs(:source_dir).returns('/tmp/package-1.2.3') assert_equal 'package', @metadata.name assert_equal '1.2.3', @metadata.version end end context 'with gemspec' do setup do @gemspec = mock @metadata = Gem2Deb::Metadata.new('test/tmp') @metadata.stubs(:gemspec).returns(@gemspec) end should 'obtain gem name from gemspec' do @gemspec.stubs(:name).returns('weird') assert_equal 'weird', @metadata.name end should 'obtain gem version from gemspec' do @gemspec.stubs(:version).returns(Gem::Version.new('0.0.1')) assert_equal '0.0.1', @metadata.version end should 'obtain homepage from gemspec' do @gemspec.stubs(:homepage).returns('http://www.debian.org/') assert_equal 'http://www.debian.org/', @metadata.homepage end should 'obtain short description from gemspec' do @gemspec.stubs(:summary).returns('This library does stuff') assert_equal 'This library does stuff', @metadata.short_description end should 'obtain long detect from gemspec' do @gemspec.stubs(:description).returns('This is the long description, bla bla bla') assert_equal 'This is the long description, bla bla bla', @metadata.long_description end should 'obtain dependencies list from gemspec' do @gemspec.stubs(:dependencies).returns(['gem1', 'gem2']) assert_equal ['gem1', 'gem2'], @metadata.dependencies end should 'obtain test files list from gemspec' do @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 gem2deb-0.6.1/test/unit/gem2tgz_test.rb0000644000000000000000000000527312247100552014617 0ustar require 'test_helper' require 'yaml' require 'rubygems' require 'gem2deb/gem2tgz' class Gem2TgzTest < Gem2DebTestCase SIMPLE_GEM_TARBALL = File.join(tmpdir, "#{SIMPLE_GEM_DIRNAME}.tar.gz") SIMPLE_TGZ_TARBALL = File.join(tmpdir, "#{SIMPLE_TGZ_DIRNAME}.tar.gz") should 'convert using a new instance when converting through the class' do gem2tgz = mock gem2tgz.expects(:convert!) Gem2Deb::Gem2Tgz.expects(:new).with(SIMPLE_GEM, SIMPLE_GEM_TARBALL).returns(gem2tgz) Gem2Deb::Gem2Tgz.convert!(SIMPLE_GEM, SIMPLE_GEM_TARBALL) end class << self attr_accessor :instance end def instance self.class.instance end one_time_setup do self.instance = Gem2Deb::Gem2Tgz.new(SIMPLE_GEM, SIMPLE_GEM_TARBALL) self.instance.convert! end context 'converting a simple gem' do should 'create tarball' do assert_file_exists SIMPLE_GEM_TARBALL end should 'include the contents of the gem in the tarball' do assert_contained_in_tarball SIMPLE_GEM_TARBALL, 'simplegem-0.0.1/lib/simplegem.rb' end should 'not include data.tar.gz' do assert_not_contained_in_tarball SIMPLE_GEM_TARBALL, 'simplegem-0.0.1/data.tar.gz' end should 'not include metadata.gz' do assert_not_contained_in_tarball SIMPLE_GEM_TARBALL, 'simplegem-0.0.1/metadata.gz' end should 'not leave temporary directory after creating tarball' do assert_no_file_exists instance.target_dir end should 'create metadata.yml' do unpack(SIMPLE_GEM_TARBALL) do assert_file_exists 'simplegem-0.0.1/metadata.yml' end end context 'looking inside metadata.yml' do setup do @gemspec = unpack(SIMPLE_GEM_TARBALL) do YAML.load_file('simplegem-0.0.1/metadata.yml') end end should 'be valid gemspec' do assert_kind_of Gem::Specification, @gemspec end should "be simplegem's spec" do assert_equal 'simplegem', @gemspec.name end end end context('tgz package') do setup do @tgz = Gem2Deb::Gem2Tgz.new(SIMPLE_TGZ, SIMPLE_TGZ_TARBALL) @tgz.convert! end should 'create tarball' do assert_file_exists SIMPLE_TGZ_TARBALL end should 'include the contents of the tgz in the tarball' do assert_contained_in_tarball SIMPLE_TGZ_TARBALL, 'simpletgz-0.0.1/lib/simpletgz.rb' end end should 'not mess with the full path' do testdir = File.join(tmpdir, 'Downloads') # uppercase FileUtils.mkdir_p(testdir) FileUtils.cp(SIMPLE_GEM, testdir) gem = File.join(testdir, File.basename(SIMPLE_GEM)) tarball = gem.gsub('.gem', '.tar.gz') Gem2Deb::Gem2Tgz.new(gem).convert! assert File.exists?(tarball) end end gem2deb-0.6.1/test/unit/dh_ruby_test.rb0000644000000000000000000001374312247472736014715 0ustar require 'test_helper' require 'gem2deb/gem2tgz' require 'gem2deb/dh_make_ruby' require 'gem2deb/dh_ruby' require 'rbconfig' class DhRubyTest < Gem2DebTestCase one_time_setup do build(SIMPLE_GEM, SIMPLE_GEM_DIRNAME) build(SIMPLE_PROGRAM, SIMPLE_PROGRAM_DIRNAME) build(SIMPLE_EXTENSION, SIMPLE_EXTENSION_DIRNAME) build(SIMPLE_MIXED, SIMPLE_MIXED_DIRNAME) build(SIMPLE_ROOT_EXTENSION, SIMPLE_ROOT_EXTENSION_DIRNAME) build(SIMPLE_EXTENSION_WITH_NAME_CLASH, SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME) end context 'installing simplegem' do should 'install pure-Ruby code' do assert_installed SIMPLE_GEM_DIRNAME, 'ruby-simplegem', '/usr/lib/ruby/vendor_ruby/simplegem.rb' end end context 'installing a Ruby program' do should 'install programs at /usr/bin' do assert_installed SIMPLE_PROGRAM_DIRNAME, 'ruby-simpleprogram', '/usr/bin/simpleprogram' end should 'rewrite shebang of installed programs' do assert_match %r(#!/usr/bin/env ruby), read_installed_file(SIMPLE_PROGRAM_DIRNAME, 'ruby-simpleprogram', '/usr/bin/simpleprogram').lines.first end end context 'installing native extension' do SUPPORTED_VERSION_NUMBERS.each do |version_number| vendorarchdir = VENDOR_ARCH_DIRS['ruby' + version_number] target_so = "#{vendorarchdir}/simpleextension.so" should "install native extension for Ruby #{version_number}" do assert_installed SIMPLE_EXTENSION_DIRNAME, "ruby-simpleextension", target_so end should "link #{target_so} against libruby#{version_number}" do installed_so = installed_file_path(SIMPLE_EXTENSION_DIRNAME, "ruby-simpleextension", target_so) assert_match /libruby-?#{version_number}/, `ldd #{installed_so}` end end end context 'installing native extension with extconf.rb in the sources root' do SUPPORTED_VERSION_NUMBERS.each do |version_number| vendorarchdir = VENDOR_ARCH_DIRS['ruby' + version_number] target_so = "#{vendorarchdir}/simpleextension_in_root.so" should "install native extension for Ruby #{version_number}" do assert_installed SIMPLE_ROOT_EXTENSION_DIRNAME, "ruby-simpleextension-in-root", target_so end end end context 'skipping checks' do setup do @dh_ruby = Gem2Deb::DhRuby.new @dh_ruby.verbose = false end should 'not skip tests if DEB_BUILD_OPTIONS is not defined' do ENV.expects(:[]).with('DEB_BUILD_OPTIONS').returns(nil) assert_equal false, @dh_ruby.send(:skip_checks?) end should 'not skip tests if DEB_BUILD_OPTIONS does not include nocheck' do ENV.expects(:[]).with('DEB_BUILD_OPTIONS').returns('nostrip').at_least_once assert_equal false, @dh_ruby.send(:skip_checks?) end should 'skip tests if DEB_BUILD_OPTIONS contains exactly nocheck' do ENV.expects(:[]).with('DEB_BUILD_OPTIONS').returns('nocheck').at_least_once assert_equal true, @dh_ruby.send(:skip_checks?) end should 'skip tests if DEB_BUILD_OPTIONS contains nocheck among other options' do ENV.expects(:[]).with('DEB_BUILD_OPTIONS').returns('nostrip nocheck noopt').at_least_once assert_equal true, @dh_ruby.send(:skip_checks?) end end context 'running tests' do setup do @dh_ruby = Gem2Deb::DhRuby.new @dh_ruby.verbose = false end should 'handle test failure gracefully' do @dh_ruby.stubs(:skip_checks?).returns(false) @dh_ruby.expects(:run).raises(Gem2Deb::CommandFailed) @dh_ruby.expects(:handle_test_failure) @dh_ruby.send(:run_tests_for_version, SUPPORTED_RUBY_VERSIONS.keys.first) end end context 'versions supported' do setup do @dh_ruby = Gem2Deb::DhRuby.new @dh_ruby.verbose = false end should 'bail out if XS-Ruby-Versions is not found' do File.expects(:readlines).with('debian/control').returns([]) @dh_ruby.expects(:exit).with(1) @dh_ruby.send(:ruby_versions) end should 'read supported versions from debian/control' do File.expects(:readlines).with('debian/control').returns(["XS-Ruby-Versions: all\n"]) assert_equal SUPPORTED_RUBY_VERSIONS.keys, @dh_ruby.send(:ruby_versions) end end context 'installing gemspec' do SUPPORTED_VERSION_NUMBERS.each do |version| should 'install gemspec for simplegem under Ruby ' + version do assert_installed SIMPLE_GEM_DIRNAME, 'ruby-simplegem', "/usr/share/rubygems-integration/#{version}/specifications/simplegem-0.0.1.gemspec" end end end context "selecting package layout" do setup do @dh_ruby = Gem2Deb::DhRuby.new @dh_ruby.verbose = false 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 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 protected def read_installed_file(gem_dirname, package, path) File.read(installed_file_path(gem_dirname, package, path)) end def self.build(gem, source_package) package_path = File.join(tmpdir, 'ruby-' + source_package) tarball = File.join(tmpdir, source_package + '.tar.gz') Gem2Deb::Gem2Tgz.convert!(gem, tarball) Gem2Deb::DhMakeRuby.new(tarball).build build_package(package_path) end def self.build_package(directory) Dir.chdir(directory) do dh_ruby = Gem2Deb::DhRuby.new dh_ruby.verbose = false silence_stream(STDOUT) 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(directory, 'debian', 'tmp')]) end end end end gem2deb-0.6.1/test/unit/secure_code_test.rb0000644000000000000000000000051612243202532015510 0ustar require 'test_helper' class SecureCodeTest < Gem2DebTestCase should 'not interpolate variables into shell commands' do insecure_code = `grep -rl '\\(system\\|run\\)[( ][^,]*\#{' lib/ bin/`.split unless insecure_code.empty? fail "files containing insecure code: \n\t" + insecure_code.join("\n\t") end end end gem2deb-0.6.1/test/unit/dh_make_ruby_test.rb0000644000000000000000000001051412245666425015701 0ustar require 'test_helper' require 'gem2deb/gem2tgz' require 'gem2deb/dh_make_ruby' class DhMakeRubyTest < Gem2DebTestCase DEBIANIZED_SIMPLE_GEM = File.join(tmpdir, 'ruby-' + SIMPLE_GEM_DIRNAME) SIMPLE_GEM_UPSTREAM_TARBALL = DEBIANIZED_SIMPLE_GEM + '.tar.gz' one_time_setup do # generate tarball Gem2Deb::Gem2Tgz.convert!(SIMPLE_GEM, SIMPLE_GEM_UPSTREAM_TARBALL) Gem2Deb::DhMakeRuby.new(SIMPLE_GEM_UPSTREAM_TARBALL).build end should 'use ruby-* package name by default' do assert_equal 'ruby-simplegem', Gem2Deb::DhMakeRuby.new(SIMPLE_GEM_UPSTREAM_TARBALL).source_package_name end should 'be able to specify a package name' do assert_equal 'xyz', Gem2Deb::DhMakeRuby.new(SIMPLE_GEM_UPSTREAM_TARBALL, :source_package_name => 'xyz').source_package_name end should 'replace underscores with dashes in source package name' do assert_equal 'ruby-foo-bar', Gem2Deb::DhMakeRuby.new('foo_bar-0.0.1.tar.gz').source_package_name end should 'not duplicate "ruby" in the name of a package' do assert_equal 'ruby-foo', Gem2Deb::DhMakeRuby.new('ruby_foo-1.2.3.tar.gz').source_package_name assert_equal 'ruby-foo', Gem2Deb::DhMakeRuby.new('foo_ruby-1.2.3.tar.gz').source_package_name end context 'simple gem' do %w[ debian/control debian/rules debian/copyright debian/changelog debian/compat debian/watch debian/source/format ].each do |file| filename = File.join(DEBIANIZED_SIMPLE_GEM, file) should "create #{file}" do assert_file_exists filename end should "create non-empty #{file} file" do assert !File.zero?(filename), "#{filename} expected NOT to be empty" end end end DEBIANIZED_SIMPLE_EXTENSION = File.join(tmpdir, 'ruby-' + SIMPLE_EXTENSION_DIRNAME) SIMPLE_EXTENSION_UPSTREAM_TARBALL = DEBIANIZED_SIMPLE_EXTENSION + '.tar.gz' one_time_setup do Gem2Deb::Gem2Tgz.convert!(SIMPLE_EXTENSION, SIMPLE_EXTENSION_UPSTREAM_TARBALL) Gem2Deb::DhMakeRuby.new(SIMPLE_EXTENSION_UPSTREAM_TARBALL).build end DEBIANIZED_SIMPLE_PROGRAM = File.join(tmpdir, SIMPLE_PROGRAM_DIRNAME) SIMPLE_PROGRAM_UPSTREAM_TARBALL = DEBIANIZED_SIMPLE_PROGRAM + '.tar.gz' one_time_setup do # generate tarball Gem2Deb::Gem2Tgz.convert!(SIMPLE_PROGRAM, SIMPLE_PROGRAM_UPSTREAM_TARBALL) pkg = Gem2Deb::DhMakeRuby.new(SIMPLE_PROGRAM_UPSTREAM_TARBALL, :source_package_name => 'simpleprogram') pkg.build end context 'simple program' do should "create manpages file for dh_installman" do filename = File.join(DEBIANIZED_SIMPLE_PROGRAM, "debian/simpleprogram.manpages") assert_file_exists filename end end TEST_SIMPLE_GIT = File.join(tmpdir, 'simplegit') one_time_setup do FileUtils.cp_r(SIMPLE_GIT, TEST_SIMPLE_GIT) Gem2Deb::DhMakeRuby.new(TEST_SIMPLE_GIT).build end context 'running dh-make-ruby against a directory' do should 'get the package name correctly' do assert_equal ['ruby-simplegit'], Dir.chdir(TEST_SIMPLE_GIT) { packages } end should 'get the version name correctly' do assert_equal 'Version: 0.0.1-1', Dir.chdir(TEST_SIMPLE_GIT) { `dpkg-parsechangelog | grep Version:`.strip } end should 'create debian/control' do assert_file_exists File.join(TEST_SIMPLE_GIT, 'debian/control') end should 'create debian/rules' do assert_file_exists File.join(TEST_SIMPLE_GIT, 'debian/rules') end end FANCY_PACKAGE_TARBALL = File.join(tmpdir, 'fancy-package-0.0.1.tar.gz') one_time_setup do Gem2Deb::Gem2Tgz.convert!(FANCY_PACKAGE, FANCY_PACKAGE_TARBALL) $__fancy_package_dh_make_ruby = Gem2Deb::DhMakeRuby.new(FANCY_PACKAGE_TARBALL) $__fancy_package_dh_make_ruby.build end context 'a package with a fancy name that is not a valid Debian package name' do should 'use upstream name from metadata' do assert_equal 'Fancy_Package', $__fancy_package_dh_make_ruby.gem_name end should 'use actual upstream name in debian/watch' do assert_match /gemwatch\/Fancy_Package/, File.read(File.join(tmpdir, 'ruby-fancy-package-0.0.1/debian/watch')) end should 'use actual upstream name in debian/copyright' do assert_match /Upstream-Name: Fancy_Package/, File.read(File.join(tmpdir, 'ruby-fancy-package-0.0.1/debian/copyright')) end end protected def packages `dh_listpackages`.split end end gem2deb-0.6.1/test/unit/test_runner_test.rb0000644000000000000000000000302212200777673015613 0ustar require 'test_helper' require 'gem2deb/test_runner' class TestRunnerTest < Gem2DebTestCase def self.should_pass_tests(dir) should_succeed(dir, true) end def self.should_fail_tests(dir) should_succeed(dir, false) end def self.should_detect_test_runner(dir) should "detect a test runner for #{dir}" do Dir.chdir(dir) do assert Gem2Deb::TestRunner.detect end end end def self.should_succeed(dir, true_or_false) should_detect_test_runner(dir) should "pass tests on #{dir}" do begin Dir.chdir(dir) do self.class.silence_stream(STDOUT) do self.class.silence_stream(STDERR) do runner = Gem2Deb::TestRunner.detect def runner.exec(*cmd) system(*cmd) exit($?.exitstatus) end rubylib = ENV['RUBYLIB'] ENV['RUBYLIB'] = GEM2DEB_ROOT_SOURCE_DIR + '/lib' runner.run_tests ENV['RUBYLIB'] = rubylib end end end rescue SystemExit => e assert_equal true_or_false, e.success? end end end should_pass_tests 'test/sample/test_runner/yaml/pass' should_fail_tests 'test/sample/test_runner/yaml/fail' should_pass_tests 'test/sample/test_runner/rake/pass' should_fail_tests 'test/sample/test_runner/rake/fail' should_pass_tests 'test/sample/test_runner/rb/pass' should_fail_tests 'test/sample/test_runner/rb/fail' should_detect_test_runner 'test/sample/test_runner/no_tests' end gem2deb-0.6.1/test/unit/extension_builder_test.rb0000644000000000000000000000153512200777673016774 0ustar require 'test_helper' require 'gem2deb/extension_builder' class ExtensionBuilderTest < Gem2DebTestCase gem = SIMPLE_EXTENSION_WITH_NAME_CLASH_NAME build_dir = 'ruby-' + SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME target_dir = File.join(tmpdir, build_dir) package = 'ruby-' + SIMPLE_EXTENSION_WITH_NAME_CLASH_NAME.gsub('_', '-') one_time_setup do FileUtils.cp_r(File.join('test/sample/', gem), target_dir) Dir.chdir(target_dir) do silence_stream STDOUT do Gem2Deb::ExtensionBuilder.build_all_extensions('.', "debian/#{package}") end end end context 'building simpleextension' do should 'install .so for current Ruby' do Dir.chdir(target_dir) do assert_file_exists File.join('debian', package, RbConfig::CONFIG['vendorarchdir'] + '/simpleextension_with_name_clash.so') end end end end gem2deb-0.6.1/test/unit/installer_test.rb0000644000000000000000000001441612200777673015251 0ustar 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 #{OLDER_RUBY_VERSION_BINARY} if only #{OLDER_RUBY_VERSION} is supported" do @installer.stubs(:ruby_versions).returns([OLDER_RUBY_VERSION]) @installer.stubs(:supported_ruby_versions).returns([OLDER_RUBY_VERSION, 'rubyX.Y']) @installer.expects(:rewrite_shebangs).with(OLDER_RUBY_VERSION_BINARY) @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([OLDER_RUBY_VERSION]) @installer.stubs(:supported_ruby_versions).returns([OLDER_RUBY_VERSION, 'rubyX.Y']) assert_equal false, @installer.send(:all_ruby_versions_supported?) end end end gem2deb-0.6.1/tools/0000755000000000000000000000000011705076552011061 5ustar gem2deb-0.6.1/tools/shell.bash0000644000000000000000000000040211705076356013025 0ustar #!/bin/sh gem2deb_root=$(readlink -f $BASH_SOURCE | xargs dirname | xargs dirname) export PATH="${gem2deb_root}/bin:${PATH}" export PERL5LIB="${gem2deb_root}/debhelper7" export RUBYLIB="${gem2deb_root}/lib" PS1="\033[31;40;01m** gem2deb debug **\033[m $PS1" gem2deb-0.6.1/README0000644000000000000000000000234711543165110010574 0ustar gem2deb is a set of tools to create Debian packages from Rubygems The workflow looks like: Download gem: gem fetch foo | v Create a tarball. It contains the gem spec as metadata.yml gem2tgz foo-1.2.gem | v Convert to a Debian source package with sane defaults: dh-make-ruby foo-1.2.tar.gz | v Modify, if needed | v Build the package: dpkg-buildpackage -us -uc Alternatively, you can use the gem2deb command, that tries to do everything automatically. The generated Debian source package uses Debhelper 7 with a specific build system called "ruby". That buildsystem uses the dh_ruby tool for the various steps (clean, build, test, install). Building from source and testing this package: ============================================== # install build-dependencies, look at the Build-Depends line # in debian/control # build the package dpkg-buildpackage -us -uc # install sudo debi # or simply: "rake install" Developers: Lucas Nussbaum Antonio Terceiro License: GPLv3 or later Current status: gem2tgz and dh-make-ruby work. dh_ruby is not yet feature-comparable with setup.rb, and needs some work. gem2deb-0.6.1/Rakefile0000644000000000000000000000465712247473375011410 0ustar require 'rake/testtask' ENV['LANG'] = 'C' task :default => :test task :test => :version_check do puts '=> Unit tests' Rake::Task['test:unit'].invoke puts '=> Integration tests' Rake::Task['test:integration'].invoke end Rake::TestTask.new('test:unit') do |t| t.libs << "test" t.test_files = FileList['test/unit/*_test.rb'] t.verbose = true end Rake::TestTask.new('test:integration') do |t| t.libs << 'test' t.test_files = FileList['test/integration/*_test.rb'] t.verbose = true end desc "Run tests in debug mode (e.g. don't delete temporary files)" task 'test:debug' do ENV['GEM2DEB_TEST_DEBUG'] = 'yes' Rake::Task['test'].invoke end desc "Builds the Debian package and installs it on your system" task :install do sh 'dpkg-buildpackage -us -uc' sh "sudo debi" end desc "Builds a git snapshot package" 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 desc "Checks for inconsistencies between version numbers in the code and in debian/changelog" task :version_check do $code_version = `ruby -Ilib -rgem2deb/version -e 'puts Gem2Deb::VERSION'`.strip $debian_version = `dpkg-parsechangelog | grep '^Version: ' | cut -d ' ' -f 2`.strip if $code_version != $debian_version msg ="W: Inconsistent version numbers: lib/gem2deb/version.rb says #{$code_version}, debian/changelog says #{$debian_version}" if STDIN.isatty && STDOUT.isatty && STDERR.isatty # highlight the message in red puts("\033[31;40m%s\033[m" % msg) else puts msg end fail if ENV.has_key?('VERSION_CHECK_FATAL') end end namespace :release do desc "Releases to Debian sid (very much tied to terceiro's workflow)" task :sid do ENV['VERSION_CHECK_FATAL'] = 'yes' Rake::Task['version_check'].invoke sh 'git buildpackage --git-builder=sbuild' sh 'git buildpackage --git-tag-only' sh 'git push --all' sh 'git push --tags' sh 'debsign' sh 'debrelease' end end gem2deb-0.6.1/debhelper7/0000755000000000000000000000000011705073623011736 5ustar gem2deb-0.6.1/debhelper7/Debian/0000755000000000000000000000000011705073431013115 5ustar gem2deb-0.6.1/debhelper7/Debian/Debhelper/0000755000000000000000000000000011705073435015013 5ustar gem2deb-0.6.1/debhelper7/Debian/Debhelper/Buildsystem/0000755000000000000000000000000011705073444017317 5ustar gem2deb-0.6.1/debhelper7/Debian/Debhelper/Buildsystem/ruby.pm0000644000000000000000000000171311705073357020643 0ustar # A debhelper build system class for building Ruby projects. # # Copyright: © 2011 Lucas Nussbaum # License: GPL-2+ # Strongly based on other build systems. Thanks! package Debian::Debhelper::Buildsystem::ruby; use strict; use base 'Debian::Debhelper::Buildsystem'; sub DESCRIPTION { "Ruby (Gem2Deb)" } sub check_auto_buildable { my $this=shift; return (-e $this->get_sourcepath("metadata.yml")) ? 1 : 0; } sub new { my $class=shift; my $this=$class->SUPER::new(@_); $this->enforce_in_source_building(); return $this; } sub configure { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--configure", @_); } sub build { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--build", @_); } sub test { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--test", @_); } sub install { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--install", @_); } sub clean { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--clean", @_); } 1 gem2deb-0.6.1/debhelper7/Debian/Debhelper/Buildsystem/rubysetuprb.pm0000644000000000000000000000176711705073357022261 0ustar # A debhelper build system class for building Ruby projects. # # Copyright: © 2011 Vincent Fourmond # License: GPL-2+ # Based on the ruby.pm build system package Debian::Debhelper::Buildsystem::rubysetuprb; use strict; use base 'Debian::Debhelper::Buildsystem'; sub DESCRIPTION { "Ruby (Gem2Deb+setup.rb)" } sub check_auto_buildable { my $this=shift; return 0; # Never autobuildable } sub new { my $class=shift; my $this=$class->SUPER::new(@_); $this->enforce_in_source_building(); return $this; } sub configure { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--setuprb", "--configure", @_); } sub build { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--setuprb", "--build", @_); } sub test { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--setuprb", "--test", @_); } sub install { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--setuprb", "--install", @_); } sub clean { my $this=shift; $this->doit_in_sourcedir("dh_ruby", "--setuprb", "--clean", @_); } 1 gem2deb-0.6.1/debhelper7/Debian/Debhelper/Sequence/0000755000000000000000000000000012151734760016564 5ustar gem2deb-0.6.1/debhelper7/Debian/Debhelper/Sequence/ruby.pm0000644000000000000000000000032411705073357020104 0ustar #! /usr/bin/perl # debhelper sequence file for ruby use warnings; use strict; use Debian::Debhelper::Dh_Lib; insert_after("dh_shlibdeps", "dh_ruby_fixdepends"); add_command_options("dh_compress", "-X.rb"); 1 gem2deb-0.6.1/HACKING0000644000000000000000000000102011705077152010676 0ustar Running a development gem2deb version without installing ======================================================== To debug a gem2deb source tree, you might want to run the contained programs against other packages, but you probably don't want to install a development version on your system just to be able to that. $ . /path/to/gem2deb/tools/shell.bash This will make the programs in bin/ available in your $PATH, the Ruby code in lib/ available for Ruby and the debhelper Perl code in debhelper7/ available for debhelper. gem2deb-0.6.1/bin/0000755000000000000000000000000012247072547010473 5ustar gem2deb-0.6.1/bin/dh-make-ruby0000755000000000000000000000665512200772064012710 0ustar #!/usr/bin/ruby # # Copyright © 2011, Lucas Nussbaum # # 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' require 'gem2deb/dh_make_ruby' require 'optparse' options = {} optparse = OptionParser.new do |opts| opts.on('-h', '--help', 'show help') do puts opts exit end opts.on('-v', '--version', 'show version') do puts "dh-make-ruby version #{Gem2Deb::VERSION}" exit end opts.on('-p', '--package PACKAGE', 'specify package name (default: ruby-*)') do |package_name| options[:source_package_name] = package_name end opts.on('', '--ruby-versions VERSIONS', 'ruby versions to use (default: all)') do |versions| options[:ruby_versions] = versions end end optparse.parse! if ARGV.length != 1 puts optparse exit(1) end input = ARGV[0] dmr = Gem2Deb::DhMakeRuby::new(input, options) dmr.build __END__ =head1 NAME dh-make-ruby - build Debian source package from Ruby library =head1 USAGE B [I] I|I =head1 DESCRIPTION B will create a basic Debian source package from a tarball named I generated with B, or from a I containing Ruby code and metadata in a .gemspec file. =head1 OPTIONS =over =item B<-p PACKAGE>, B<--package PACKAGE> Uses PACKAGE as package name. By default, new packages will be named as ruby-$gem, where $gem is the upstream name. If the package is mainly used as a 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<--ruby-versions VERSIONS> Ruby versions to build the package for. This is used to generate the X-Ruby-Versions: field in the source package, that can later be used to tune this value. By default, gem2deb generates a package that works on all known Ruby versions, but it might be necessary to only build the package for Ruby 1.9.1, for example (using B<--ruby-versions "ruby1.9.1">). =item B<-h>, B<--help> Displays the help =item B<-v>, B<--version> Displays version information and exits. =back =head1 SEE ALSO L>(1), L>(1) =head1 COPYRIGHT AND AUTHORS Copyright (c) 2011, Lucas Nussbaum 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 . gem2deb-0.6.1/bin/dh_ruby0000755000000000000000000002431712204463024012047 0ustar #!/usr/bin/ruby -w # # Copyright © 2011, Lucas Nussbaum # # 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' require 'gem2deb/dh_ruby' require 'gem2deb/setup_rb_installer' require 'optparse' include Gem2Deb engine = Gem2Deb::DhRuby.new optparse = OptionParser.new do |opts| opts.on('-h', '--help', 'show help') do puts opts exit end opts.on('', '--setuprb', 'use setup.rb for installation') do engine.installer_class = Gem2Deb::SetupRbInstaller end opts.on('-v', '--version', 'show dh_ruby version') do puts "dh_ruby version #{Gem2Deb::VERSION}" exit end opts.on('', '--print-supported', 'prints supported Ruby versions') do Gem2Deb::SUPPORTED_RUBY_VERSIONS.keys.sort.each do |v| puts v end exit end opts.on('', '--clean', 'debhelper clean helper') do engine.clean exit(0) end opts.on('', '--configure', 'debhelper configure helper') do engine.configure exit(0) end opts.on('', '--build', 'debhelper build helper') do engine.build exit(0) end opts.on('', '--test', 'debhelper test helper') do engine.test exit(0) end opts.on('', '--install', 'debhelper install helper') do engine.install(ARGV) exit(0) end end optparse.parse! puts optparse exit(1) __END__ =head1 NAME dh_ruby - debhelper7 build system for Ruby software =head1 SYNOPSIS B [I] =head1 DESCRIPTION B is a Debhelper 7 build system for Ruby software. It will automatically build and install files contained in Ruby packages, trying to work as close to Rubygems as possible but respecting Debian standards for Ruby packages. dh_ruby can automatically run your tests against all supported Ruby versions, see the "FILES" section below. 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 =item B<--clean>, B<--configure>, B<--build>, B<--test>, B<--install> Commands called by debhelper at various steps of the build process. =item B<--print-supported> Prints the supported Ruby versions. =item B<-h>, B<--help> Displays B usage information. =item B<-v>, B<--version> Displays B version information. =item B<--setuprb> This option indicates that the build should use I rather than the usual gem-based build. To take effect, this option must come first ! =back =head1 ENVIRONMENT VARIABLES =over =item I This is a space-separated list of tests that dh_ruby will ignore during package build. The available test names are "require-rubygems" plus the names of all supported Ruby versions. At the time of writing, only "ruby1.9.1" and ruby2.0 are supported. If set to "all", all tests will be ignored during the package build. =item I If this variable is defined (to anything), dh_ruby will respect the directory informed by dh_auto_install(1), usually I. By default, gem2deb will install files to debian/I, where I is the first binary package listed in debian/control. 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 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 will I to use DH_RUBY_GEMSPEC to instruct dh_ruby about which one to use. =back =head1 FILES =over =item debian/I, debian/I, debian/I Theses files can be used to explicitly tell dh_ruby how to run the tests in your package. When running the tests, dh_ruby will automatically set RUBYLIB to include the appropriate directories where the package files were installed in your package to make sure the tests use them instead of the files in the source directory. B debian/I must contain a YAML document with a list of test files to be run. If the package metadata contains an explicit list of test files, gem2deb(1) will automatically generate this file for you. Example from ruby-mime-types: --- - test/test_mime_type.rb - test/test_mime_types.rb debian/I can be used to run the tests with rake(1). If you use this file, your package must Build-Depend on the I package. You can use anything you would use in a regular Rakefile, but you must define a default task. gem2deb includes utility test task that makes it easier for you by creating a default task automatically. Example: require 'gem2deb/rake/testtask' Gem2Deb::Rake::TestTask.new do |t| t.test_files = FileList['test/*_test.rb'] end If debian/I exists, it will be run with each supported Ruby version, and must finish with a exit status of I<0>, otherwise dh_ruby assumes the tests failed. A simple example: require 'test/unit' require 'mypackage' # if 'mypackage.rb' or 'mypackage.so' was not installed properly, this will fail class MyPackageTest < Test::Unit::TestCase def test_features assert_equal 4, MyPackage.sum(2,2) end end =item debian/I Fine-tune the "require-rubygems" test. If the package has a very good reason to actually `require "rubygems"`, you can use this file as a whitelist of files allowed to have `require "rubygems"`. 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: --- - debian/ruby-foo/usr/lib/ruby/vendor_ruby/foo.rb - debian/ruby-foo/usr/lib/ruby/vendor_ruby/foo/rubygems.rg As you can see above, you have to list filenames based on their corresponding install locations in the package temporary install directory, i.e. `debian/${pkg}/..` =back =head1 SEE ALSO L>(1) =head1 COPYRIGHT AND AUTHORS Copyright (c) 2011, Lucas Nussbaum 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 . gem2deb-0.6.1/bin/gem2deb0000755000000000000000000001372512243202551011720 0ustar #!/usr/bin/ruby -w # # Copyright © 2011, Lucas Nussbaum # # 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' require 'gem2deb/gem2tgz' require 'gem2deb/dh_make_ruby' require 'optparse' $only_tarball = false $only_source_dir = false $only_debian_source = false $check_build_deps = true dh_make_ruby_options = {} optparse = OptionParser.new do |opts| opts.on('-h', '--help', 'show gem2deb help') do puts opts exit end opts.on('-v', '--version', 'show gem2deb version') do puts "gem2deb version #{Gem2Deb::VERSION}" exit end opts.on('-t', '--only-tarball', 'stop after creating the tar.gz archive') do $only_tarball = true end opts.on('-s', '--only-source-dir', 'stop after preparing the Debian source package') do $only_source_dir = true end opts.on('-S', '--only-debian-source', 'only build source package ; no binary packages') do $only_debian_source = true end opts.on('-d', '--dont-check-builddeps', 'do not check build dependencies; used for testing') do $check_build_deps = false end opts.on('-p', '--package PACKAGE', 'specify package name (default: ruby-*)') do |package_name| dh_make_ruby_options[:source_package_name] = package_name end opts.on('', '--ruby-versions VERSIONS', 'ruby versions to use (default: all)') do |versions| dh_make_ruby_options[:ruby_versions] = versions end end optparse.parse! if ARGV.length != 1 puts optparse exit(1) end gemfile = ARGV[0] # Download gem if not available locally if not File::exists?(gemfile) and gemfile !~ /.gem$/ puts "#{gemfile} doesn't seem to exist. Let's try to download it with 'gem fetch #{ARGV[0]}'" run("gem", "fetch", gemfile) gemfile = Dir::glob("#{gemfile}-*.gem")[0] end puts "-- Creating source tarball from #{gemfile} ..." tarball = Gem2Deb::Gem2Tgz.convert!(gemfile) puts "-- Successfully created #{tarball}" exit(0) if $only_tarball puts puts "-- Creating Debian source package from #{tarball} ..." dmr = Gem2Deb::DhMakeRuby::new(tarball, dh_make_ruby_options) dmr.build puts "-- Generated Debian source tree in #{dmr.source_dirname}" exit(0) if $only_source_dir puts puts "-- Building Debian package ..." dmr.buildpackage($only_debian_source, $check_build_deps) puts "-- Debian package successfully built!" __END__ =head1 NAME gem2deb - converts Rubygems' .gem file into Debian package =head1 SYNOPSIS B [I] I (to download the gem with I) B [I] I (to use a local .gem file) =head1 DESCRIPTION B converts the gem into a Debian source package, and then will attempt to build it. The process is made of several steps. First, B converts the gem file to a tar.gz archive containing a metadata.yml file with the Gem specification. This is equivalent to what B does. Then, B unpacks the tar.gz archive and prepares a Debian source package, guess many of the defaults from the files included in the archive, or the Gem specification. This is equivalent to what B does. B cannot determine all parameters for obvious reasons. It is recommended to search for the "FIXME" string in the I directory. The generated Debian source package uses B to build the package. Finally, B tries to build the source and binary packages using B. =head1 OPTIONS =over =item B<-t>, B<--only-tarball> Stop after creating the tar.gz archive. =item B<-s>, B<--only-source-dir> Stop after preparing the Debian source package directory (do not attempt to build the package). =item B<-S>, B<--only-debian-source> Only build a Debian source package (do not build binary packages). =item B<-p PACKAGE>, B<--package PACKAGE> Specify package name (default: ruby-*). Passed to dh-make-ruby. See B. =item B<--ruby-versions VERSIONS> Ruby versions to build the package for (default: all). Passed to dh-make-ruby. See B. =item B<-h>, B<--help> Displays B usage information. =item B<-v>, B<--version> Displays B version information. =back =head1 HOW THE .GEM -> .TGZ CONVERSION WORKS A gem named I is converted in a tarball with (approximately) the following steps: mkdir mygem-0.1.0 cd mygem-0.1.0 tar xfm /absolute/path/to/mygem-0.1.0.gem tar xzfm data.tar.gz zcat metadata.gz > metadata.yml rm -f data.tar.gz metadata.gz cd .. tar czf mygem-0.1.0.tar.gz mygem-0.1.0 rm -rf mygem-0.1.0 The generated tarball has the following properties: =over =item Files It contains all the files the gem contains. =item Metadata It contains the gem metadata in a file named ``metadata.yml`` inside the I directory. =back =head1 SEE ALSO L>(1) =head1 COPYRIGHT AND AUTHORS Copyright (c) 2011, Lucas Nussbaum 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 . gem2deb-0.6.1/bin/gem2tgz0000755000000000000000000000516712243202551011773 0ustar #!/usr/bin/ruby # # Copyright © 2010, Antonio Terceiro # # 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' require 'gem2deb/gem2tgz' require 'optparse' optparse = OptionParser.new do |opts| opts.on('-h', '--help', 'show help') do puts opts exit end opts.on('-v', '--version', 'show version') do puts "gem2tgz version #{Gem2Deb::VERSION}" exit end end optparse.parse! if ARGV.length != 1 && ARGV.length != 2 puts optparse exit(1) end gemfile = ARGV[0] # Download gem if not available locally if not File::exists?(gemfile) and gemfile !~ /.gem$/ puts "#{gemfile} doesn't seem to exist. Let's try to download it with 'gem fetch #{ARGV[0]}'" run("gem", "fetch", gemfile) gemfile = Dir::glob("#{gemfile}-*.gem")[0] end Gem2Deb::Gem2Tgz.convert!(gemfile, ARGV[1] || nil) __END__ =head1 NAME gem2tgz - converts Rubygems' .gem file into tarballs =head1 SYNOPSIS B [I] I [I] (to download the gem with I) B [I] I [I] (to use a local .gem file) =head1 DESCRIPTION B will convert the .gem file I into a tarball named I. If I is omitted, B will try to guess the filename for the tarball by taking I and replacing '.gem' with '.tar.gz'. =head1 SEE ALSO L>(1) =head1 COPYRIGHT AND AUTHORS Copyright (c) 2010, Antonio Terceiro 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 . gem2deb-0.6.1/bin/dh_ruby_fixdepends0000755000000000000000000000470712200776575014277 0ustar #!/usr/bin/ruby -w # # Copyright © 2011, Lucas Nussbaum # # 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' require 'gem2deb/dh_ruby' include Gem2Deb `dh_listpackages`.split.each do |package| next if not File::exists?("debian/#{package}.substvars") s = IO::read("debian/#{package}.substvars") fd = File::new("debian/#{package}.substvars", "w") s.each_line do |l| if l =~ /^shlibs:Depends=/ deps = l.chomp.split('=', 2)[1].split(', ') std_deps = [] ruby_deps = [] deps.each do |dep| if SUPPORTED_RUBY_SHARED_LIBRARIES.include?(dep.split(' ')[0]) ruby_deps << dep else std_deps << dep end end # p ruby_deps # p std_deps newdeps = (std_deps + [(ruby_deps.join(' | '))]).join(', ') fd.puts "shlibs:Depends=#{newdeps}" else fd.puts l end end fd.close end __END__ =head1 NAME dh_ruby_fixdepends - fix dependencies in shlibs file after dh_shlibdeps =head1 SYNOPSIS B =head1 DESCRIPTION B is called by the I dh sequence. You should not call it directly. =head1 SEE ALSO L>(1), L>(1) =head1 COPYRIGHT AND AUTHORS Copyright (c) 2011, Lucas Nussbaum 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 . gem2deb-0.6.1/bin/gen-ruby-trans-pkgs0000755000000000000000000000405711725254126014241 0ustar #!/usr/bin/ruby -w # Generate debian/control snippets if ARGV.length != 1 puts "generate-ruby-transitional-packages OLD_SOURCE_PACKAGE" exit(1) end version = `dpkg-parsechangelog`.split($/).grep(/^Version: /)[0].split[1] package = `dh_listpackages`.split[0] allpackages = `dh_listpackages`.split binaries = [] `apt-cache showsrc #{ARGV[0]}`.split($/).grep(/^Binary/).each do |l| binaries += l.split(/[, ]+/)[1..-1] end binaries.uniq! binaries -= allpackages rstring = binaries.map { |pkg| "#{pkg} (<< #{version}~)" }.join(', ') puts "# For the replacement package" puts "Replaces: #{rstring}" puts "Breaks: #{rstring}" puts "Provides: #{binaries.join(', ')}" puts puts "# Transitional packages" binaries.each do |pkg| puts <<-EOF Package: #{pkg} Section: oldlibs Priority: extra Architecture: all Depends: ${misc:Depends}, #{package} Description: Transitional package for #{package} This is a transitional package to ease upgrades to the #{package} package. It can safely be removed. EOF end __END__ =head1 NAME gen-ruby-trans-pkgs - generate ruby transitional packages =head1 SYNOPSIS B I =head1 DESCRIPTION B reads debian/control, debian/changelog, and the output of apt-cache showsrc I, and generates debian/control snippets to add transitional packages. =head1 SEE ALSO L>(1) =head1 COPYRIGHT AND AUTHORS Copyright (c) 2011, Lucas Nussbaum 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 . gem2deb-0.6.1/debian/0000755000000000000000000000000012247476171011146 5ustar gem2deb-0.6.1/debian/compat0000644000000000000000000000000211543165110012326 0ustar 7 gem2deb-0.6.1/debian/changelog0000644000000000000000000002653212247473274013031 0ustar gem2deb (0.6.1) unstable; urgency=low [ Marc Deslauriers ] * Fix regression when handling test failures [ Antonio Terceiro ] * Add unit test for regression fix when handling test failures -- Antonio Terceiro Tue, 03 Dec 2013 21:26:35 -0300 gem2deb (0.6.0) unstable; urgency=low * gem2tgz: fix full path handling when generating tarball name (Closes: #730854) * Don't interpolate path in regular expression when loading templates. This fixes the build when the source directory contains regular expression metacharacters such as '+' (Closes: #730854) * debian/control: add versioned build-depends on ruby-mocha (Closes: #730690) * Ignore non-installed interpreters. This will ease backports of gem2deb without also having to backport the interpreters supported in unstable. (Closes: #730694) -- Antonio Terceiro Mon, 02 Dec 2013 09:49:30 -0300 gem2deb (0.5.1) unstable; urgency=low * Don't interpolate arguments for shell commands. This fixes handling of files with weird characters in their names such as ")" and whitespace in general, and improves security against maliciously-crafted filenames which could inject unwanted shell commands in the system that is building a package with gem2deb. (Closes: #729981) -- Antonio Terceiro Wed, 20 Nov 2013 16:19:46 -0300 gem2deb (0.5.0) unstable; urgency=low * Drop Ruby 1.8 support * Add Ruby 2.0 support * Centralize references to supported Ruby versions to make it dead simple to remove/add new ones. * Run tests in verbose mode during package build -- Antonio Terceiro Tue, 03 Sep 2013 23:42:41 -0300 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 * Install gemspec for use with rubygems-integration -- Antonio Terceiro Fri, 22 Jun 2012 09:43:33 -0300 gem2deb (0.2.17) unstable; urgency=low * Eliminate annoying warnings when running gem2deb/dh_ruby + Only force default external encoding if absolutely required. + Drop workaround for Rubygems/YAML issue. -- Antonio Terceiro Thu, 14 Jun 2012 22:05:39 -0300 gem2deb (0.2.16) unstable; urgency=low * Assume that any external files are UTF-8. Closes: #676192 -- Antonio Terceiro Tue, 05 Jun 2012 15:25:09 -0300 gem2deb (0.2.15) unstable; urgency=low * dh_ruby: read debian/control as UTF-8, not ASCII. Closes: #675974 -- Lucas Nussbaum Mon, 04 Jun 2012 23:06:19 +0200 gem2deb (0.2.14) unstable; urgency=low [ Antonio Terceiro ] * New release. * Fix documentation of require-rubygems.overrides * Changed all shebangs from ruby.8 to ruby * debian/control: + Bump Standards version for gem2deb itself and for generated packages + add dependency on `ruby | ruby-interpreter` [ Per Andersson ] * Depend on rubygems instead of transitional package rubygems1.8. (Closes: #654234) * Correct typo in dh_ruby man page. [ Cédric Boutillier ] * use official DEP5 copyright formal url in templates -- Antonio Terceiro Sun, 03 Jun 2012 12:05:14 -0300 gem2deb (0.2.13) unstable; urgency=low [ Cédric Boutillier ] * Use Gem.load_yaml to require yaml, in order to ensure the definition of the constant Gem::SyckDefaultKey, required by newer versions of rubygems. [ Antonio Terceiro ] * debian/control: adjust (Build-)Depends: to require the newest versions of Rubygems. -- Antonio Terceiro Mon, 26 Dec 2011 10:55:41 -0200 gem2deb (0.2.12) unstable; urgency=low * Added myself to uploaders * Keep Lintian happy: gen-ruby-trans-pkgs sets transitional packages to "Priority: extra" -- Gunnar Wolf Tue, 22 Nov 2011 19:13:05 -0600 gem2deb (0.2.11) unstable; urgency=low * Fix crash when removing duplicate files in subdirectories, e.g. ${vendordir}/foo/bar.rb versus ${vendorarchdir}/foo/bar.rb. This was found when trying to update libldap-ruby into a new ruby-ldap package. * Do not compress Ruby code examples -- Antonio Terceiro Sat, 05 Nov 2011 23:05:57 -0200 gem2deb (0.2.10) unstable; urgency=low [ Antonio Terceiro ] * If all Rubies are supported, use `/usr/bin/env ruby` as shebang line. [ Dmitry Borodaenko ] * Don't rewrite shebangs of non-Ruby scripts -- Antonio Terceiro Sat, 24 Sep 2011 12:17:38 -0700 gem2deb (0.2.9) unstable; urgency=low [ Cédric Boutillier ] * Do not skip tests after failing one [ Antonio Terceiro ] * Bug fix upload. * Split templates in their own files. This fixes the build on Ruby 1.9 under the `C` locale. -- Antonio Terceiro Sun, 18 Sep 2011 01:04:43 -0700 gem2deb (0.2.8) unstable; urgency=low * Generate a non-lintian-clean copyright file * Fix --only-tarball option * Fix typo in integration test * Keep upstream names that are not valid Debian package names * Make tests more portable * Rename test_helper samples file * Make tests pass under Ruby 1.9 as well * Run tests under 1.8 and 1.9 during build * Make sure that programs without shebangs get one * Keep correct permission bits on rewritten programs * Rewrite shebangs before running tests -- Antonio Terceiro Sun, 11 Sep 2011 13:29:03 -0700 gem2deb (0.2.7) unstable; urgency=low * Fix .so/.rb name clash resolution for the case of multiple binary packages. -- Antonio Terceiro Thu, 11 Aug 2011 12:05:47 -0700 gem2deb (0.2.6) unstable; urgency=low * Added Gem2Deb::Rake::TestTask for helping running tests using rake. See dh_ruby(1) * Install symlinks for .rb files masked by .so files * Support multi-binary packages by allowing maintainers to tell dh_ruby to install files at the place designated by dh_auto_install, usually debian/tmp. See dh_ruby(1) for details. (Closes: #632553) * Document files and environment variables used by dh_ruby in its manpage (Closes: #625797) -- Antonio Terceiro Thu, 21 Jul 2011 10:56:24 -0700 gem2deb (0.2.5) unstable; urgency=low * Replace libshoulda-ruby1.8 for ruby-shoulda-context in Build-Depends * Always create installation dirs (Closes: #630738) * gen-ruby-trans-pkgs: use Breaks: instead of Conflicts for transitional packages. -- Antonio Terceiro Sun, 19 Jun 2011 19:32:00 -0700 gem2deb (0.2.4) unstable; urgency=low [ Lucas Nussbaum ] * Set the team as maintainer, move myself to Uploaders. [ Vincent Fourmond ] * Add myself to uploaders * Add a rubysetuprb build system for debhelper to build packages with setup.rb [ Lucas Nussbaum ] * Merge Ubuntu-specific change which is harmless on Debian. [ Antonio Terceiro ] * Do not crash when package creates subdirectories in /usr/bin (Closes: #629036) * Shut up on commented 'require "rubygems"' lines (Closes: #628704) -- Antonio Terceiro Mon, 06 Jun 2011 10:33:11 -0700 gem2deb (0.2.3) unstable; urgency=low [ Daigo Moriwaki ] * Escape including the .git directory in a tar archive. * debuild friendly logging. [ Antonio Terceiro ] * Extract method to read the supported Ruby versions * Packages generated by dh-make-ruby now depend on 'ruby | ruby-interpreter' by default * Correct handling of shebangs: packages with 'all' in XS-Ruby-Versions use #!/usr/bin/ruby as shebang; packages for specific versions use the corresponding binary in the shebang. * Now debian/ruby-tests.rake is also supported for for running package tests. * debian/control: bump Standards-Version to 3.9.2 -- Antonio Terceiro Tue, 10 May 2011 19:28:23 -0700 gem2deb (0.2.2) unstable; urgency=low * Fix generation of Vcs-Browser. * Add support for env-var DH_RUBY_GEMSPEC to specify the .gemspec. * Support running dh-make-ruby over a directory. * Fix: don't create native packages by default. * Remove identical duplicate files installed by rubygems in the arch-specific dir. -- Lucas Nussbaum Wed, 13 Apr 2011 23:12:50 +0200 gem2deb (0.2.1) unstable; urgency=low * Export RUBY_TEST_VERSION and RUBY_TEST_BIN environment variables when running tests. * Run make distclean || make clean instead of just make clean * When building extensions, run the test suite for a given version immediately after building the extension for this version. The previous behaviour resulted in testing each ruby implementation with the last extension to be built. * Add bin/gen-ruby-trans-pkgs: script to generate debian/control snippets for transitional packages -- Lucas Nussbaum Sun, 03 Apr 2011 14:36:10 +0200 gem2deb (0.2.0) unstable; urgency=low * Many, many changes to how gem2deb generates Debian packages: + Put everything in the same binary package. + Rewrite depends after dh_shlibdeps to create ORed deps. + Support building only for specific ruby versions. + Rename library files to match the Ruby convention + Add --package option to gem2deb and dh-make-ruby, to specify the name of the package to generate + Generate packages that depend on ruby1.8 | ruby-interpreter. + gem2tgz gemname now downloads the gem if needed. + Generate a better debian/copyright template. + Add a dh7 sequence. * Add Vcs-* fields after moving to PRE repo * Support DEB_BUILD_OPTIONS=nocheck. * Add perl:Depends, reorganize Depends: * Switch to 3.0 (native) * Other bugfixes and code cleanup -- Lucas Nussbaum Fri, 25 Mar 2011 09:29:56 +0100 gem2deb (0.1.0) experimental; urgency=low * Initial release. -- Lucas Nussbaum Fri, 04 Mar 2011 09:59:56 +0100 gem2deb-0.6.1/debian/copyright0000644000000000000000000000205311725254125013072 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: gem2deb Source: http://github.com/ln/gem2deb Files: * Copyright: Copyright © 2010, 2011, Antonio Terceiro Copyright © 2011, Lucas Nussbaum License: GPL-3+ 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 . . On Debian systems, the full text of the GNU General Public License version 3 can be found in the file `/usr/share/common-licenses/GPL-3'. gem2deb-0.6.1/debian/control0000644000000000000000000000253612247100552012542 0ustar Source: gem2deb Section: ruby Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: Lucas Nussbaum , Antonio Terceiro , Vincent Fourmond , Gunnar Wolf Build-Depends: debhelper (>= 7.0.50~), rake, ruby-shoulda-context, ruby-mocha (>= 0.14.0), ruby1.9.1 (>= 1.9.3.0-1~), ruby1.9.1-dev (>= 1.9.3.0-1~), ruby2.0, ruby2.0-dev, devscripts, ruby-setup, lintian 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 Depends: ruby | ruby-interpreter, ruby1.9.1 (>= 1.9.3.0-1~), ruby1.9.1-dev (>= 1.9.3.0-1~), ruby2.0, ruby2.0-dev, build-essential, devscripts, debhelper (>= 7.0.50~), ${perl:Depends}, ${shlibs:Depends}, ${misc:Depends} Description: Debian Ruby packaging suite gem2deb is a set of tools to create Debian package from ruby software distributed with Rubygems. gem2tgz converts the .gem file to a tar archive, then dh-make-ruby creates a Debian source package from that archive. That Debian package uses the included Debhelper7 helper, dh_ruby, to generate a proper Debian package. Both pure-ruby and native packages are supported. gem2deb-0.6.1/debian/gem2deb.docs0000644000000000000000000000001411702034045013301 0ustar README TODO gem2deb-0.6.1/debian/rules0000755000000000000000000000067012201001401012173 0ustar #!/usr/bin/make -f #export DH_VERBOSE=1 %: dh $@ override_dh_auto_build: ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) # NO_PKG_MANGLE=1 is only useful on Ubuntu buildds, to disable pkgbinarymangler NO_PKG_MANGLE=1 ruby1.9.1 -S rake test TESTOPTS=-v NO_PKG_MANGLE=1 ruby2.0 -S rake test TESTOPTS=-v endif mkdir -p man for i in bin/*; do pod2man -c "" -r "" $$i > man/$$(basename $$i).1; done override_dh_auto_clean: rm -rf man/ gem2deb-0.6.1/debian/source/0000755000000000000000000000000011561340034012430 5ustar gem2deb-0.6.1/debian/source/format0000644000000000000000000000001511543165110013637 0ustar 3.0 (native) gem2deb-0.6.1/debian/source/options0000644000000000000000000000002611561340034014044 0ustar --tar-ignore = ".git" gem2deb-0.6.1/debian/gem2deb.install0000644000000000000000000000012011705074254014026 0ustar bin/* /usr/bin/ lib/* /usr/lib/ruby/vendor_ruby/ debhelper7/* /usr/share/perl5/ gem2deb-0.6.1/debian/gem2deb.manpages0000644000000000000000000000000611543165110014146 0ustar man/* gem2deb-0.6.1/debian/gem2deb.lintian-overrides0000644000000000000000000000013212152522426016015 0ustar script-not-executable usr/lib/ruby/vendor_ruby/gem2deb/dh_make_ruby/template/debian/rules gem2deb-0.6.1/debian/gbp.conf0000644000000000000000000000004311626511334012551 0ustar [DEFAULT] debian-tag = %(version)s gem2deb-0.6.1/lib/0000755000000000000000000000000012247100552010455 5ustar gem2deb-0.6.1/lib/gem2deb.rb0000644000000000000000000000345712247100552012320 0ustar # Copyright © 2011, Lucas Nussbaum # # 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 . if defined?(Encoding) && Encoding.default_external.name == 'US-ASCII' Encoding.default_external = 'UTF-8' end module Gem2Deb class CommandFailed < Exception end SUPPORTED_RUBY_VERSIONS = { #name Ruby binary #--------------- ------------------- 'ruby1.9.1' => '/usr/bin/ruby1.9.1', 'ruby2.0' => '/usr/bin/ruby2.0', }.select do |version, binary| # To help backporters without having to also backport the interpreters. File.exists?(binary) end RUBY_CONFIG_VERSION = { 'ruby1.9.1' => '1.9.1', 'ruby2.0' => '2.0', } SUPPORTED_RUBY_SHARED_LIBRARIES = [ 'libruby1.9.1', 'libruby2.0', ] 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(*argv) puts(_format_cmdline(argv)) if $VERBOSE system(*argv) if $?.exitstatus != 0 raise Gem2Deb::CommandFailed, _format_cmdline(argv) end end private def _format_cmdline(argv) argv.map { |a| a =~ /\s/ && a.inspect || a }.join(' ') end end require 'gem2deb/version' gem2deb-0.6.1/lib/gem2deb/0000755000000000000000000000000012247473265012000 5ustar gem2deb-0.6.1/lib/gem2deb/rake/0000755000000000000000000000000011605657335012721 5ustar gem2deb-0.6.1/lib/gem2deb/rake/testtask.rb0000644000000000000000000000042011605657335015104 0ustar require 'rake/testtask' module Gem2Deb module Rake class TestTask < ::Rake::TestTask def initialize super(:default) end def define self.libs.reject! { |path| ['lib','ext'].include?(path) } super end end end end gem2deb-0.6.1/lib/gem2deb/gem2tgz.rb0000644000000000000000000000555312247100552013676 0ustar # Copyright © 2010, Antonio Terceiro # # 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 'fileutils' require 'tmpdir' require 'gem2deb' include Gem2Deb module Gem2Deb class Gem2Tgz GEMEXT = /(\.gem)$/ TGZEXT = /(\.tgz|\.tar\.gz)$/ def self.convert!(gem, tarball = nil) self.new(gem, tarball).convert! end attr_reader :gem, :gem_full_path attr_reader :tarball, :tarball_full_path attr_reader :target_dir def initialize(gem, tarball = nil) if gem =~ GEMEXT || gem =~ TGZEXT @ext = $1 @gem = gem @gem_full_path = File.expand_path(gem) @tarball = tarball if @tarball.nil? path = File.dirname(@gem) filename = File.basename(@gem) # the _ -> - substitution is required because '_' is invalid # in Debian packages names # same for downcase filename = filename.gsub(@ext, '.tar.gz').gsub(/_/,'-').downcase @tarball = File.join(path, filename) end @tarball_full_path = File.expand_path(@tarball) @target_dirname = File::basename(@tarball).gsub('.tar.gz', '') else puts "#{gem} does not look like a valid .gem file." exit(1) end end def convert! create_target_dir extract_gem_contents if @ext =~ GEMEXT extract_tgz_contents if @ext =~ TGZEXT create_resulting_tarball cleanup @tarball end protected def create_target_dir @tmp_dir = Dir::mktmpdir('gem2tgz') @target_dir = @tmp_dir + '/' + @target_dirname Dir::mkdir(@target_dir) end def extract_gem_contents Dir.chdir(@target_dir) do run('tar', 'xfm', gem_full_path) run 'tar xzfm data.tar.gz' FileUtils.rm_f('data.tar.gz') run "zcat metadata.gz > metadata.yml" FileUtils.rm_f('metadata.gz') end end def extract_tgz_contents Dir.chdir(@target_dir) do run('tar', 'xfm', gem_full_path, '--strip', '1') end end def create_resulting_tarball Dir.chdir(@tmp_dir) do run('tar', 'czf', @tarball_full_path, @target_dirname) end end def cleanup FileUtils.rm_rf(@tmp_dir) end end end gem2deb-0.6.1/lib/gem2deb/extension_builder.rb0000644000000000000000000000467712243174335016055 0ustar # Copyright © 2011, Antonio Terceiro # # 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' require 'yaml' require 'rubygems/ext' require 'gem2deb/metadata' require 'fileutils' module Gem2Deb class ExtensionBuilder include Gem2Deb attr_reader :extension attr_reader :directory def initialize(extension) @extension = extension @directory = File.dirname(extension) end def clean Dir.chdir(directory) do if File.exists?('Makefile') run 'make clean' end end end def build_and_install(destdir) clean results = [] rubygems_builder = case extension when /extconf/ then Gem::Ext::ExtConfBuilder when /configure/ then Gem::Ext::ConfigureBuilder when /rakefile/i, /mkrf_conf/i then Gem::Ext::RakeBuilder else puts "Cannot build extension '#{extension}'" exit(1) end begin target = File.expand_path(File.join(destdir, RbConfig::CONFIG['vendorarchdir'])) FileUtils.mkdir_p(File.dirname(target)) Dir.chdir(directory) do rubygems_builder.build(extension, '.', target, results) puts results end rescue Exception => e puts results raise e end end def self.build_all_extensions(root, destdir) all_extensions(root).each do |extension| ext = new(extension) ext.clean ext.build_and_install(destdir) end end def self.all_extensions(root) @metadata ||= Gem2Deb::Metadata.new(root) @metadata.native_extensions end end end if $PROGRAM_NAME == __FILE__ if ARGV.length == 2 Gem2Deb::ExtensionBuilder.build_all_extensions(*ARGV) else puts "usage: #{File.basename($PROGRAM_NAME)} ROOT DESTDIR" exit(1) end end gem2deb-0.6.1/lib/gem2deb/test_runner.rb0000644000000000000000000000736011701636433014673 0ustar # Copyright © 2011, Lucas Nussbaum # # 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 'rbconfig' module Gem2Deb class TestRunner def load_path # We should only use installation paths for the current Ruby # version. # # We assume that installation has already proceeded into # subdirectories of the debian/ directory. # # It is important that the directories under debian/ $LOAD_PATH in the # same order than their system-wide equivalent dirs = [] $LOAD_PATH.grep(/vendor/).each do |dir| dirs += Dir.glob('debian/*/' + dir) end # And we add the current directory: dirs << "." dirs end # Override in subclasses def run_tests end # override in subclasses def required_file nil end def activate? required_file && File.exists?(required_file) end def run_ruby(*cmd) rubylib = load_path.join(':') cmd.unshift(rubyver) if $VERBOSE print "RUBYLIB=#{rubylib} " puts cmd.map { |part| part =~ /['"]/ ? part.inspect : part }.join(' ') end ENV['RUBYLIB'] = (ENV['RUBYLIB'] ? ENV['RUBYLIB'] + ':' : '') + rubylib exec(*cmd) end def self.inherited(subclass) @subclasses ||= [] @subclasses << subclass end def self.subclasses @subclasses end def self.detect_and_run detect.run_tests end def self.detect subclasses.map(&:new).find do |runner| runner.activate? end end def rubyver @rubyver ||= RbConfig::CONFIG['ruby_install_name'] end def ruby_binary @ruby_binary ||= File.join('/usr/bin', rubyver) end class TestsListedInMetadata < TestRunner def required_file 'debian/ruby-test-files.yaml' end def run_tests puts "Running tests for #{rubyver} with test file list from debian/ruby-test-files.yaml ..." run_ruby( '-ryaml', '-e', 'YAML.load_file("debian/ruby-test-files.yaml").each { |f| require f }' ) end end class DebianRakefile < TestRunner def required_file 'debian/ruby-tests.rake' end def run_tests puts "Running tests for #{rubyver} using debian/ruby-tests.rake ..." run_ruby( '-rrake', '-e', 'ARGV.unshift("-f", "debian/ruby-tests.rake"); Rake.application.run' ) end end class DebianRubyFile < TestRunner def required_file 'debian/ruby-tests.rb' end def run_tests puts "Running tests for #{rubyver} using debian/ruby-tests.rb..." ENV['RUBY_TEST_VERSION'] = rubyver ENV['RUBY_TEST_BIN'] = ruby_binary run_ruby(required_file) end end class DontKnownHowToRunTests < TestRunner def required_file 'debian/rules' end def run_tests puts "Running tests for #{rubyver}: found no way to run a test suite!" end end end end if $PROGRAM_NAME == __FILE__ if ARGV.length == 0 Gem2Deb::TestRunner.detect_and_run else puts "usage: #{File.basename($PROGRAM_NAME)}" exit(1) end end gem2deb-0.6.1/lib/gem2deb/dh_make_ruby.rb0000644000000000000000000002445512247100552014752 0ustar # vim: ts=2 sw=2 expandtab # -*- coding: utf-8 -*- # Copyright © 2011, Lucas Nussbaum # # 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' require 'yaml' require 'gem2deb/metadata' require 'rubygems' require 'fileutils' require 'erb' require 'date' module Gem2Deb class DhMakeRuby include Gem2Deb EMAIL_REGEXP = /^(.*)\s+<(.*)>$/ attr_accessor :gem_name attr_accessor :gem_version attr_accessor :metadata attr_reader :source_package_name def source_package_name=(value) @source_package_name = value.gsub('_', '-') end attr_accessor :binary_package attr_accessor :source_tarball_name attr_accessor :orig_tarball_name attr_accessor :orig_tarball_dir attr_accessor :ruby_versions attr_accessor :input_directory def initialize(input, options = {}) initialize_from_options(options) if File.directory?(input) initialize_from_directory(input) else initialize_from_tarball(input) end end def initialize_from_options(options) self.ruby_versions = 'all' options.each do |attr,value| self.send("#{attr}=", value) end end def initialize_from_directory(directory) self.input_directory = directory read_metadata(directory) self.gem_name = metadata.name self.gem_version = metadata.version self.source_package_name ||= gem_name_to_source_package_name(gem_name) end def initialize_from_tarball(tarball) self.source_tarball_name = File.basename(tarball) self.orig_tarball_dir = File.dirname(tarball) if source_tarball_name =~ /^(.*)_(.*).orig.tar.gz$/ self.gem_name = $1 self.gem_version = $2 self.source_package_name ||= gem_name # assume orig.tar.gz was previously prepared and is already correct self.orig_tarball_name = source_tarball_name elsif source_tarball_name =~ /^(.*)-(.*).tar.gz$/ self.gem_name = $1 self.gem_version = $2 self.source_package_name ||= gem_name_to_source_package_name(gem_name) self.orig_tarball_name = "#{source_package_name}_#{gem_version}.orig.tar.gz" else raise "Could not determine gem name and version from tarball #{source_tarball_name}" end end def gem_name_to_source_package_name(gem_name) 'ruby-' + gem_name.gsub(/^ruby[-_]|[-_]ruby$/, '') end def gem_dirname [gem_name, gem_version].join('-') end def source_dirname [source_package_name, gem_version].join('-') end def homepage metadata.homepage end def short_description metadata.short_description end def long_description metadata.long_description end def build if input_directory build_in_directory(input_directory) else Dir.chdir(orig_tarball_dir) do create_orig_tarball extract initialize_from_directory(source_dirname) build_in_directory(source_dirname) end end end def build_in_directory(directory) Dir.chdir(directory) do read_upstream_source_info create_debian_boilerplates other_files test_suite end end def read_upstream_source_info read_metadata('.') initialize_binary_package end def read_metadata(directory) @metadata ||= Gem2Deb::Metadata.new(directory) end def initialize_binary_package self.binary_package = Package.new(source_package_name, metadata.has_native_extensions? ? 'any' : 'all') metadata.dependencies.each do |dependency| binary_package.gem_dependencies << dependency end binary_package end def buildpackage(source_only = false, check_build_deps = true) dpkg_buildpackage_opts = [] dpkg_buildpackage_opts << '-S' if source_only dpkg_buildpackage_opts << '-d' unless check_build_deps Dir.chdir(source_dirname) do run('dpkg-buildpackage', '-us', '-uc', *dpkg_buildpackage_opts) end end def create_orig_tarball if source_package_name != orig_tarball_name && !File.exists?(orig_tarball_name) run('ln', '-s', source_tarball_name, orig_tarball_name) end end def extract run('tar', 'xzf', orig_tarball_name) if !File.directory?(gem_dirname) raise "Extracting did not create #{gem_dirname} directory." end if gem_dirname != source_dirname && !File.exists?(source_dirname) FileUtils.mv gem_dirname, source_dirname end end def create_debian_boilerplates FileUtils.mkdir_p('debian') unless File.exists?('debian/changelog') run('dch', '--create', '--empty', '--package', source_package_name, '--newversion', "#{gem_version}-1", 'Initial release (Closes: #nnnn)') end templates.each do |template| FileUtils.mkdir_p(template.directory) File.open(template.filename, 'w') do |f| f.puts ERB.new(template.data, nil, '<>').result(binding) end end FileUtils.chmod 0755, 'debian/rules' end def templates @templates ||= Template.load_all end class Template attr_accessor :filename attr_accessor :data TEMPLATES_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'dh_make_ruby', 'template')) def self.load_all template_files = Dir.chdir(TEMPLATES_DIR) { Dir.glob("**/*").select { |f| !File.directory?(f) } } template_files.map do |filename| template = Template.new(filename) template.data = File.read(File.join(TEMPLATES_DIR, filename)) template end end def initialize(filename) self.filename = filename self.data = '' end def directory File.dirname(filename) end end ## # Try to find the maintainer from ENV # logic translated from perl in package « devscripts: /usr/bin/dch » # def maintainer debenv = {} # defaults debenv['DEBFULLNAME'] = ENV['DEBFULLNAME'] debenv['DEBEMAIL'] = ENV['DEBEMAIL'] || ENV['EMAIL'] # DEBEMAIL is like "Full Name " # extract DEBFULLNAME from it if ENV['DEBEMAIL'] && ENV['DEBEMAIL'] =~ EMAIL_REGEXP debenv['DEBFULLNAME'] = $1 if ENV['DEBFULLNAME'].nil? debenv['DEBEMAIL'] = $2 end # dont have DEBEMAIL nor DEBFULLNAME from ENV # try with EMAIL if ENV['DEBEMAIL'].nil? || ENV['DEBFULLNAME'].nil? if ENV['EMAIL'] && ENV['EMAIL'] =~ EMAIL_REGEXP debenv['DEBFULLNAME'] = $1 if ENV['DEBFULLNAME'].nil? debenv['DEBEMAIL'] = $2 end end debenv end class Package attr_accessor :name attr_accessor :architecture def initialize(name, architecture = 'all') self.name = name self.architecture = architecture end def dependencies ['${shlibs:Depends}', '${misc:Depends}', 'ruby | ruby-interpreter' ] end def gem_dependencies @gem_dependencies ||= [] end end def test_suite if !metadata.test_files.empty? File::open("debian/ruby-test-files.yaml", 'w') do |f| YAML::dump(metadata.test_files, f) end else if File::directory?("test") or File::directory?("spec") File::open("debian/ruby-tests.rb", 'w') do |f| f.puts <<-EOF # FIXME # there's a spec/ or a test/ directory in the upstream source, but # no test suite was defined in the Gem specification. It would be # a good idea to define it here so the package gets tested at build time. # Examples: # $: << 'lib' << '.' # Dir['{spec,test}/**/*.rb'].each { |f| require f } # # require 'test/ts_foo.rb' # # require 'rbconfig' # ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) # exec("\#{ruby} -I. test/runtests.rb") EOF end end end end def other_files # docs docs = "" if File::directory?('doc') docs += <<-EOF # FIXME: doc/ dir found in source. Consider installing the docs. # Examples: # doc/manual.html # doc/site/* EOF end readmes = Dir::glob('README*') docs += <<-EOF # FIXME: READMEs found EOF readmes.each do |r| docs << "# #{r}\n" end if docs != "" File::open("debian/#{source_package_name}.docs", 'w') do |f| f.puts docs end end # examples examples = "" ['examples', 'sample'].each do |d| if File::directory?(d) examples += <<-EOF # FIXME: #{d}/ dir found in source. Consider installing the examples. # Examples: # #{d}/* EOF end end if examples != "" File::open("debian/#{source_package_name}.examples", 'w') do |f| f.puts examples end end # data & conf installs = "" if File::directory?('data') installs += <<-EOF # FIXME: data/ dir found in source. Consider installing it somewhere. # Examples: # data/* /usr/share/#{source_package_name}/ EOF end if File::directory?('conf') installs += <<-EOF # FIXME: conf/ dir found in source. Consider installing it somewhere. # Examples: # conf/* /etc/ EOF end if installs != "" File::open("debian/#{source_package_name}.install", 'w') do |f| f.puts installs end end # manpages if File::directory?('man') manpages = Dir.glob("man/**/*.[1-8]") manpages_header = "# FIXME: man/ dir found in source. Consider installing manpages" File::open("debian/#{source_package_name}.manpages", 'w') do |f| f.puts manpages_header manpages.each do |m| f.puts "# " + m end end end end end end gem2deb-0.6.1/lib/gem2deb/setup_rb_installer.rb0000644000000000000000000000274212243202551016212 0ustar # 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 gem2deb-0.6.1/lib/gem2deb/metadata.rb0000644000000000000000000000613012152515217014072 0ustar # Copyright © 2011, Antonio Terceiro # # 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 'rubygems' require 'rubygems/specification' require 'yaml' module Gem2Deb class Metadata attr_reader :gemspec attr_reader :source_dir attr_reader :root def initialize(root) @source_dir = File.expand_path(root) @root = root Dir.chdir(source_dir) do load_gemspec end end def has_native_extensions? 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 def version @version ||= gemspec && gemspec.version.to_s || read_version_from(source_dir) || '0.1.0~FIXME' end def homepage gemspec && gemspec.homepage end def short_description gemspec && gemspec.summary end def long_description gemspec && gemspec.description end def dependencies gemspec ? gemspec.dependencies : [] end def test_files gemspec ? gemspec.test_files.select { |filename| filename =~ /\.rb$/ } : [] end protected def load_gemspec if File.exists?('metadata.yml') @gemspec = YAML.load_file('metadata.yml') elsif ENV['DH_RUBY_GEMSPEC'] @gemspec = Gem::Specification.load(ENV['DH_RUBY_GEMSPEC']) else gemspec_files = Dir.glob('*.gemspec') if gemspec_files.size == 1 @gemspec = Gem::Specification.load(gemspec_files.first) else unless gemspec_files.empty? raise "More than one .gemspec file in this directory: #{gemspec_files.join(', ')}" end end end end # FIXME duplicated logic (see below) def read_name_from(directory) return nil if directory.nil? basename = File.basename(directory) if basename =~ /^(.*)-([0-9.]+)$/ $1 else basename end end # FIXME duplicated logic (see above) def read_version_from(directory) return nil if directory.nil? basename = File.basename(directory) if basename =~ /^(.*)-([0-9.]+)$/ $2 else nil end end end end gem2deb-0.6.1/lib/gem2deb/installer.rb0000644000000000000000000001750312243202551014310 0ustar 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_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 end def 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 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 gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/0000755000000000000000000000000011635322134014415 5ustar gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/template/0000755000000000000000000000000011635322134016230 5ustar gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/template/debian/0000755000000000000000000000000012245664220017455 5ustar gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/template/debian/compat0000644000000000000000000000000212245664214020656 0ustar 7 gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/template/debian/copyright0000644000000000000000000000253112245664220021411 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: <%= gem_name %> Source: FIXME Files: * 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 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'. gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/template/debian/control0000644000000000000000000000224612245664220021064 0ustar Source: <%= source_package_name %> Section: ruby Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: <%= maintainer['DEBFULLNAME'] %> <<%= maintainer['DEBEMAIL'] %>> Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= <%= Gem2Deb::VERSION %>~) 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 %> Package: <%= binary_package.name %> Architecture: <%= binary_package.architecture %> XB-Ruby-Versions: ${ruby:Versions} Depends: <%= binary_package.dependencies.join(', ') %> <% if binary_package.gem_dependencies.length > 0 %> # <%= binary_package.gem_dependencies.join(', ') %> <% end %> Description: <%= short_description ? short_description : 'FIXME' %> <% if long_description %> <%= long_description.lines.map { |line| ' ' + (line.strip.empty? ? '.' : line.strip) }.join("\n") + "\n" %> <% else %> <%= " \n" %> <% end %> gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/template/debian/rules0000644000000000000000000000070112245664214020533 0ustar #!/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.9.1 ruby2.0 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 gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/template/debian/source/0000755000000000000000000000000011635322322020751 5ustar gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/template/debian/source/format0000644000000000000000000000001412245664214022166 0ustar 3.0 (quilt) gem2deb-0.6.1/lib/gem2deb/dh_make_ruby/template/debian/watch0000644000000000000000000000016312245664220020506 0ustar version=3 http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/<%= gem_name %> .*/<%= gem_name %>-(.*).tar.gz gem2deb-0.6.1/lib/gem2deb/dh_ruby.rb0000644000000000000000000001336512247472736013773 0ustar # Copyright © 2011, Lucas Nussbaum # # 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' require 'gem2deb/installer' require 'find' require 'fileutils' module Gem2Deb class DhRuby include Gem2Deb attr_accessor :verbose attr_accessor :installer_class def initialize @verbose = true @skip_checks = nil @installer_class = Gem2Deb::Installer end def clean puts " Entering dh_ruby --clean" if @verbose installers.each do |installer| installer.run_make_clean_on_extensions end puts " Leaving dh_ruby --clean" if @verbose end def configure # puts " Entering dh_ruby --configure" if @verbose # puts " Leaving dh_ruby --configure" if @verbose end def build # puts " Entering dh_ruby --build" if @verbose # puts " Leaving dh_ruby --build" if @verbose end def test # puts " Entering dh_ruby --test" if @verbose # puts " Leaving dh_ruby --test" if @verbose end TEST_RUNNER = File.expand_path(File.join(File.dirname(__FILE__),'test_runner.rb')) def install(argv) puts " Entering dh_ruby --install" if @verbose installers.each do |installer| installer.dh_auto_install_destdir = argv.first installer.install_files_and_build_extensions installer.update_shebangs end run_tests installers.each do |installer| installer.install_substvars installer.install_gemspec check_rubygems(installer) end puts " Leaving dh_ruby --install" if @verbose end protected def check_rubygems(installer) if skip_checks? return end begin installer.check_rubygems rescue Gem2Deb::Installer::RequireRubygemsFound handle_test_failure("require-rubygems") end end def handle_test_failure(test) if ENV['DH_RUBY_IGNORE_TESTS'] if ENV['DH_RUBY_IGNORE_TESTS'].split.include?('all') puts "WARNING: Test \"#{test}\" failed, but ignoring all test results." return elsif ENV['DH_RUBY_IGNORE_TESTS'].split.include?(test) puts "WARNING: Test \"#{test}\" failed, but ignoring this test result." return end end if STDIN.isatty and STDOUT.isatty and STDERR.isatty # running interactively continue = nil begin puts print "Test \"#{test}\" failed. Continue building the package? (Y/N) " STDOUT.flush c = STDIN.getc continue = true if c.chr.downcase == 'y' continue = false if c.chr.downcase == 'n' end while continue.nil? if not continue exit(1) end else puts "ERROR: Test \"#{test}\" failed. Exiting." exit(1) end end def run_tests ruby_versions.each do |rubyver| run_tests_for_version(rubyver) end end def run_tests_for_version(rubyver) if skip_checks? return end begin run(SUPPORTED_RUBY_VERSIONS[rubyver], '-I' + LIBDIR, TEST_RUNNER) rescue Gem2Deb::CommandFailed handle_test_failure(rubyver) end end def skip_checks? if @skip_checks.nil? if ENV['DEB_BUILD_OPTIONS'] && ENV['DEB_BUILD_OPTIONS'].split(' ').include?('nocheck') puts "DEB_BUILD_OPTIONS includes nocheck, skipping all checks (test suite, rubygems usage etc)." if @verbose @skip_checks = true else @skip_checks = false end end @skip_checks end 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 package = packages.first package[:root] = '.' [package] end end end 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 end def ruby_versions @ruby_versions ||= begin # find ruby versions to build the package for. lines = File.readlines('debian/control').grep(/^XS-Ruby-Versions: /) if lines.empty? puts "No XS-Ruby-Versions: field found in source!" if @verbose exit(1) else list = lines.first.split[1..-1] if list.include?('all') SUPPORTED_RUBY_VERSIONS.keys else list end end end end end end gem2deb-0.6.1/lib/gem2deb/version.rb0000644000000000000000000000004712247473265014013 0ustar module Gem2Deb VERSION = '0.6.1' end