dpkg-tools 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/CHANGES +198 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +17 -0
  4. data/Rakefile +1 -0
  5. data/bin/dpkg-etc +6 -0
  6. data/bin/dpkg-gem +6 -0
  7. data/bin/dpkg-rails +6 -0
  8. data/lib/dpkg-tools.rb +6 -0
  9. data/lib/dpkg-tools/command_line.rb +142 -0
  10. data/lib/dpkg-tools/package.rb +30 -0
  11. data/lib/dpkg-tools/package/builder.rb +112 -0
  12. data/lib/dpkg-tools/package/config.rb +96 -0
  13. data/lib/dpkg-tools/package/control_files.rb +24 -0
  14. data/lib/dpkg-tools/package/control_files/base.rb +75 -0
  15. data/lib/dpkg-tools/package/control_files/changelog.rb +23 -0
  16. data/lib/dpkg-tools/package/control_files/control.rb +148 -0
  17. data/lib/dpkg-tools/package/control_files/copyright.rb +27 -0
  18. data/lib/dpkg-tools/package/control_files/rakefile.rb +28 -0
  19. data/lib/dpkg-tools/package/control_files/rules.rb +29 -0
  20. data/lib/dpkg-tools/package/data.rb +125 -0
  21. data/lib/dpkg-tools/package/etc.rb +26 -0
  22. data/lib/dpkg-tools/package/etc/builder.rb +19 -0
  23. data/lib/dpkg-tools/package/etc/control_files.rb +22 -0
  24. data/lib/dpkg-tools/package/etc/control_files/changelog.rb +30 -0
  25. data/lib/dpkg-tools/package/etc/control_files/rakefile.rb +18 -0
  26. data/lib/dpkg-tools/package/etc/data.rb +48 -0
  27. data/lib/dpkg-tools/package/etc/rake.rb +31 -0
  28. data/lib/dpkg-tools/package/etc/setup.rb +30 -0
  29. data/lib/dpkg-tools/package/fs_methods.rb +10 -0
  30. data/lib/dpkg-tools/package/gem.rb +43 -0
  31. data/lib/dpkg-tools/package/gem/builder.rb +77 -0
  32. data/lib/dpkg-tools/package/gem/control_files.rb +23 -0
  33. data/lib/dpkg-tools/package/gem/control_files/changelog.rb +19 -0
  34. data/lib/dpkg-tools/package/gem/control_files/copyright.rb +24 -0
  35. data/lib/dpkg-tools/package/gem/control_files/rakefile.rb +19 -0
  36. data/lib/dpkg-tools/package/gem/data.rb +115 -0
  37. data/lib/dpkg-tools/package/gem/gem_format.rb +10 -0
  38. data/lib/dpkg-tools/package/gem/rake.rb +37 -0
  39. data/lib/dpkg-tools/package/gem/setup.rb +159 -0
  40. data/lib/dpkg-tools/package/rails.rb +26 -0
  41. data/lib/dpkg-tools/package/rails/builder.rb +77 -0
  42. data/lib/dpkg-tools/package/rails/cap.rb +30 -0
  43. data/lib/dpkg-tools/package/rails/control_files.rb +22 -0
  44. data/lib/dpkg-tools/package/rails/control_files/changelog.rb +19 -0
  45. data/lib/dpkg-tools/package/rails/control_files/rakefile.rb +24 -0
  46. data/lib/dpkg-tools/package/rails/data.rb +160 -0
  47. data/lib/dpkg-tools/package/rails/rake.rb +40 -0
  48. data/lib/dpkg-tools/package/rails/setup.rb +84 -0
  49. data/lib/dpkg-tools/package/rake.rb +90 -0
  50. data/lib/dpkg-tools/package/setup.rb +145 -0
  51. data/lib/dpkg-tools/version.rb +23 -0
  52. data/spec/dpkg-tools/command_line_spec.rb +9 -0
  53. data/spec/dpkg-tools/package/builder_spec.rb +159 -0
  54. data/spec/dpkg-tools/package/config_spec.rb +150 -0
  55. data/spec/dpkg-tools/package/control_files/base_spec.rb +111 -0
  56. data/spec/dpkg-tools/package/control_files/changelog_spec.rb +22 -0
  57. data/spec/dpkg-tools/package/control_files/control_spec.rb +131 -0
  58. data/spec/dpkg-tools/package/control_files/copyright_spec.rb +29 -0
  59. data/spec/dpkg-tools/package/control_files/rakefile_spec.rb +37 -0
  60. data/spec/dpkg-tools/package/control_files/rules_spec.rb +16 -0
  61. data/spec/dpkg-tools/package/control_files_spec.rb +12 -0
  62. data/spec/dpkg-tools/package/data_spec.rb +115 -0
  63. data/spec/dpkg-tools/package/etc/builder_spec.rb +28 -0
  64. data/spec/dpkg-tools/package/etc/control_files/changelog_spec.rb +21 -0
  65. data/spec/dpkg-tools/package/etc/control_files/rakefile_spec.rb +16 -0
  66. data/spec/dpkg-tools/package/etc/control_files_spec.rb +12 -0
  67. data/spec/dpkg-tools/package/etc/data_spec.rb +74 -0
  68. data/spec/dpkg-tools/package/etc/rake_spec.rb +71 -0
  69. data/spec/dpkg-tools/package/etc/setup_spec.rb +62 -0
  70. data/spec/dpkg-tools/package/etc_spec.rb +39 -0
  71. data/spec/dpkg-tools/package/fs_methods_spec.rb +33 -0
  72. data/spec/dpkg-tools/package/gem/builder_spec.rb +84 -0
  73. data/spec/dpkg-tools/package/gem/control_files/changelog_spec.rb +25 -0
  74. data/spec/dpkg-tools/package/gem/control_files/copyright_spec.rb +28 -0
  75. data/spec/dpkg-tools/package/gem/control_files/rakefile_spec.rb +17 -0
  76. data/spec/dpkg-tools/package/gem/control_files_spec.rb +12 -0
  77. data/spec/dpkg-tools/package/gem/data_spec.rb +176 -0
  78. data/spec/dpkg-tools/package/gem/gem_format_spec.rb +26 -0
  79. data/spec/dpkg-tools/package/gem/rake_spec.rb +102 -0
  80. data/spec/dpkg-tools/package/gem/setup_spec.rb +274 -0
  81. data/spec/dpkg-tools/package/gem_spec.rb +68 -0
  82. data/spec/dpkg-tools/package/rails/builder_spec.rb +113 -0
  83. data/spec/dpkg-tools/package/rails/cap_spec.rb +37 -0
  84. data/spec/dpkg-tools/package/rails/control_files/changelog_spec.rb +25 -0
  85. data/spec/dpkg-tools/package/rails/control_files/rakefile_spec.rb +24 -0
  86. data/spec/dpkg-tools/package/rails/control_files_spec.rb +12 -0
  87. data/spec/dpkg-tools/package/rails/data_spec.rb +178 -0
  88. data/spec/dpkg-tools/package/rails/rake_spec.rb +78 -0
  89. data/spec/dpkg-tools/package/rails/setup_spec.rb +152 -0
  90. data/spec/dpkg-tools/package/rails_spec.rb +27 -0
  91. data/spec/dpkg-tools/package/rake_spec.rb +87 -0
  92. data/spec/dpkg-tools/package/setup_spec.rb +247 -0
  93. data/spec/dpkg-tools/package_spec.rb +34 -0
  94. data/spec/fixtures/BlueCloth-1.0.0.gem +1190 -0
  95. data/spec/fixtures/database.yml +33 -0
  96. data/spec/spec.opts +1 -0
  97. data/spec/spec_helper.rb +52 -0
  98. data/tasks/dist.rake +118 -0
  99. data/tasks/rspec.rake +21 -0
  100. metadata +165 -0
