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,14 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe PathFetcher do
|
5
|
-
let(:source_path) {
|
6
|
-
let(:project_dir) {
|
7
|
-
let(:build_dir) {
|
5
|
+
let(:source_path) { "/local/path" }
|
6
|
+
let(:project_dir) { "/project/dir" }
|
7
|
+
let(:build_dir) { "/build/dir" }
|
8
8
|
|
9
9
|
let(:manifest_entry) do
|
10
10
|
double(ManifestEntry,
|
11
|
-
name:
|
11
|
+
name: "software",
|
12
12
|
locked_version: nil,
|
13
13
|
described_version: nil,
|
14
14
|
locked_source: { path: source_path })
|
@@ -17,37 +17,37 @@ module Omnibus
|
|
17
17
|
subject { described_class.new(manifest_entry, project_dir, build_dir) }
|
18
18
|
|
19
19
|
describe '#fetch_required?' do
|
20
|
-
context
|
20
|
+
context "when the SHAs match" do
|
21
21
|
before do
|
22
|
-
allow(subject).to receive(:target_shasum).and_return(
|
23
|
-
allow(subject).to receive(:destination_shasum).and_return(
|
22
|
+
allow(subject).to receive(:target_shasum).and_return("abcd1234")
|
23
|
+
allow(subject).to receive(:destination_shasum).and_return("abcd1234")
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it "returns false" do
|
27
27
|
expect(subject.fetch_required?).to be(false)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
context
|
31
|
+
context "when the SHAs do not match" do
|
32
32
|
before do
|
33
|
-
allow(subject).to receive(:target_shasum).and_return(
|
34
|
-
allow(subject).to receive(:destination_shasum).and_return(
|
33
|
+
allow(subject).to receive(:target_shasum).and_return("abcd1234")
|
34
|
+
allow(subject).to receive(:destination_shasum).and_return("efgh5678")
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "returns true" do
|
38
38
|
expect(subject.fetch_required?).to be_truthy
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#version_guid' do
|
44
|
-
it
|
44
|
+
it "returns the path" do
|
45
45
|
expect(subject.version_guid).to eq("path:#{source_path}")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe '#clean' do
|
50
|
-
it
|
50
|
+
it "returns true" do
|
51
51
|
expect(subject.clean).to be_truthy
|
52
52
|
end
|
53
53
|
end
|
@@ -58,14 +58,14 @@ module Omnibus
|
|
58
58
|
allow(FileSyncer).to receive(:sync)
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
61
|
+
it "copies the new files over" do
|
62
62
|
expect(FileSyncer).to receive(:sync).with(source_path, project_dir, {})
|
63
63
|
subject.fetch
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '#version_for_cache' do
|
68
|
-
let(:shasum) {
|
68
|
+
let(:shasum) { "abcd1234" }
|
69
69
|
|
70
70
|
before do
|
71
71
|
allow(subject).to receive(:digest_directory)
|
@@ -73,7 +73,7 @@ module Omnibus
|
|
73
73
|
.and_return(shasum)
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it "returns the shasum of the source directory" do
|
77
77
|
expect(subject.version_for_cache).to eq("path:#{source_path}|shasum:#{shasum}")
|
78
78
|
end
|
79
79
|
end
|
data/spec/unit/generator_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Generator do
|
@@ -15,15 +15,15 @@ module Omnibus
|
|
15
15
|
let(:structure) do
|
16
16
|
Dir.glob("#{tmp_path}/**/*", File::FNM_DOTMATCH)
|
17
17
|
.sort
|
18
|
-
.reject { |path| %w
|
19
|
-
.map { |path| path.sub("#{tmp_path}/",
|
18
|
+
.reject { |path| %w{. ..}.include?(File.basename(path)) }
|
19
|
+
.map { |path| path.sub("#{tmp_path}/", "") }
|
20
20
|
end
|
21
21
|
|
22
|
-
context
|
23
|
-
it
|
24
|
-
Generator.new([
|
22
|
+
context "with no arguments" do
|
23
|
+
it "generates the proper file structure" do
|
24
|
+
Generator.new(["name"], path: tmp_path).invoke_all
|
25
25
|
|
26
|
-
expect(structure).to eq(%w
|
26
|
+
expect(structure).to eq(%w{
|
27
27
|
omnibus-name
|
28
28
|
omnibus-name/.gitignore
|
29
29
|
omnibus-name/.kitchen.local.yml
|
@@ -43,48 +43,48 @@ module Omnibus
|
|
43
43
|
omnibus-name/package-scripts/name/postrm
|
44
44
|
omnibus-name/package-scripts/name/preinst
|
45
45
|
omnibus-name/package-scripts/name/prerm
|
46
|
-
)
|
46
|
+
})
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
context
|
51
|
-
it
|
52
|
-
Generator.new([
|
50
|
+
context "with the --bff-assets flag" do
|
51
|
+
it "generates the proper file structure" do
|
52
|
+
Generator.new(["name"], path: tmp_path, bff_assets: true).invoke_all
|
53
53
|
|
54
|
-
expect(structure).to include(*%w
|
54
|
+
expect(structure).to include(*%w{
|
55
55
|
omnibus-name/resources/name/bff/gen.template.erb
|
56
|
-
)
|
56
|
+
})
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
context
|
61
|
-
it
|
62
|
-
Generator.new([
|
60
|
+
context "with the --deb-assets flag" do
|
61
|
+
it "generates the proper file structure" do
|
62
|
+
Generator.new(["name"], path: tmp_path, deb_assets: true).invoke_all
|
63
63
|
|
64
|
-
expect(structure).to include(*%w
|
64
|
+
expect(structure).to include(*%w{
|
65
65
|
omnibus-name/resources/name/deb/conffiles.erb
|
66
66
|
omnibus-name/resources/name/deb/control.erb
|
67
67
|
omnibus-name/resources/name/deb/md5sums.erb
|
68
|
-
)
|
68
|
+
})
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
context
|
73
|
-
it
|
74
|
-
Generator.new([
|
72
|
+
context "with the --dmg-assets flag" do
|
73
|
+
it "generates the proper file structure" do
|
74
|
+
Generator.new(["name"], path: tmp_path, dmg_assets: true).invoke_all
|
75
75
|
|
76
|
-
expect(structure).to include(*%w
|
76
|
+
expect(structure).to include(*%w{
|
77
77
|
omnibus-name/resources/name/dmg/background.png
|
78
78
|
omnibus-name/resources/name/dmg/icon.png
|
79
|
-
)
|
79
|
+
})
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
context
|
84
|
-
it
|
85
|
-
Generator.new([
|
83
|
+
context "with the --msi-assets flag" do
|
84
|
+
it "generates the proper file structure" do
|
85
|
+
Generator.new(["name"], path: tmp_path, msi_assets: true).invoke_all
|
86
86
|
|
87
|
-
expect(structure).to include(*%w
|
87
|
+
expect(structure).to include(*%w{
|
88
88
|
omnibus-name/resources/name/msi/assets/LICENSE.rtf
|
89
89
|
omnibus-name/resources/name/msi/assets/banner_background.bmp
|
90
90
|
omnibus-name/resources/name/msi/assets/dialog_background.bmp
|
@@ -94,32 +94,32 @@ module Omnibus
|
|
94
94
|
omnibus-name/resources/name/msi/localization-en-us.wxl.erb
|
95
95
|
omnibus-name/resources/name/msi/parameters.wxi.erb
|
96
96
|
omnibus-name/resources/name/msi/source.wxs.erb
|
97
|
-
)
|
97
|
+
})
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
context
|
102
|
-
it
|
103
|
-
Generator.new([
|
101
|
+
context "with the --pkg-assets flag" do
|
102
|
+
it "generates the proper file structure" do
|
103
|
+
Generator.new(["name"], path: tmp_path, pkg_assets: true).invoke_all
|
104
104
|
|
105
|
-
expect(structure).to include(*%w
|
105
|
+
expect(structure).to include(*%w{
|
106
106
|
omnibus-name/resources/name/pkg/background.png
|
107
107
|
omnibus-name/resources/name/pkg/license.html.erb
|
108
108
|
omnibus-name/resources/name/pkg/welcome.html.erb
|
109
109
|
omnibus-name/resources/name/pkg/distribution.xml.erb
|
110
|
-
)
|
110
|
+
})
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
context
|
115
|
-
it
|
116
|
-
Generator.new([
|
114
|
+
context "with the --rpm-assets flag" do
|
115
|
+
it "generates the proper file structure" do
|
116
|
+
Generator.new(["name"], path: tmp_path, rpm_assets: true).invoke_all
|
117
117
|
|
118
|
-
expect(structure).to include(*%w
|
118
|
+
expect(structure).to include(*%w{
|
119
119
|
omnibus-name/resources/name/rpm/rpmmacros.erb
|
120
120
|
omnibus-name/resources/name/rpm/signing.erb
|
121
121
|
omnibus-name/resources/name/rpm/spec.erb
|
122
|
-
)
|
122
|
+
})
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
data/spec/unit/git_cache_spec.rb
CHANGED
@@ -1,47 +1,49 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe GitCache do
|
5
5
|
let(:project) do
|
6
|
-
Project.new(
|
7
|
-
name
|
8
|
-
install_dir
|
6
|
+
Project.new("/path/to/demo.rb").evaluate do
|
7
|
+
name "demo"
|
8
|
+
install_dir "/opt/demo"
|
9
9
|
|
10
|
-
build_version
|
10
|
+
build_version "1.0.0"
|
11
11
|
|
12
|
-
maintainer
|
13
|
-
homepage
|
12
|
+
maintainer "Chef Software, Inc"
|
13
|
+
homepage "http://getchef.com"
|
14
14
|
|
15
|
-
dependency
|
16
|
-
dependency
|
17
|
-
dependency
|
15
|
+
dependency "preparation"
|
16
|
+
dependency "snoopy"
|
17
|
+
dependency "zlib"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
let(:install_dir) { project.install_dir }
|
22
22
|
|
23
23
|
let(:zlib) do
|
24
|
-
Software.new(project,
|
25
|
-
name
|
26
|
-
default_version
|
24
|
+
Software.new(project, "zlib.rb").evaluate do
|
25
|
+
name "zlib"
|
26
|
+
default_version "1.7.2"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
let(:snoopy) do
|
31
|
-
Software.new(project,
|
32
|
-
name
|
33
|
-
default_version
|
31
|
+
Software.new(project, "snoopy.rb").evaluate do
|
32
|
+
name "snoopy"
|
33
|
+
default_version "1.0.0"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
let(:preparation) do
|
38
|
-
Software.new(project,
|
39
|
-
name
|
40
|
-
default_version
|
38
|
+
Software.new(project, "preparation.rb").evaluate do
|
39
|
+
name "preparation"
|
40
|
+
default_version "1.0.0"
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
let(:cache_path) { File.join(
|
44
|
+
let(:cache_path) { File.join("/var/cache/omnibus/cache/git_cache", install_dir) }
|
45
|
+
|
46
|
+
let(:cache_serial_number) { described_class::SERIAL_NUMBER }
|
45
47
|
|
46
48
|
let(:ipc) do
|
47
49
|
project.library.component_added(preparation)
|
@@ -51,29 +53,29 @@ module Omnibus
|
|
51
53
|
end
|
52
54
|
|
53
55
|
describe '#cache_path' do
|
54
|
-
it
|
56
|
+
it "returns the install path appended to the install_cache path" do
|
55
57
|
expect(ipc.cache_path).to eq(cache_path)
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
59
61
|
describe '#tag' do
|
60
|
-
it
|
61
|
-
expect(ipc.tag).to eql(
|
62
|
+
it "returns the correct tag" do
|
63
|
+
expect(ipc.tag).to eql("zlib-24a8ec71da04059dcf7ed3c6e8e0fd9d155476abe4b5156d1f13c42e85478c2b-#{cache_serial_number}")
|
62
64
|
end
|
63
65
|
|
64
|
-
describe
|
66
|
+
describe "with no deps" do
|
65
67
|
let(:ipc) do
|
66
68
|
described_class.new(zlib)
|
67
69
|
end
|
68
70
|
|
69
|
-
it
|
70
|
-
expect(ipc.tag).to eql(
|
71
|
+
it "returns the correct tag" do
|
72
|
+
expect(ipc.tag).to eql("zlib-ee71fc1a512f03b9dd46c1fd9b5ab71fcc51b638857bf328496a31abb2654c2b-#{cache_serial_number}")
|
71
73
|
end
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
77
|
describe '#create_cache_path' do
|
76
|
-
it
|
78
|
+
it "runs git init if the cache path does not exist" do
|
77
79
|
allow(File).to receive(:directory?)
|
78
80
|
.with(ipc.cache_path)
|
79
81
|
.and_return(false)
|
@@ -87,7 +89,7 @@ module Omnibus
|
|
87
89
|
ipc.create_cache_path
|
88
90
|
end
|
89
91
|
|
90
|
-
it
|
92
|
+
it "does not run git init if the cache path exists" do
|
91
93
|
allow(File).to receive(:directory?)
|
92
94
|
.with(ipc.cache_path)
|
93
95
|
.and_return(true)
|
@@ -105,49 +107,49 @@ module Omnibus
|
|
105
107
|
allow(ipc).to receive(:create_cache_path)
|
106
108
|
end
|
107
109
|
|
108
|
-
it
|
110
|
+
it "creates the cache path" do
|
109
111
|
expect(ipc).to receive(:create_cache_path)
|
110
112
|
ipc.incremental
|
111
113
|
end
|
112
114
|
|
113
|
-
it
|
115
|
+
it "adds all the changes to git removing git directories" do
|
114
116
|
expect(ipc).to receive(:remove_git_dirs)
|
115
117
|
expect(ipc).to receive(:shellout!)
|
116
118
|
.with("git -c core.autocrlf=false --git-dir=#{cache_path} --work-tree=#{install_dir} add -A -f")
|
117
119
|
ipc.incremental
|
118
120
|
end
|
119
121
|
|
120
|
-
it
|
122
|
+
it "commits the backup for the software" do
|
121
123
|
expect(ipc).to receive(:shellout!)
|
122
|
-
.with(%Q
|
124
|
+
.with(%Q{git -c core.autocrlf=false --git-dir=#{cache_path} --work-tree=#{install_dir} commit -q -m "Backup of #{ipc.tag}"})
|
123
125
|
ipc.incremental
|
124
126
|
end
|
125
127
|
|
126
|
-
it
|
128
|
+
it "tags the software backup" do
|
127
129
|
expect(ipc).to receive(:shellout!)
|
128
|
-
.with(%Q
|
130
|
+
.with(%Q{git -c core.autocrlf=false --git-dir=#{cache_path} --work-tree=#{install_dir} tag -f "#{ipc.tag}"})
|
129
131
|
ipc.incremental
|
130
132
|
end
|
131
133
|
end
|
132
134
|
|
133
135
|
describe '#remove_git_dirs' do
|
134
|
-
let(:git_files) { [
|
135
|
-
it
|
136
|
-
allow(Dir).to receive(:glob).and_return([
|
136
|
+
let(:git_files) { ["git/HEAD", "git/description", "git/hooks", "git/info", "git/objects", "git/refs" ] }
|
137
|
+
it "removes bare git directories" do
|
138
|
+
allow(Dir).to receive(:glob).and_return(["git/config"])
|
137
139
|
git_files.each do |git_file|
|
138
140
|
expect(File).to receive(:exist?).with(git_file).and_return(true)
|
139
141
|
end
|
140
|
-
allow(File).to receive(:dirname).and_return(
|
141
|
-
expect(FileUtils).to receive(:rm_rf).with(
|
142
|
+
allow(File).to receive(:dirname).and_return("git")
|
143
|
+
expect(FileUtils).to receive(:rm_rf).with("git")
|
142
144
|
|
143
145
|
ipc.remove_git_dirs
|
144
146
|
end
|
145
147
|
|
146
|
-
it
|
147
|
-
allow(Dir).to receive(:glob).and_return([
|
148
|
-
expect(File).to receive(:exist?).with(
|
149
|
-
allow(File).to receive(:dirname).and_return(
|
150
|
-
expect(FileUtils).not_to receive(:rm_rf).with(
|
148
|
+
it "does ignores non git directories" do
|
149
|
+
allow(Dir).to receive(:glob).and_return(["not_git/config"])
|
150
|
+
expect(File).to receive(:exist?).with("not_git/HEAD").and_return(false)
|
151
|
+
allow(File).to receive(:dirname).and_return("not_git")
|
152
|
+
expect(FileUtils).not_to receive(:rm_rf).with("not_git")
|
151
153
|
|
152
154
|
ipc.remove_git_dirs
|
153
155
|
end
|
@@ -165,36 +167,36 @@ module Omnibus
|
|
165
167
|
|
166
168
|
before(:each) do
|
167
169
|
allow(ipc).to receive(:shellout!)
|
168
|
-
.with(%Q
|
170
|
+
.with(%Q{git -c core.autocrlf=false --git-dir=#{cache_path} --work-tree=#{install_dir} tag -l "#{ipc.tag}"})
|
169
171
|
.and_return(tag_cmd)
|
170
172
|
allow(ipc).to receive(:shellout!)
|
171
|
-
.with(%Q
|
173
|
+
.with(%Q{git -c core.autocrlf=false --git-dir=#{cache_path} --work-tree=#{install_dir} checkout -f "#{ipc.tag}"})
|
172
174
|
allow(ipc).to receive(:create_cache_path)
|
173
175
|
end
|
174
176
|
|
175
|
-
it
|
177
|
+
it "creates the cache path" do
|
176
178
|
expect(ipc).to receive(:create_cache_path)
|
177
179
|
ipc.restore
|
178
180
|
end
|
179
181
|
|
180
|
-
it
|
182
|
+
it "checks for a tag with the software and version, and if it finds it, checks it out" do
|
181
183
|
expect(ipc).to receive(:shellout!)
|
182
|
-
.with(%Q
|
184
|
+
.with(%Q{git -c core.autocrlf=false --git-dir=#{cache_path} --work-tree=#{install_dir} tag -l "#{ipc.tag}"})
|
183
185
|
.and_return(tag_cmd)
|
184
186
|
expect(ipc).to receive(:shellout!)
|
185
|
-
.with(%Q
|
187
|
+
.with(%Q{git -c core.autocrlf=false --git-dir=#{cache_path} --work-tree=#{install_dir} checkout -f "#{ipc.tag}"})
|
186
188
|
ipc.restore
|
187
189
|
end
|
188
190
|
|
189
|
-
describe
|
191
|
+
describe "if the tag does not exist" do
|
190
192
|
let(:git_tag_output) { "\n" }
|
191
193
|
|
192
|
-
it
|
194
|
+
it "does nothing" do
|
193
195
|
expect(ipc).to receive(:shellout!)
|
194
|
-
.with(%Q
|
196
|
+
.with(%Q{git -c core.autocrlf=false --git-dir=#{cache_path} --work-tree=#{install_dir} tag -l "#{ipc.tag}"})
|
195
197
|
.and_return(tag_cmd)
|
196
198
|
expect(ipc).to_not receive(:shellout!)
|
197
|
-
.with(%Q
|
199
|
+
.with(%Q{git -c core.autocrlf=false --git-dir=#{cache_path} --work-tree=#{install_dir} checkout -f "#{ipc.tag}"})
|
198
200
|
ipc.restore
|
199
201
|
end
|
200
202
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe GitRepository do
|
@@ -21,7 +21,7 @@ module Omnibus
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "returns an error if the tags don't exist" do
|
24
|
-
expect{git_repo.authors("1.0", "WUT")}.to raise_error(RuntimeError)
|
24
|
+
expect { git_repo.authors("1.0", "WUT") }.to raise_error(RuntimeError)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "pedump"
|
3
3
|
|
4
4
|
module Omnibus
|
5
5
|
describe HealthCheck do
|
6
6
|
let(:project) do
|
7
7
|
double(Project,
|
8
|
-
name:
|
9
|
-
install_dir:
|
8
|
+
name: "chefdk",
|
9
|
+
install_dir: "/opt/chefdk",
|
10
10
|
library: double(Library,
|
11
|
-
components: []
|
12
|
-
)
|
11
|
+
components: []
|
12
|
+
)
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
@@ -19,8 +19,8 @@ module Omnibus
|
|
19
19
|
x64?: x64,
|
20
20
|
ioh: double(x64 ? PEdump::IMAGE_OPTIONAL_HEADER64 : PEdump::IMAGE_OPTIONAL_HEADER32,
|
21
21
|
ImageBase: base,
|
22
|
-
SizeOfImage: size
|
23
|
-
)
|
22
|
+
SizeOfImage: size
|
23
|
+
)
|
24
24
|
)
|
25
25
|
expect(dump).to receive(:pe).and_return(pe)
|
26
26
|
dump
|
@@ -28,22 +28,22 @@ module Omnibus
|
|
28
28
|
|
29
29
|
subject { described_class.new(project) }
|
30
30
|
|
31
|
-
context
|
31
|
+
context "on windows" do
|
32
32
|
before do
|
33
|
-
stub_ohai(platform:
|
33
|
+
stub_ohai(platform: "windows", version: "2012")
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
37
|
-
stub_ohai(platform:
|
36
|
+
it "will perform dll base relocation checks" do
|
37
|
+
stub_ohai(platform: "windows", version: "2012")
|
38
38
|
expect(subject.relocation_checkable?).to be true
|
39
39
|
end
|
40
40
|
|
41
|
-
context
|
41
|
+
context "when performing dll base relocation checks" do
|
42
42
|
let(:pmdumps) do
|
43
43
|
{
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
"a" => mkdump(0x10000000, 0x00001000),
|
45
|
+
"b/b" => mkdump(0x20000000, 0x00002000),
|
46
|
+
"c/c/c" => mkdump(0x30000000, 0x00004000),
|
47
47
|
}
|
48
48
|
end
|
49
49
|
|
@@ -54,45 +54,45 @@ module Omnibus
|
|
54
54
|
pmdumps.each do |file, dump|
|
55
55
|
path = File.join(search_dir, file)
|
56
56
|
r.and_yield(path)
|
57
|
-
expect(File).to receive(:open).with(path,
|
57
|
+
expect(File).to receive(:open).with(path, "rb").and_yield(double(File))
|
58
58
|
expect(PEdump).to receive(:new).with(path).and_return(dump)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
context
|
63
|
-
it
|
62
|
+
context "when given non-overlapping dlls" do
|
63
|
+
it "should always return true" do
|
64
64
|
expect(subject.run!).to eq(true)
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
67
|
+
it "should not identify conflicts" do
|
68
68
|
expect(subject.relocation_check).to eq({})
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
context
|
72
|
+
context "when presented with overlapping dlls" do
|
73
73
|
let(:pmdumps) do
|
74
74
|
{
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
"a" => mkdump(0x10000000, 0x00001000),
|
76
|
+
"b/b" => mkdump(0x10000500, 0x00002000),
|
77
|
+
"c/c/c" => mkdump(0x30000000, 0x00004000),
|
78
78
|
}
|
79
79
|
end
|
80
80
|
|
81
|
-
it
|
81
|
+
it "should always return true" do
|
82
82
|
expect(subject.run!).to eq(true)
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it "should identify two conflicts" do
|
86
86
|
expect(subject.relocation_check).to eq({
|
87
|
-
|
87
|
+
"a" => {
|
88
88
|
base: 0x10000000,
|
89
89
|
size: 0x00001000,
|
90
|
-
conflicts: [
|
90
|
+
conflicts: [ "b" ],
|
91
91
|
},
|
92
|
-
|
92
|
+
"b" => {
|
93
93
|
base: 0x10000500,
|
94
94
|
size: 0x00002000,
|
95
|
-
conflicts: [
|
95
|
+
conflicts: [ "a" ],
|
96
96
|
},
|
97
97
|
})
|
98
98
|
end
|
@@ -100,12 +100,12 @@ module Omnibus
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
context
|
104
|
-
before { stub_ohai(platform:
|
103
|
+
context "on linux" do
|
104
|
+
before { stub_ohai(platform: "ubuntu", version: "12.04") }
|
105
105
|
|
106
106
|
let(:bad_healthcheck) do
|
107
|
-
double(
|
108
|
-
stdout: <<-EOH.gsub(/^ {12}/,
|
107
|
+
double("Mixlib::Shellout",
|
108
|
+
stdout: <<-EOH.gsub(/^ {12}/, "")
|
109
109
|
/bin/ls:
|
110
110
|
linux-vdso.so.1 => (0x00007fff583ff000)
|
111
111
|
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fad8592a000)
|
@@ -125,8 +125,8 @@ module Omnibus
|
|
125
125
|
end
|
126
126
|
|
127
127
|
let(:good_healthcheck) do
|
128
|
-
double(
|
129
|
-
stdout: <<-EOH.gsub(/^ {12}/,
|
128
|
+
double("Mixlib::Shellout",
|
129
|
+
stdout: <<-EOH.gsub(/^ {12}/, "")
|
130
130
|
/bin/echo:
|
131
131
|
linux-vdso.so.1 => (0x00007fff8a6ee000)
|
132
132
|
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f70f58c0000)
|
@@ -139,9 +139,9 @@ module Omnibus
|
|
139
139
|
)
|
140
140
|
end
|
141
141
|
|
142
|
-
let(:regexp) {".*(\\.[ch]|\\.e*rb|\\.gemspec|\\.gitignore|\\.h*h|\\.java|\\.js|\\.json|\\.lock|\\.log|\\.lua|\\.md|\\.mkd|\\.out|\\.pl|\\.pm|\\.png|\\.py[oc]*|\\.r*html|\\.rdoc|\\.ri|\\.sh|\\.sql|\\.toml|\\.ttf|\\.txt|\\.xml|\\.yml|Gemfile|LICENSE|README|Rakefile|VERSION)$|.*\\/share\\/doc\\/.*|.*\\/share\\/postgresql\\/.*|.*\\/share\\/terminfo\\/.*|.*\\/terminfo\\/.*"}
|
142
|
+
let(:regexp) { ".*(\\.[ch]|\\.e*rb|\\.gemspec|\\.gitignore|\\.h*h|\\.java|\\.js|\\.json|\\.lock|\\.log|\\.lua|\\.md|\\.mkd|\\.out|\\.pl|\\.pm|\\.png|\\.py[oc]*|\\.r*html|\\.rdoc|\\.ri|\\.sh|\\.sql|\\.toml|\\.ttf|\\.txt|\\.xml|\\.yml|Gemfile|LICENSE|README|Rakefile|VERSION)$|.*\\/share\\/doc\\/.*|.*\\/share\\/postgresql\\/.*|.*\\/share\\/terminfo\\/.*|.*\\/terminfo\\/.*" }
|
143
143
|
|
144
|
-
it
|
144
|
+
it "raises an exception when there are external dependencies" do
|
145
145
|
allow(subject).to receive(:shellout)
|
146
146
|
.with("find #{project.install_dir}/ -type f -regextype posix-extended ! -regex '#{regexp}' | xargs ldd")
|
147
147
|
.and_return(bad_healthcheck)
|
@@ -149,7 +149,7 @@ module Omnibus
|
|
149
149
|
expect { subject.run! }.to raise_error(HealthCheckFailed)
|
150
150
|
end
|
151
151
|
|
152
|
-
it
|
152
|
+
it "does not raise an exception when the healthcheck passes" do
|
153
153
|
allow(subject).to receive(:shellout)
|
154
154
|
.with("find #{project.install_dir}/ -type f -regextype posix-extended ! -regex '#{regexp}' | xargs ldd")
|
155
155
|
.and_return(good_healthcheck)
|
@@ -157,7 +157,7 @@ module Omnibus
|
|
157
157
|
expect { subject.run! }.to_not raise_error
|
158
158
|
end
|
159
159
|
|
160
|
-
it
|
160
|
+
it "will not perform dll base relocation checks" do
|
161
161
|
expect(subject.relocation_checkable?).to be false
|
162
162
|
end
|
163
163
|
end
|