dpkg-tools 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ #!/bin/bash -e
2
+
3
+ DATADIR="<%= app_install_path %>"
4
+
5
+ # Create a group for the app if it isn't already there
6
+ if ! getent group "<%= name %>" >/dev/null; then
7
+ # Adding system group for the app: <%= name %>.
8
+ addgroup --system "<%= name %>" >/dev/null
9
+ fi
10
+
11
+ # Create a user for the app if it isn't already there
12
+ if ! getent passwd <%= name %> >/dev/null; then
13
+ # Adding system user: <%= name %>.
14
+ adduser \
15
+ --system \
16
+ --disabled-login \
17
+ --ingroup <%= name %> \
18
+ --home $DATADIR \
19
+ --gecos "<%= name %> Rails app" \
20
+ --shell /bin/bash \
21
+ <%= name %> >/dev/null
22
+ fi
23
+
24
+ # Create the app's home dir, if it isn't there already...
25
+ if [ ! -d $DATADIR -a ! -L $DATADIR ]; then
26
+ mkdir -p $DATADIR
27
+ fi
28
+
29
+ # Fix ownership of the app's home dir...
30
+ # The "set +e" is necessary as e.g. a ".journal" of a ext3 partition is
31
+ # not chgrp'able (#318435). [nicked from mysql-server 5's preinst]
32
+ set +e
33
+ chown <%= name %>:<%= name %> $DATADIR
34
+ find $DATADIR -follow -not -group "<%= name %>" -print0 2>/dev/null \
35
+ | xargs -0 --no-run-if-empty chgrp "<%= name %>"
36
+ set -e
@@ -1,159 +1,176 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
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)
3
+ describe DpkgTools::Package::Builder do
4
+ describe ".from_path support methods" do
5
+ it "should provide a for-overriding method to return the Package::Data subclass to use" do
6
+ DpkgTools::Package::Builder.data_class.should == DpkgTools::Package::Data
7
+ end
16
8
  end
17
9
 
18
- it "should provide access to @data" do
19
- @builder.data.should == @stub_data
10
+ describe ".from_path" do
11
+ it "should be able to grab all needed config stuff and create a Data and a Builder instance" do
12
+ DpkgTools::Package::Data.expects(:new).with('/path/to/app').returns(:data)
13
+ DpkgTools::Package::Builder.expects(:new).with(:data).returns(:instance)
14
+
15
+ DpkgTools::Package::Builder.from_path('/path/to/app').should == :instance
16
+ end
20
17
  end
21
18
 
22
- it "should be able to provide access to its DpkgTools::Package::Config entry" do
23
- @builder.config.should == @config
24
- end
19
+ describe "instances" do
20
+ before(:each) do
21
+ DpkgTools::Package::Config.stubs(:root_path).returns('/a/path/to/')
22
+ @config = DpkgTools::Package::Config.new('rails-app', '1.0.8', {})
23
+ DpkgTools::Package::Config.expects(:new).with('rails-app', '1.0.8', {}).returns(@config)
24
+
25
+ @stub_data = stub("stub DpkgTools::Package::Rails::Data", :name => 'rails-app', :version => '1.0.8',
26
+ :full_name => 'rails-app-1.0.8', :debian_revision => "1", :debian_arch => "all",
27
+ :mongrel_ports => ['8000', '8001', '8002'])
28
+ stub_data_binding = @stub_data.send(:binding)
29
+ @stub_data.stubs(:binding).returns(stub_data_binding)
30
+
31
+ @builder = DpkgTools::Package::Builder.new(@stub_data)
32
+ end
33
+
34
+ it "should provide access to @data" do
35
+ @builder.data.should == @stub_data
36
+ end
37
+
38
+ it "should be able to provide access to its DpkgTools::Package::Config entry" do
39
+ @builder.config.should == @config
40
+ end
25
41
 
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')
42
+ it "should be able to create an intermediate tmp build directory" do
43
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app-1.0.8/dpkg-tools-tmp')
28
44
 
29
- @builder.create_intermediate_buildroot
30
- end
45
+ @builder.create_intermediate_buildroot
46
+ end
31
47
 
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')
48
+ it "should be able to create the debian/tmp buildroot dir" do
49
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app-1.0.8/debian/tmp')
34
50
 
