gem2deb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +7 -0
- data/LICENSE +20 -0
- data/README.rdoc +25 -0
- data/Rakefile +54 -0
- data/TODO +2 -0
- data/lib/commands/deb.rb +116 -0
- data/lib/rubygems_plugin.rb +10 -0
- data/lib/templates/debian/changelog +5 -0
- data/lib/templates/debian/compat +1 -0
- data/lib/templates/debian/control +13 -0
- data/lib/templates/debian/copyright +1 -0
- data/lib/templates/debian/rules +67 -0
- data/test/gem2deb_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +71 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 David A. Cuadrado
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= gem2deb
|
2
|
+
|
3
|
+
Converts a rubygem to debian package.
|
4
|
+
|
5
|
+
== Dependencies
|
6
|
+
|
7
|
+
- debhelper (sudo apt-get install debhelper)
|
8
|
+
- fakeroot (sudo apt-get install fakeroot)
|
9
|
+
- ruby-dev
|
10
|
+
|
11
|
+
== Note on Patches/Pull Requests
|
12
|
+
|
13
|
+
* Fork the project.
|
14
|
+
* Make your feature addition or bug fix.
|
15
|
+
* Add tests for it. This is important so I don't break it in a
|
16
|
+
future version unintentionally.
|
17
|
+
* Commit, do not mess with rakefile, version, or history.
|
18
|
+
(if you want to have your own version, that is fine but
|
19
|
+
bump version in a commit by itself I can ignore when I pull)
|
20
|
+
* Send me a pull request. Bonus points for topic branches.
|
21
|
+
|
22
|
+
== Copyright
|
23
|
+
|
24
|
+
Copyright (c) 2009 David A. Cuadrado. See LICENSE for details.
|
25
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "gem2deb"
|
8
|
+
gem.summary = %Q{Convert ruby gems to debian packages}
|
9
|
+
gem.email = "krawek@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/dcu/gem2deb"
|
11
|
+
gem.authors = ["David A. Cuadrado"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
rescue LoadError
|
15
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'rake/testtask'
|
19
|
+
Rake::TestTask.new(:test) do |test|
|
20
|
+
test.libs << 'lib' << 'test'
|
21
|
+
test.pattern = 'test/**/*_test.rb'
|
22
|
+
test.verbose = true
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'rcov/rcovtask'
|
27
|
+
Rcov::RcovTask.new do |test|
|
28
|
+
test.libs << 'test'
|
29
|
+
test.pattern = 'test/**/*_test.rb'
|
30
|
+
test.verbose = true
|
31
|
+
end
|
32
|
+
rescue LoadError
|
33
|
+
task :rcov do
|
34
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
task :test => :check_dependencies
|
39
|
+
|
40
|
+
task :default => :test
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
if File.exist?('VERSION')
|
45
|
+
version = File.read('VERSION')
|
46
|
+
else
|
47
|
+
version = ""
|
48
|
+
end
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "gem2deb #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/lib/commands/deb.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'rubygems/install_update_options'
|
2
|
+
require 'rubygems/dependency_installer'
|
3
|
+
require 'rubygems/local_remote_options'
|
4
|
+
require 'rubygems/version_option'
|
5
|
+
require 'rubygems/validator'
|
6
|
+
|
7
|
+
require 'tmpdir'
|
8
|
+
require 'erb'
|
9
|
+
|
10
|
+
class Gem::Commands::DebCommand < Gem::Command
|
11
|
+
include Gem::LocalRemoteOptions
|
12
|
+
include Gem::VersionOption
|
13
|
+
include Gem::InstallUpdateOptions
|
14
|
+
|
15
|
+
def description
|
16
|
+
'Convert a rubygem to debian package'
|
17
|
+
end
|
18
|
+
|
19
|
+
def arguments
|
20
|
+
"GEM gem to convert"
|
21
|
+
end
|
22
|
+
|
23
|
+
def usage
|
24
|
+
"#{program_name} GEM"
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
|
29
|
+
:generate_rdoc => false,
|
30
|
+
:generate_ri => true,
|
31
|
+
:format_executable => false,
|
32
|
+
:test => false,
|
33
|
+
:version => Gem::Requirement.default,
|
34
|
+
})
|
35
|
+
|
36
|
+
super 'deb', 'Convert a rubygem to debian package', defaults
|
37
|
+
|
38
|
+
add_install_update_options
|
39
|
+
add_local_remote_options
|
40
|
+
add_version_option
|
41
|
+
|
42
|
+
@templates_dir = File.dirname(__FILE__)+"/../templates"
|
43
|
+
@install_dir = Dir.tmpdir+"/gemdeb_home"
|
44
|
+
@current_dir = Dir.getwd
|
45
|
+
|
46
|
+
FileUtils.mkpath(@install_dir)
|
47
|
+
end
|
48
|
+
|
49
|
+
def execute
|
50
|
+
install_options = {
|
51
|
+
:env_shebang => options[:env_shebang],
|
52
|
+
:domain => options[:domain],
|
53
|
+
:force => options[:force],
|
54
|
+
:format_executable => options[:format_executable],
|
55
|
+
:ignore_dependencies => options[:ignore_dependencies],
|
56
|
+
:install_dir => @install_dir,
|
57
|
+
:security_policy => options[:security_policy],
|
58
|
+
:wrappers => options[:wrappers],
|
59
|
+
:bin_dir => "#{@install_dir}/bin",
|
60
|
+
:development => options[:development]
|
61
|
+
}
|
62
|
+
|
63
|
+
get_all_gem_names.each do |gem_name|
|
64
|
+
installer = Gem::DependencyInstaller.new(install_options)
|
65
|
+
installer.install gem_name, options[:version]
|
66
|
+
|
67
|
+
installer.installed_gems.each do |spec|
|
68
|
+
generate_deb_for(spec)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
def generate_deb_for(spec)
|
75
|
+
say "Generating deb for #{spec.full_name}..."
|
76
|
+
target_dir = @install_dir+"/gems/#{spec.full_name}"
|
77
|
+
deb_package_path = nil
|
78
|
+
Dir.chdir(target_dir) do
|
79
|
+
deb_package_path = install_debian_template(target_dir, spec)
|
80
|
+
system("dpkg-buildpackage -rfakeroot -b")
|
81
|
+
end
|
82
|
+
|
83
|
+
if deb_package_path && File.exist?(deb_package_path)
|
84
|
+
FileUtils.mv(deb_package_path, @current_dir)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def install_debian_template(target_dir, spec)
|
89
|
+
debian_tpl_dir = @templates_dir+"/debian"
|
90
|
+
debian_dir = target_dir+"/debian"
|
91
|
+
FileUtils.mkpath(debian_dir)
|
92
|
+
|
93
|
+
files = Dir.glob("*")
|
94
|
+
Dir.foreach(debian_tpl_dir) do |tpl|
|
95
|
+
next if File.directory?(tpl)
|
96
|
+
|
97
|
+
tpl_path = File.join(debian_tpl_dir, tpl)
|
98
|
+
|
99
|
+
@tpl_options = {:spec => spec, :files => files}
|
100
|
+
@tpl_options[:libdir] = Config::CONFIG["rubylibdir"]
|
101
|
+
@tpl_options[:arch] = "all" # FIXME: autodetect
|
102
|
+
|
103
|
+
data = ERB.new(File.read(tpl_path)).result(binding)
|
104
|
+
File.open("#{debian_dir}/#{tpl}", "w") do |f|
|
105
|
+
f.puts data
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
old_umask=File.umask(0)
|
110
|
+
File.chmod(0755, "#{debian_dir}/rules")
|
111
|
+
File.umask(old_umask)
|
112
|
+
|
113
|
+
File.expand_path("#{target_dir}/../#{spec.name}_#{spec.version}_#{@tpl_options[:arch]}.deb")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
4
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Source: <%= @tpl_options[:spec].name %>
|
2
|
+
Maintainer: Gem Debianizer <gemdeb@gmail.com>
|
3
|
+
Section: interpreters
|
4
|
+
Priority: optional
|
5
|
+
Homepage: <%= @tpl_options[:spec].homepage %>
|
6
|
+
Build-Depends: debhelper (>= 4), ruby1.8, ruby1.8-dev, fakeroot
|
7
|
+
Standards-Version: 3.8.0
|
8
|
+
|
9
|
+
Package: <%= @tpl_options[:spec].name %>
|
10
|
+
Architecture: <%= @tpl_options[:arch] %>
|
11
|
+
Depends: ${shlibs:Depends}
|
12
|
+
Description: <%= @tpl_options[:spec].summary %>
|
13
|
+
<%= (@tpl_options[:spec].description.split("\n").map{|e| e.strip.empty? ? "." : e}.join("\n ")) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/make -f
|
2
|
+
SHELL = /bin/bash
|
3
|
+
|
4
|
+
tmp = debian/tmp
|
5
|
+
bindir = /usr/bin
|
6
|
+
libdir = <%= @tpl_options[:libdir] %>
|
7
|
+
|
8
|
+
|
9
|
+
build:
|
10
|
+
dh_testdir
|
11
|
+
|
12
|
+
mkdir -p "$(tmp)$(libdir)/deb/"
|
13
|
+
<% @tpl_options[:files].each do |file| %>
|
14
|
+
<% next if file =~ /^debian/ %>
|
15
|
+
-cp -r <%= file %> "$(tmp)$(libdir)/deb/"
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
install: build
|
19
|
+
dh_testdir
|
20
|
+
dh_testroot
|
21
|
+
|
22
|
+
echo "$(tmp)$(libdir)/deb/" >debian/<%= @tpl_options[:spec].name %>.install
|
23
|
+
|
24
|
+
dh_install
|
25
|
+
|
26
|
+
binary: binary-indep binary-arch
|
27
|
+
|
28
|
+
binary-indep: install
|
29
|
+
dh_testdir -i
|
30
|
+
dh_testroot -i
|
31
|
+
|
32
|
+
# dh_installchangelogs -i CHANGELOG.rdoc
|
33
|
+
# dh_installdocs -i
|
34
|
+
dh_link -i
|
35
|
+
# dh_compress -i -X.rb -X.html
|
36
|
+
dh_fixperms -i
|
37
|
+
dh_installdeb -i
|
38
|
+
dh_gencontrol -i
|
39
|
+
dh_md5sums -i
|
40
|
+
dh_builddeb -i
|
41
|
+
|
42
|
+
binary-arch: install
|
43
|
+
dh_testdir -a
|
44
|
+
dh_testroot -a
|
45
|
+
|
46
|
+
# dh_installchangelogs -a CHANGELOG.rdoc
|
47
|
+
# dh_installdocs -a -A README.rdoc doc/faq
|
48
|
+
dh_link -a
|
49
|
+
dh_strip -a
|
50
|
+
# dh_compress -a -X.rb -X.html
|
51
|
+
dh_fixperms -a
|
52
|
+
dh_makeshlibs -a
|
53
|
+
dh_installdeb -a
|
54
|
+
dh_shlibdeps -a
|
55
|
+
dh_gencontrol -a
|
56
|
+
dh_md5sums -a
|
57
|
+
dh_builddeb -a
|
58
|
+
|
59
|
+
clean:
|
60
|
+
dh_testdir
|
61
|
+
dh_testroot
|
62
|
+
-rm -f debian/*.install
|
63
|
+
|
64
|
+
dh_clean
|
65
|
+
|
66
|
+
.PHONY: build binary binary-indep binary-arch clean
|
67
|
+
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gem2deb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David A. Cuadrado
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-17 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: krawek@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .document
|
27
|
+
- .gitignore
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- TODO
|
32
|
+
- lib/commands/deb.rb
|
33
|
+
- lib/rubygems_plugin.rb
|
34
|
+
- lib/templates/debian/changelog
|
35
|
+
- lib/templates/debian/compat
|
36
|
+
- lib/templates/debian/control
|
37
|
+
- lib/templates/debian/copyright
|
38
|
+
- lib/templates/debian/rules
|
39
|
+
- test/gem2deb_test.rb
|
40
|
+
- test/test_helper.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/dcu/gem2deb
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --charset=UTF-8
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.3.5
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Convert ruby gems to debian packages
|
69
|
+
test_files:
|
70
|
+
- test/test_helper.rb
|
71
|
+
- test/gem2deb_test.rb
|