omnibus 5.4.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/CHANGELOG.md +21 -0
- data/Gemfile +8 -5
- data/README.md +3 -1
- data/Rakefile +20 -13
- data/appveyor.yml +4 -3
- data/bin/omnibus +3 -3
- data/features/commands/manifest.feature +19 -5
- data/features/step_definitions/generator_steps.rb +5 -6
- data/features/support/env.rb +4 -4
- data/lib/omnibus/build_version.rb +14 -14
- data/lib/omnibus/build_version_dsl.rb +3 -3
- data/lib/omnibus/builder.rb +50 -61
- data/lib/omnibus/changelog.rb +2 -2
- data/lib/omnibus/changelog_printer.rb +4 -4
- data/lib/omnibus/cleaner.rb +4 -4
- data/lib/omnibus/cli/base.rb +15 -15
- data/lib/omnibus/cli/cache.rb +13 -13
- data/lib/omnibus/cli/changelog.rb +8 -9
- data/lib/omnibus/cli/publish.rb +12 -13
- data/lib/omnibus/cli.rb +26 -27
- data/lib/omnibus/compressor.rb +6 -6
- data/lib/omnibus/compressors/base.rb +7 -2
- data/lib/omnibus/compressors/dmg.rb +12 -12
- data/lib/omnibus/compressors/null.rb +1 -1
- data/lib/omnibus/compressors/tgz.rb +8 -8
- data/lib/omnibus/config.rb +37 -26
- data/lib/omnibus/core_extensions/open_uri.rb +3 -3
- data/lib/omnibus/core_extensions.rb +1 -1
- data/lib/omnibus/digestable.rb +5 -4
- data/lib/omnibus/download_helpers.rb +7 -6
- data/lib/omnibus/exceptions.rb +29 -13
- data/lib/omnibus/fetcher.rb +0 -1
- data/lib/omnibus/fetchers/git_fetcher.rb +7 -7
- data/lib/omnibus/fetchers/net_fetcher.rb +19 -19
- data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
- data/lib/omnibus/file_syncer.rb +3 -3
- data/lib/omnibus/generator.rb +60 -47
- data/lib/omnibus/git_cache.rb +33 -22
- data/lib/omnibus/git_repository.rb +5 -5
- data/lib/omnibus/health_check.rb +122 -119
- data/lib/omnibus/instrumentation.rb +1 -1
- data/lib/omnibus/licensing.rb +348 -60
- data/lib/omnibus/logger.rb +12 -9
- data/lib/omnibus/logging.rb +1 -1
- data/lib/omnibus/manifest.rb +4 -4
- data/lib/omnibus/manifest_diff.rb +6 -7
- data/lib/omnibus/manifest_entry.rb +1 -1
- data/lib/omnibus/metadata.rb +36 -36
- data/lib/omnibus/ohai.rb +6 -7
- data/lib/omnibus/package.rb +1 -1
- data/lib/omnibus/packager.rb +37 -28
- data/lib/omnibus/packagers/appx.rb +86 -0
- data/lib/omnibus/packagers/base.rb +21 -18
- data/lib/omnibus/packagers/bff.rb +22 -24
- data/lib/omnibus/packagers/deb.rb +20 -20
- data/lib/omnibus/packagers/ips.rb +18 -17
- data/lib/omnibus/packagers/makeself.rb +7 -7
- data/lib/omnibus/packagers/msi.rb +38 -193
- data/lib/omnibus/packagers/pkg.rb +16 -16
- data/lib/omnibus/packagers/rpm.rb +53 -54
- data/lib/omnibus/packagers/solaris.rb +14 -14
- data/lib/omnibus/packagers/windows_base.rb +192 -0
- data/lib/omnibus/project.rb +45 -43
- data/lib/omnibus/publisher.rb +3 -3
- data/lib/omnibus/publishers/artifactory_publisher.rb +39 -39
- data/lib/omnibus/publishers/s3_publisher.rb +7 -7
- data/lib/omnibus/reports.rb +10 -10
- data/lib/omnibus/s3_cache.rb +7 -7
- data/lib/omnibus/s3_helpers.rb +8 -7
- data/lib/omnibus/semantic_version.rb +1 -1
- data/lib/omnibus/software.rb +131 -81
- data/lib/omnibus/sugarable.rb +10 -10
- data/lib/omnibus/templating.rb +5 -5
- data/lib/omnibus/thread_pool.rb +1 -1
- data/lib/omnibus/util.rb +5 -5
- data/lib/omnibus/version.rb +1 -1
- data/lib/omnibus.rb +65 -65
- data/omnibus.gemspec +34 -32
- data/resources/appx/AppxManifest.xml.erb +18 -0
- data/resources/appx/assets/clear.png +0 -0
- data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-bundler-audit-0.5.0-COPYING.txt +674 -0
- data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-inifile-3.0.0-README.md +215 -0
- data/spec/fixtures/licensing/license_scout/snoopy/snoopy-dependency-licenses.json +24 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-inifile-3.0.0-README.md +215 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mime-types-3.1-Licence.rdoc +25 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mini_portile2-2.1.0-LICENSE.txt +20 -0
- data/spec/fixtures/licensing/license_scout/zlib/zlib-dependency-licenses.json +32 -0
- data/spec/functional/builder_spec.rb +149 -150
- data/spec/functional/fetchers/git_fetcher_spec.rb +69 -71
- data/spec/functional/fetchers/net_fetcher_spec.rb +79 -79
- data/spec/functional/fetchers/path_fetcher_spec.rb +19 -20
- data/spec/functional/file_syncer_spec.rb +74 -74
- data/spec/functional/licensing_spec.rb +344 -35
- data/spec/functional/templating_spec.rb +17 -17
- data/spec/spec_helper.rb +20 -20
- data/spec/support/examples.rb +21 -15
- data/spec/support/file_helpers.rb +1 -1
- data/spec/support/git_helpers.rb +37 -37
- data/spec/support/matchers.rb +3 -3
- data/spec/support/ohai_helpers.rb +4 -4
- data/spec/support/path_helpers.rb +2 -2
- data/spec/support/shell_helpers.rb +2 -2
- data/spec/unit/build_version_dsl_spec.rb +5 -5
- data/spec/unit/build_version_spec.rb +63 -63
- data/spec/unit/builder_spec.rb +86 -70
- data/spec/unit/changelog_spec.rb +4 -4
- data/spec/unit/changelogprinter_spec.rb +130 -0
- data/spec/unit/cleanroom_spec.rb +11 -11
- data/spec/unit/compressor_spec.rb +16 -16
- data/spec/unit/compressors/base_spec.rb +6 -6
- data/spec/unit/compressors/dmg_spec.rb +76 -76
- data/spec/unit/compressors/null_spec.rb +4 -4
- data/spec/unit/compressors/tgz_spec.rb +20 -20
- data/spec/unit/config_spec.rb +44 -43
- data/spec/unit/digestable_spec.rb +13 -13
- data/spec/unit/fetcher_spec.rb +11 -12
- data/spec/unit/fetchers/git_fetcher_spec.rb +31 -31
- data/spec/unit/fetchers/net_fetcher_spec.rb +172 -173
- data/spec/unit/fetchers/path_fetcher_spec.rb +18 -18
- data/spec/unit/generator_spec.rb +38 -38
- data/spec/unit/git_cache_spec.rb +56 -54
- data/spec/unit/git_repository_spec.rb +2 -2
- data/spec/unit/health_check_spec.rb +40 -40
- data/spec/unit/library_spec.rb +35 -35
- data/spec/unit/manifest_diff_spec.rb +10 -11
- data/spec/unit/manifest_spec.rb +17 -17
- data/spec/unit/metadata_spec.rb +152 -152
- data/spec/unit/ohai_spec.rb +5 -5
- data/spec/unit/omnibus_spec.rb +31 -31
- data/spec/unit/package_spec.rb +20 -20
- data/spec/unit/packager_spec.rb +48 -42
- data/spec/unit/packagers/appx_spec.rb +165 -0
- data/spec/unit/packagers/base_spec.rb +34 -34
- data/spec/unit/packagers/bff_spec.rb +60 -60
- data/spec/unit/packagers/deb_spec.rb +71 -71
- data/spec/unit/packagers/ips_spec.rb +45 -45
- data/spec/unit/packagers/makeself_spec.rb +22 -22
- data/spec/unit/packagers/msi_spec.rb +141 -147
- data/spec/unit/packagers/pkg_spec.rb +59 -60
- data/spec/unit/packagers/rpm_spec.rb +125 -126
- data/spec/unit/packagers/solaris_spec.rb +52 -52
- data/spec/unit/project_spec.rb +137 -135
- data/spec/unit/publisher_spec.rb +70 -70
- data/spec/unit/publishers/artifactory_publisher_spec.rb +85 -85
- data/spec/unit/publishers/s3_publisher_spec.rb +36 -36
- data/spec/unit/s3_cacher_spec.rb +34 -34
- data/spec/unit/s3_helpers_spec.rb +6 -6
- data/spec/unit/semantic_version_spec.rb +2 -2
- data/spec/unit/software_spec.rb +346 -384
- data/spec/unit/sugarable_spec.rb +10 -10
- data/spec/unit/util_spec.rb +60 -60
- metadata +54 -6
- data/.rubocop.yml +0 -48
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Packager::DEB do
|
5
5
|
let(:project) do
|
6
6
|
Project.new.tap do |project|
|
7
|
-
project.name(
|
8
|
-
project.homepage(
|
9
|
-
project.install_dir(
|
10
|
-
project.build_version(
|
11
|
-
project.build_iteration(
|
12
|
-
project.maintainer(
|
7
|
+
project.name("project")
|
8
|
+
project.homepage("https://example.com")
|
9
|
+
project.install_dir("/opt/project")
|
10
|
+
project.build_version("1.2.3")
|
11
|
+
project.build_iteration("2")
|
12
|
+
project.maintainer("Chef Software")
|
13
13
|
project.license(project_license) if project_license
|
14
14
|
end
|
15
15
|
end
|
@@ -17,9 +17,9 @@ module Omnibus
|
|
17
17
|
subject { described_class.new(project) }
|
18
18
|
|
19
19
|
let(:project_license) { nil }
|
20
|
-
let(:project_root) { File.join(tmp_path,
|
21
|
-
let(:package_dir) { File.join(tmp_path,
|
22
|
-
let(:staging_dir) { File.join(tmp_path,
|
20
|
+
let(:project_root) { File.join(tmp_path, "project/root") }
|
21
|
+
let(:package_dir) { File.join(tmp_path, "package/dir") }
|
22
|
+
let(:staging_dir) { File.join(tmp_path, "staging/dir") }
|
23
23
|
|
24
24
|
before do
|
25
25
|
Config.project_root(project_root)
|
@@ -31,87 +31,87 @@ module Omnibus
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#vendor' do
|
34
|
-
it
|
34
|
+
it "is a DSL method" do
|
35
35
|
expect(subject).to have_exposed_method(:vendor)
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
39
|
-
expect(subject.vendor).to eq(
|
38
|
+
it "has a default value" do
|
39
|
+
expect(subject.vendor).to eq("Omnibus <omnibus@getchef.com>")
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
42
|
+
it "must be a string" do
|
43
43
|
expect { subject.vendor(Object.new) }.to raise_error(InvalidValue)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe '#license' do
|
48
|
-
it
|
48
|
+
it "is a DSL method" do
|
49
49
|
expect(subject).to have_exposed_method(:license)
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
53
|
-
expect(subject.license).to eq(
|
52
|
+
it "has a default value" do
|
53
|
+
expect(subject.license).to eq("Unspecified")
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it "must be a string" do
|
57
57
|
expect { subject.license(Object.new) }.to raise_error(InvalidValue)
|
58
58
|
end
|
59
59
|
|
60
|
-
context
|
61
|
-
let(:project_license) {
|
60
|
+
context "with project license" do
|
61
|
+
let(:project_license) { "custom-license" }
|
62
62
|
|
63
|
-
it
|
64
|
-
expect(subject.license).to eq(
|
63
|
+
it "uses project license" do
|
64
|
+
expect(subject.license).to eq("custom-license")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe '#priority' do
|
70
|
-
it
|
70
|
+
it "is a DSL method" do
|
71
71
|
expect(subject).to have_exposed_method(:priority)
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
75
|
-
expect(subject.priority).to eq(
|
74
|
+
it "has a default value" do
|
75
|
+
expect(subject.priority).to eq("extra")
|
76
76
|
end
|
77
77
|
|
78
|
-
it
|
78
|
+
it "must be a string" do
|
79
79
|
expect { subject.priority(Object.new) }.to raise_error(InvalidValue)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
describe '#section' do
|
84
|
-
it
|
84
|
+
it "is a DSL method" do
|
85
85
|
expect(subject).to have_exposed_method(:section)
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
89
|
-
expect(subject.section).to eq(
|
88
|
+
it "has a default value" do
|
89
|
+
expect(subject.section).to eq("misc")
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
92
|
+
it "must be a string" do
|
93
93
|
expect { subject.section(Object.new) }.to raise_error(InvalidValue)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
describe '#id' do
|
98
|
-
it
|
98
|
+
it "is :deb" do
|
99
99
|
expect(subject.id).to eq(:deb)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
describe '#package_name' do
|
104
104
|
before do
|
105
|
-
allow(subject).to receive(:safe_architecture).and_return(
|
105
|
+
allow(subject).to receive(:safe_architecture).and_return("amd64")
|
106
106
|
end
|
107
107
|
|
108
|
-
it
|
109
|
-
expect(subject.package_name).to eq(
|
108
|
+
it "includes the name, version, and build iteration" do
|
109
|
+
expect(subject.package_name).to eq("project_1.2.3-2_amd64.deb")
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
describe '#debian_dir' do
|
114
|
-
it
|
114
|
+
it "is nested inside the staging_dir" do
|
115
115
|
expect(subject.debian_dir).to eq("#{staging_dir}/DEBIAN")
|
116
116
|
end
|
117
117
|
end
|
@@ -121,12 +121,12 @@ module Omnibus
|
|
121
121
|
allow(subject).to receive(:safe_architecture).and_return("amd64")
|
122
122
|
end
|
123
123
|
|
124
|
-
it
|
124
|
+
it "generates the file" do
|
125
125
|
subject.write_control_file
|
126
126
|
expect("#{staging_dir}/DEBIAN/control").to be_a_file
|
127
127
|
end
|
128
128
|
|
129
|
-
it
|
129
|
+
it "has the correct content" do
|
130
130
|
subject.write_control_file
|
131
131
|
contents = File.read("#{staging_dir}/DEBIAN/control")
|
132
132
|
|
@@ -146,25 +146,25 @@ module Omnibus
|
|
146
146
|
|
147
147
|
describe '#write_conffiles_file' do
|
148
148
|
before do
|
149
|
-
project.config_file(
|
150
|
-
project.config_file(
|
149
|
+
project.config_file("/opt/project/file1")
|
150
|
+
project.config_file("/opt/project/file2")
|
151
151
|
end
|
152
152
|
|
153
|
-
context
|
153
|
+
context "when there are no files" do
|
154
154
|
before { project.config_files.clear }
|
155
155
|
|
156
|
-
it
|
156
|
+
it "does not render the file" do
|
157
157
|
subject.write_conffiles_file
|
158
158
|
expect("#{staging_dir}/DEBIAN/conffiles").to_not be_a_file
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
-
it
|
162
|
+
it "generates the file" do
|
163
163
|
subject.write_conffiles_file
|
164
164
|
expect("#{staging_dir}/DEBIAN/conffiles").to be_a_file
|
165
165
|
end
|
166
166
|
|
167
|
-
it
|
167
|
+
it "has the correct content" do
|
168
168
|
subject.write_conffiles_file
|
169
169
|
contents = File.read("#{staging_dir}/DEBIAN/conffiles")
|
170
170
|
|
@@ -181,7 +181,7 @@ module Omnibus
|
|
181
181
|
create_file("#{project_root}/package-scripts/project/postrm") { "postrm" }
|
182
182
|
end
|
183
183
|
|
184
|
-
it
|
184
|
+
it "copies the scripts into the DEBIAN dir with permissions = 100755", :not_supported_on_windows do
|
185
185
|
subject.write_scripts
|
186
186
|
|
187
187
|
expect("#{staging_dir}/DEBIAN/preinst").to be_a_file
|
@@ -189,13 +189,13 @@ module Omnibus
|
|
189
189
|
expect("#{staging_dir}/DEBIAN/prerm").to be_a_file
|
190
190
|
expect("#{staging_dir}/DEBIAN/postrm").to be_a_file
|
191
191
|
|
192
|
-
expect("#{staging_dir}/DEBIAN/preinst").to have_permissions
|
193
|
-
expect("#{staging_dir}/DEBIAN/postinst").to have_permissions
|
194
|
-
expect("#{staging_dir}/DEBIAN/prerm").to have_permissions
|
195
|
-
expect("#{staging_dir}/DEBIAN/postrm").to have_permissions
|
192
|
+
expect("#{staging_dir}/DEBIAN/preinst").to have_permissions "100755"
|
193
|
+
expect("#{staging_dir}/DEBIAN/postinst").to have_permissions "100755"
|
194
|
+
expect("#{staging_dir}/DEBIAN/prerm").to have_permissions "100755"
|
195
|
+
expect("#{staging_dir}/DEBIAN/postrm").to have_permissions "100755"
|
196
196
|
end
|
197
197
|
|
198
|
-
it
|
198
|
+
it "logs a message" do
|
199
199
|
output = capture_logging do
|
200
200
|
subject.write_scripts
|
201
201
|
end
|
@@ -216,12 +216,12 @@ module Omnibus
|
|
216
216
|
create_file("#{staging_dir}/DEBIAN/postrm") { "postrm" }
|
217
217
|
end
|
218
218
|
|
219
|
-
it
|
219
|
+
it "generates the file" do
|
220
220
|
subject.write_md5_sums
|
221
221
|
expect("#{staging_dir}/DEBIAN/md5sums").to be_a_file
|
222
222
|
end
|
223
223
|
|
224
|
-
it
|
224
|
+
it "has the correct content" do
|
225
225
|
subject.write_md5_sums
|
226
226
|
contents = File.read("#{staging_dir}/DEBIAN/md5sums")
|
227
227
|
|
@@ -241,18 +241,18 @@ module Omnibus
|
|
241
241
|
allow(subject).to receive(:safe_architecture).and_return("amd64")
|
242
242
|
end
|
243
243
|
|
244
|
-
it
|
244
|
+
it "logs a message" do
|
245
245
|
output = capture_logging { subject.create_deb_file }
|
246
|
-
expect(output).to include(
|
246
|
+
expect(output).to include("Creating .deb file")
|
247
247
|
end
|
248
248
|
|
249
|
-
it
|
249
|
+
it "executes the command using `fakeroot`" do
|
250
250
|
expect(subject).to receive(:shellout!)
|
251
251
|
.with(/\Afakeroot/)
|
252
252
|
subject.create_deb_file
|
253
253
|
end
|
254
254
|
|
255
|
-
it
|
255
|
+
it "uses the correct command" do
|
256
256
|
expect(subject).to receive(:shellout!)
|
257
257
|
.with(/dpkg-deb -z9 -Zgzip -D --build/)
|
258
258
|
subject.create_deb_file
|
@@ -267,25 +267,25 @@ module Omnibus
|
|
267
267
|
create_file("#{staging_dir}/file2") { "2" * 20_000 }
|
268
268
|
end
|
269
269
|
|
270
|
-
it
|
270
|
+
it "stats all the files in the install_dir" do
|
271
271
|
expect(subject.package_size).to eq(29)
|
272
272
|
end
|
273
273
|
end
|
274
274
|
|
275
275
|
describe '#safe_base_package_name' do
|
276
276
|
context 'when the project name is "safe"' do
|
277
|
-
it
|
278
|
-
expect(subject.safe_base_package_name).to eq(
|
277
|
+
it "returns the value without logging a message" do
|
278
|
+
expect(subject.safe_base_package_name).to eq("project")
|
279
279
|
expect(subject).to_not receive(:log)
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
283
|
-
context
|
283
|
+
context "when the project name has invalid characters" do
|
284
284
|
before { project.name("Pro$ject123.for-realz_2") }
|
285
285
|
|
286
|
-
it
|
286
|
+
it "returns the value while logging a message" do
|
287
287
|
output = capture_logging do
|
288
|
-
expect(subject.safe_base_package_name).to eq(
|
288
|
+
expect(subject.safe_base_package_name).to eq("pro-ject123.for-realz-2")
|
289
289
|
end
|
290
290
|
|
291
291
|
expect(output).to include("The `name' component of Debian package names can only include")
|
@@ -294,37 +294,37 @@ module Omnibus
|
|
294
294
|
end
|
295
295
|
|
296
296
|
describe '#safe_build_iteration' do
|
297
|
-
it
|
297
|
+
it "returns the build iteration" do
|
298
298
|
expect(subject.safe_build_iteration).to eq(project.build_iteration)
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
302
302
|
describe '#safe_version' do
|
303
303
|
context 'when the project build_version is "safe"' do
|
304
|
-
it
|
305
|
-
expect(subject.safe_version).to eq(
|
304
|
+
it "returns the value without logging a message" do
|
305
|
+
expect(subject.safe_version).to eq("1.2.3")
|
306
306
|
expect(subject).to_not receive(:log)
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
310
|
-
context
|
311
|
-
before { project.build_version(
|
310
|
+
context "when the project build_version has dashes" do
|
311
|
+
before { project.build_version("1.2-rc.1") }
|
312
312
|
|
313
|
-
it
|
313
|
+
it "returns the value while logging a message" do
|
314
314
|
output = capture_logging do
|
315
|
-
expect(subject.safe_version).to eq(
|
315
|
+
expect(subject.safe_version).to eq("1.2~rc.1")
|
316
316
|
end
|
317
317
|
|
318
318
|
expect(output).to include("Dashes hold special significance in the Debian package versions.")
|
319
319
|
end
|
320
320
|
end
|
321
321
|
|
322
|
-
context
|
322
|
+
context "when the project build_version has invalid characters" do
|
323
323
|
before { project.build_version("1.2$alpha.~##__2") }
|
324
324
|
|
325
|
-
it
|
325
|
+
it "returns the value while logging a message" do
|
326
326
|
output = capture_logging do
|
327
|
-
expect(subject.safe_version).to eq(
|
327
|
+
expect(subject.safe_version).to eq("1.2_alpha.~_2")
|
328
328
|
end
|
329
329
|
|
330
330
|
expect(output).to include("The `version' component of Debian package names can only include")
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "pry"
|
3
3
|
|
4
4
|
module Omnibus
|
5
5
|
describe Packager::IPS do
|
6
6
|
let(:project) do
|
7
7
|
Project.new.tap do |project|
|
8
|
-
project.name(
|
9
|
-
project.homepage(
|
10
|
-
project.install_dir(
|
11
|
-
project.build_version(
|
12
|
-
project.build_iteration(
|
13
|
-
project.maintainer(
|
8
|
+
project.name("project")
|
9
|
+
project.homepage("https://example.com")
|
10
|
+
project.install_dir("/opt/project")
|
11
|
+
project.build_version("1.2.3")
|
12
|
+
project.build_iteration("2")
|
13
|
+
project.maintainer("Chef Software")
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
subject { described_class.new(project) }
|
18
18
|
|
19
|
-
let(:project_root) { File.join(tmp_path,
|
20
|
-
let(:package_dir) { File.join(tmp_path,
|
21
|
-
let(:staging_dir) { File.join(tmp_path,
|
22
|
-
let(:source_dir) { File.join(staging_dir,
|
23
|
-
let(:repo_dir) { File.join(staging_dir,
|
24
|
-
let(:architecture) {
|
19
|
+
let(:project_root) { File.join(tmp_path, "project/root") }
|
20
|
+
let(:package_dir) { File.join(tmp_path, "package/dir") }
|
21
|
+
let(:staging_dir) { File.join(tmp_path, "staging/dir") }
|
22
|
+
let(:source_dir) { File.join(staging_dir, "proto_install") }
|
23
|
+
let(:repo_dir) { File.join(staging_dir, "publish/repo") }
|
24
|
+
let(:architecture) { "i86pc" }
|
25
25
|
let(:shellout) { double("Mixlib::ShellOut", :run_command => true, :error! => nil) }
|
26
26
|
|
27
27
|
before do
|
@@ -34,18 +34,18 @@ module Omnibus
|
|
34
34
|
create_directory(source_dir)
|
35
35
|
create_directory(repo_dir)
|
36
36
|
|
37
|
-
stub_ohai(platform:
|
38
|
-
data[
|
37
|
+
stub_ohai(platform: "solaris2", version: "5.11") do |data|
|
38
|
+
data["kernel"]["machine"] = architecture
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe '#publisher_prefix' do
|
43
|
-
it
|
43
|
+
it "is a DSL method" do
|
44
44
|
expect(subject).to have_exposed_method(:publisher_prefix)
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
48
|
-
expect(subject.publisher_prefix).to eq(
|
47
|
+
it "has a default value" do
|
48
|
+
expect(subject.publisher_prefix).to eq("Omnibus")
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -54,55 +54,55 @@ module Omnibus
|
|
54
54
|
end
|
55
55
|
|
56
56
|
describe '#package_name' do
|
57
|
-
it
|
58
|
-
expect(subject.package_name).to eq(
|
57
|
+
it "should create correct package name" do
|
58
|
+
expect(subject.package_name).to eq("project-1.2.3-2.i386.p5p")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
describe '#fmri_package_name' do
|
63
|
-
it
|
64
|
-
expect(subject.fmri_package_name).to eq (
|
63
|
+
it "should create correct fmri package name" do
|
64
|
+
expect(subject.fmri_package_name).to eq ("project@1.2.3,5.11-2")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
describe '#pkg_metadata_file' do
|
69
|
-
it
|
69
|
+
it "is created inside the staging_dir" do
|
70
70
|
expect(subject.pkg_metadata_file).to eq("#{subject.staging_dir}/gen.manifestfile")
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
describe '#pkg_manifest_file' do
|
75
|
-
it
|
75
|
+
it "is created inside the staging_dir" do
|
76
76
|
expect(subject.pkg_manifest_file).to eq("#{subject.staging_dir}/#{subject.safe_base_package_name}.p5m")
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
describe '#repo_dir' do
|
81
|
-
it
|
81
|
+
it "is created inside the staging_dir" do
|
82
82
|
expect(subject.repo_dir).to eq("#{subject.staging_dir}/publish/repo")
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
describe '#source_dir' do
|
87
|
-
it
|
87
|
+
it "is created inside the staging_dir" do
|
88
88
|
expect(subject.source_dir).to eq("#{subject.staging_dir}/proto_install")
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe '#safe_base_package_name' do
|
93
93
|
context 'when the project name is "safe"' do
|
94
|
-
it
|
95
|
-
expect(subject.safe_base_package_name).to eq(
|
94
|
+
it "returns the value without logging a message" do
|
95
|
+
expect(subject.safe_base_package_name).to eq("project")
|
96
96
|
expect(subject).to_not receive(:log)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
context
|
100
|
+
context "when the project name has invalid characters" do
|
101
101
|
before { project.name("Pro$ject123.for-realz_2") }
|
102
102
|
|
103
|
-
it
|
103
|
+
it "returns the value while logging a message" do
|
104
104
|
output = capture_logging do
|
105
|
-
expect(subject.safe_base_package_name).to eq(
|
105
|
+
expect(subject.safe_base_package_name).to eq("pro-ject123.for-realz-2")
|
106
106
|
end
|
107
107
|
|
108
108
|
expect(output).to include("The `name' component of IPS package names can only include")
|
@@ -111,27 +111,27 @@ module Omnibus
|
|
111
111
|
end
|
112
112
|
|
113
113
|
describe '#safe_architecture' do
|
114
|
-
context
|
115
|
-
let(:architecture) {
|
114
|
+
context "the architecture is Intel-based" do
|
115
|
+
let(:architecture) { "i86pc" }
|
116
116
|
|
117
|
-
it
|
118
|
-
expect(subject.safe_architecture).to eq(
|
117
|
+
it "returns `i386`" do
|
118
|
+
expect(subject.safe_architecture).to eq("i386")
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
context
|
123
|
-
let(:architecture) {
|
122
|
+
context "the architecture is SPARC-based" do
|
123
|
+
let(:architecture) { "sun4v" }
|
124
124
|
|
125
|
-
it
|
126
|
-
expect(subject.safe_architecture).to eq(
|
125
|
+
it "returns `sparc`" do
|
126
|
+
expect(subject.safe_architecture).to eq("sparc")
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
context
|
131
|
-
let(:architecture) {
|
130
|
+
context "anything else" do
|
131
|
+
let(:architecture) { "FOO" }
|
132
132
|
|
133
|
-
it
|
134
|
-
expect(subject.safe_architecture).to eq(
|
133
|
+
it "returns the value from Ohai" do
|
134
|
+
expect(subject.safe_architecture).to eq("FOO")
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
@@ -211,7 +211,7 @@ module Omnibus
|
|
211
211
|
describe "#export_pkg_archive_file" do
|
212
212
|
it "uses the correct commands" do
|
213
213
|
expect(subject).to receive(:shellout!)
|
214
|
-
.with("pkgrecv -s #{staging_dir}/publish/repo -a -d #{package_dir}/project.p5p project")
|
214
|
+
.with("pkgrecv -s #{staging_dir}/publish/repo -a -d #{package_dir}/project-1.2.3-2.i386.p5p project")
|
215
215
|
|
216
216
|
expect(shellout).to receive(:stdout)
|
217
217
|
subject.export_pkg_archive_file
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Packager::Makeself do
|
5
5
|
let(:project) do
|
6
6
|
Project.new.tap do |project|
|
7
|
-
project.name(
|
8
|
-
project.homepage(
|
9
|
-
project.install_dir(
|
10
|
-
project.build_version(
|
11
|
-
project.build_iteration(
|
12
|
-
project.maintainer(
|
7
|
+
project.name("project")
|
8
|
+
project.homepage("https://example.com")
|
9
|
+
project.install_dir("/opt/project")
|
10
|
+
project.build_version("1.2.3")
|
11
|
+
project.build_iteration("2")
|
12
|
+
project.maintainer("Chef Software")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
subject { described_class.new(project) }
|
17
17
|
|
18
|
-
let(:project_root) { File.join(tmp_path,
|
19
|
-
let(:package_dir) { File.join(tmp_path,
|
20
|
-
let(:staging_dir) { File.join(tmp_path,
|
18
|
+
let(:project_root) { File.join(tmp_path, "project/root") }
|
19
|
+
let(:package_dir) { File.join(tmp_path, "package/dir") }
|
20
|
+
let(:staging_dir) { File.join(tmp_path, "staging/dir") }
|
21
21
|
|
22
22
|
before do
|
23
23
|
Config.project_root(project_root)
|
@@ -28,37 +28,37 @@ module Omnibus
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#id' do
|
31
|
-
it
|
31
|
+
it "is :makeself" do
|
32
32
|
expect(subject.id).to eq(:makeself)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#package_name' do
|
37
37
|
before do
|
38
|
-
allow(subject).to receive(:safe_architecture).and_return(
|
38
|
+
allow(subject).to receive(:safe_architecture).and_return("x86_64")
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
42
|
-
expect(subject.package_name).to eq(
|
41
|
+
it "includes the name, version, and build iteration" do
|
42
|
+
expect(subject.package_name).to eq("project-1.2.3_2.x86_64.sh")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '#write_makeselfinst' do
|
47
|
-
it
|
47
|
+
it "generates the executable file", :not_supported_on_windows do
|
48
48
|
subject.write_makeselfinst
|
49
49
|
expect("#{staging_dir}/makeselfinst").to be_an_executable
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
52
|
+
it "has the correct content" do
|
53
53
|
subject.write_makeselfinst
|
54
54
|
contents = File.read("#{staging_dir}/makeselfinst")
|
55
55
|
|
56
|
-
expect(contents).to include(
|
56
|
+
expect(contents).to include("INSTALL_DIR=/opt/project")
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe '#write_scripts' do
|
61
|
-
let(:default_scripts) { %w
|
61
|
+
let(:default_scripts) { %w{ postinst } }
|
62
62
|
before do
|
63
63
|
default_scripts.each do |script_name|
|
64
64
|
create_file("#{project_root}/package-scripts/project/#{script_name}") do
|
@@ -67,7 +67,7 @@ module Omnibus
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
it
|
70
|
+
it "writes the scripts into the staging dir" do
|
71
71
|
subject.write_scripts
|
72
72
|
|
73
73
|
default_scripts.each do |script_name|
|
@@ -85,12 +85,12 @@ module Omnibus
|
|
85
85
|
allow(Dir).to receive(:chdir) { |_, &b| b.call }
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
88
|
+
it "logs a message" do
|
89
89
|
output = capture_logging { subject.create_makeself_package }
|
90
|
-
expect(output).to include(
|
90
|
+
expect(output).to include("Creating makeself package")
|
91
91
|
end
|
92
92
|
|
93
|
-
it
|
93
|
+
it "uses the correct command" do
|
94
94
|
expect(subject).to receive(:shellout!)
|
95
95
|
.with(/makeself\.sh/)
|
96
96
|
subject.create_makeself_package
|