35
- @builder.create_buildroot
36
- end
51
+ @builder.create_buildroot
52
+ end
37
53
 
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)
54
+ it "should be able to create the buildroot/DEBIAN dir" do
55
+ Dir.expects(:mkdir).with('/a/path/to/rails-app-1.0.8/debian/tmp/DEBIAN')
56
+ File.expects(:directory?).with('/a/path/to/rails-app-1.0.8/debian/tmp/DEBIAN').returns(false)
41
57
 
42
- @builder.create_DEBIAN_dir
43
- end
58
+ @builder.create_DEBIAN_dir
59
+ end
44
60
 
45
- it "should be able to create the DEBIAN/* package metadata files" do
46
- @builder.expects(:sh).with('dpkg-gencontrol')
61
+ it "should be able to create the DEBIAN/* package metadata files" do
62
+ @builder.expects(:sh).with('dpkg-gencontrol')
47
63
 
48
- @builder.create_control_files
49
- end
64
+ @builder.create_control_files
65
+ end
50
66
 
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
67
+ it "should be able to generate the path to the built .deb package" do
68
+ @builder.built_deb_path.should == "/a/path/to/rails-app_1.0.8-1_all.deb"
69
+ end
54
70
 
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')
71
+ it "should be able to create the .deb package" do
72
+ @builder.stubs(:built_deb_path).returns('/a/path/to/rails-app_1.0.8-1_all.deb')
57
73
 
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
74
+ @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"')
75
+ @builder.create_deb
76
+ end
61
77
 
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
78
+ it "should be able to report which maintainer scripts need to be generated" do
79
+ Dir.expects(:entries).with('/a/path/to/rails-app-1.0.8/debian').returns(['.', '..', 'postinst.erb', 'preinst.erb', 'postinst'])
80
+ @builder.maintainer_script_targets.should == ['postinst', 'preinst']
81
+ end
66
82
 
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
83
+ it "should be able to render an erb template using data as the binding" do
84
+ @builder.render_template("<%= mongrel_ports.inspect %>").
85
+ should == '["8000", "8001", "8002"]'
86
+ end
71
87
 
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')
88
+ it "should be able to generate a maintainer script" do
89
+ File.expects(:read).with('/a/path/to/rails-app-1.0.8/debian/postinst.erb').returns('template')
90
+ mock_file = mock('File')
91
+ mock_file.expects(:write).with('rendered template')
92
+ File.expects(:open).with('/a/path/to/rails-app-1.0.8/debian/tmp/DEBIAN/postinst', 'w').yields(mock_file)
93
+ File.expects(:chmod).with(0755, '/a/path/to/rails-app-1.0.8/debian/tmp/DEBIAN/postinst')
78
94
 
79
- @builder.expects(:render_template).with('template').returns('rendered template')
95
+ @builder.expects(:render_template).with('template').returns('rendered template')
80
96
 
81
- @builder.generate_maintainer_script('postinst')
82
- end
97
+ @builder.generate_maintainer_script('postinst')
98
+ end
83
99
 
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')
100
+ it "should be able to generate all the maintainer scripts" do
101
+ @builder.expects(:maintainer_script_targets).returns(['postinst', 'preinst'])
102
+ @builder.expects(:generate_maintainer_script).with('postinst')
103
+ @builder.expects(:generate_maintainer_script).with('preinst')
88
104
 
89
- @builder.generate_maintainer_scripts
90
- end
105
+ @builder.generate_maintainer_scripts
106
+ end
91
107
 
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
108
+ it "should be able to report that it's an architecture independent package when it is" do
109
+ @stub_data.stubs(:architecture_independent?).returns(true)
110
+ @builder.architecture_independent?.should be_true
111
+ end
96
112
 
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
113
+ it "should be able to report that it's an architecture dependent package when it is" do
114
+ @stub_data.stubs(:architecture_independent?).returns(false)
115
+ @builder.architecture_independent?.should be_false
116
+ end
100
117
  end
