omnibus 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -1
- data/.travis.yml +11 -3
- data/CHANGELOG.md +39 -1
- data/Gemfile +0 -4
- data/README.md +10 -8
- data/Rakefile +18 -7
- data/bin/omnibus +3 -3
- data/docs/Building on Windows.md +98 -0
- data/features/commands/_deprecated.feature +46 -0
- data/features/commands/build.feature +9 -0
- data/features/commands/clean.feature +21 -0
- data/features/commands/list.feature +16 -0
- data/features/commands/new.feature +8 -0
- data/features/commands/version.feature +12 -0
- data/features/step_definitions/generator_steps.rb +28 -0
- data/features/support/env.rb +13 -0
- data/lib/omnibus.rb +319 -240
- data/lib/omnibus/artifact.rb +16 -0
- data/lib/omnibus/build_version.rb +39 -20
- data/lib/omnibus/build_version_dsl.rb +136 -0
- data/lib/omnibus/builder.rb +28 -23
- data/lib/omnibus/cleaner.rb +72 -0
- data/lib/omnibus/cli.rb +115 -11
- data/lib/omnibus/cli/base.rb +82 -81
- data/lib/omnibus/cli/cache.rb +80 -32
- data/lib/omnibus/cli/deprecated.rb +79 -0
- data/lib/omnibus/cli/release.rb +17 -21
- data/lib/omnibus/config.rb +38 -13
- data/lib/omnibus/exceptions.rb +70 -18
- data/lib/omnibus/fetcher.rb +18 -11
- data/lib/omnibus/fetchers/git_fetcher.rb +48 -53
- data/lib/omnibus/fetchers/net_fetcher.rb +29 -27
- data/lib/omnibus/fetchers/path_fetcher.rb +9 -12
- data/lib/omnibus/fetchers/s3_cache_fetcher.rb +5 -8
- data/lib/omnibus/generator.rb +131 -0
- data/lib/omnibus/{templates → generator_files}/.kitchen.local.yml.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/.kitchen.yml.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/Berksfile.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/Gemfile.erb +2 -2
- data/lib/omnibus/{templates → generator_files}/README.md.erb +6 -7
- data/lib/omnibus/{templates → generator_files}/Vagrantfile.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/gitignore.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/mac_dmg/background.png +0 -0
- data/lib/omnibus/{templates → generator_files}/mac_dmg/icon.png +0 -0
- data/lib/omnibus/{templates → generator_files}/mac_pkg/background.png +0 -0
- data/lib/omnibus/{templates → generator_files}/mac_pkg/license.html.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/mac_pkg/welcome.html.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/omnibus.rb.example.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/package_scripts/makeselfinst.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/package_scripts/postinst.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/package_scripts/postrm.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/package_scripts/preinst.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/package_scripts/prerm.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/project.rb.erb +0 -1
- data/lib/omnibus/{templates → generator_files}/software/c-example.rb.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/software/erlang-example.rb.erb +0 -0
- data/lib/omnibus/{templates → generator_files}/software/ruby-example.rb.erb +0 -0
- data/lib/omnibus/generator_files/windows_msi/assets/LICENSE.rtf +8 -0
- data/lib/omnibus/generator_files/windows_msi/assets/banner_background.bmp +0 -0
- data/lib/omnibus/generator_files/windows_msi/assets/dialog_background.bmp +0 -0
- data/lib/omnibus/generator_files/windows_msi/assets/project.ico +0 -0
- data/lib/omnibus/generator_files/windows_msi/assets/project_16x16.ico +0 -0
- data/lib/omnibus/generator_files/windows_msi/assets/project_32x32.ico +0 -0
- data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +20 -0
- data/lib/omnibus/generator_files/windows_msi/parameters.wxi.erb +9 -0
- data/lib/omnibus/generator_files/windows_msi/source.wxs.erb +74 -0
- data/lib/omnibus/health_check.rb +80 -40
- data/lib/omnibus/install_path_cache.rb +11 -12
- data/lib/omnibus/library.rb +30 -3
- data/lib/omnibus/logger.rb +47 -0
- data/lib/omnibus/logging.rb +60 -0
- data/lib/omnibus/null_builder.rb +23 -0
- data/lib/omnibus/ohai.rb +70 -0
- data/lib/omnibus/overrides.rb +69 -48
- data/lib/omnibus/package_release.rb +7 -14
- data/lib/omnibus/packagers/base.rb +66 -13
- data/lib/omnibus/packagers/mac_dmg.rb +23 -3
- data/lib/omnibus/packagers/mac_pkg.rb +20 -10
- data/lib/omnibus/packagers/windows_msi.rb +109 -0
- data/lib/omnibus/project.rb +136 -79
- data/lib/omnibus/reports.rb +1 -2
- data/lib/omnibus/{s3_cacher.rb → s3_cache.rb} +15 -37
- data/lib/omnibus/software.rb +77 -27
- data/lib/omnibus/software_s3_urls.rb +50 -0
- data/lib/omnibus/sugar.rb +1 -3
- data/lib/omnibus/util.rb +45 -18
- data/lib/omnibus/version.rb +2 -3
- data/omnibus.gemspec +5 -3
- data/spec/data/complicated/config/patches/bzip2/makefile_take_env_vars.patch +15 -0
- data/spec/data/complicated/config/patches/couchdb/patch_for_couchjs_stack.patch +19 -0
- data/spec/data/complicated/config/patches/gd/gd-2.0.33-configure-libpng.patch +100 -0
- data/spec/data/complicated/config/patches/keepalived/keepalived-1.2.9_opscode_centos_5.patch +15 -0
- data/spec/data/complicated/config/patches/libedit/freebsd-vi-fix.patch +24 -0
- data/spec/data/complicated/config/patches/libiconv/libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch +29 -0
- data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-makefile-dest-fix.patch +35 -0
- data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-malloc-fix.patch +13 -0
- data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-shared_lib_plus_plus-1.patch +1035 -0
- data/spec/data/complicated/config/patches/logrotate/logrotate_basedir_override.patch +12 -0
- data/spec/data/complicated/config/patches/ncurses/ncurses-5.9-solaris-xopen_source_extended-detection.patch +11 -0
- data/spec/data/complicated/config/patches/ncurses/ncurses-clang.patch +42 -0
- data/spec/data/complicated/config/patches/ncurses/patch-aa +23 -0
- data/spec/data/complicated/config/patches/ncurses/patch-ab +44 -0
- data/spec/data/complicated/config/patches/ncurses/patch-ac +40 -0
- data/spec/data/complicated/config/patches/ncurses/patch-ad +12 -0
- data/spec/data/complicated/config/patches/ncurses/patch-aix-configure +23 -0
- data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesf.h +22 -0
- data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesm.h +22 -0
- data/spec/data/complicated/config/patches/nrpe/fix_for_runit.patch +64 -0
- data/spec/data/complicated/config/patches/openssl/openssl-1.0.1f-do-not-build-docs.patch +101 -0
- data/spec/data/complicated/config/patches/postgresql/postgresql-9.1.2-configure-ncurses-fix.patch +12 -0
- data/spec/data/complicated/config/patches/ruby/patch-configure +103 -0
- data/spec/data/complicated/config/patches/ruby/ruby-aix-configure.patch +10 -0
- data/spec/data/complicated/config/patches/ruby/ruby-openssl-1.0.1c.patch +42 -0
- data/spec/data/complicated/config/patches/ruby/ruby_aix_1_9_3_448_ssl_EAGAIN.patch +57 -0
- data/spec/data/complicated/config/patches/ruby/rvm-cflags.patch +27 -0
- data/spec/data/complicated/config/projects/angrychef.rb +32 -0
- data/spec/data/complicated/config/projects/chef-windows.rb +32 -0
- data/spec/data/complicated/config/projects/chef.rb +32 -0
- data/spec/data/complicated/config/projects/chefdk-windows.rb +41 -0
- data/spec/data/complicated/config/projects/chefdk.rb +44 -0
- data/spec/data/complicated/config/software/appbundler.rb +25 -0
- data/spec/data/complicated/config/software/autoconf.rb +35 -0
- data/spec/data/complicated/config/software/automake.rb +39 -0
- data/spec/data/complicated/config/software/berkshelf.rb +44 -0
- data/{lib/omnibus/fetchers.rb → spec/data/complicated/config/software/bundler.rb} +8 -5
- data/spec/data/complicated/config/software/bzip2.rb +46 -0
- data/spec/data/complicated/config/software/cacerts.rb +44 -0
- data/spec/data/complicated/config/software/chef-client-msi.rb +88 -0
- data/spec/data/complicated/config/software/chef-gem.rb +26 -0
- data/spec/data/complicated/config/software/chef-vault.rb +43 -0
- data/spec/data/complicated/config/software/chef-windows.rb +158 -0
- data/spec/data/complicated/config/software/chef.rb +170 -0
- data/spec/data/complicated/config/software/chefdk.rb +103 -0
- data/spec/data/complicated/config/software/couchdb.rb +53 -0
- data/spec/data/complicated/config/software/curl.rb +48 -0
- data/spec/data/complicated/config/software/erlang.rb +65 -0
- data/spec/data/complicated/config/software/expat.rb +21 -0
- data/spec/data/complicated/config/software/fcgi.rb +56 -0
- data/spec/data/complicated/config/software/fcgiwrap.rb +41 -0
- data/spec/data/complicated/config/software/gd.rb +56 -0
- data/spec/data/complicated/config/software/gdbm.rb +40 -0
- data/spec/data/complicated/config/software/gecode.rb +48 -0
- data/spec/data/complicated/config/software/git.rb +40 -0
- data/spec/data/complicated/config/software/help2man.rb +30 -0
- data/spec/data/complicated/config/software/icu.rb +40 -0
- data/spec/data/complicated/config/software/jre.rb +48 -0
- data/spec/data/complicated/config/software/keepalived.rb +43 -0
- data/spec/data/complicated/config/software/libarchive.rb +50 -0
- data/spec/data/complicated/config/software/libedit.rb +69 -0
- data/spec/data/complicated/config/software/libffi.rb +71 -0
- data/spec/data/complicated/config/software/libgcc.rb +39 -0
- data/spec/data/complicated/config/software/libiconv.rb +66 -0
- data/spec/data/complicated/config/software/libjpeg.rb +39 -0
- data/spec/data/complicated/config/software/libpng.rb +38 -0
- data/spec/data/complicated/config/software/libtool.rb +52 -0
- data/spec/data/complicated/config/software/libwrap.rb +50 -0
- data/spec/data/complicated/config/software/libxml2.rb +51 -0
- data/spec/data/complicated/config/software/libxslt.rb +52 -0
- data/spec/data/complicated/config/software/libyaml-windows.rb +43 -0
- data/spec/data/complicated/config/software/libyaml.rb +62 -0
- data/spec/data/complicated/config/software/logrotate.rb +41 -0
- data/spec/data/complicated/config/software/makedepend.rb +73 -0
- data/spec/data/complicated/config/software/mysql2.rb +42 -0
- data/spec/data/complicated/config/software/nagios-plugins.rb +53 -0
- data/spec/data/complicated/config/software/nagios.rb +66 -0
- data/spec/data/complicated/config/software/ncurses.rb +149 -0
- data/spec/data/complicated/config/software/nginx.rb +40 -0
- data/spec/data/complicated/config/software/nodejs.rb +44 -0
- data/spec/data/complicated/config/software/nokogiri.rb +55 -0
- data/spec/data/complicated/config/software/nrpe.rb +61 -0
- data/spec/data/complicated/config/software/ohai.rb +64 -0
- data/spec/data/complicated/config/software/omnibus-ctl.rb +34 -0
- data/spec/data/complicated/config/software/openresty.rb +67 -0
- data/spec/data/complicated/config/software/openssl.rb +158 -0
- data/spec/data/complicated/config/software/pcre.rb +42 -0
- data/spec/data/complicated/config/software/perl-extutils-embed.rb +15 -0
- data/spec/data/complicated/config/software/perl-extutils-makemaker.rb +15 -0
- data/spec/data/complicated/config/software/perl.rb +48 -0
- data/spec/data/complicated/config/software/perl_pg_driver.rb +12 -0
- data/spec/data/complicated/config/software/php.rb +41 -0
- data/spec/data/complicated/config/software/pip.rb +30 -0
- data/spec/data/complicated/config/software/pkg-config.rb +66 -0
- data/spec/data/complicated/config/software/popt.rb +47 -0
- data/spec/data/complicated/config/software/postgresql.rb +51 -0
- data/spec/data/complicated/config/software/preparation.rb +30 -0
- data/spec/data/complicated/config/software/pygments.rb +25 -0
- data/spec/data/complicated/config/software/python.rb +49 -0
- data/spec/data/complicated/config/software/rabbitmq.rb +36 -0
- data/spec/data/complicated/config/software/rebar.rb +36 -0
- data/spec/data/complicated/config/software/redis.rb +33 -0
- data/spec/data/complicated/config/software/rsync.rb +48 -0
- data/spec/data/complicated/config/software/ruby-windows-devkit.rb +30 -0
- data/spec/data/complicated/config/software/ruby-windows.rb +30 -0
- data/spec/data/complicated/config/software/ruby.rb +162 -0
- data/spec/data/complicated/config/software/rubygems-customization.rb +57 -0
- data/spec/data/complicated/config/software/rubygems.rb +37 -0
- data/spec/data/complicated/config/software/runit.rb +118 -0
- data/spec/data/complicated/config/software/server-jre.rb +46 -0
- data/spec/data/complicated/config/software/setuptools.rb +30 -0
- data/spec/data/complicated/config/software/spawn-fcgi.rb +40 -0
- data/spec/data/complicated/config/software/sphinx.rb +26 -0
- data/spec/data/complicated/config/software/spidermonkey.rb +60 -0
- data/spec/data/complicated/config/software/sqitch.rb +24 -0
- data/spec/data/complicated/config/software/test-kitchen.rb +39 -0
- data/spec/data/complicated/config/software/unicorn.rb +27 -0
- data/spec/data/complicated/config/software/util-macros.rb +46 -0
- data/spec/data/complicated/config/software/version-manifest.rb +32 -0
- data/spec/data/complicated/config/software/xproto.rb +46 -0
- data/spec/data/complicated/config/software/yajl.rb +30 -0
- data/spec/data/complicated/config/software/zlib.rb +67 -0
- data/spec/data/projects/chefdk.rb +4 -4
- data/spec/data/projects/sample.rb +3 -0
- data/spec/data/software/erchef.rb +1 -1
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/LICENSE.rtf +8 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/banner_background.bmp +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/dialog_background.bmp +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/project.ico +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_16x16.ico +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_32x32.ico +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/localization-en-us.wxl +20 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/parameters.wxi.erb +9 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/source.wxs +74 -0
- data/spec/functional/packagers/mac_spec.rb +3 -20
- data/spec/functional/packagers/windows_spec.rb +69 -0
- data/spec/spec_helper.rb +79 -1
- data/spec/unit/artifact_spec.rb +0 -18
- data/spec/unit/build_version_dsl_spec.rb +136 -0
- data/spec/unit/build_version_spec.rb +185 -198
- data/spec/unit/config_spec.rb +18 -1
- data/spec/unit/fetchers/git_fetcher_spec.rb +55 -80
- data/spec/unit/fetchers/net_fetcher_spec.rb +11 -21
- data/spec/unit/install_path_cache_spec.rb +164 -136
- data/spec/unit/library_spec.rb +125 -5
- data/spec/unit/omnibus_spec.rb +25 -9
- data/spec/unit/overrides_spec.rb +2 -14
- data/spec/unit/package_release_spec.rb +0 -18
- data/spec/unit/packagers/base_spec.rb +84 -21
- data/spec/unit/packagers/mac_pkg_spec.rb +34 -24
- data/spec/unit/project_spec.rb +100 -102
- data/spec/unit/s3_cacher_spec.rb +0 -18
- data/spec/unit/software_spec.rb +152 -6
- data/spec/{sugar_spec.rb → unit/sugar_spec.rb} +0 -3
- metadata +365 -38
- data/lib/omnibus/cli/application.rb +0 -147
- data/lib/omnibus/cli/build.rb +0 -64
data/spec/unit/config_spec.rb
CHANGED
@@ -6,7 +6,10 @@ module Omnibus
|
|
6
6
|
expect(described_class).to be_a(Mixlib::Config)
|
7
7
|
end
|
8
8
|
|
9
|
-
before
|
9
|
+
before do
|
10
|
+
described_class.reset
|
11
|
+
stub_ohai(platform: 'linux')
|
12
|
+
end
|
10
13
|
|
11
14
|
shared_examples 'a configurable' do |id, default|
|
12
15
|
it "responds to .#{id}" do
|
@@ -40,5 +43,19 @@ module Omnibus
|
|
40
43
|
include_examples 'a configurable', :solaris_compiler, nil
|
41
44
|
include_examples 'a configurable', :append_timestamp, true
|
42
45
|
include_examples 'a configurable', :build_retries, 3
|
46
|
+
|
47
|
+
context 'on Windows' do
|
48
|
+
before do
|
49
|
+
stub_ohai(platform: 'windows')
|
50
|
+
stub_const('File::ALT_SEPARATOR', '\\')
|
51
|
+
end
|
52
|
+
|
53
|
+
include_examples 'a configurable', :cache_dir, 'C:\\omnibus-ruby\\cache'
|
54
|
+
include_examples 'a configurable', :install_path_cache_dir, 'C:\\omnibus-ruby\\cache\\install_path'
|
55
|
+
include_examples 'a configurable', :source_dir, 'C:\\omnibus-ruby\\src'
|
56
|
+
include_examples 'a configurable', :build_dir, 'C:\\omnibus-ruby\\build'
|
57
|
+
include_examples 'a configurable', :package_dir, 'C:\\omnibus-ruby\\pkg'
|
58
|
+
include_examples 'a configurable', :package_tmp, 'C:\\omnibus-ruby\\pkg-tmp'
|
59
|
+
end
|
43
60
|
end
|
44
61
|
end
|
@@ -1,101 +1,76 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
source: { git: 'git@example.com:test/project.git' },
|
13
|
-
version: '0.0.1',
|
14
|
-
project_dir: '/tmp/project'
|
3
|
+
module Omnibus
|
4
|
+
describe GitFetcher do
|
5
|
+
let(:software) do
|
6
|
+
double(Software,
|
7
|
+
name: 'project',
|
8
|
+
source: { git: 'git@example.com:test/project.git' },
|
9
|
+
version: '0.0.1',
|
10
|
+
project_dir: '/tmp/project',
|
11
|
+
)
|
15
12
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def expect_git_clone_and_ls_remote
|
19
|
-
expect_git_clone
|
20
|
-
expect_git_ls_remote
|
21
|
-
end
|
22
13
|
|
23
|
-
|
24
|
-
double('git_clone').tap do |g|
|
25
|
-
expect(shell_out).to receive(:new)
|
26
|
-
.with('git clone git@example.com:test/project.git /tmp/project', live_stream: STDOUT)
|
27
|
-
.ordered
|
28
|
-
.and_return(g)
|
29
|
-
expect(g).to receive(:run_command).ordered
|
30
|
-
expect(g).to receive(:error!).ordered
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def expect_git_ls_remote
|
35
|
-
double('git_ls_remote').tap do |g|
|
36
|
-
expect(shell_out).to receive(:new)
|
37
|
-
.with('git ls-remote origin 0.0.1*', live_stream: STDOUT, cwd: '/tmp/project')
|
38
|
-
.ordered
|
39
|
-
.and_return(g)
|
40
|
-
expect(g).to receive(:run_command).ordered
|
41
|
-
expect(g).to receive(:error!).ordered
|
42
|
-
g.stub(stdout: git_ls_remote_out)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#fetch' do
|
47
|
-
context 'when the project is not cloned yet' do
|
48
|
-
before do
|
49
|
-
File.stub(:exist?).with('/tmp/project/.git').and_return(false)
|
50
|
-
end
|
14
|
+
subject { described_class.new(software) }
|
51
15
|
|
52
|
-
|
53
|
-
|
54
|
-
|
16
|
+
describe '#fetch' do
|
17
|
+
context 'when the project is cloned' do
|
18
|
+
before do
|
19
|
+
subject.stub(:existing_git_clone?).and_return(true)
|
20
|
+
subject.stub(:fetch_updates)
|
55
21
|
end
|
56
22
|
|
57
|
-
context 'when the
|
58
|
-
|
59
|
-
|
23
|
+
context 'when the rev matches' do
|
24
|
+
before { subject.stub(:current_rev_matches_target_rev?).and_return(true) }
|
25
|
+
|
26
|
+
it 'does not fetch updates' do
|
27
|
+
expect(subject).to_not receive(:fetch_updates)
|
28
|
+
subject.fetch
|
60
29
|
end
|
30
|
+
end
|
61
31
|
|
62
|
-
|
63
|
-
|
64
|
-
double('git_checkout').tap do |g|
|
65
|
-
expect(shell_out).to receive(:new)
|
66
|
-
.with('git checkout a2ed66c01f42514bcab77fd628149eccb4ecee28', live_stream: STDOUT, cwd: '/tmp/project')
|
67
|
-
.ordered
|
68
|
-
.and_return(g)
|
69
|
-
expect(g).to receive(:run_command).ordered
|
70
|
-
expect(g).to receive(:error!).ordered
|
71
|
-
end
|
32
|
+
context 'when the rev does not match' do
|
33
|
+
before { subject.stub(:current_rev_matches_target_rev?).and_return(false) }
|
72
34
|
|
73
|
-
|
35
|
+
it 'fetches the updates' do
|
36
|
+
expect(subject).to receive(:fetch_updates).once
|
37
|
+
subject.fetch
|
74
38
|
end
|
75
39
|
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when the project is not cloned' do
|
43
|
+
before do
|
44
|
+
subject.stub(:existing_git_clone?).and_return(false)
|
45
|
+
subject.stub(:clone)
|
46
|
+
subject.stub(:checkout)
|
47
|
+
end
|
76
48
|
|
77
|
-
|
78
|
-
|
79
|
-
|
49
|
+
it 'clones the project' do
|
50
|
+
expect(subject).to receive(:clone).once
|
51
|
+
subject.fetch
|
52
|
+
end
|
80
53
|
|
81
|
-
|
54
|
+
it 'checkouts the ref' do
|
55
|
+
expect(subject).to receive(:checkout).once
|
56
|
+
subject.fetch
|
57
|
+
end
|
58
|
+
end
|
82
59
|
|
83
|
-
|
84
|
-
|
85
|
-
.with(%(Failed to fetch git repository 'git@example.com:test/project.git'))
|
60
|
+
context 'when something fails' do
|
61
|
+
let(:error_reporter) { double(Fetcher::ErrorReporter, explain: nil) }
|
86
62
|
|
87
|
-
|
88
|
-
|
89
|
-
|
63
|
+
before do
|
64
|
+
subject.stub(:existing_git_clone?).and_return(false)
|
65
|
+
subject.stub(:clone).and_raise(RuntimeError)
|
90
66
|
|
91
|
-
|
67
|
+
Fetcher::ErrorReporter.stub(:new).and_return(error_reporter)
|
68
|
+
end
|
92
69
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
expect { subject.fetch }.to raise_error(Omnibus::UnresolvableGitReference)
|
98
|
-
end
|
70
|
+
it 'retries 4 times' do
|
71
|
+
subject.stub(:sleep)
|
72
|
+
expect(subject).to receive(:clone).exactly(4).times
|
73
|
+
expect { subject.fetch }.to raise_error(RuntimeError)
|
99
74
|
end
|
100
75
|
end
|
101
76
|
end
|
@@ -49,27 +49,17 @@ describe Omnibus::NetFetcher do
|
|
49
49
|
source_dir: '/tmp/out',
|
50
50
|
project_dir: '/tmp/project'
|
51
51
|
@net_fetcher = Omnibus::NetFetcher.new(software_mock)
|
52
|
-
env_vars = %w(HTTP_PROXY HTTP_PROXY_USER HTTP_PROXY_PASS http_proxy http_proxy_user http_proxy_pass)
|
53
|
-
@orig_env = env_vars.reduce({}) do |h, var|
|
54
|
-
h[var] = ENV.delete(var)
|
55
|
-
h
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
after(:each) do
|
60
|
-
# restore ENV hash
|
61
|
-
@orig_env.each { |var, val| ENV[var] = val }
|
62
52
|
end
|
63
53
|
|
64
54
|
describe 'get_env handles upper and lower case env vars' do
|
65
55
|
it 'lower via upper' do
|
66
|
-
|
56
|
+
stub_env('lower', 'abc')
|
67
57
|
expect(@net_fetcher.get_env('LOWER')).to eq('abc')
|
68
58
|
expect(@net_fetcher.get_env('lower')).to eq('abc')
|
69
59
|
end
|
70
60
|
|
71
61
|
it 'upper via lower' do
|
72
|
-
|
62
|
+
stub_env('UPPER', 'abc')
|
73
63
|
expect(@net_fetcher.get_env('upper')).to eq('abc')
|
74
64
|
expect(@net_fetcher.get_env('UPPER')).to eq('abc')
|
75
65
|
end
|
@@ -80,26 +70,26 @@ describe Omnibus::NetFetcher do
|
|
80
70
|
end
|
81
71
|
|
82
72
|
it 'should return a URI object when HTTP_PROXY is set' do
|
83
|
-
|
73
|
+
stub_env('HTTP_PROXY', 'http://my.proxy')
|
84
74
|
expect(@net_fetcher.http_proxy).to eq(URI.parse('http://my.proxy'))
|
85
75
|
end
|
86
76
|
|
87
77
|
it 'sets user and pass from env when set' do
|
88
|
-
|
89
|
-
|
90
|
-
|
78
|
+
stub_env('HTTP_PROXY', 'my.proxy')
|
79
|
+
stub_env('HTTP_PROXY_USER', 'alex')
|
80
|
+
stub_env('HTTP_PROXY_PASS', 'sesame')
|
91
81
|
expect(@net_fetcher.http_proxy).to eq(URI.parse('http://alex:sesame@my.proxy'))
|
92
82
|
end
|
93
83
|
|
94
84
|
it 'uses user and pass in URL before those in env' do
|
95
|
-
|
96
|
-
|
97
|
-
|
85
|
+
stub_env('HTTP_PROXY', 'sally:peanut@my.proxy')
|
86
|
+
stub_env('HTTP_PROXY_USER', 'alex')
|
87
|
+
stub_env('HTTP_PROXY_PASS', 'sesame')
|
98
88
|
expect(@net_fetcher.http_proxy).to eq(URI.parse('http://sally:peanut@my.proxy'))
|
99
89
|
end
|
100
90
|
|
101
91
|
it "proxies if host doesn't match exclude list" do
|
102
|
-
|
92
|
+
stub_env('NO_PROXY', 'google.com,www.buz.org')
|
103
93
|
a_url = URI.parse('http://should.proxy.com/123')
|
104
94
|
expect(@net_fetcher.excluded_from_proxy?(a_url.host)).to be_false
|
105
95
|
|
@@ -108,7 +98,7 @@ describe Omnibus::NetFetcher do
|
|
108
98
|
end
|
109
99
|
|
110
100
|
it 'does not proxy if host matches exclude list' do
|
111
|
-
|
101
|
+
stub_env('NO_PROXY', 'google.com,www.buz.org')
|
112
102
|
a_url = URI.parse('http://google.com/hello')
|
113
103
|
expect(@net_fetcher.excluded_from_proxy?(a_url.host)).to be_true
|
114
104
|
|
@@ -1,175 +1,203 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'omnibus/util'
|
3
|
-
require 'omnibus/install_path_cache'
|
4
|
-
|
5
|
-
describe Omnibus::InstallPathCache do
|
6
|
-
let(:install_path) { '/opt/chef' }
|
7
|
-
|
8
|
-
let(:project) do
|
9
|
-
raw_project = <<-EOH
|
10
|
-
name "demo"
|
11
|
-
install_path "/opt/demo"
|
12
|
-
build_version "1.0.0"
|
13
|
-
maintainer 'Chef Software, Inc'
|
14
|
-
homepage 'http://getchef.com'
|
15
|
-
dependency 'preparation'
|
16
|
-
dependency 'snoopy'
|
17
|
-
dependency 'zlib'
|
18
|
-
EOH
|
19
|
-
project = Omnibus::Project.new(raw_project, 'demo.rb')
|
20
|
-
project
|
21
|
-
end
|
22
|
-
|
23
|
-
let(:fake_software_config_file) do
|
24
|
-
File.join(Omnibus::RSpec::SPEC_DATA, 'software', 'zlib.rb')
|
25
|
-
end
|
26
2
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
3
|
+
module Omnibus
|
4
|
+
describe InstallPathCache do
|
5
|
+
before do
|
6
|
+
# Stub to prevent a real Ohai run for faster specs
|
7
|
+
Ohai.stub(:platform).and_return('linux')
|
8
|
+
end
|
33
9
|
|
34
|
-
|
35
|
-
software = Omnibus::Software.new('', 'snoopy.rb', project)
|
36
|
-
software.name('snoopy')
|
37
|
-
software.default_version('1.0.0')
|
38
|
-
software
|
39
|
-
end
|
10
|
+
let(:install_path) { '/opt/chef' }
|
40
11
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
12
|
+
let(:project) do
|
13
|
+
raw_project = <<-EOH
|
14
|
+
name "demo"
|
15
|
+
install_path "/opt/demo"
|
16
|
+
build_version "1.0.0"
|
17
|
+
maintainer 'Chef Software, Inc'
|
18
|
+
homepage 'http://getchef.com'
|
19
|
+
dependency 'preparation'
|
20
|
+
dependency 'snoopy'
|
21
|
+
dependency 'zlib'
|
22
|
+
EOH
|
23
|
+
project = Omnibus::Project.new(raw_project, 'demo.rb')
|
24
|
+
project
|
25
|
+
end
|
47
26
|
|
48
|
-
|
27
|
+
let(:fake_software_config_file) do
|
28
|
+
File.join(Omnibus::RSpec::SPEC_DATA, 'software', 'zlib.rb')
|
29
|
+
end
|
49
30
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
31
|
+
let(:zlib) do
|
32
|
+
software = Omnibus::Software.new('', fake_software_config_file, project)
|
33
|
+
software.name('zlib')
|
34
|
+
software.default_version('1.7.2')
|
35
|
+
software
|
36
|
+
end
|
56
37
|
|
57
|
-
|
58
|
-
|
59
|
-
|
38
|
+
let(:snoopy) do
|
39
|
+
software = Omnibus::Software.new('', 'snoopy.rb', project)
|
40
|
+
software.name('snoopy')
|
41
|
+
software.default_version('1.0.0')
|
42
|
+
software
|
60
43
|
end
|
61
|
-
end
|
62
44
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
45
|
+
let(:preparation) do
|
46
|
+
software = Omnibus::Software.new('', 'preparation.rb', project)
|
47
|
+
software.name('preparation')
|
48
|
+
software.default_version('1.0.0')
|
49
|
+
software
|
67
50
|
end
|
68
|
-
end
|
69
51
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
it 'returns a tag with the softwares name, version, and hash of deps name+version' do
|
78
|
-
expect(ipc.tag).to eql('zlib-1.7.2-13b3f7f2653e40b9d5b393659210775ac5b56f7e0009f82f85b83f5132409362')
|
52
|
+
let(:cache_path) { "/var/cache/omnibus/cache/install_path#{install_path}" }
|
53
|
+
|
54
|
+
let(:ipc) do
|
55
|
+
project.library.component_added(preparation)
|
56
|
+
project.library.component_added(snoopy)
|
57
|
+
project.library.component_added(zlib)
|
58
|
+
Omnibus::InstallPathCache.new(install_path, zlib)
|
79
59
|
end
|
80
60
|
|
81
|
-
describe '
|
82
|
-
|
83
|
-
|
61
|
+
describe '#cache_path' do
|
62
|
+
it 'returns the install path appended to the install_cache path' do
|
63
|
+
expect(ipc.cache_path).to eq('/var/cache/omnibus/cache/install_path/opt/chef')
|
84
64
|
end
|
65
|
+
end
|
85
66
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
67
|
+
describe '#cache_path_exists?' do
|
68
|
+
it 'checks for existence' do
|
69
|
+
expect(File).to receive(:directory?).with(ipc.cache_path)
|
70
|
+
ipc.cache_path_exists?
|
90
71
|
end
|
91
72
|
end
|
92
|
-
end
|
93
73
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
74
|
+
describe '#tag' do
|
75
|
+
# 13b3f7f2653e40b9d5b393659210775ac5b56f7e0009f82f85b83f5132409362
|
76
|
+
#
|
77
|
+
# Is the sha256sum of:
|
78
|
+
# cat spec/data/software/zlib.rb > t
|
79
|
+
# echo -n 'preparation-1.0.0-snoopy-1.0.0' >> t
|
80
|
+
# sha256sum t
|
81
|
+
it 'returns a tag with the softwares name, version, and hash of deps name+version' do
|
82
|
+
expect(ipc.tag).to eql('zlib-1.7.2-13b3f7f2653e40b9d5b393659210775ac5b56f7e0009f82f85b83f5132409362')
|
83
|
+
end
|
102
84
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
ipc.create_cache_path
|
108
|
-
end
|
109
|
-
end
|
85
|
+
describe 'with no deps' do
|
86
|
+
let(:ipc) do
|
87
|
+
Omnibus::InstallPathCache.new(install_path, zlib)
|
88
|
+
end
|
110
89
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
90
|
+
it 'uses the shasum of the software config file' do
|
91
|
+
# gsha256sum spec/data/software/zlib.rb
|
92
|
+
# 363e6cc2475fcdd6e18b2dc10f6022d1cab498b9961e8225d8a309d18ed3c94b spec/data/software/zlib.rb
|
93
|
+
expect(ipc.tag).to eql('zlib-1.7.2-363e6cc2475fcdd6e18b2dc10f6022d1cab498b9961e8225d8a309d18ed3c94b')
|
94
|
+
end
|
95
|
+
end
|
115
96
|
end
|
116
97
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
98
|
+
describe '#create_cache_path' do
|
99
|
+
it 'runs git init if the cache path does not exist' do
|
100
|
+
allow(File).to receive(:directory?)
|
101
|
+
.with(ipc.cache_path)
|
102
|
+
.and_return(false)
|
103
|
+
allow(File).to receive(:directory?)
|
104
|
+
.with(File.dirname(ipc.cache_path))
|
105
|
+
.and_return(false)
|
106
|
+
expect(FileUtils).to receive(:mkdir_p)
|
107
|
+
.with(File.dirname(ipc.cache_path))
|
108
|
+
expect(ipc).to receive(:quiet_shellout!)
|
109
|
+
.with("git --git-dir=#{cache_path} init -q")
|
110
|
+
ipc.create_cache_path
|
111
|
+
end
|
121
112
|
|
122
|
-
|
123
|
-
|
124
|
-
|
113
|
+
it 'does not run git init if the cache path exists' do
|
114
|
+
allow(File).to receive(:directory?)
|
115
|
+
.with(ipc.cache_path)
|
116
|
+
.and_return(true)
|
117
|
+
allow(File).to receive(:directory?)
|
118
|
+
.with(File.dirname(ipc.cache_path))
|
119
|
+
.and_return(true)
|
120
|
+
expect(ipc).to_not receive(:quiet_shellout!)
|
121
|
+
.with("git --git-dir=#{cache_path} init -q")
|
122
|
+
ipc.create_cache_path
|
123
|
+
end
|
125
124
|
end
|
126
125
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
126
|
+
describe '#incremental' do
|
127
|
+
before(:each) do
|
128
|
+
allow(ipc).to receive(:quiet_shellout!)
|
129
|
+
allow(ipc).to receive(:create_cache_path)
|
130
|
+
end
|
131
131
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
end
|
132
|
+
it 'creates the cache path' do
|
133
|
+
expect(ipc).to receive(:create_cache_path)
|
134
|
+
ipc.incremental
|
135
|
+
end
|
137
136
|
|
138
|
-
|
139
|
-
|
137
|
+
it 'adds all the changes to git' do
|
138
|
+
expect(ipc).to receive(:quiet_shellout!)
|
139
|
+
.with("git --git-dir=#{cache_path} --work-tree=#{install_path} add -A -f")
|
140
|
+
ipc.incremental
|
141
|
+
end
|
140
142
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
end
|
143
|
+
it 'commits the backup for the software' do
|
144
|
+
expect(ipc).to receive(:quiet_shellout!)
|
145
|
+
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} commit -q -m "Backup of #{ipc.tag}"))
|
146
|
+
ipc.incremental
|
147
|
+
end
|
147
148
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
149
|
+
it 'tags the software backup' do
|
150
|
+
expect(ipc).to receive(:quiet_shellout!)
|
151
|
+
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -f "#{ipc.tag}"))
|
152
|
+
ipc.incremental
|
153
|
+
end
|
152
154
|
end
|
153
155
|
|
154
|
-
|
155
|
-
|
156
|
-
ipc.restore
|
157
|
-
end
|
156
|
+
describe '#restore' do
|
157
|
+
let(:git_tag_output) { "#{ipc.tag}\n" }
|
158
158
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
159
|
+
let(:tag_cmd) do
|
160
|
+
cmd_double = double(Mixlib::ShellOut)
|
161
|
+
allow(cmd_double).to receive(:stdout).and_return(git_tag_output)
|
162
|
+
allow(cmd_double).to receive(:error!).and_return(cmd_double)
|
163
|
+
cmd_double
|
164
|
+
end
|
165
|
+
|
166
|
+
before(:each) do
|
167
|
+
allow(ipc).to receive(:quiet_shellout)
|
168
|
+
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l "#{ipc.tag}"))
|
169
|
+
.and_return(tag_cmd)
|
170
|
+
allow(ipc).to receive(:quiet_shellout!)
|
171
|
+
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f "#{ipc.tag}"))
|
172
|
+
allow(ipc).to receive(:create_cache_path)
|
173
|
+
end
|
164
174
|
|
165
|
-
|
166
|
-
|
175
|
+
it 'creates the cache path' do
|
176
|
+
expect(ipc).to receive(:create_cache_path)
|
177
|
+
ipc.restore
|
178
|
+
end
|
167
179
|
|
168
|
-
it '
|
169
|
-
expect(ipc).to receive(:
|
170
|
-
|
180
|
+
it 'checks for a tag with the software and version, and if it finds it, checks it out' do
|
181
|
+
expect(ipc).to receive(:quiet_shellout)
|
182
|
+
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l "#{ipc.tag}"))
|
183
|
+
.and_return(tag_cmd)
|
184
|
+
expect(ipc).to receive(:quiet_shellout!)
|
185
|
+
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f "#{ipc.tag}"))
|
171
186
|
ipc.restore
|
172
187
|
end
|
188
|
+
|
189
|
+
describe 'if the tag does not exist' do
|
190
|
+
let(:git_tag_output) { "\n" }
|
191
|
+
|
192
|
+
it 'does nothing' do
|
193
|
+
expect(ipc).to receive(:quiet_shellout)
|
194
|
+
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l "#{ipc.tag}"))
|
195
|
+
.and_return(tag_cmd)
|
196
|
+
expect(ipc).to_not receive(:quiet_shellout!)
|
197
|
+
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f "#{ipc.tag}"))
|
198
|
+
ipc.restore
|
199
|
+
end
|
200
|
+
end
|
173
201
|
end
|
174
202
|
end
|
175
203
|
end
|