@@ -0,0 +1,10 @@
1
+ module DpkgTools
2
+ module Package
3
+ module FSMethods
4
+ def create_dir_if_needed(target_path)
5
+ FileUtils.mkdir_p(target_path) unless File.exists?(target_path)
6
+ raise IOError, "the path '#{target_path}' points to a file, so we can't make a directory there." if File.file?(target_path)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,43 @@
1
+ require 'dpkg-tools/package/gem/data'
2
+ require 'dpkg-tools/package/gem/setup'
3
+ require 'dpkg-tools/package/gem/control_files'
4
+ require 'dpkg-tools/package/gem/builder'
5
+ require 'dpkg-tools/package/gem/rake'
6
+
7
+ module DpkgTools
8
+ module Package
9
+ module Gem
10
+ class << self
11
+ def setup_from_path(gem_path, options = {})
12
+ Setup.from_path(gem_path).create_structure
13
+ end
14
+
15
+ def setup_from_name(gem_name, options = {})
16
+ setup = Setup.from_name(gem_name)
17
+ unless options[:ignore_dependencies]
18
+ setup.fetch_dependencies.each do |dependency|
19
+ dependency.create_structure
20
+ end
21
+ end
22
+ setup.create_structure
23
+ end
24
+
25
+ def create_builder(path_to_gem_file)
26
+ Builder.from_file_path(path_to_gem_file)
27
+ end
28
+
29
+ def config_cache(name_version_pair)
30
+ name, version = name_version_pair
31
+ @config_cache ||= {}
32
+ @config_cache[name_version_pair] ||= DpkgTools::Package::Config.new(name, version, :suffix => 'rubygem')
33
+ yield(@config_cache[name_version_pair]) if block_given?
34
+ @config_cache[name_version_pair]
35
+ end
36
+
37
+ def rubygems_version
38
+ "0.9.4"
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,77 @@
1
+ require 'rake'
2
+ require 'rubygems'
3
+ require 'rubygems/installer'
4
+ require 'rubygems/doc_manager'
5
+
6
+ require 'fileutils'
7
+
8
+ # module GemBindir
9
+ # class << self
10
+ # def bindir(install_dir = nil)
11
+ #
12
+ # end
13
+ # end
14
+
15
+ module DpkgTools
16
+ module Package
17
+ module Gem
18
+ class Builder < DpkgTools::Package::Builder
19
+ class << self
20
+ include DpkgTools::Package::Gem::GemFormat
21
+
22
+ def from_file_path(gem_file_path)
23
+ format, gem_byte_string = format_and_file_from_file_path(gem_file_path)
24
+ data = Data.new(format, gem_byte_string)
25
+ self.new(data)
26
+ end
27
+
28
+ def format_and_file_from_file_path(gem_file_path)
29
+ gem_file = File.open(gem_file_path, 'rb')
30
+ gem_byte_string = gem_file.read
31
+ format = format_from_string(gem_byte_string)
32
+ [format, gem_byte_string]
33
+ end
34
+ end
35
+
36
+ def config_options
37
+ {:suffix => 'rubygem'}
38
+ end
39
+
40
+ def gem_byte_string
41
+ data.gem_byte_string
42
+ end
43
+
44
+ def create_install_dirs
45
+ create_dir_if_needed(config.gem_install_path)
46
+ create_dir_if_needed(config.bin_install_path)
47
+ end
48
+
49
+ def override_gem_bindir
50
+ ::Gem.module_eval %q{def self.bindir(install_dir = nil) "} + config.bin_install_path + %q{" end}
51
+ end
52
+
53
+ def install_gem
54
+ override_gem_bindir
55
+ installer = ::Gem::Installer.new(config.gem_path, {:wrappers => true, :env_shebang => true})
56
+ installer.install(false, config.gem_install_path)
57
+ end
58
+
59
+ # installs RDoc / RI docs
60
+ def install_docs(installed_gem_spec)
61
+ doc_manager = ::Gem::DocManager.new(installed_gem_spec)
62
+ doc_manager.generate_ri
63
+ doc_manager.generate_rdoc
64
+ end
65
+
66
+ def build_package_files
67
+ installed_gem_spec = install_gem
68
+ install_docs(installed_gem_spec)
69
+ end
70
+
71
+ def install_package_files
72
+ sh "chown -R root:root \"#{config.buildroot}\""
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,23 @@
1
+ require 'dpkg-tools/package/gem/control_files/copyright'
2
+ require 'dpkg-tools/package/gem/control_files/changelog'
3
+ require 'dpkg-tools/package/gem/control_files/rakefile'
4
+
5
+ module DpkgTools
6
+ module Package
7
+ module Gem
8
+ module ControlFiles
9
+ class << self
10
+ def classes
11
+ [
12
+ DpkgTools::Package::Gem::ControlFiles::Changelog,
13
+ DpkgTools::Package::ControlFiles::Control,
14
+ DpkgTools::Package::Gem::ControlFiles::Copyright,
15
+ DpkgTools::Package::Gem::ControlFiles::Rakefile,
16
+ DpkgTools::Package::ControlFiles::Rules
17
+ ]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module DpkgTools
2
+ module Package
3
+ module Gem
4
+ module ControlFiles
5
+ class Changelog < DpkgTools::Package::ControlFiles::Changelog
6
+ def change_time
7
+ Time.now.rfc822
8
+ end
9
+
10
+ def changelog
11
+ "#{config.package_name} (#{config.deb_version(data.debian_revision)}) cp-gutsy; urgency=low\n"\
12
+ " * Packaged up #{data.full_name}\n"\
13
+ " -- Matt Patterson <matt@reprocessed.org> #{self.change_time}\n"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ module DpkgTools
2
+ module Package
3
+ module Gem
4
+ module ControlFiles
5
+ class Copyright < DpkgTools::Package::ControlFiles::Copyright
6
+ def license_file
7
+ # first, look for LICENSE or MIT-LICENSE in the gem
8
+ licenses = data.files.select do |file_path|
9
+ (file_path.match(/license/i) || file_path.match(/copying/i)) unless file_path.nil?
10
+ end
11
+
12
+ if licenses.size == 1
13
+ license_path = licenses.first
14
+ license_files = data.file_entries.select do |meta, data|
15
+ meta["path"] == license_path
16
+ end
17
+ license_files.first[1]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ module DpkgTools
2
+ module Package
3
+ module Gem
4
+ module ControlFiles
5
+ class Rakefile < DpkgTools::Package::ControlFiles::Rakefile
6
+ def rakefile
7
+ "require 'rubygems'\n" \
8
+ "require 'dpkg-tools'\n" \
9
+ "\n" \
10
+ "DpkgTools::Package::Gem::BuildTasks.new do |t|\n" \
11
+ " t.root_path = File.dirname(Rake.original_dir)\n" \
12
+ " t.gem_path = File.join(Rake.original_dir, '#{config.gem_filename}')\n" \
13
+ "end\n"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,115 @@
1
+ module DpkgTools
2
+ module Package
3
+ module Gem
4
+ class Data < DpkgTools::Package::Data
5
+ class << self
6
+ def resources_dirname
7
+ 'gem'
8
+ end
9
+
10
+ def process_extensions_map(input_hash)
11
+ output_hash = {}
12
+ input_hash.each do |gem_name, value|
13
+ case value
14
+ when Hash
15
+ output_hash[gem_name] = {}
16
+ value.each do |version_key, deps|
17
+ version_key = version_key.to_s
18
+ case deps
19
+ when Array
20
+ output_hash[gem_name][version_key] = deps.collect { |dep| {:name => dep} }
21
+ when String
22
+ output_hash[gem_name][version_key] = [{:name => deps}]
23
+ end
24
+ end
25
+ when Array
26
+ output_hash[gem_name] = {'all' => value.collect { |dep| {:name => dep} }}
27
+ when String
28
+ output_hash[gem_name] = {'all' => [{:name => value}]}
29
+ end
30
+ end
31
+ output_hash
32
+ end
33
+
34
+ def native_extensions_deps_map
35
+ @native_extensions_deps_map ||= process_extensions_map(YAML.load_file(File.join(resources_path, 'gems_to_deps.yml')))
36
+ end
37
+
38
+ def native_extension_deps(name, version)
39
+ deps_map = native_extensions_deps_map[name]
40
+ return [] if deps_map.nil?
41
+ deps = deps_map[version]
42
+ deps = deps_map['all'] if deps.nil?
43
+ return [] if deps.nil?
44
+ deps
45
+ end
46
+ end
47
+
48
+ attr_reader :spec, :config, :gem_byte_string
49
+
50
+ def initialize(format, gem_byte_string)
51
+ @format = format
52
+ @gem_byte_string = gem_byte_string
53
+ @spec = format.spec
54
+ end
55
+
56
+ def name
57
+ @spec.name
58
+ end
59
+
60
+ def version
61
+ @version ||= @spec.version.to_s
62
+ end
63
+
64
+ def full_name
65
+ @spec.full_name
66
+ end
67
+
68
+ def debian_arch
69
+ return 'all' if @spec.extensions.empty?
70
+ 'i386'
71
+ end
72
+
73
+ def build_dependencies
74
+ [{:name => "rubygems", :requirements => [">= #{Gem.rubygems_version}-1"]},
75
+ {:name => "rake-rubygem", :requirements => [">= 0.7.0-1"]},
76
+ {:name => "dpkg-tools-rubygem", :requirements => [">= #{DpkgTools::VERSION::STRING}-1"]}] \
77
+ + base_deps \
78
+ + self.class.native_extension_deps(name, version)
79
+ end
80
+
81
+ def dependencies
82
+ [{:name => "rubygems", :requirements => [">= #{Gem.rubygems_version}-1"]}] + base_deps
83
+ end
84
+
85
+ def summary
86
+ @spec.summary
87
+ end
88
+
89
+ def files
90
+ @spec.files
91
+ end
92
+
93
+ def file_entries
94
+ @format.file_entries
95
+ end
96
+
97
+ private
98
+
99
+ def base_deps
100
+ return @base_deps unless @base_deps.nil?
101
+ @base_deps = []
102
+ @spec.dependencies.each do |dependency|
103
+ dep_conf = DpkgTools::Package::Config.new(dependency.name, nil, :suffix => 'rubygem')
104
+ entry = {:name => dep_conf.package_name, :requirements => []}
105
+ dependency.version_requirements.as_list.each do |version|
106
+ entry[:requirements] << "#{version}-1"
107
+ end
108
+ @base_deps << entry
109
+ end
110
+ @base_deps
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems/old_format'
2
+ require 'rubygems/format'
3
+
4
+ module DpkgTools::Package::Gem::GemFormat
5
+ def format_from_string(gem_byte_string)
6
+ gem_io = StringIO.new(gem_byte_string)
7
+ return ::Gem::OldFormat.from_io(gem_io) if gem_byte_string[0,20].include?("MD5SUM =")
8
+ ::Gem::Format.from_io(gem_io)
9
+ end
10
+ end
@@ -0,0 +1,37 @@
1
+ module DpkgTools
2
+ module Package
3
+ module Gem
4
+ class BuildTasks < DpkgTools::Package::BuildTasks
5
+ attr_accessor :gem_path, :root_path
6
+
7
+ def check_setup
8
+ raise ArgumentError, "Needs to have gem_path and root_path set" unless @gem_path && @root_path
9
+ DpkgTools::Package::Config.root_path = self.root_path
10
+ end
11
+
12
+ def create_builder
13
+ DpkgTools::Package::Gem.create_builder(@gem_path)
14
+ end
15
+
16
+ def define_tasks
17
+ # build
18
+ task "build-arch" do
19
+ create_builder.build_package
20
+ end
21
+
22
+ task "build-indep" do
23
+ create_builder.build_package
24
+ end
25
+
26
+ task "binary-arch" do
27
+ create_builder.binary_package
28
+ end
29
+
30
+ task "binary-indep" do
31
+ create_builder.binary_package
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,159 @@
1
+ require 'stringio'
2
+ require 'zlib'
3
+ require 'rubygems/package'
4
+ require 'rubygems/specification'
5
+ require 'rubygems/remote_fetcher'
6
+
7
+ require File.join(File.dirname(__FILE__), 'gem_format')
8
+
9
+ module DpkgTools
10
+ module Package
11
+ module Gem
12
+ class Setup < DpkgTools::Package::Setup
13
+ class << self
14
+ include DpkgTools::Package::Gem::GemFormat
15
+
16
+ def write_gem_file(config, gem_byte_string)
17
+ File.open(config.gem_path, 'wb') {|f| f.write(gem_byte_string)}
18
+ end
19
+
20
+ def most_recent_spec_n_source(specs_n_sources)
21
+ specs_n_sources.select {|spec, source| spec.platform == ::Gem::Platform::RUBY || spec.platform.nil?}.first
22
+ end
23
+
24
+ def specs_n_sources_for_name(gem_name)
25
+ ::Gem::RemoteInstaller.new.specs_n_sources_matching(gem_name, nil)
26
+ end
27
+
28
+ def spec_n_source_for_name(gem_name)
29
+ most_recent_spec_n_source(specs_n_sources_for_name(gem_name))
30
+ end
31
+
32
+ def most_recent_spec_n_source_satisfying_requirement(requirement, specs_n_sources)
33
+ okay_specs = specs_n_sources.select do |spec, source|
34
+ (spec.platform == ::Gem::Platform::RUBY || spec.platform.nil?) && requirement.satisfied_by?(spec.version)
35
+ end
36
+ okay_specs.first
37
+ end
38
+
39
+ def spec_n_source_for_name_and_requirement(gem_name, requirement)
40
+ most_recent_spec_n_source_satisfying_requirement(requirement, specs_n_sources_for_name(gem_name))
41
+ end
42
+
43
+ def gem_file_from_uri(uri)
44
+ ::Gem::RemoteFetcher.fetcher.fetch_path(uri)
45
+ end
46
+
47
+ def gem_uri_from_spec_n_source(spec, source_uri)
48
+ source_uri + "/gems/#{spec.full_name}.gem"
49
+ end
50
+
51
+ def format_and_file_from_path(gem_path)
52
+ gem_byte_string = File.read(gem_path)
53
+ format = format_from_string(gem_byte_string)
54
+ [format, gem_byte_string]
55
+ end
56
+
57
+ def cache_key_from_spec(spec)
58
+ "#{spec.name}-#{spec.version}"
59
+ end
60
+
61
+ def from_spec_and_source(spec, source)
62
+ gem_byte_string = gem_file_from_uri(gem_uri_from_spec_n_source(spec, source))
63
+ self.new(DpkgTools::Package::Gem::Data.new(format_from_string(gem_byte_string), gem_byte_string))
64
+ end
65
+
66
+ def from_spec_and_source_via_cache(spec, source)
67
+ cache_key = cache_key_from_spec(spec)
68
+ return dependency_cache[cache_key] if dependency_cache.has_key?(cache_key)
69
+ dependency_cache[cache_key] = from_spec_and_source(spec, source)
70
+ end
71
+
72
+ def from_name(gem_name)
73
+ from_spec_and_source_via_cache(*spec_n_source_for_name(gem_name))
74
+ end
75
+
76
+ def from_name_and_requirement(gem_name, requirement)
77
+ from_spec_and_source_via_cache(*spec_n_source_for_name_and_requirement(gem_name, requirement))
78
+ end
79
+
80
+ def from_path(gem_path)
81
+ format, gem_byte_string = format_and_file_from_path(gem_path)
82
+ self.new(DpkgTools::Package::Gem::Data.new(format, gem_byte_string))
83
+ end
84
+
85
+ def write_orig_tarball(config, gem_byte_string)
86
+ output_io = StringIO.new
87
+ gz_io = Zlib::GzipWriter.new(output_io)
88
+ tar_io = StringIO.new
89
+ ::Gem::Package::TarWriter.new(tar_io) do |tar_stream|
90
+ tar_stream.mkdir(config.package_dir_name, 0755)
91
+ tar_stream.add_file("#{config.package_dir_name}/#{config.gem_filename}", 0644) {|f| f.write(gem_byte_string) }
92
+ end
93
+ tar_io.flush
94
+ tar_io.rewind
95
+ gz_io.write(tar_io.read)
96
+ gz_io.finish
97
+ output_io.rewind
98
+ File.open(File.join(config.orig_tarball_path), 'w') do |f|
99
+ f.write(output_io.read)
100
+ end
101
+ end
102
+
103
+ def dependency_cache
104
+ @dependency_cache ||= {}
105
+ end
106
+ end
107
+
108
+ attr_reader :data, :config
109
+
110
+ def control_file_classes
111
+ DpkgTools::Package::Gem::ControlFiles.classes
112
+ end
113
+
114
+ def config_options
115
+ {:suffix => 'rubygem'}
116
+ end
117
+
118
+ def fetch_gem_file
119
+ self.class.fetch_gem_file(@source_uri + "/gems/#{@spec.full_name}.gem")
120
+ end
121
+
122
+ def write_orig_tarball
123
+ self.class.write_orig_tarball(config, data.gem_byte_string)
124
+ end
125
+
126
+ def write_gem_file
127
+ self.class.write_gem_file(config, data.gem_byte_string)
128
+ end
129
+
130
+ def prepare_package
131
+ write_orig_tarball
132
+ write_gem_file
133
+ end
134
+
135
+ def fetch_dependency(dependency)
136
+ dep_setup = self.class.from_name_and_requirement(dependency.name, dependency.version_requirements)
137
+ return dep_setup if dep_setup.fetched_dependencies?
138
+ [dep_setup] + dep_setup.fetch_dependencies
139
+ end
140
+
141
+ def fetch_dependencies
142
+ deps = data.spec.dependencies.collect do |dependency|
143
+ fetch_dependency(dependency)
144
+ end
145
+ @fetched_dependencies = true
146
+ deps.flatten
147
+ end
148
+
149
+ def fetched_dependencies?
150
+ @fetched_dependencies ||= false
151
+ end
152
+
153
+ def dependency_cache
154
+ self.class.dependency_cache
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end