101
- end
102
118
 
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
119
+ describe DpkgTools::Package::Builder, "#build_package" do
120
+ it "should perform the equivalent steps to configure/make" do
121
+ stub_data = stub("stub DpkgTools::Package::Gem::Data", :name => 'rails-app', :version => '1.0.8',
122
+ :full_name => 'rails-app-1.0.8')
123
+ builder = DpkgTools::Package::Builder.new(stub_data)
124
+ builder.expects(:create_buildroot)
125
+ builder.expects(:create_install_dirs)
126
+ builder.expects(:build_package_files)
127
+
128
+ builder.build_package
129
+ end
113
130
  end
114
- end
115
131
 
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
132
+ describe DpkgTools::Package::Builder, "#binary_package" do
133
+ it "should perform the steps needed to make a .deb and .dsc" do
134
+ stub_data = stub("stub DpkgTools::Package::Gem::Data", :name => 'rails-app', :version => '1.0.8',
135
+ :full_name => 'rails-app-1.0.8')
136
+ builder = DpkgTools::Package::Builder.new(stub_data)
137
+ builder.expects(:create_buildroot)
138
+ builder.expects(:create_install_dirs)
139
+ builder.expects(:install_package_files)
140
+ builder.expects(:generate_maintainer_scripts)
141
+ builder.expects(:create_DEBIAN_dir)
142
+ builder.expects(:create_control_files)
143
+ builder.expects(:create_deb)
144
+
145
+ builder.binary_package
146
+ end
130
147
  end
131
- end
132
148
 
133
- describe DpkgTools::Package::Builder, "#remove_build_products" do
134
- before(:each) do
135
- DpkgTools::Package::Config.stubs(:root_path).returns("a/path/to")
149
+ describe DpkgTools::Package::Builder, "#remove_build_products" do
150
+ before(:each) do
151
+ DpkgTools::Package::Config.stubs(:root_path).returns("a/path/to")
136
152
 
137
- @stub_data = stub("stub DpkgTools::Package::Gem::Data", :name => 'rails-app', :version => '1.0.8',
138
- :full_name => 'rails-app-1.0.8')
153
+ @stub_data = stub("stub DpkgTools::Package::Gem::Data", :name => 'rails-app', :version => '1.0.8',
154
+ :full_name => 'rails-app-1.0.8')
139
155
 
140
- @builder = DpkgTools::Package::Builder.new(@stub_data)
141
- end
156
+ @builder = DpkgTools::Package::Builder.new(@stub_data)
157
+ end
142
158
 
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
159
+ it "should only try to remove build products when debian/tmp exists" do
160
+ File.expects(:exists?).with('a/path/to/rails-app-1.0.8/debian/tmp').returns(false)
161
+ File.expects(:exists?).with('a/path/to/rails-app-1.0.8/dpkg-tools-tmp').returns(false)
162
+ FileUtils.expects(:remove_dir).never
147
163
 
148
- @builder.remove_build_products
149
- end
164
+ @builder.remove_build_products
165
+ end
150
166
 
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')
167
+ it "should remove all the build products" do
168
+ File.expects(:exists?).with('a/path/to/rails-app-1.0.8/debian/tmp').returns(true)
169
+ FileUtils.expects(:remove_dir).with('a/path/to/rails-app-1.0.8/debian/tmp')
170
+ File.expects(:exists?).with('a/path/to/rails-app-1.0.8/dpkg-tools-tmp').returns(true)
171
+ FileUtils.expects(:remove_dir).with('a/path/to/rails-app-1.0.8/dpkg-tools-tmp')
156
172
 
157
- @builder.remove_build_products
173
+ @builder.remove_build_products
174
+ end
158
175
  end
159
176
  end
@@ -89,12 +89,21 @@ describe DpkgTools::Package::Data::YamlConfigHelpers do
89
89
  should include({:name => 'rspec-rubygem', :requirements => ['>= 1.0.8-1']})
90
90
  end
91
91
 
92
+ it "should be able to cope with deps without version requirements" do
93
+ fixture_data = {'dependencies' => {'gem' => ['rspec']}}
94
+
95
+ @module.process_dependencies(fixture_data).
96
+ should include({:name => 'rspec-rubygem'})
97
+ end
98
+
92
99
  it "should raise an appropriate error if the dependencies collection is not a Hash (YAML collection)" do
