dpkg-tools 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,90 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+
4
+ module DpkgTools
5
+ module Package
6
+ class BuildTasks < Rake::TaskLib
7
+ def initialize
8
+ yield(self) if block_given?
9
+
10
+ check_setup
11
+ define_base_tasks
12
+ define_tasks
13
+ end
14
+
15
+ # Override this to check that people did the right thing in the block on init
16
+ def check_setup
17
+
18
+ end
19
+
20
+ # Override this to define subclass-specific building functionality
21
+ def define_tasks
22
+
23
+ end
24
+
25
+ # Override this method to properly return an instantiated Builder object
26
+ # You can use this yourself for the build steps, and it's used by :clean
27
+ # to invoke remove_build_products on your builder
28
+ def create_builder
29
+
30
+ end
31
+
32
+ # Override this method to properly return an instantiated Setup object.
33
+ # This is used by the setup helpers, like dpkg:setup:diff and dpkg:setup:regen
34
+ def create_setup
35
+
36
+ end
37
+
38
+ # Defines the base rake tasks and ensures that you only need to define the create_builder function and
39
+ # build-arch, build-indep, binary-arch and binary-indep tasks as you need to
40
+ def define_base_tasks
41
+ # build
42
+ desc "Perform architecture-dependent build steps"
43
+ task "build-arch"
44
+
45
+ desc "Perform architecture-independent build steps"
46
+ task "build-indep"
47
+
48
+ desc "Perform all needed build steps"
49
+ task :build do
50
+ package_type = create_builder.architecture_independent? ? 'indep' : 'arch'
51
+ Rake::Task["build-#{package_type}"].invoke
52
+ end
53
+
54
+ desc "Perform architecture dependent post-build install steps"
55
+ task "binary-arch"
56
+
57
+ desc "Perform architecture independent post-build install steps"
58
+ task "binary-indep"
59
+
60
+ desc "Perform all needed build steps"
61
+ task :binary do
62
+ package_type = create_builder.architecture_independent? ? 'indep' : 'arch'
63
+ Rake::Task["binary-#{package_type}"].invoke
64
+ end
65
+
66
+ desc "Remove all build and install generated files"
67
+ task :clean do
68
+ create_builder.remove_build_products
69
+ end
70
+
71
+ # dpkg-tools rake tasks
72
+ namespace :dpkg do
73
+ namespace :setup do
74
+ desc <<-EOD
75
+ Reset any files generated during initial setup to their pristine state.
76
+ Any of those files modified by you will be moved to <file_name>.bak first.
77
+ Identical files won't be touched.
78
+ EOD
79
+ task :reset do
80
+ setup = create_setup
81
+ setup.reset_maintainer_script_templates
82
+ setup.reset_control_files
83
+ setup.reset_package_resource_files
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,145 @@
1
+ module DpkgTools
2
+ module Package
3
+ class Setup
4
+ class << self
5
+ include DpkgTools::Package::FSMethods
6
+
7
+ # Should be overridden by subclasses to check whether the
8
+ # directory at base_path needs to be bootstrapped in order
9
+ # for a DpkgTools::Package::Data subclass to be instantiated
10
+ def needs_bootstrapping?(base_path)
11
+ bootstrap_files.each do |filename|
12
+ return true unless File.file?(bootstrap_file_path(base_path, filename))
13
+ end
14
+ false
15
+ end
16
+
17
+ # Should be overridden by subclasses to return the files
18
+ # that are expected to be present under base_path to
19
+ # support a DpkgTools::Package::Data subclass being instantiated
20
+ def bootstrap_files
21
+ ['deb.yml']
22
+ end
23
+
24
+ # Shoule be overridden by subclasses and return the dir under
25
+ # base_path where files required by the bootstrapping process
26
+ # should live (can be base_path)
27
+ def bootstrap_file_path(base_path, filename)
28
+ "#{base_path}/#{filename}"
29
+ end
30
+
31
+ # Should be overridden by subclasses to bootstrap the
32
+ # directory at base_path, to put it in a state that would
33
+ # support a DpkgTools::Package::Data subclass being instantiated
34
+ def bootstrap(base_path)
35
+ bootstrap_files.each do |filename|
36
+ bootstrap_file(base_path, filename)
37
+ end
38
+ end
39
+
40
+ def file_exists?(file_path)
41
+ File.file?(file_path)
42
+ end
43
+
44
+ def move_original_aside(file_path)
45
+ FileUtils.mv(file_path, file_path + '.bak')
46
+ end
47
+
48
+ def copy_bootstrap_file_across(src_file, target_file)
49
+ FileUtils.cp(src_file, target_file)
50
+ end
51
+
52
+ def bootstrap_file(base_path, filename, options = {})
53
+ target_file = bootstrap_file_path(base_path, filename)
54
+ src_file = File.join(data_class.resources_path, filename)
55
+ file_exists = File.file?(target_file)
56
+ if file_exists && options[:backup]
57
+ move_original_aside(target_file)
58
+ file_exists = false
59
+ end
60
+ copy_bootstrap_file_across(src_file, target_file) unless file_exists
61
+ end
62
+
63
+ # Should be overridden by subclasses to return the specific
64
+ # DpkgTools::Package::Data subclass they want to use
65
+ def data_class
66
+ DpkgTools::Package::Data
67
+ end
68
+
69
+ def from_path(base_path)
70
+ self.bootstrap(base_path) if self.needs_bootstrapping?(base_path)
71
+ self.new(self.data_class.new(base_path), base_path)
72
+ end
73
+ end
74
+
75
+ def initialize(data, options = {})
76
+ @data = data
77
+ @config = DpkgTools::Package::Config.new(data.name, data.version, config_options)
78
+ end
79
+
80
+ def config_options
81
+ {}
82
+ end
83
+
84
+ def control_file_classes
85
+ DpkgTools::Package::ControlFiles.classes
86
+ end
87
+
88
+ def write_control_files
89
+ control_file_classes.each do |klass|
90
+ klass.new(@data, @config).write
91
+ end
92
+ end
93
+
94
+ def maintainer_script_template_names
95
+ ['postinst.erb', 'postrm.erb', 'preinst.erb', 'prerm.erb']
96
+ end
97
+
98
+ def copy_maintainer_script_templates
99
+ maintainer_script_template_names.each do |filename|
100
+ resource = File.join(@data.resources_path, filename)
101
+ FileUtils.cp(resource, File.join(@config.debian_path, filename)) if File.file?(resource)
102
+ end
103
+ end
104
+
105
+ def prepare_package
106
+ end
107
+
108
+ def create_structure
109
+ DpkgTools::Package.check_package_dir(@config)
110
+
111
+ prepare_package
112
+ write_control_files
113
+ copy_maintainer_script_templates
114
+ end
115
+
116
+ def reset_control_files
117
+ control_file_classes.each do |klass|
118
+ control_file = klass.new(@data, @config)
119
+ if control_file.needs_reset?
120
+ FileUtils.mv(control_file.file_path, control_file.file_path + '.bak') if File.exist?(control_file.file_path)
121
+ control_file.write
122
+ end
123
+ end
124
+ end
125
+
126
+ def reset_maintainer_script_templates
127
+ maintainer_script_template_names.each do |filename|
128
+ source = File.join(@data.resources_path, filename)
129
+ target = File.join(@config.debian_path, filename)
130
+ if File.file?(source) && !FileUtils.identical?(source, target)
131
+ FileUtils.mv(target, target + '.bak')
132
+ FileUtils.cp(source, target)
133
+ end
134
+ end
135
+ end
136
+
137
+ # This should be overridden to allow features such as the dpkg:setup:regen rake task to
138
+ # reset the state of package-type specific files (i.e. files that get copied across by
139
+ # prepare_package).
140
+ def reset_package_resource_files
141
+
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,23 @@
1
+ module DpkgTools #:nodoc:
2
+ module VERSION
3
+ unless defined? MAJOR
4
+ MAJOR = 0
5
+ MINOR = 3
6
+ TINY = 3
7
+ RELEASE_CANDIDATE = nil
8
+
9
+ BUILD_TIME = "2008-06-06T12:49:00+01:00"
10
+
11
+ STRING = [MAJOR, MINOR, TINY].join('.')
12
+ TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
13
+ FULL_VERSION = "#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')} (build #{BUILD_TIME})"
14
+
15
+ end
16
+ end
17
+
18
+ NAME = "dpkg-tools"
19
+ GEM_NAME = NAME
20
+ URL = "http://dpkg-tools.rubyforge.org/"
21
+
22
+ DESCRIPTION = "#{NAME}-#{VERSION::FULL_VERSION} - Painless OS package building\n#{URL}"
23
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ require File.dirname(__FILE__) + '/../../lib/dpkg-tools/command_line'
4
+
5
+ describe DpkgTools::CommandLine, ".run" do
6
+ it "should test something..." do
7
+
8
+ end
9
+ end
@@ -0,0 +1,159 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe DpkgTools::Package::Builder, "instances" do
4
+ before(:each) do
5
+ DpkgTools::Package::Config.stubs(:root_path).returns('/a/path/to/')
6
+ @config = DpkgTools::Package::Config.new('rails-app', '1.0.8', {})
7
+ DpkgTools::Package::Config.expects(:new).with('rails-app', '1.0.8', {}).returns(@config)
8
+
9
+ @stub_data = stub("stub DpkgTools::Package::Rails::Data", :name => 'rails-app', :version => '1.0.8',
10
+ :full_name => 'rails-app-1.0.8', :debian_revision => "1", :debian_arch => "all",
11
+ :mongrel_ports => ['8000', '8001', '8002'])
12
+ stub_data_binding = @stub_data.send(:binding)
13
+ @stub_data.stubs(:binding).returns(stub_data_binding)
14
+
15
+ @builder = DpkgTools::Package::Builder.new(@stub_data)
16
+ end
17
+
18
+ it "should provide access to @data" do
19
+ @builder.data.should == @stub_data
20
+ end
21
+
22
+ it "should be able to provide access to its DpkgTools::Package::Config entry" do
23
+ @builder.config.should == @config
24
+ end
25
+
26
+ it "should be able to create an intermediate tmp build directory" do
27
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app-1.0.8/dpkg-tools-tmp')
28
+
29
+ @builder.create_intermediate_buildroot
30
+ end
31
+
32
+ it "should be able to create the debian/tmp buildroot dir" do
33
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app-1.0.8/debian/tmp')
34
+
35
+ @builder.create_buildroot
36
+ end
37
+
38
+ it "should be able to create the buildroot/DEBIAN dir" do
39
+ Dir.expects(:mkdir).with('/a/path/to/rails-app-1.0.8/debian/tmp/DEBIAN')
40
+ File.expects(:directory?).with('/a/path/to/rails-app-1.0.8/debian/tmp/DEBIAN').returns(false)
41
+
42
+ @builder.create_DEBIAN_dir
43
+ end
44
+
45
+ it "should be able to create the DEBIAN/* package metadata files" do
46
+ @builder.expects(:sh).with('dpkg-gencontrol')
47
+
48
+ @builder.create_control_files
49
+ end
50
+
51
+ it "should be able to generate the path to the built .deb package" do
52
+ @builder.built_deb_path.should == "/a/path/to/rails-app_1.0.8-1_all.deb"
53
+ end
54
+
55
+ it "should be able to create the .deb package" do
56
+ @builder.stubs(:built_deb_path).returns('/a/path/to/rails-app_1.0.8-1_all.deb')
57
+
58
+ @builder.expects(:sh).with('dpkg-deb --build "/a/path/to/rails-app-1.0.8/debian/tmp" "/a/path/to/rails-app_1.0.8-1_all.deb"')
59
+ @builder.create_deb
60
+ end
61
+
62
+ it "should be able to report which maintainer scripts need to be generated" do
63
+ Dir.expects(:entries).with('/a/path/to/rails-app-1.0.8/debian').returns(['.', '..', 'postinst.erb', 'preinst.erb', 'postinst'])
64
+ @builder.maintainer_script_targets.should == ['postinst', 'preinst']
65
+ end
66
+
67
+ it "should be able to render an erb template using data as the binding" do
68
+ @builder.render_template("<%= mongrel_ports.inspect %>").
69
+ should == '["8000", "8001", "8002"]'
70
+ end
71
+
72
+ it "should be able to generate a maintainer script" do
73
+ File.expects(:read).with('/a/path/to/rails-app-1.0.8/debian/postinst.erb').returns('template')
74
+ mock_file = mock('File')
75
+ mock_file.expects(:write).with('rendered template')
76
+ File.expects(:open).with('/a/path/to/rails-app-1.0.8/debian/tmp/DEBIAN/postinst', 'w').yields(mock_file)
77
+ File.expects(:chmod).with(0755, '/a/path/to/rails-app-1.0.8/debian/tmp/DEBIAN/postinst')
78
+
79
+ @builder.expects(:render_template).with('template').returns('rendered template')
80
+
81
+ @builder.generate_maintainer_script('postinst')
82
+ end
83
+
84
+ it "should be able to generate all the maintainer scripts" do
85
+ @builder.expects(:maintainer_script_targets).returns(['postinst', 'preinst'])
86
+ @builder.expects(:generate_maintainer_script).with('postinst')
87
+ @builder.expects(:generate_maintainer_script).with('preinst')
88
+
89
+ @builder.generate_maintainer_scripts
90
+ end
91
+
92
+ it "should be able to report that it's an architecture independent package when it is" do
93
+ @stub_data.stubs(:architecture_independent?).returns(true)
94
+ @builder.architecture_independent?.should be_true
95
+ end
96
+
97
+ it "should be able to report that it's an architecture dependent package when it is" do
98
+ @stub_data.stubs(:architecture_independent?).returns(false)
99
+ @builder.architecture_independent?.should be_false
100
+ end
101
+ end
102
+
103
+ describe DpkgTools::Package::Builder, "#build_package" do
104
+ it "should perform the equivalent steps to configure/make" do
105
+ stub_data = stub("stub DpkgTools::Package::Gem::Data", :name => 'rails-app', :version => '1.0.8',
106
+ :full_name => 'rails-app-1.0.8')
107
+ builder = DpkgTools::Package::Builder.new(stub_data)
108
+ builder.expects(:create_buildroot)
109
+ builder.expects(:create_install_dirs)
110
+ builder.expects(:build_package_files)
111
+
112
+ builder.build_package
113
+ end
114
+ end
115
+
116
+ describe DpkgTools::Package::Builder, "#binary_package" do
117
+ it "should perform the steps needed to make a .deb and .dsc" do
118
+ stub_data = stub("stub DpkgTools::Package::Gem::Data", :name => 'rails-app', :version => '1.0.8',
119
+ :full_name => 'rails-app-1.0.8')
120
+ builder = DpkgTools::Package::Builder.new(stub_data)
121
+ builder.expects(:create_buildroot)
122
+ builder.expects(:create_install_dirs)
123
+ builder.expects(:install_package_files)
124
+ builder.expects(:generate_maintainer_scripts)
125
+ builder.expects(:create_DEBIAN_dir)
126
+ builder.expects(:create_control_files)
127
+ builder.expects(:create_deb)
128
+
129
+ builder.binary_package
130
+ end
131
+ end
132
+
133
+ describe DpkgTools::Package::Builder, "#remove_build_products" do
134
+ before(:each) do
135
+ DpkgTools::Package::Config.stubs(:root_path).returns("a/path/to")
136
+
137
+ @stub_data = stub("stub DpkgTools::Package::Gem::Data", :name => 'rails-app', :version => '1.0.8',
138
+ :full_name => 'rails-app-1.0.8')
139
+
140
+ @builder = DpkgTools::Package::Builder.new(@stub_data)
141
+ end
142
+
143
+ it "should only try to remove build products when debian/tmp exists" do
144
+ File.expects(:exists?).with('a/path/to/rails-app-1.0.8/debian/tmp').returns(false)
145
+ File.expects(:exists?).with('a/path/to/rails-app-1.0.8/dpkg-tools-tmp').returns(false)
146
+ FileUtils.expects(:remove_dir).never
147
+
148
+ @builder.remove_build_products
149
+ end
150
+
151
+ it "should remove all the build products" do
152
+ File.expects(:exists?).with('a/path/to/rails-app-1.0.8/debian/tmp').returns(true)
153
+ FileUtils.expects(:remove_dir).with('a/path/to/rails-app-1.0.8/debian/tmp')
154
+ File.expects(:exists?).with('a/path/to/rails-app-1.0.8/dpkg-tools-tmp').returns(true)
155
+ FileUtils.expects(:remove_dir).with('a/path/to/rails-app-1.0.8/dpkg-tools-tmp')
156
+
157
+ @builder.remove_build_products
158
+ end
159
+ end
@@ -0,0 +1,150 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe DpkgTools::Package::Config do
4
+ it "should be able to set and return the root dir in which all package making is happening" do
5
+ DpkgTools::Package::Config.root_path = "a/path"
6
+ DpkgTools::Package::Config.root_path.should == "a/path"
7
+ end
8
+ end
9
+
10
+ describe DpkgTools::Package::Config, ".new" do
11
+ it "should require a name, version pair of arguments" do
12
+ DpkgTools::Package::Config.new('gem_name', '1.0.8').
13
+ should be_an_instance_of(DpkgTools::Package::Config)
14
+ end
15
+
16
+ it "should throw an error if the argument is not present" do
17
+ lambda { DpkgTools::Package::Config.new() }.should raise_error
18
+ end
19
+
20
+ it "should allow base_path to be specified as well as name and version" do
21
+ DpkgTools::Package::Config.new('gem_name', '1.0.8', {:base_path => '/a/path/to'}).
22
+ should be_an_instance_of(DpkgTools::Package::Config)
23
+ end
24
+ end
25
+
26
+ describe DpkgTools::Package::Config, "instances" do
27
+ before(:each) do
28
+ DpkgTools::Package::Config.root_path = "a/path"
29
+ @config = DpkgTools::Package::Config.new('gemname', '1.0.8', {:suffix => "rubygem"})
30
+ end
31
+
32
+ it "should be able to set and return the path to the base package dir" do
33
+ @config.base_path.should == "a/path/gemname-rubygem-1.0.8"
34
+ end
35
+
36
+ it "should be able to return the path to the debian dir in the package" do
37
+ @config.debian_path.should == "a/path/gemname-rubygem-1.0.8/debian"
38
+ end
39
+
40
+ it "should be able to return the path to the .gem with #base_path" do
41
+ @config.gem_path.should == "a/path/gemname-rubygem-1.0.8/gemname-1.0.8.gem"
42
+ end
43
+
44
+ it "should be able to return the root_path set on the class" do
45
+ DpkgTools::Package::Config.root_path = 'a/root/path'
46
+ @config.root_path.should == 'a/root/path'
47
+ end
48
+
49
+ it "should be able to return the file name of the gem" do
50
+ @config.gem_filename.should == 'gemname-1.0.8.gem'
51
+ end
52
+
53
+ it "should be able to return the name of the dpkg package dir" do
54
+ @config.package_dir_name.should == 'gemname-rubygem-1.0.8'
55
+ end
56
+
57
+ it "should be able to return the name of the dpkg package name of the gem" do
58
+ @config.package_name.should == 'gemname-rubygem'
59
+ end
60
+
61
+ it "should be able to return the path to where the .orig.tar.gz file should be" do
62
+ @config.orig_tarball_path.should == "a/path/gemname-rubygem-1.0.8.orig.tar.gz"
63
+ end
64
+
65
+ it "should be able to return the path to where the package buildroot should be" do
66
+ @config.intermediate_buildroot.should == "a/path/gemname-rubygem-1.0.8/dpkg-tools-tmp"
67
+ end
68
+
69
+ it "should be able to return the path to where the package intermediate buildroot should be" do
70
+ @config.buildroot.should == "a/path/gemname-rubygem-1.0.8/debian/tmp"
71
+ end
72
+
73
+ it "should be able to return the path to where the bin dir in the buildroot should be" do
74
+ @config.bin_install_path.should == "a/path/gemname-rubygem-1.0.8/debian/tmp/usr/bin"
75
+ end
76
+
77
+ it "should be able to return the path to where the gem install dir in the package buildroot should be" do
78
+ @config.gem_install_path.should == "a/path/gemname-rubygem-1.0.8/debian/tmp/usr/lib/ruby/gems/1.8"
79
+ end
80
+
81
+ it "should be able to return the path to where the etc dir in the package buildroot should be" do
82
+ @config.etc_install_path.should == "a/path/gemname-rubygem-1.0.8/debian/tmp/etc"
83
+ end
84
+
85
+ it "should be able to return the path to the DEBIAN control dir of the buildroot" do
86
+ @config.buildroot_DEBIAN_path.should == "a/path/gemname-rubygem-1.0.8/debian/tmp/DEBIAN"
87
+ end
88
+
89
+ it "should provide access to the filename the built .deb will have" do
90
+ @config.deb_filename("1", "i386").should == "gemname-rubygem_1.0.8-1_i386.deb"
91
+ end
92
+
93
+ it "should provide access to the version" do
94
+ @config.version.should == "1.0.8"
95
+ end
96
+
97
+ it "should provide access to the debianized version (with package release suffix)" do
98
+ @config.deb_version("1").should == "1.0.8-1"
99
+ end
100
+ end
101
+
102
+ describe DpkgTools::Package::Config, "instances with suffix specified directly" do
103
+ before(:each) do
104
+ DpkgTools::Package::Config.root_path = "a/path"
105
+ end
106
+
107
+ it "should be able to cope with 'rubygem' suffix" do
108
+ config = DpkgTools::Package::Config.new('package-name', '1.0.8', :suffix => "rubygem")
109
+ config.package_name.should == 'package-name-rubygem'
110
+ end
111
+
112
+ it "should be able to cope with non-'rubygem' suffix" do
113
+ config = DpkgTools::Package::Config.new('package-name', '1.0.8', :suffix => "fnordling")
114
+ config.package_name.should == 'package-name-fnordling'
115
+ end
116
+ end
117
+
118
+ describe DpkgTools::Package::Config, "instances for gem names with debian oddities" do
119
+ before(:each) do
120
+ DpkgTools::Package::Config.root_path = "a/path"
121
+ end
122
+
123
+ it "should be able to cope with gem names with underscores in them" do
124
+ config = DpkgTools::Package::Config.new('gem_name', '1.0.8', :suffix => "rubygem")
125
+ config.package_name.should == 'gem-name-rubygem'
126
+ end
127
+
128
+ it "should be able to cope with gem names with capitalisation in them" do
129
+ config = DpkgTools::Package::Config.new('BlueCloth', '1.0.8', :suffix => "rubygem")
130
+ config.package_name.should == 'bluecloth-rubygem'
131
+ end
132
+ end
133
+
134
+ describe DpkgTools::Package::Config, "instances with base_path specified directly" do
135
+ before(:each) do
136
+ @config = DpkgTools::Package::Config.new('package-name', '1.0.8', :base_path => '/a/path/to/package-name')
137
+ end
138
+
139
+ it "should be able to set and return the path to the base package dir" do
140
+ @config.base_path.should == "/a/path/to/package-name"
141
+ end
142
+
143
+ it "should be able to return the name of the dpkg package dir" do
144
+ @config.package_dir_name.should == 'package-name'
145
+ end
146
+
147
+ it "should be able to return the correct root_path" do
148
+ @config.root_path.should == '/a/path/to'
149
+ end
150
+ end