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
data/spec/unit/omnibus_spec.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "omnibus"
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe Omnibus do
|
5
5
|
before do
|
6
6
|
allow(File).to receive(:directory?).and_return(true)
|
7
7
|
|
8
8
|
allow(Gem::Specification).to receive(:find_all_by_name)
|
9
|
-
.with(
|
10
|
-
.and_return([double(gem_dir: File.join(tmp_path,
|
9
|
+
.with("omnibus-software")
|
10
|
+
.and_return([double(gem_dir: File.join(tmp_path, "/gem/omnibus-software"))])
|
11
11
|
|
12
12
|
allow(Gem::Specification).to receive(:find_all_by_name)
|
13
|
-
.with(
|
14
|
-
.and_return([double(gem_dir: File.join(tmp_path,
|
13
|
+
.with("custom-omnibus-software")
|
14
|
+
.and_return([double(gem_dir: File.join(tmp_path, "/gem/custom-omnibus-software"))])
|
15
15
|
|
16
|
-
Omnibus::Config.project_root(File.join(tmp_path,
|
17
|
-
Omnibus::Config.local_software_dirs([File.join(tmp_path,
|
18
|
-
Omnibus::Config.software_gems([
|
16
|
+
Omnibus::Config.project_root(File.join(tmp_path, "/foo/bar"))
|
17
|
+
Omnibus::Config.local_software_dirs([File.join(tmp_path, "/local"), File.join(tmp_path, "/other")])
|
18
|
+
Omnibus::Config.software_gems(["omnibus-software", "custom-omnibus-software"])
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#which' do
|
22
|
-
it
|
23
|
-
stub_env(
|
24
|
-
expect(subject.which(
|
22
|
+
it "returns nil when the file does not exist" do
|
23
|
+
stub_env("PATH", nil)
|
24
|
+
expect(subject.which("not_a_real_executable")).to be nil
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it "returns the path when the file exists" do
|
28
28
|
|
29
|
-
ruby_cmd = windows? ?
|
29
|
+
ruby_cmd = windows? ? "ruby.exe" : "ruby"
|
30
30
|
ruby = Bundler.which(ruby_cmd)
|
31
31
|
expect(subject.which(ruby)).to eq(ruby)
|
32
32
|
expect(subject.which(ruby_cmd)).to eq(ruby)
|
@@ -36,50 +36,50 @@ describe Omnibus do
|
|
36
36
|
describe '#project_path' do
|
37
37
|
before do
|
38
38
|
allow(Omnibus).to receive(:project_map)
|
39
|
-
.and_return(
|
39
|
+
.and_return("chef" => "/projects/chef")
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
expect(subject.project_path(
|
42
|
+
it "accepts a string" do
|
43
|
+
expect(subject.project_path("chef")).to eq("/projects/chef")
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
47
|
-
expect(subject.project_path(:chef)).to eq(
|
46
|
+
it "accepts a symbol" do
|
47
|
+
expect(subject.project_path(:chef)).to eq("/projects/chef")
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
51
|
-
expect(subject.project_path(
|
50
|
+
it "returns nil when the project does not exist" do
|
51
|
+
expect(subject.project_path("bacon")).to be nil
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
describe '#software_path' do
|
56
56
|
before do
|
57
57
|
allow(Omnibus).to receive(:software_map)
|
58
|
-
.and_return(
|
58
|
+
.and_return("chef" => "/software/chef")
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
62
|
-
expect(subject.software_path(
|
61
|
+
it "accepts a string" do
|
62
|
+
expect(subject.software_path("chef")).to eq("/software/chef")
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
66
|
-
expect(subject.software_path(:chef)).to eq(
|
65
|
+
it "accepts a symbol" do
|
66
|
+
expect(subject.software_path(:chef)).to eq("/software/chef")
|
67
67
|
end
|
68
68
|
|
69
|
-
it
|
70
|
-
expect(subject.software_path(
|
69
|
+
it "returns nil when the project does not exist" do
|
70
|
+
expect(subject.software_path("bacon")).to be nil
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
describe '#possible_paths_for' do
|
75
|
-
it
|
76
|
-
expect(subject.possible_paths_for(
|
75
|
+
it "searches all paths" do
|
76
|
+
expect(subject.possible_paths_for("file")).to eq(%w{
|
77
77
|
/foo/bar/file
|
78
78
|
/local/file
|
79
79
|
/other/file
|
80
80
|
/gem/omnibus-software/file
|
81
81
|
/gem/custom-omnibus-software/file
|
82
|
-
|
82
|
+
}.map { |path| File.join(tmp_path, path) })
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
data/spec/unit/package_spec.rb
CHANGED
@@ -1,68 +1,68 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Package do
|
5
|
-
let(:path) { windows? ?
|
5
|
+
let(:path) { windows? ? "C:/path/to/files/thing.deb" : "/path/to/files/thing.deb" }
|
6
6
|
|
7
7
|
subject { described_class.new(path) }
|
8
8
|
|
9
|
-
describe
|
10
|
-
it
|
9
|
+
describe ".initialize" do
|
10
|
+
it "sets the path" do
|
11
11
|
expect(subject.instance_variables).to include(:@path)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#name' do
|
16
|
-
it
|
17
|
-
expect(subject.name).to eq(
|
16
|
+
it "returns the basename of the file" do
|
17
|
+
expect(subject.name).to eq("thing.deb")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#md5' do
|
22
|
-
let(:md5) {
|
22
|
+
let(:md5) { "abcdef123456" }
|
23
23
|
|
24
24
|
before { allow(subject).to receive(:digest).with(path, :md5).and_return(md5) }
|
25
25
|
|
26
|
-
it
|
26
|
+
it "returns the md5 of the package at the path" do
|
27
27
|
expect(subject.md5).to eq(md5)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '#sha256' do
|
32
|
-
let(:sha256) {
|
32
|
+
let(:sha256) { "abcdef123456" }
|
33
33
|
|
34
34
|
before { allow(subject).to receive(:digest).with(path, :sha256).and_return(sha256) }
|
35
35
|
|
36
|
-
it
|
36
|
+
it "returns the sha256 of the package at the path" do
|
37
37
|
expect(subject.sha256).to eq(sha256)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe '#sha512' do
|
42
|
-
let(:sha512) {
|
42
|
+
let(:sha512) { "abcdef123456" }
|
43
43
|
|
44
44
|
before { allow(subject).to receive(:digest).with(path, :sha512).and_return(sha512) }
|
45
45
|
|
46
|
-
it
|
46
|
+
it "returns the sha512 of the package at the path" do
|
47
47
|
expect(subject.sha512).to eq(sha512)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe '#content' do
|
52
|
-
context
|
53
|
-
let(:content) {
|
52
|
+
context "when the file exists" do
|
53
|
+
let(:content) { "BINARY" }
|
54
54
|
|
55
55
|
before { allow(IO).to receive(:read).with(path).and_return(content) }
|
56
56
|
|
57
|
-
it
|
57
|
+
it "reads the file" do
|
58
58
|
expect(subject.content).to eq(content)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
context
|
62
|
+
context "when the file does not exist" do
|
63
63
|
before { allow(IO).to receive(:read).and_raise(Errno::ENOENT) }
|
64
64
|
|
65
|
-
it
|
65
|
+
it "raises an exception" do
|
66
66
|
expect { subject.content }.to raise_error(NoPackageFile)
|
67
67
|
end
|
68
68
|
end
|
@@ -73,12 +73,12 @@ module Omnibus
|
|
73
73
|
|
74
74
|
before { allow(IO).to receive(:read).and_return(content) }
|
75
75
|
|
76
|
-
it
|
76
|
+
it "returns a Metadata object" do
|
77
77
|
expect(subject.metadata).to be_a(Metadata)
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
81
|
-
expect(subject.metadata[:platform]).to eq(
|
80
|
+
it "reads the information in the file" do
|
81
|
+
expect(subject.metadata[:platform]).to eq("ubuntu")
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
data/spec/unit/packager_spec.rb
CHANGED
@@ -1,63 +1,69 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Packager do
|
5
|
-
describe
|
6
|
-
context
|
7
|
-
before { stub_ohai(platform:
|
8
|
-
it
|
9
|
-
|
10
|
-
|
5
|
+
describe ".for_current_system" do
|
6
|
+
context "on Mac OS X" do
|
7
|
+
before { stub_ohai(platform: "mac_os_x", version: "10.9.2") }
|
8
|
+
it "prefers PKG" do
|
9
|
+
expect(described_class.for_current_system).to eq([Packager::PKG])
|
10
|
+
end
|
11
11
|
end
|
12
12
|
|
13
|
-
context
|
14
|
-
before { stub_ohai(platform:
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
context "on Windows 2012" do
|
14
|
+
before { stub_ohai(platform: "windows", version: "2012") }
|
15
|
+
it "prefers MSI and APPX" do
|
16
|
+
expect(described_class.for_current_system).to eq([Packager::MSI, Packager::APPX])
|
17
|
+
end
|
18
18
|
end
|
19
19
|
|
20
|
-
context
|
21
|
-
before { stub_ohai(platform:
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
context "on Windows 2008 R2" do
|
21
|
+
before { stub_ohai(platform: "windows", version: "2008R2") }
|
22
|
+
it "prefers MSI only" do
|
23
|
+
expect(described_class.for_current_system).to eq([Packager::MSI])
|
24
|
+
end
|
25
25
|
end
|
26
26
|
|
27
|
-
context
|
28
|
-
before { stub_ohai(platform:
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
context "on Solaris 11" do
|
28
|
+
before { stub_ohai(platform: "solaris2", version: "5.11") }
|
29
|
+
it "prefers IPS" do
|
30
|
+
expect(described_class.for_current_system).to eq([Packager::IPS])
|
31
|
+
end
|
32
32
|
end
|
33
33
|
|
34
|
+
context "on Solaris 10" do
|
35
|
+
before { stub_ohai(platform: "solaris2", version: "5.10") }
|
36
|
+
it "prefers Solaris" do
|
37
|
+
expect(described_class.for_current_system).to eq([Packager::Solaris])
|
38
|
+
end
|
39
|
+
end
|
34
40
|
|
35
|
-
context
|
36
|
-
before { stub_ohai(platform:
|
37
|
-
|
38
|
-
|
39
|
-
|
41
|
+
context "on aix" do
|
42
|
+
before { stub_ohai(platform: "aix", version: "7.1") }
|
43
|
+
it "prefers BFF" do
|
44
|
+
expect(described_class.for_current_system).to eq([Packager::BFF])
|
45
|
+
end
|
40
46
|
end
|
41
47
|
|
42
|
-
context
|
43
|
-
before { stub_ohai(platform:
|
44
|
-
|
45
|
-
|
46
|
-
|
48
|
+
context "on fedora" do
|
49
|
+
before { stub_ohai(platform: "fedora", version: "20") }
|
50
|
+
it "prefers RPM" do
|
51
|
+
expect(described_class.for_current_system).to eq([Packager::RPM])
|
52
|
+
end
|
47
53
|
end
|
48
54
|
|
49
|
-
context
|
50
|
-
before { stub_ohai(platform:
|
51
|
-
|
52
|
-
|
53
|
-
|
55
|
+
context "on debian" do
|
56
|
+
before { stub_ohai(platform: "debian", version: "7.2") }
|
57
|
+
it "prefers RPM" do
|
58
|
+
expect(described_class.for_current_system).to eq([Packager::DEB])
|
59
|
+
end
|
54
60
|
end
|
55
61
|
|
56
|
-
context
|
57
|
-
before { stub_ohai(platform:
|
58
|
-
|
59
|
-
|
60
|
-
|
62
|
+
context "on suse" do
|
63
|
+
before { stub_ohai(platform: "suse", version: "12.0") }
|
64
|
+
it "prefers RPM" do
|
65
|
+
expect(described_class.for_current_system).to eq([Packager::RPM])
|
66
|
+
end
|
61
67
|
end
|
62
68
|
end
|
63
69
|
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Omnibus
|
4
|
+
describe Packager::APPX do
|
5
|
+
let(:project) do
|
6
|
+
Project.new.tap do |project|
|
7
|
+
project.name("project")
|
8
|
+
project.homepage("https://example.com")
|
9
|
+
project.install_dir(install_dir)
|
10
|
+
project.build_version("1.2.3")
|
11
|
+
project.build_iteration("2")
|
12
|
+
project.maintainer("Chef Software <maintainers@chef.io>")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
subject { described_class.new(project) }
|
17
|
+
|
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
|
+
let(:install_dir) { File.join(tmp_path, "install/dir") }
|
22
|
+
|
23
|
+
before do
|
24
|
+
Config.project_root(project_root)
|
25
|
+
Config.package_dir(package_dir)
|
26
|
+
|
27
|
+
allow(subject).to receive(:staging_dir).and_return(staging_dir)
|
28
|
+
create_directory(install_dir)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "DSL" do
|
32
|
+
it "exposes :signing_identity" do
|
33
|
+
expect(subject).to have_exposed_method(:signing_identity)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#id' do
|
38
|
+
it "is :pkg" do
|
39
|
+
expect(subject.id).to eq(:appx)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#package_name' do
|
44
|
+
it "includes the name, version, and build iteration" do
|
45
|
+
expect(subject.package_name).to eq("project-1.2.3-2.appx")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#write_manifest_file' do
|
50
|
+
before do
|
51
|
+
allow(subject).to receive(:shellout!).and_return(double("output", stdout: "CN=Chef "))
|
52
|
+
allow(subject).to receive(:signing_identity).and_return({})
|
53
|
+
end
|
54
|
+
|
55
|
+
it "generates the file" do
|
56
|
+
subject.write_manifest_file
|
57
|
+
expect("#{install_dir}/AppxManifest.xml").to be_a_file
|
58
|
+
end
|
59
|
+
|
60
|
+
it "has the correct content" do
|
61
|
+
subject.write_manifest_file
|
62
|
+
contents = File.read("#{install_dir}/AppxManifest.xml")
|
63
|
+
|
64
|
+
expect(contents).to include('Name="project"')
|
65
|
+
expect(contents).to include('Version="1.2.3.2"')
|
66
|
+
expect(contents).to include('Publisher="CN=Chef"')
|
67
|
+
expect(contents).to include("<DisplayName>Project</DisplayName>")
|
68
|
+
expect(contents).to include(
|
69
|
+
'<PublisherDisplayName>"Chef Software <maintainers@chef.io>"</PublisherDisplayName>'
|
70
|
+
)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#windows_package_version' do
|
75
|
+
context "when the project build_version semver" do
|
76
|
+
it "returns the right value" do
|
77
|
+
expect(subject.windows_package_version).to eq("1.2.3.2")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when the project build_version is git" do
|
82
|
+
before { project.build_version("1.2.3-alpha.1+20140501194641.git.94.561b564") }
|
83
|
+
|
84
|
+
it "returns the right value" do
|
85
|
+
expect(subject.windows_package_version).to eq("1.2.3.2")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#pack_command' do
|
91
|
+
it "returns a String" do
|
92
|
+
expect(subject.pack_command("foo")).to be_a(String)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "packages install directory" do
|
96
|
+
expect(subject.pack_command("foo")).to(
|
97
|
+
include("/d \"#{subject.windows_safe_path(install_dir)}\"")
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "writes to the given appx file" do
|
102
|
+
expect(subject.pack_command("foo")).to include("/p foo")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "when signing parameters are provided" do
|
107
|
+
let(:appx) { "someappx.appx" }
|
108
|
+
|
109
|
+
context "when invalid parameters" do
|
110
|
+
it "should raise an InvalidValue error when the certificate name is not a String" do
|
111
|
+
expect { subject.signing_identity(Object.new) }.to raise_error(InvalidValue)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should raise an InvalidValue error when params is not a Hash" do
|
115
|
+
expect { subject.signing_identity("foo", Object.new) }.to raise_error(InvalidValue)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should raise an InvalidValue error when params contains an invalid key" do
|
119
|
+
expect { subject.signing_identity("foo", bar: "baz") }.to raise_error(InvalidValue)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "when valid parameters" do
|
124
|
+
before do
|
125
|
+
allow(subject).to receive(:shellout!)
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#timestamp_servers' do
|
129
|
+
it "defaults to using ['http://timestamp.digicert.com','http://timestamp.verisign.com/scripts/timestamp.dll']" do
|
130
|
+
subject.signing_identity("foo")
|
131
|
+
expect(subject).to receive(:try_sign).with(appx, "http://timestamp.digicert.com").and_return(false)
|
132
|
+
expect(subject).to receive(:try_sign).with(appx, "http://timestamp.verisign.com/scripts/timestamp.dll").and_return(true)
|
133
|
+
subject.sign_package(appx)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'uses the timestamp server if provided through the #timestamp_server dsl' do
|
137
|
+
subject.signing_identity("foo", timestamp_servers: "http://fooserver")
|
138
|
+
expect(subject).to receive(:try_sign).with(appx, "http://fooserver").and_return(true)
|
139
|
+
subject.sign_package(appx)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'tries all timestamp server if provided through the #timestamp_server dsl' do
|
143
|
+
subject.signing_identity("foo", timestamp_servers: ["http://fooserver", "http://barserver"])
|
144
|
+
expect(subject).to receive(:try_sign).with(appx, "http://fooserver").and_return(false)
|
145
|
+
expect(subject).to receive(:try_sign).with(appx, "http://barserver").and_return(true)
|
146
|
+
subject.sign_package(appx)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'tries all timestamp server if provided through the #timestamp_servers dsl and stops at the first available' do
|
150
|
+
subject.signing_identity("foo", timestamp_servers: ["http://fooserver", "http://barserver"])
|
151
|
+
expect(subject).to receive(:try_sign).with(appx, "http://fooserver").and_return(true)
|
152
|
+
expect(subject).not_to receive(:try_sign).with(appx, "http://barserver")
|
153
|
+
subject.sign_package(appx)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "raises an exception if there are no available timestamp servers" do
|
157
|
+
subject.signing_identity("foo", timestamp_servers: "http://fooserver")
|
158
|
+
expect(subject).to receive(:try_sign).with(appx, "http://fooserver").and_return(false)
|
159
|
+
expect { subject.sign_package(appx) }.to raise_error(FailedToSignWindowsPackage)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -1,60 +1,60 @@
|
|
1
|
-
require
|
1
|
+
require "stringio"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Packager::Base do
|
5
5
|
let(:project) do
|
6
6
|
Project.new.tap do |project|
|
7
|
-
project.name(
|
8
|
-
project.install_dir(File.join(tmp_path,
|
9
|
-
project.homepage(
|
10
|
-
project.build_version(
|
11
|
-
project.build_iteration(
|
12
|
-
project.maintainer(
|
7
|
+
project.name("project")
|
8
|
+
project.install_dir(File.join(tmp_path, "opt/project"))
|
9
|
+
project.homepage("https://example.com")
|
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
|
before do
|
17
17
|
# Force the Dir.mktmpdir call on staging_dir
|
18
|
-
allow(Dir).to receive(:mktmpdir).and_return(File.join(tmp_path,
|
18
|
+
allow(Dir).to receive(:mktmpdir).and_return(File.join(tmp_path, "tmp/dir"))
|
19
19
|
|
20
20
|
Config.package_dir(tmp_path)
|
21
21
|
end
|
22
22
|
|
23
23
|
subject { described_class.new(project) }
|
24
24
|
|
25
|
-
it
|
25
|
+
it "includes Cleanroom" do
|
26
26
|
expect(subject).to be_a(Cleanroom)
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it "includes Digestable" do
|
30
30
|
expect(subject).to be_a(Digestable)
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it "includes Logging" do
|
34
34
|
expect(subject).to be_a(Logging)
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "includes NullArgumentable" do
|
38
38
|
expect(subject).to be_a(NullArgumentable)
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it "includes Templating" do
|
42
42
|
expect(subject).to be_a(Templating)
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it "includes Util" do
|
46
46
|
expect(subject).to be_a(Util)
|
47
47
|
end
|
48
48
|
|
49
|
-
describe
|
50
|
-
it
|
49
|
+
describe ".id" do
|
50
|
+
it "defines the id method on the instance" do
|
51
51
|
described_class.id(:base)
|
52
52
|
expect(subject.id).to eq(:base)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
57
|
-
it
|
56
|
+
describe ".setup" do
|
57
|
+
it "sets the value of the block" do
|
58
58
|
block = proc {}
|
59
59
|
described_class.setup(&block)
|
60
60
|
|
@@ -62,8 +62,8 @@ module Omnibus
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
describe
|
66
|
-
it
|
65
|
+
describe ".build" do
|
66
|
+
it "sets the value of the block" do
|
67
67
|
block = proc {}
|
68
68
|
described_class.build(&block)
|
69
69
|
|
@@ -72,17 +72,17 @@ module Omnibus
|
|
72
72
|
end
|
73
73
|
|
74
74
|
describe '#install_dir' do
|
75
|
-
it
|
75
|
+
it "is a DSL method" do
|
76
76
|
expect(subject).to have_exposed_method(:install_dir)
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
79
|
+
it "returns the project instances install_dir" do
|
80
80
|
expect(subject.install_dir).to eq(project.install_dir)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
describe '#windows_safe_path' do
|
85
|
-
it
|
85
|
+
it "is a DSL method" do
|
86
86
|
expect(subject).to have_exposed_method(:windows_safe_path)
|
87
87
|
end
|
88
88
|
end
|
@@ -95,10 +95,10 @@ module Omnibus
|
|
95
95
|
allow(described_class).to receive(:setup).and_return(proc {})
|
96
96
|
allow(described_class).to receive(:build).and_return(proc {})
|
97
97
|
|
98
|
-
allow(subject).to receive(:package_name).and_return(
|
98
|
+
allow(subject).to receive(:package_name).and_return("foo")
|
99
99
|
end
|
100
100
|
|
101
|
-
it
|
101
|
+
it "calls the methods in order" do
|
102
102
|
expect(described_class).to receive(:setup).ordered
|
103
103
|
expect(described_class).to receive(:build).ordered
|
104
104
|
subject.run!
|
@@ -106,7 +106,7 @@ module Omnibus
|
|
106
106
|
end
|
107
107
|
|
108
108
|
describe '#staging_dir' do
|
109
|
-
it
|
109
|
+
it "creates a temporary directory" do
|
110
110
|
expect(Dir).to receive(:mktmpdir)
|
111
111
|
subject.send(:staging_dir)
|
112
112
|
end
|
@@ -116,8 +116,8 @@ module Omnibus
|
|
116
116
|
let(:id) { :base }
|
117
117
|
before { allow(subject).to receive(:id).and_return(id) }
|
118
118
|
|
119
|
-
context
|
120
|
-
let(:resources_path) { File.join(tmp_path,
|
119
|
+
context "when a local resource exists" do
|
120
|
+
let(:resources_path) { File.join(tmp_path, "/resources/path") }
|
121
121
|
|
122
122
|
before do
|
123
123
|
project.resources_path(resources_path)
|
@@ -127,18 +127,18 @@ module Omnibus
|
|
127
127
|
.and_return(true)
|
128
128
|
end
|
129
129
|
|
130
|
-
it
|
131
|
-
expect(subject.resource_path(
|
130
|
+
it "returns the local path" do
|
131
|
+
expect(subject.resource_path("foo/bar.erb")).to eq("#{resources_path}/#{id}/foo/bar.erb")
|
132
132
|
end
|
133
133
|
|
134
|
-
it
|
134
|
+
it "returns the path with the id" do
|
135
135
|
expect(subject.resources_path).to eq("#{resources_path}/#{id}")
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
context
|
140
|
-
it
|
141
|
-
expect(subject.resource_path(
|
139
|
+
context "when a local resource does not exist" do
|
140
|
+
it "returns the remote path" do
|
141
|
+
expect(subject.resource_path("foo/bar.erb")).to eq("#{Omnibus.source_root.join("resources/#{id}/foo/bar.erb")}")
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|