93
100
  fixture_data = {'dependencies' => 'string'}
94
101
 
95
102
  lambda { @module.process_dependencies(fixture_data) }.
96
103
  should raise_error(DpkgTools::Package::DebYAMLParseError)
97
104
  end
105
+
106
+
98
107
  end
99
108
 
100
109
  describe @module, ".process_dependencies_by_type" do
@@ -1,28 +1,48 @@
1
1
  require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
- describe DpkgTools::Package::Etc::Builder, "instances" do
4
- before(:each) do
5
- @config = DpkgTools::Package::Config.new('rails-app', '1.0.8')
6
- DpkgTools::Package::Etc::Data.expects(:load_package_data).with('/a/path/to/conf-package', 'deb.yml').
7
- returns({'name' => 'conf-package', 'version' => '1.0.8'})
8
- @data = DpkgTools::Package::Etc::Data.new('/a/path/to/conf-package')
9
-
10
- @builder = DpkgTools::Package::Etc::Builder.new(@data)
11
- end
12
-
13
- it "should provide the correct options for DpkgTools::Package::Config " do
14
- @builder.config_options.should == {:base_path => "/a/path/to/conf-package"}
3
+ describe DpkgTools::Package::Etc::Builder do
4
+ describe ".from_path support" do
5
+ it "should return DpkgTools::Package::Etc::Data when asked for the data subclass to use" do
6
+ DpkgTools::Package::Etc::Builder.data_class.should == DpkgTools::Package::Etc::Data
7
+ end
15
8
  end
16
9
 
17
- it "should be able to create the needed install dirs" do
18
- @builder.expects(:create_dir_if_needed).with('/a/path/to/conf-package/debian/tmp/etc')
10
+ describe "instances" do
11
+ before(:each) do
12
+ @config = DpkgTools::Package::Config.new('rails-app', '1.0.8')
13
+ DpkgTools::Package::Etc::Data.expects(:load_package_data).with('/a/path/to/conf-package', 'deb.yml').
14
+ returns({'name' => 'conf-package', 'version' => '1.0.8'})
15
+ @data = DpkgTools::Package::Etc::Data.new('/a/path/to/conf-package')
19
16
 
20
- @builder.create_install_dirs
21
- end
17
+ @builder = DpkgTools::Package::Etc::Builder.new(@data)
18
+ end
19
+
20
+ it "should provide the correct options for DpkgTools::Package::Config " do
21
+ @builder.config_options.should == {:base_path => "/a/path/to/conf-package"}
22
+ end
22
23
 
23
- it "should copy the contents of package/etc to package/debian/tmp/etc/" do
24
- FileUtils.expects(:cp_r).with('/a/path/to/conf-package/etc', '/a/path/to/conf-package/debian/tmp/etc')
24
+ it "should be able to create the needed install dirs" do
25
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/conf-package/debian/tmp/etc')
25
26
 
26
- @builder.install_package_files
27
+ @builder.create_install_dirs
28
+ end
29
+
30
+ it "should copy the contents of package/etc to package/debian/tmp/etc/" do
31
+ Dir.expects(:[]).with('/a/path/to/conf-package/etc/**/*').returns(['/a/path/to/conf-package/etc/thing',
32
+ '/a/path/to/conf-package/etc/thing/conf_file',
33
+ '/a/path/to/conf-package/etc/thing/wotsit.yml'])
34
+ File.expects(:file?).with('/a/path/to/conf-package/etc/thing').returns(false)
35
+ File.expects(:file?).with('/a/path/to/conf-package/etc/thing/conf_file').returns(true)
36
+ FileUtils.expects(:mkdir_p).with('/a/path/to/conf-package/debian/tmp/etc/thing')
37
+ FileUtils.expects(:install).with('/a/path/to/conf-package/etc/thing/conf_file',
38
+ '/a/path/to/conf-package/debian/tmp/etc/thing/conf_file',
39
+ {:mode => 0644, :verbose => true})
40
+ File.expects(:file?).with('/a/path/to/conf-package/etc/thing/wotsit.yml').returns(true)
41
+ FileUtils.expects(:mkdir_p).with('/a/path/to/conf-package/debian/tmp/etc/thing')
42
+ FileUtils.expects(:install).with('/a/path/to/conf-package/etc/thing/wotsit.yml',
43
+ '/a/path/to/conf-package/debian/tmp/etc/thing/wotsit.yml',
44
+ {:mode => 0644, :verbose => true})
45
+ @builder.install_package_files
46
+ end
27
47
  end
