omnibus 3.2.2 → 4.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +140 -10
- data/CHANGELOG.md +181 -8
- data/README.md +63 -35
- data/Rakefile +1 -1
- data/docs/omnibus-build-cache.md b/data/docs/Build → Cache.md +0 -0
- data/docs/Building on Debian.md +59 -0
- data/docs/Building on OSX.md +61 -35
- data/docs/Building on RHEL.md +74 -0
- data/docs/Building on Windows.md +40 -81
- data/features/commands/build.feature +1 -2
- data/features/commands/clean.feature +1 -1
- data/lib/omnibus.rb +111 -204
- data/lib/omnibus/build_version.rb +3 -20
- data/lib/omnibus/build_version_dsl.rb +2 -3
- data/lib/omnibus/builder.rb +103 -211
- data/lib/omnibus/cleaner.rb +5 -7
- data/lib/omnibus/cli.rb +1 -4
- data/lib/omnibus/cli/base.rb +9 -16
- data/lib/omnibus/compressor.rb +60 -0
- data/{spec/data/complicated/config/software/version-manifest.rb → lib/omnibus/compressors/base.rb} +17 -12
- data/lib/omnibus/compressors/dmg.rb +312 -0
- data/lib/omnibus/{null_builder.rb → compressors/null.rb} +10 -4
- data/lib/omnibus/compressors/tgz.rb +141 -0
- data/lib/omnibus/config.rb +89 -83
- data/lib/omnibus/core_extensions.rb +1 -0
- data/lib/omnibus/core_extensions/open_uri.rb +58 -0
- data/lib/omnibus/digestable.rb +9 -3
- data/lib/omnibus/exceptions.rb +116 -175
- data/lib/omnibus/fetcher.rb +97 -138
- data/lib/omnibus/fetchers/git_fetcher.rb +130 -165
- data/lib/omnibus/fetchers/net_fetcher.rb +205 -164
- data/lib/omnibus/fetchers/{s3_cache_fetcher.rb → null_fetcher.rb} +27 -17
- data/lib/omnibus/fetchers/path_fetcher.rb +74 -32
- data/lib/omnibus/file_syncer.rb +149 -0
- data/lib/omnibus/generator.rb +103 -32
- data/lib/omnibus/generator_files/.kitchen.yml.erb +5 -1
- data/lib/omnibus/generator_files/Gemfile.erb +13 -7
- data/lib/omnibus/generator_files/config/projects/project.rb.erb +28 -0
- data/lib/omnibus/generator_files/config/software/zlib.rb.erb +55 -0
- data/lib/omnibus/generator_files/omnibus.rb.erb +5 -7
- data/lib/omnibus/git_cache.rb +11 -13
- data/lib/omnibus/logger.rb +76 -22
- data/lib/omnibus/logging.rb +1 -1
- data/lib/omnibus/metadata.rb +264 -0
- data/lib/omnibus/ohai.rb +0 -51
- data/lib/omnibus/package.rb +4 -228
- data/lib/omnibus/packager.rb +71 -0
- data/lib/omnibus/packagers/base.rb +118 -176
- data/lib/omnibus/packagers/bff.rb +136 -0
- data/lib/omnibus/packagers/deb.rb +389 -0
- data/lib/omnibus/packagers/makeself.rb +114 -0
- data/lib/omnibus/packagers/msi.rb +346 -0
- data/lib/omnibus/packagers/pkg.rb +278 -0
- data/lib/omnibus/packagers/rpm.rb +438 -0
- data/lib/omnibus/packagers/solaris.rb +110 -0
- data/lib/omnibus/project.rb +263 -666
- data/lib/omnibus/publisher.rb +3 -3
- data/lib/omnibus/s3_cache.rb +21 -30
- data/lib/omnibus/software.rb +132 -271
- data/lib/omnibus/templating.rb +66 -0
- data/lib/omnibus/thread_pool.rb +109 -0
- data/lib/omnibus/util.rb +137 -15
- data/lib/omnibus/version.rb +1 -1
- data/omnibus.gemspec +2 -2
- data/resources/bff/gen.template.erb +22 -0
- data/resources/bff/postinstall.sh +0 -0
- data/resources/bff/unpostinstall.sh +0 -0
- data/resources/deb/conffiles.erb +3 -0
- data/resources/deb/control.erb +25 -0
- data/resources/deb/md5sums.erb +3 -0
- data/{lib/omnibus/generator_files/mac_dmg → resources/dmg}/background.png +0 -0
- data/resources/dmg/create_dmg.osascript.erb +17 -0
- data/{lib/omnibus/generator_files/mac_dmg → resources/dmg}/icon.png +0 -0
- data/{bin → resources/makeself}/makeself-header.sh +0 -0
- data/{bin → resources/makeself}/makeself.sh +0 -0
- data/{lib/omnibus/generator_files/package_scripts/makeselfinst.erb → resources/makeself/post_extract.sh.erb} +4 -4
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/LICENSE.rtf +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/banner_background.bmp +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/dialog_background.bmp +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project.ico +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project_16x16.ico +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project_32x32.ico +0 -0
- data/{spec/fixtures/sample/files/windows_msi/Resources/localization-en-us.wxl → resources/msi/localization-en-us.wxl.erb} +3 -4
- data/resources/msi/parameters.wxi.erb +9 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/source.wxs.erb +14 -15
- data/{lib/omnibus/generator_files/mac_pkg → resources/pkg}/background.png +0 -0
- data/resources/pkg/distribution.xml.erb +21 -0
- data/resources/pkg/license.html.erb +3 -0
- data/resources/pkg/welcome.html.erb +7 -0
- data/resources/rpm/rpmmacros.erb +3 -0
- data/resources/rpm/signing.erb +40 -0
- data/resources/rpm/spec.erb +70 -0
- data/spec/functional/builder_spec.rb +90 -111
- data/spec/functional/fetchers/git_fetcher_spec.rb +130 -0
- data/spec/functional/fetchers/net_fetcher_spec.rb +110 -0
- data/spec/functional/fetchers/path_fetcher_spec.rb +97 -0
- data/spec/functional/file_syncer_spec.rb +206 -0
- data/spec/functional/templating_spec.rb +73 -0
- data/spec/spec_helper.rb +31 -94
- data/spec/support/env_helpers.rb +20 -0
- data/spec/support/examples.rb +56 -0
- data/spec/support/file_helpers.rb +46 -0
- data/spec/support/git_helpers.rb +107 -0
- data/spec/support/logging_helpers.rb +33 -0
- data/spec/support/matchers.rb +36 -0
- data/spec/support/ohai_helpers.rb +22 -0
- data/spec/support/path_helpers.rb +19 -0
- data/spec/support/shell_helpers.rb +14 -0
- data/spec/unit/build_version_dsl_spec.rb +0 -17
- data/spec/unit/build_version_spec.rb +1 -19
- data/spec/unit/builder_spec.rb +158 -46
- data/spec/unit/compressor_spec.rb +45 -0
- data/spec/unit/compressors/base_spec.rb +26 -0
- data/spec/unit/compressors/dmg_spec.rb +291 -0
- data/spec/unit/compressors/null_spec.rb +23 -0
- data/spec/unit/compressors/tgz_spec.rb +67 -0
- data/spec/unit/config_spec.rb +27 -34
- data/spec/unit/digestable_spec.rb +4 -4
- data/spec/unit/fetchers/git_fetcher_spec.rb +110 -39
- data/spec/unit/fetchers/net_fetcher_spec.rb +182 -72
- data/spec/unit/fetchers/path_fetcher_spec.rb +111 -0
- data/spec/unit/generator_spec.rb +137 -0
- data/spec/unit/git_cache_spec.rb +24 -34
- data/spec/unit/library_spec.rb +21 -82
- data/spec/unit/metadata_spec.rb +207 -0
- data/spec/unit/ohai_spec.rb +0 -7
- data/spec/unit/omnibus_spec.rb +41 -36
- data/spec/unit/package_spec.rb +1 -216
- data/spec/unit/packagers/base_spec.rb +76 -190
- data/spec/unit/packagers/bff_spec.rb +160 -0
- data/spec/unit/packagers/deb_spec.rb +324 -0
- data/spec/unit/packagers/makeself_spec.rb +80 -0
- data/spec/unit/packagers/msi_spec.rb +267 -0
- data/spec/unit/packagers/pkg_spec.rb +219 -0
- data/spec/unit/packagers/rpm_spec.rb +328 -0
- data/spec/unit/project_spec.rb +217 -80
- data/spec/unit/publisher_spec.rb +6 -2
- data/spec/unit/publishers/artifactory_publisher_spec.rb +1 -1
- data/spec/unit/publishers/s3_publisher_spec.rb +1 -1
- data/spec/unit/s3_cacher_spec.rb +22 -5
- data/spec/unit/software_spec.rb +89 -232
- data/spec/unit/util_spec.rb +188 -0
- metadata +159 -402
- data/features/commands/_deprecated.feature +0 -84
- data/lib/omnibus/cleanroom.rb +0 -141
- data/lib/omnibus/cli/deprecated.rb +0 -132
- data/lib/omnibus/generator_files/mac_pkg/license.html.erb +0 -1
- data/lib/omnibus/generator_files/mac_pkg/welcome.html.erb +0 -9
- data/lib/omnibus/generator_files/project.rb.erb +0 -20
- data/lib/omnibus/generator_files/software/c-example.rb.erb +0 -42
- data/lib/omnibus/generator_files/software/erlang-example.rb.erb +0 -38
- data/lib/omnibus/generator_files/software/ruby-example.rb.erb +0 -24
- data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +0 -20
- data/lib/omnibus/generator_files/windows_msi/parameters.wxi.erb +0 -9
- data/lib/omnibus/packagers/mac_dmg.rb +0 -235
- data/lib/omnibus/packagers/mac_pkg.rb +0 -176
- data/lib/omnibus/packagers/windows_msi.rb +0 -109
- data/spec/data/complicated/config/patches/bzip2/makefile_take_env_vars.patch +0 -15
- data/spec/data/complicated/config/patches/couchdb/patch_for_couchjs_stack.patch +0 -19
- data/spec/data/complicated/config/patches/gd/gd-2.0.33-configure-libpng.patch +0 -100
- data/spec/data/complicated/config/patches/keepalived/keepalived-1.2.9_opscode_centos_5.patch +0 -15
- data/spec/data/complicated/config/patches/libedit/freebsd-vi-fix.patch +0 -24
- data/spec/data/complicated/config/patches/libiconv/libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch +0 -29
- data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-makefile-dest-fix.patch +0 -35
- data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-malloc-fix.patch +0 -13
- data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-shared_lib_plus_plus-1.patch +0 -1035
- data/spec/data/complicated/config/patches/logrotate/logrotate_basedir_override.patch +0 -12
- data/spec/data/complicated/config/patches/ncurses/ncurses-5.9-solaris-xopen_source_extended-detection.patch +0 -11
- data/spec/data/complicated/config/patches/ncurses/ncurses-clang.patch +0 -42
- data/spec/data/complicated/config/patches/ncurses/patch-aa +0 -23
- data/spec/data/complicated/config/patches/ncurses/patch-ab +0 -44
- data/spec/data/complicated/config/patches/ncurses/patch-ac +0 -40
- data/spec/data/complicated/config/patches/ncurses/patch-ad +0 -12
- data/spec/data/complicated/config/patches/ncurses/patch-aix-configure +0 -23
- data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesf.h +0 -22
- data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesm.h +0 -22
- data/spec/data/complicated/config/patches/nrpe/fix_for_runit.patch +0 -64
- data/spec/data/complicated/config/patches/openssl/openssl-1.0.1f-do-not-build-docs.patch +0 -101
- data/spec/data/complicated/config/patches/postgresql/postgresql-9.1.2-configure-ncurses-fix.patch +0 -12
- data/spec/data/complicated/config/patches/ruby/patch-configure +0 -103
- data/spec/data/complicated/config/patches/ruby/ruby-aix-configure.patch +0 -10
- data/spec/data/complicated/config/patches/ruby/ruby-openssl-1.0.1c.patch +0 -42
- data/spec/data/complicated/config/patches/ruby/ruby_aix_1_9_3_448_ssl_EAGAIN.patch +0 -57
- data/spec/data/complicated/config/patches/ruby/rvm-cflags.patch +0 -27
- data/spec/data/complicated/config/projects/angrychef.rb +0 -32
- data/spec/data/complicated/config/projects/chef-windows.rb +0 -32
- data/spec/data/complicated/config/projects/chef.rb +0 -32
- data/spec/data/complicated/config/projects/chefdk-windows.rb +0 -41
- data/spec/data/complicated/config/projects/chefdk.rb +0 -44
- data/spec/data/complicated/config/software/appbundler.rb +0 -25
- data/spec/data/complicated/config/software/autoconf.rb +0 -35
- data/spec/data/complicated/config/software/automake.rb +0 -39
- data/spec/data/complicated/config/software/berkshelf.rb +0 -44
- data/spec/data/complicated/config/software/bundler.rb +0 -25
- data/spec/data/complicated/config/software/bzip2.rb +0 -46
- data/spec/data/complicated/config/software/cacerts.rb +0 -44
- data/spec/data/complicated/config/software/chef-client-msi.rb +0 -87
- data/spec/data/complicated/config/software/chef-gem.rb +0 -26
- data/spec/data/complicated/config/software/chef-vault.rb +0 -43
- data/spec/data/complicated/config/software/chef-windows.rb +0 -158
- data/spec/data/complicated/config/software/chef.rb +0 -170
- data/spec/data/complicated/config/software/chefdk.rb +0 -103
- data/spec/data/complicated/config/software/couchdb.rb +0 -53
- data/spec/data/complicated/config/software/curl.rb +0 -48
- data/spec/data/complicated/config/software/erlang.rb +0 -65
- data/spec/data/complicated/config/software/expat.rb +0 -21
- data/spec/data/complicated/config/software/fcgi.rb +0 -56
- data/spec/data/complicated/config/software/fcgiwrap.rb +0 -41
- data/spec/data/complicated/config/software/gd.rb +0 -56
- data/spec/data/complicated/config/software/gdbm.rb +0 -40
- data/spec/data/complicated/config/software/gecode.rb +0 -48
- data/spec/data/complicated/config/software/git.rb +0 -40
- data/spec/data/complicated/config/software/help2man.rb +0 -30
- data/spec/data/complicated/config/software/icu.rb +0 -40
- data/spec/data/complicated/config/software/jre.rb +0 -48
- data/spec/data/complicated/config/software/keepalived.rb +0 -43
- data/spec/data/complicated/config/software/libarchive.rb +0 -50
- data/spec/data/complicated/config/software/libedit.rb +0 -69
- data/spec/data/complicated/config/software/libffi.rb +0 -71
- data/spec/data/complicated/config/software/libgcc.rb +0 -39
- data/spec/data/complicated/config/software/libiconv.rb +0 -55
- data/spec/data/complicated/config/software/libjpeg.rb +0 -39
- data/spec/data/complicated/config/software/libpng.rb +0 -38
- data/spec/data/complicated/config/software/libtool.rb +0 -52
- data/spec/data/complicated/config/software/libwrap.rb +0 -50
- data/spec/data/complicated/config/software/libxml2.rb +0 -51
- data/spec/data/complicated/config/software/libxslt.rb +0 -52
- data/spec/data/complicated/config/software/libyaml-windows.rb +0 -43
- data/spec/data/complicated/config/software/libyaml.rb +0 -62
- data/spec/data/complicated/config/software/logrotate.rb +0 -41
- data/spec/data/complicated/config/software/makedepend.rb +0 -73
- data/spec/data/complicated/config/software/mysql2.rb +0 -42
- data/spec/data/complicated/config/software/nagios-plugins.rb +0 -53
- data/spec/data/complicated/config/software/nagios.rb +0 -66
- data/spec/data/complicated/config/software/ncurses.rb +0 -149
- data/spec/data/complicated/config/software/nginx.rb +0 -40
- data/spec/data/complicated/config/software/nodejs.rb +0 -44
- data/spec/data/complicated/config/software/nokogiri.rb +0 -55
- data/spec/data/complicated/config/software/nrpe.rb +0 -61
- data/spec/data/complicated/config/software/ohai.rb +0 -64
- data/spec/data/complicated/config/software/omnibus-ctl.rb +0 -34
- data/spec/data/complicated/config/software/openresty.rb +0 -67
- data/spec/data/complicated/config/software/openssl.rb +0 -158
- data/spec/data/complicated/config/software/pcre.rb +0 -42
- data/spec/data/complicated/config/software/perl-extutils-embed.rb +0 -15
- data/spec/data/complicated/config/software/perl-extutils-makemaker.rb +0 -15
- data/spec/data/complicated/config/software/perl.rb +0 -48
- data/spec/data/complicated/config/software/perl_pg_driver.rb +0 -12
- data/spec/data/complicated/config/software/php.rb +0 -41
- data/spec/data/complicated/config/software/pip.rb +0 -30
- data/spec/data/complicated/config/software/pkg-config.rb +0 -66
- data/spec/data/complicated/config/software/popt.rb +0 -47
- data/spec/data/complicated/config/software/postgresql.rb +0 -51
- data/spec/data/complicated/config/software/preparation.rb +0 -30
- data/spec/data/complicated/config/software/pygments.rb +0 -25
- data/spec/data/complicated/config/software/python.rb +0 -49
- data/spec/data/complicated/config/software/rabbitmq.rb +0 -36
- data/spec/data/complicated/config/software/rebar.rb +0 -36
- data/spec/data/complicated/config/software/redis.rb +0 -33
- data/spec/data/complicated/config/software/rsync.rb +0 -48
- data/spec/data/complicated/config/software/ruby-windows-devkit.rb +0 -30
- data/spec/data/complicated/config/software/ruby-windows.rb +0 -30
- data/spec/data/complicated/config/software/ruby.rb +0 -162
- data/spec/data/complicated/config/software/rubygems-customization.rb +0 -57
- data/spec/data/complicated/config/software/rubygems.rb +0 -37
- data/spec/data/complicated/config/software/runit.rb +0 -118
- data/spec/data/complicated/config/software/server-jre.rb +0 -46
- data/spec/data/complicated/config/software/setuptools.rb +0 -30
- data/spec/data/complicated/config/software/spawn-fcgi.rb +0 -40
- data/spec/data/complicated/config/software/sphinx.rb +0 -26
- data/spec/data/complicated/config/software/spidermonkey.rb +0 -60
- data/spec/data/complicated/config/software/sqitch.rb +0 -24
- data/spec/data/complicated/config/software/test-kitchen.rb +0 -39
- data/spec/data/complicated/config/software/unicorn.rb +0 -27
- data/spec/data/complicated/config/software/util-macros.rb +0 -46
- data/spec/data/complicated/config/software/xproto.rb +0 -46
- data/spec/data/complicated/config/software/yajl.rb +0 -30
- data/spec/data/complicated/config/software/zlib.rb +0 -67
- data/spec/data/overrides/bad_line.overrides +0 -3
- data/spec/data/overrides/good.overrides +0 -5
- data/spec/data/overrides/with_dupes.overrides +0 -4
- data/spec/data/projects/chefdk.rb +0 -41
- data/spec/data/projects/sample.rb +0 -13
- data/spec/data/software/erchef.rb +0 -42
- data/spec/data/software/zlib.rb +0 -67
- data/spec/fixtures/sample/files/mac_dmg/Resources/background.png +0 -0
- data/spec/fixtures/sample/files/mac_dmg/Resources/icon.png +0 -0
- data/spec/fixtures/sample/files/mac_pkg/Resources/background.png +0 -0
- data/spec/fixtures/sample/files/mac_pkg/Resources/license.html +0 -1
- data/spec/fixtures/sample/files/mac_pkg/Resources/welcome.html +0 -9
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/LICENSE.rtf +0 -8
- 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/parameters.wxi.erb +0 -9
- data/spec/fixtures/sample/files/windows_msi/Resources/source.wxs +0 -74
- data/spec/integration/packagers/mac_spec.rb +0 -58
- data/spec/integration/packagers/windows_spec.rb +0 -70
- data/spec/unit/packagers/mac_pkg_spec.rb +0 -151
@@ -22,16 +22,16 @@ module Omnibus
|
|
22
22
|
let(:io) { StringIO.new }
|
23
23
|
|
24
24
|
it 'inspects the file types of glob entries' do
|
25
|
-
expect(
|
25
|
+
expect(FileSyncer).to receive(:glob).with(glob).and_return([subdir])
|
26
26
|
expect(File).to receive(:ftype).with(subdir).and_return('directory')
|
27
|
-
expect(subject.digest_directory(path)).to eq('
|
27
|
+
expect(subject.digest_directory(path)).to eq('8b91792e7917b1152d8494670caaeb85')
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'inspects the contents of the files' do
|
31
|
-
expect(
|
31
|
+
expect(FileSyncer).to receive(:glob).with(glob).and_return([subfile])
|
32
32
|
expect(File).to receive(:ftype).with(subfile).and_return('file')
|
33
33
|
expect(File).to receive(:open).with(subfile).and_yield(io)
|
34
|
-
expect(subject.digest_directory(path)).to eq('
|
34
|
+
expect(subject.digest_directory(path)).to eq('c8f023976b95ace2ae3678540fd3b4f1')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -2,77 +2,148 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe GitFetcher do
|
5
|
+
let(:source_path) { '/local/path' }
|
6
|
+
let(:project_dir) { '/project/dir' }
|
7
|
+
|
5
8
|
let(:software) do
|
6
9
|
double(Software,
|
7
|
-
name: '
|
8
|
-
source: {
|
9
|
-
|
10
|
-
project_dir: '/tmp/project',
|
10
|
+
name: 'software',
|
11
|
+
source: { path: source_path },
|
12
|
+
project_dir: project_dir,
|
11
13
|
)
|
12
14
|
end
|
13
15
|
|
14
16
|
subject { described_class.new(software) }
|
15
17
|
|
16
|
-
describe '#
|
17
|
-
context 'when the
|
18
|
-
before
|
19
|
-
|
20
|
-
|
18
|
+
describe '#fetch_required?' do
|
19
|
+
context 'when the repository is not cloned' do
|
20
|
+
before { allow(subject).to receive(:cloned?).and_return(false) }
|
21
|
+
|
22
|
+
it 'returns true' do
|
23
|
+
expect(subject.fetch_required?).to be_truthy
|
21
24
|
end
|
25
|
+
end
|
22
26
|
|
23
|
-
|
24
|
-
|
27
|
+
context 'when the repository is cloned' do
|
28
|
+
before { allow(subject).to receive(:cloned?).and_return(true) }
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
|
30
|
+
context 'when the revision is difference' do
|
31
|
+
before { allow(subject).to receive(:same_revision?).and_return(false) }
|
32
|
+
|
33
|
+
it 'returns true' do
|
34
|
+
expect(subject.fetch_required?).to be_truthy
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
32
|
-
context 'when the
|
33
|
-
before { allow(subject).to receive(:
|
38
|
+
context 'when the same revision is checked out' do
|
39
|
+
before { allow(subject).to receive(:same_revision?).and_return(true) }
|
34
40
|
|
35
|
-
it '
|
36
|
-
expect(subject).to
|
37
|
-
subject.fetch
|
41
|
+
it 'returns false' do
|
42
|
+
expect(subject.fetch_required?).to be(false)
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#version_guid' do
|
49
|
+
let(:revision) { 'abcd1234' }
|
50
|
+
|
51
|
+
before do
|
52
|
+
allow(subject).to receive(:current_revision).and_return(revision)
|
53
|
+
end
|
41
54
|
|
42
|
-
|
55
|
+
it 'returns the revision' do
|
56
|
+
expect(subject.version_guid).to eq("git:#{revision}")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#clean' do
|
61
|
+
before { allow(subject).to receive(:git) }
|
62
|
+
|
63
|
+
context 'when the repository is cloned' do
|
43
64
|
before do
|
44
|
-
allow(subject).to receive(:
|
45
|
-
allow(subject).to receive(:clone)
|
46
|
-
allow(subject).to receive(:checkout)
|
65
|
+
allow(subject).to receive(:cloned?).and_return(true)
|
47
66
|
end
|
48
67
|
|
49
|
-
it '
|
50
|
-
expect(subject).to receive(:
|
51
|
-
subject.
|
68
|
+
it 'gleans the directory' do
|
69
|
+
expect(subject).to receive(:git).with('clean -fdx')
|
70
|
+
subject.clean
|
52
71
|
end
|
53
72
|
|
54
|
-
it '
|
55
|
-
expect(subject).to
|
56
|
-
subject.fetch
|
73
|
+
it 'returns true' do
|
74
|
+
expect(subject.clean).to be_truthy
|
57
75
|
end
|
58
76
|
end
|
59
77
|
|
60
|
-
context 'when
|
61
|
-
let(:error_reporter) { double(Fetcher::ErrorReporter, explain: nil) }
|
62
|
-
|
78
|
+
context 'when the repository is not cloned' do
|
63
79
|
before do
|
64
|
-
allow(subject).to receive(:
|
65
|
-
|
80
|
+
allow(subject).to receive(:cloned?).and_return(false)
|
81
|
+
end
|
66
82
|
|
67
|
-
|
83
|
+
it 'does not clean the repository' do
|
84
|
+
expect(subject).to_not receive(:git)
|
85
|
+
subject.clean
|
68
86
|
end
|
69
87
|
|
70
|
-
it '
|
71
|
-
|
72
|
-
expect(subject).to receive(:clone).exactly(4).times
|
73
|
-
expect { subject.fetch }.to raise_error(RuntimeError)
|
88
|
+
it 'returns false' do
|
89
|
+
expect(subject.clean).to be(false)
|
74
90
|
end
|
75
91
|
end
|
76
92
|
end
|
93
|
+
|
94
|
+
describe '#fetch' do
|
95
|
+
before do
|
96
|
+
allow(subject).to receive(:create_required_directories)
|
97
|
+
allow(subject).to receive(:git_fetch)
|
98
|
+
allow(subject).to receive(:git_clone)
|
99
|
+
allow(subject).to receive(:git_checkout)
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when the repository is cloned' do
|
103
|
+
before { allow(subject).to receive(:cloned?).and_return(true) }
|
104
|
+
|
105
|
+
context 'when the revision is different' do
|
106
|
+
before { allow(subject).to receive(:same_revision?).and_return(false) }
|
107
|
+
|
108
|
+
it 'fetches and resets' do
|
109
|
+
expect(subject).to receive(:git_fetch)
|
110
|
+
subject.fetch
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'when the revision is the same' do
|
115
|
+
before { allow(subject).to receive(:same_revision?).and_return(true) }
|
116
|
+
|
117
|
+
it 'does not fetch or reset' do
|
118
|
+
expect(subject).to_not receive(:git_fetch)
|
119
|
+
subject.fetch
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'when the repository is not cloned' do
|
125
|
+
before { allow(subject).to receive(:cloned?).and_return(false) }
|
126
|
+
|
127
|
+
it 'clones the repository' do
|
128
|
+
expect(subject).to receive(:git_clone).once
|
129
|
+
subject.fetch
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'checks out the correct revision' do
|
133
|
+
expect(subject).to receive(:git_checkout).once
|
134
|
+
subject.fetch
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#version_for_cache' do
|
140
|
+
let(:revision) { 'abcd1234' }
|
141
|
+
|
142
|
+
before { allow(subject).to receive(:current_revision).and_return(revision) }
|
143
|
+
|
144
|
+
it 'returns the shasum of the project_dir' do
|
145
|
+
expect(subject.version_for_cache).to eq("revision:#{revision}")
|
146
|
+
end
|
147
|
+
end
|
77
148
|
end
|
78
149
|
end
|
@@ -2,116 +2,226 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe NetFetcher do
|
5
|
-
let(:
|
5
|
+
let(:project_dir) { '/tmp/project' }
|
6
|
+
|
7
|
+
let(:software) do
|
6
8
|
double(Software,
|
7
|
-
|
9
|
+
downloaded_file: 'file.tar.gz',
|
8
10
|
name: 'file',
|
9
|
-
source: '/
|
11
|
+
source: { url: 'https://get.example.com/file.tar.gz', md5: 'abcd1234' },
|
10
12
|
checksum: 'abc123',
|
11
13
|
source_uri: 'http://example.com/file.tar.gz',
|
12
|
-
project_dir:
|
14
|
+
project_dir: project_dir,
|
13
15
|
)
|
14
16
|
end
|
15
17
|
|
18
|
+
let(:cache_dir) { '/cache' }
|
19
|
+
|
16
20
|
before do
|
17
|
-
Config.
|
21
|
+
Config.cache_dir(cache_dir)
|
18
22
|
end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
subject { described_class.new(software) }
|
25
|
+
|
26
|
+
describe '#fetch_required?' do
|
27
|
+
context 'when file is not downloaded' do
|
28
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
29
|
+
|
30
|
+
it 'returns true' do
|
31
|
+
expect(subject.fetch_required?).to be_truthy
|
25
32
|
end
|
33
|
+
end
|
26
34
|
|
27
|
-
|
28
|
-
|
35
|
+
context 'when the file is downloaded' do
|
36
|
+
before { allow(File).to receive(:exist?).and_return(true) }
|
37
|
+
|
38
|
+
context 'when the shasums differ' do
|
39
|
+
before do
|
40
|
+
allow(subject).to receive(:digest).and_return('abcd1234')
|
41
|
+
allow(subject).to receive(:checksum).and_return('efgh5678')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns true' do
|
45
|
+
expect(subject.fetch_required?).to be_truthy
|
46
|
+
end
|
29
47
|
end
|
48
|
+
|
49
|
+
context 'when the shasums are the same' do
|
50
|
+
before do
|
51
|
+
allow(subject).to receive(:digest).and_return('abcd1234')
|
52
|
+
allow(subject).to receive(:checksum).and_return('abcd1234')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns true' do
|
56
|
+
expect(subject.fetch_required?).to be(false)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#version_guid' do
|
63
|
+
it 'returns the shasum' do
|
64
|
+
expect(subject.version_guid).to eq('md5:abcd1234')
|
30
65
|
end
|
31
66
|
end
|
32
67
|
|
33
|
-
|
68
|
+
describe '#clean' do
|
69
|
+
before do
|
70
|
+
allow(FileUtils).to receive(:rm_rf)
|
71
|
+
allow(subject).to receive(:extract)
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when the project directory exists' do
|
75
|
+
before { allow(File).to receive(:exist?).and_return(true) }
|
34
76
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
77
|
+
it 'extracts the archive' do
|
78
|
+
expect(subject).to receive(:extract)
|
79
|
+
subject.clean
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'returns true' do
|
83
|
+
expect(subject.clean).to be_truthy
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'removes the project directory' do
|
87
|
+
expect(FileUtils).to receive(:rm_rf).with(project_dir)
|
88
|
+
subject.clean
|
89
|
+
end
|
48
90
|
end
|
49
91
|
|
50
|
-
context '
|
51
|
-
before {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
it_behaves_like 'an extractor', 'tar.xz', 'tar Jxf file.tar.xz -C/tmp/out'
|
92
|
+
context 'when the project directory does not exist' do
|
93
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
94
|
+
|
95
|
+
it 'extracts the archive' do
|
96
|
+
expect(subject).to receive(:extract)
|
97
|
+
subject.clean
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns false' do
|
101
|
+
expect(subject.clean).to be(false)
|
102
|
+
end
|
62
103
|
end
|
63
104
|
end
|
64
105
|
|
65
|
-
describe '#
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
106
|
+
describe '#version_for_cache' do
|
107
|
+
before do
|
108
|
+
allow(software).to receive(:source).and_return({
|
109
|
+
url: 'https://url',
|
110
|
+
md5: 'abcd1234',
|
111
|
+
})
|
70
112
|
end
|
71
113
|
|
72
|
-
it '
|
73
|
-
|
74
|
-
expect(subject.get_env('upper')).to eq('abc')
|
75
|
-
expect(subject.get_env('UPPER')).to eq('abc')
|
114
|
+
it 'returns the download URL and md5' do
|
115
|
+
expect(subject.version_for_cache).to eq('download_url:https://url|md5:abcd1234')
|
76
116
|
end
|
77
117
|
end
|
78
118
|
|
79
|
-
|
80
|
-
|
81
|
-
|
119
|
+
shared_examples 'an extractor' do |extension, command|
|
120
|
+
context "when the file is a .#{extension}" do
|
121
|
+
before do
|
122
|
+
software.source[:url] = "https://example.com/file.#{extension}"
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'is the right command' do
|
126
|
+
expect(subject.send(:extract_command)).to eq(command)
|
127
|
+
end
|
82
128
|
end
|
129
|
+
end
|
83
130
|
|
84
|
-
|
85
|
-
|
86
|
-
|
131
|
+
describe '#extract' do
|
132
|
+
before do
|
133
|
+
described_class.send(:public, :extract)
|
87
134
|
end
|
88
135
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
136
|
+
context 'when the downloaded file is a folder' do
|
137
|
+
before do
|
138
|
+
allow(FileUtils).to receive(:cp_r)
|
139
|
+
allow(File).to receive(:directory?).and_return(true)
|
140
|
+
allow(subject).to receive(:extract_command)
|
141
|
+
software.source[:url] = 'https://example.com/folder'
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'copies the entire directory to project_dir' do
|
145
|
+
expect(FileUtils).to receive(:cp_r).with("#{cache_dir}/folder", project_dir)
|
146
|
+
subject.extract
|
147
|
+
end
|
94
148
|
end
|
95
149
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
150
|
+
context 'when the downloaded file is a regular file' do
|
151
|
+
before do
|
152
|
+
allow(FileUtils).to receive(:mkdir_p)
|
153
|
+
allow(FileUtils).to receive(:cp)
|
154
|
+
allow(File).to receive(:directory?).and_return(false)
|
155
|
+
allow(subject).to receive(:extract_command)
|
156
|
+
software.source[:url] = 'https://example.com/file'
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'copies the file into the project_dir' do
|
160
|
+
expect(FileUtils).to receive(:cp).with("#{cache_dir}/file", "#{project_dir}/")
|
161
|
+
subject.extract
|
162
|
+
end
|
101
163
|
end
|
102
164
|
end
|
103
165
|
|
104
|
-
describe '#
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
166
|
+
describe '#extract_command' do
|
167
|
+
before { Config.source_dir('/tmp/out') }
|
168
|
+
|
169
|
+
context 'on Windows' do
|
170
|
+
before do
|
171
|
+
Config.cache_dir('C:')
|
172
|
+
stub_ohai(platform: 'windows', version: '2012')
|
173
|
+
end
|
174
|
+
|
175
|
+
it_behaves_like 'an extractor', '7z', '7z.exe x C:\\file.7z -o/tmp/out -r -y'
|
176
|
+
it_behaves_like 'an extractor', 'zip', '7z.exe x C:\\file.zip -o/tmp/out -r -y'
|
177
|
+
it_behaves_like 'an extractor', 'tar', 'tar xf C:\\file.tar -C/tmp/out'
|
178
|
+
it_behaves_like 'an extractor', 'tgz', 'tar zxf C:\\file.tgz -C/tmp/out'
|
179
|
+
it_behaves_like 'an extractor', 'tar.gz', 'tar zxf C:\\file.tar.gz -C/tmp/out'
|
180
|
+
it_behaves_like 'an extractor', 'bz2', 'tar jxf C:\\file.bz2 -C/tmp/out'
|
181
|
+
it_behaves_like 'an extractor', 'tar.bz2', 'tar jxf C:\\file.tar.bz2 -C/tmp/out'
|
182
|
+
it_behaves_like 'an extractor', 'txz', 'tar Jxf C:\\file.txz -C/tmp/out'
|
183
|
+
it_behaves_like 'an extractor', 'tar.xz', 'tar Jxf C:\\file.tar.xz -C/tmp/out'
|
109
184
|
end
|
110
185
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
186
|
+
context 'on Linux' do
|
187
|
+
before do
|
188
|
+
Config.cache_dir('/')
|
189
|
+
stub_ohai(platform: 'ubuntu', version: '12.04')
|
190
|
+
stub_const('File::ALT_SEPARATOR', nil)
|
191
|
+
end
|
192
|
+
|
193
|
+
it_behaves_like 'an extractor', '7z', '7z x /file.7z -o/tmp/out -r -y'
|
194
|
+
it_behaves_like 'an extractor', 'zip', 'unzip /file.zip -d /tmp/out'
|
195
|
+
it_behaves_like 'an extractor', 'tar', 'tar xf /file.tar -C/tmp/out'
|
196
|
+
it_behaves_like 'an extractor', 'tgz', 'tar zxf /file.tgz -C/tmp/out'
|
197
|
+
it_behaves_like 'an extractor', 'tar.gz', 'tar zxf /file.tar.gz -C/tmp/out'
|
198
|
+
it_behaves_like 'an extractor', 'bz2', 'tar jxf /file.bz2 -C/tmp/out'
|
199
|
+
it_behaves_like 'an extractor', 'tar.bz2', 'tar jxf /file.tar.bz2 -C/tmp/out'
|
200
|
+
it_behaves_like 'an extractor', 'txz', 'tar Jxf /file.txz -C/tmp/out'
|
201
|
+
it_behaves_like 'an extractor', 'tar.xz', 'tar Jxf /file.tar.xz -C/tmp/out'
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'when gtar is present' do
|
205
|
+
before do
|
206
|
+
Config.cache_dir('/')
|
207
|
+
|
208
|
+
stub_ohai(platform: 'ubuntu', version: '12.04')
|
209
|
+
stub_const('File::ALT_SEPARATOR', nil)
|
210
|
+
|
211
|
+
allow(Omnibus).to receive(:which)
|
212
|
+
.with('gtar')
|
213
|
+
.and_return('/path/to/gtar')
|
214
|
+
end
|
215
|
+
|
216
|
+
it_behaves_like 'an extractor', '7z', '7z x /file.7z -o/tmp/out -r -y'
|
217
|
+
it_behaves_like 'an extractor', 'zip', 'unzip /file.zip -d /tmp/out'
|
218
|
+
it_behaves_like 'an extractor', 'tar', 'gtar xf /file.tar -C/tmp/out'
|
219
|
+
it_behaves_like 'an extractor', 'tgz', 'gtar zxf /file.tgz -C/tmp/out'
|
220
|
+
it_behaves_like 'an extractor', 'tar.gz', 'gtar zxf /file.tar.gz -C/tmp/out'
|
221
|
+
it_behaves_like 'an extractor', 'bz2', 'gtar jxf /file.bz2 -C/tmp/out'
|
222
|
+
it_behaves_like 'an extractor', 'tar.bz2', 'gtar jxf /file.tar.bz2 -C/tmp/out'
|
223
|
+
it_behaves_like 'an extractor', 'txz', 'gtar Jxf /file.txz -C/tmp/out'
|
224
|
+
it_behaves_like 'an extractor', 'tar.xz', 'gtar Jxf /file.tar.xz -C/tmp/out'
|
115
225
|
end
|
116
226
|
end
|
117
227
|
end
|