28
48
  end
@@ -1,113 +1,112 @@
1
1
  require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe DpkgTools::Package::Rails::Builder do
4
- it "should be able to grab all needed config stuff and create a DpkgTools::Package::Rails::Data and a Builder instance" do
5
- DpkgTools::Package::Rails::Data.expects(:new).with('/path/to/app').returns(:data)
6
- DpkgTools::Package::Rails::Builder.expects(:new).with(:data).returns(:instance)
7
-
8
- DpkgTools::Package::Rails::Builder.from_path('/path/to/app').should == :instance
4
+ describe ".from_path support" do
5
+ it "should return DpkgTools::Package::Rails::Data when asked for the data subclass to use" do
6
+ DpkgTools::Package::Rails::Builder.data_class.should == DpkgTools::Package::Rails::Data
7
+ end
9
8
  end
10
- end
11
-
12
- describe DpkgTools::Package::Rails::Builder, "instances" do
13
- before(:each) do
14
- @config = DpkgTools::Package::Config.new('rails-app', '1.0.8')
15
- DpkgTools::Package::Rails::Data.expects(:load_package_data).with('/a/path/to/rails-app/working/dir', 'deb.yml').
16
- returns({'name' => 'rails-app', 'version' => '1.0.8', 'server_name' => 'rails-app.org'}, 'mongrel_cluster' => {'port' => '8000', 'servers' => 3})
17
- DpkgTools::Package::Rails::Data.expects(:load_package_data).with('/a/path/to/rails-app/working/dir', 'database.yml').
18
- returns({'development' => {'database' => 'db_name'}})
19
- @data = DpkgTools::Package::Rails::Data.new('/a/path/to/rails-app/working/dir')
9
+
10
+ describe "instances" do
11
+ before(:each) do
12
+ @config = DpkgTools::Package::Config.new('rails-app', '1.0.8')
13
+ DpkgTools::Package::Rails::Data.expects(:load_package_data).with('/a/path/to/rails-app/working/dir', 'deb.yml').
14
+ returns({'name' => 'rails-app', 'version' => '1.0.8', 'server_name' => 'rails-app.org'}, 'mongrel_cluster' => {'port' => '8000', 'servers' => 3})
15
+ DpkgTools::Package::Rails::Data.expects(:load_package_data).with('/a/path/to/rails-app/working/dir', 'database.yml').
16
+ returns({'development' => {'database' => 'db_name'}})
17
+ @data = DpkgTools::Package::Rails::Data.new('/a/path/to/rails-app/working/dir')
20
18
 
21
- @builder = DpkgTools::Package::Rails::Builder.new(@data)
22
- end
19
+ @builder = DpkgTools::Package::Rails::Builder.new(@data)
20
+ end
23
21
 
24
- it "should provide the correct options for DpkgTools::Package::Config " do
25
- @builder.config_options.should == {:base_path => "/a/path/to/rails-app/working/dir"}
26
- end
22
+ it "should provide the correct options for DpkgTools::Package::Config " do
23
+ @builder.config_options.should == {:base_path => "/a/path/to/rails-app/working/dir"}
24
+ end
27
25
 
28
- it "should be able to create the needed install dirs" do
29
- @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/etc/init.d')
30
- @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/etc/apache2/sites-available')
31
- @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/etc/logrotate.d')
32
- @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app')
33
- @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/var/log/rails-app/apache2')
26
+ it "should be able to create the needed install dirs" do
27
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/etc/init.d')
28
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/etc/apache2/sites-available')
29
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/etc/logrotate.d')
30
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app')
31
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/var/log/rails-app/apache2')
34
32
 
35
- @builder.create_install_dirs
36
- end
33
+ @builder.create_install_dirs
34
+ end
37
35
 
38
- it "should be able to generate a config file from @data, an erb template and a destination path" do
39
- File.expects(:read).with('template_path').returns('template')
36
+ it "should be able to generate a config file from @data, an erb template and a destination path" do
37
+ File.expects(:read).with('template_path').returns('template')
40
38
 
41
- @builder.expects(:render_template).with('template').returns('conf file')
39
+ @builder.expects(:render_template).with('template').returns('conf file')
42
40
 
43
- mock_file = mock('File')
44
- mock_file.expects(:write).with('conf file')
45
- File.expects(:open).with('target_path', 'w').yields(mock_file)
41
+ mock_file = mock('File')
42
+ mock_file.expects(:write).with('conf file')
43
+ File.expects(:open).with('target_path', 'w').yields(mock_file)
46
44
 
47
- @builder.generate_conf_file('template_path', 'target_path')
48
- end
45
+ @builder.generate_conf_file('template_path', 'target_path')
46
+ end
49
47
 
50
- it "should generate all the needed config files" do
51
- @builder.expects(:generate_conf_file).with('/a/path/to/rails-app/working/dir/config/apache.conf.erb',
52
- '/a/path/to/rails-app/working/dir/debian/tmp/etc/apache2/sites-available/rails-app')
48
+ it "should generate all the needed config files" do
49
+ @builder.expects(:generate_conf_file).with('/a/path/to/rails-app/working/dir/config/apache.conf.erb',
50
+ '/a/path/to/rails-app/working/dir/debian/tmp/etc/apache2/sites-available/rails-app')
53
51
 
54
- @builder.expects(:generate_conf_file).with('/a/path/to/rails-app/working/dir/config/logrotate.conf.erb',
55
- '/a/path/to/rails-app/working/dir/debian/tmp/etc/logrotate.d/rails-app')
52
+ @builder.expects(:generate_conf_file).with('/a/path/to/rails-app/working/dir/config/logrotate.conf.erb',
53
+ '/a/path/to/rails-app/working/dir/debian/tmp/etc/logrotate.d/rails-app')
56
54
 
57
- @builder.expects(:generate_conf_file).with('/a/path/to/rails-app/working/dir/config/mongrel_cluster_init.erb',
58
- '/a/path/to/rails-app/working/dir/debian/tmp/etc/init.d/rails-app')
55
+ @builder.expects(:generate_conf_file).with('/a/path/to/rails-app/working/dir/config/mongrel_cluster_init.erb',
56
+ '/a/path/to/rails-app/working/dir/debian/tmp/etc/init.d/rails-app')
59
57
 
60
- @builder.generate_conf_files
61
- end
58
+ @builder.generate_conf_files
59
+ end
62
60
 
63
- it "should be able to read the public ssh keys in deployers_ssh_keys" do
64
- @data.stubs(:deployers_ssh_keys_dir).returns('/path/to/keys')
65
- Dir.stubs(:entries).with('/path/to/keys').returns(['key1', 'key2'])
66
- File.stubs(:file?).returns(true)
67
- File.expects(:read).with('/path/to/keys/key1').returns('key1')
68
- File.expects(:read).with('/path/to/keys/key2').returns('key2')
61
+ it "should be able to read the public ssh keys in deployers_ssh_keys" do
62
+ @data.stubs(:deployers_ssh_keys_dir).returns('/path/to/keys')
63
+ Dir.stubs(:entries).with('/path/to/keys').returns(['key1', 'key2'])
64
+ File.stubs(:file?).returns(true)
65
+ File.expects(:read).with('/path/to/keys/key1').returns('key1')
66
+ File.expects(:read).with('/path/to/keys/key2').returns('key2')
69
67
 
70
- @builder.read_deployers_ssh_keys.should == ['key1', 'key2']
71
- end
68
+ @builder.read_deployers_ssh_keys.should == ['key1', 'key2']
69
+ end
72
70
 
73
- it "should be able to read the public ssh keys in deployers_ssh_keys, ignoring any directories there" do
74
- @data.stubs(:deployers_ssh_keys_dir).returns('/path/to/keys')
75
- Dir.stubs(:entries).with('/path/to/keys').returns(['is_a_dir', 'key1', 'key2'])
76
- File.stubs(:file?).returns(true)
77
- File.expects(:file?).with('/path/to/keys/is_a_dir').returns(false)
78
- File.expects(:read).with('/path/to/keys/key1').returns('key1')
79
- File.expects(:read).with('/path/to/keys/key2').returns('key2')
71
+ it "should be able to read the public ssh keys in deployers_ssh_keys, ignoring any directories there" do
72
+ @data.stubs(:deployers_ssh_keys_dir).returns('/path/to/keys')
73
+ Dir.stubs(:entries).with('/path/to/keys').returns(['is_a_dir', 'key1', 'key2'])
74
+ File.stubs(:file?).returns(true)
75
+ File.expects(:file?).with('/path/to/keys/is_a_dir').returns(false)
76
+ File.expects(:read).with('/path/to/keys/key1').returns('key1')
77
+ File.expects(:read).with('/path/to/keys/key2').returns('key2')
80
78
 
81
- @builder.read_deployers_ssh_keys.should == ['key1', 'key2']
82
- end
79
+ @builder.read_deployers_ssh_keys.should == ['key1', 'key2']
80
+ end
83
81
 
84
- it "should be able to write out an authorized_keys file from a list of keys" do
85
- mock_file = mock('File')
86
- mock_file.expects(:write).with("key1\nkey2")
87
- File.expects(:open).with('/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh/authorized_keys', 'w').
88
- yields(mock_file)
89
- @builder.expects(:sh).with('chmod 600 "/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh/authorized_keys"')
82
+ it "should be able to write out an authorized_keys file from a list of keys" do
83
+ mock_file = mock('File')
84
+ mock_file.expects(:write).with("key1\nkey2")
85
+ File.expects(:open).with('/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh/authorized_keys', 'w').
86
+ yields(mock_file)
87
+ @builder.expects(:sh).with('chmod 600 "/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh/authorized_keys"')
90
88
 
91
- @builder.write_authorized_keys(['key1', 'key2'])
92
- end
89
+ @builder.write_authorized_keys(['key1', 'key2'])
90
+ end
93
91
 
94
- it "should be able to generate the authorized_keys file from the public keys in deployers_ssh_keys" do
95
- @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh')
96
- @builder.expects(:sh).with('chmod 700 "/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh"')
92
+ it "should be able to generate the authorized_keys file from the public keys in deployers_ssh_keys" do
93
+ @builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh')
94
+ @builder.expects(:sh).with('chmod 700 "/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh"')
97
95
 
98
- @builder.expects(:read_deployers_ssh_keys).returns(['key1', 'key2'])
99
- @builder.expects(:write_authorized_keys).with(['key1', 'key2'])
96
+ @builder.expects(:read_deployers_ssh_keys).returns(['key1', 'key2'])
97
+ @builder.expects(:write_authorized_keys).with(['key1', 'key2'])
100
98
 
101
- @builder.generate_authorized_keys
102
- end
99
+ @builder.generate_authorized_keys
100
+ end
103
101
 
104
- it "should be able to perform all the needed steps to put install the package's files " do
105
- @builder.expects(:generate_conf_files)
106
- @builder.expects(:sh).with('chown -R root:root "/a/path/to/rails-app/working/dir/debian/tmp"')
107
- @builder.expects(:sh).with('chmod 755 "/a/path/to/rails-app/working/dir/debian/tmp/etc/init.d/rails-app"')
102
+ it "should be able to perform all the needed steps to put install the package's files " do
103
+ @builder.expects(:generate_conf_files)
104
+ @builder.expects(:sh).with('chown -R root:root "/a/path/to/rails-app/working/dir/debian/tmp"')
105
+ @builder.expects(:sh).with('chmod 755 "/a/path/to/rails-app/working/dir/debian/tmp/etc/init.d/rails-app"')
108
106
 
109
- @builder.expects(:generate_authorized_keys)
107
+ @builder.expects(:generate_authorized_keys)
110
108
 
111
- @builder.install_package_files
109
+ @builder.install_package_files
110
+ end
112
111
  end
113
112
  end