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
@@ -1,6 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright
|
3
|
-
# License:: Apache License, Version 2.0
|
2
|
+
# Copyright 2014 Chef Software, Inc.
|
4
3
|
#
|
5
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
5
|
# you may not use this file except in compliance with the License.
|
@@ -15,8 +14,6 @@
|
|
15
14
|
# limitations under the License.
|
16
15
|
#
|
17
16
|
|
18
|
-
require 'omnibus/util'
|
19
|
-
require 'omnibus/config'
|
20
17
|
require 'fileutils'
|
21
18
|
require 'digest'
|
22
19
|
|
@@ -25,7 +22,7 @@ module Omnibus
|
|
25
22
|
include Util
|
26
23
|
|
27
24
|
def initialize(install_path, software)
|
28
|
-
@install_path = install_path
|
25
|
+
@install_path = install_path.sub(/^([A-Za-z]:)/, '') # strip drive letter on Windows
|
29
26
|
@software = software
|
30
27
|
end
|
31
28
|
|
@@ -42,14 +39,13 @@ module Omnibus
|
|
42
39
|
# Creates the full path if it does not exist already
|
43
40
|
def create_cache_path
|
44
41
|
FileUtils.mkdir_p(File.dirname(cache_path))
|
45
|
-
|
42
|
+
quiet_shellout!("git --git-dir=#{cache_path} init -q") unless cache_path_exists?
|
46
43
|
true
|
47
44
|
end
|
48
45
|
|
49
46
|
# Computes the tag for this cache entry
|
50
47
|
def tag
|
51
48
|
name = @software.name
|
52
|
-
version = @software.version
|
53
49
|
|
54
50
|
# Accumulate an array of all the software projects that come before
|
55
51
|
# the name and version we are tagging. So if you have
|
@@ -69,26 +65,29 @@ module Omnibus
|
|
69
65
|
# build params invalidate cache.
|
70
66
|
dep_string = IO.read(@software.source_config) + dep_string
|
71
67
|
digest = Digest::SHA256.hexdigest(dep_string)
|
68
|
+
|
69
|
+
version = @software.version_for_cache
|
70
|
+
|
72
71
|
"#{name}-#{version}-#{digest}"
|
73
72
|
end
|
74
73
|
|
75
74
|
# Create an incremental install path cache for the software step
|
76
75
|
def incremental
|
77
76
|
create_cache_path
|
78
|
-
|
77
|
+
quiet_shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} add -A -f))
|
79
78
|
begin
|
80
|
-
|
79
|
+
quiet_shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} commit -q -m "Backup of #{tag}"))
|
81
80
|
rescue Mixlib::ShellOut::ShellCommandFailed => e
|
82
81
|
if e.message !~ /nothing to commit/
|
83
82
|
raise
|
84
83
|
end
|
85
84
|
end
|
86
|
-
|
85
|
+
quiet_shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -f "#{tag}"))
|
87
86
|
end
|
88
87
|
|
89
88
|
def restore
|
90
89
|
create_cache_path
|
91
|
-
cmd =
|
90
|
+
cmd = quiet_shellout(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -l "#{tag}"))
|
92
91
|
|
93
92
|
restore_me = false
|
94
93
|
cmd.stdout.each_line do |line|
|
@@ -96,7 +95,7 @@ module Omnibus
|
|
96
95
|
end
|
97
96
|
|
98
97
|
if restore_me
|
99
|
-
|
98
|
+
quiet_shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} checkout -f "#{tag}"))
|
100
99
|
true
|
101
100
|
else
|
102
101
|
false
|
data/lib/omnibus/library.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright
|
3
|
-
# License:: Apache License, Version 2.0
|
2
|
+
# Copyright 2012-2014 Chef Software, Inc.
|
4
3
|
#
|
5
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
5
|
# you may not use this file except in compliance with the License.
|
@@ -19,6 +18,14 @@ module Omnibus
|
|
19
18
|
#
|
20
19
|
# Used to generate the manifest of all software components with versions
|
21
20
|
class Library
|
21
|
+
# The list of Omnibus::Software definitions. This is populated by calling
|
22
|
+
# #component_added during code loading. The list is expected to be sorted
|
23
|
+
# in a valid order according to project and software dependencies, but this
|
24
|
+
# class does not verify that condition.
|
25
|
+
#
|
26
|
+
# @see Omnibus.expand_software
|
27
|
+
# @return [Array<Omnibus::Software>] the software components in optimized
|
28
|
+
# order.
|
22
29
|
attr_reader :components
|
23
30
|
|
24
31
|
def initialize(project)
|
@@ -26,19 +33,39 @@ module Omnibus
|
|
26
33
|
@project = project
|
27
34
|
end
|
28
35
|
|
36
|
+
# Callback method that should be called each time an Omnibus::Software
|
37
|
+
# definition file is loaded.
|
38
|
+
#
|
39
|
+
# @param component [Omnibus::Software]
|
40
|
+
# @return [void]
|
29
41
|
def component_added(component)
|
30
42
|
unless @components.find { |c| c.name == component.name }
|
31
43
|
@components << component
|
32
44
|
end
|
33
45
|
end
|
34
46
|
|
47
|
+
# The order in which each Software component should be built. The order is
|
48
|
+
# based on the order of #components, optimized to move top-level
|
49
|
+
# dependencies later in the build order to make the git caching feature
|
50
|
+
# more effective. It is assumed that #components is already sorted in a
|
51
|
+
# valid dependency order. The optimization works as follows:
|
52
|
+
#
|
53
|
+
# 1. The first component is assumed to be a preparation step that needs to
|
54
|
+
# run first, so it is not moved.
|
55
|
+
# 2. If a component is a top-level dependency of the project AND no other
|
56
|
+
# software depends on it, it is shifted to last in the optimized order.
|
57
|
+
# 3. If none of the above conditions are met, the order of that component
|
58
|
+
# is unchanged.
|
59
|
+
#
|
60
|
+
# @return [Array<Omnibus::Software>] the software components in optimized
|
61
|
+
# order.
|
35
62
|
def build_order
|
36
63
|
head = []
|
37
64
|
tail = []
|
38
65
|
@components.each do |component|
|
39
66
|
if head.length == 0
|
40
67
|
head << component
|
41
|
-
elsif @project.dependencies.include?(component.name)
|
68
|
+
elsif @project.dependencies.include?(component.name) && @components.none? { |c| c.dependencies.include?(component.name) }
|
42
69
|
tail << component
|
43
70
|
else
|
44
71
|
head << component
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Omnibus
|
4
|
+
class Logger < ::Logger
|
5
|
+
def initialize(logdev = $stdout, *)
|
6
|
+
super
|
7
|
+
@level = Logger::WARN
|
8
|
+
end
|
9
|
+
|
10
|
+
#
|
11
|
+
# Print a deprecation warning.
|
12
|
+
#
|
13
|
+
# @see (Logger#add)
|
14
|
+
#
|
15
|
+
def deprecated(progname = nil, &block)
|
16
|
+
if level <= WARN
|
17
|
+
add(WARN, 'DEPRECATED: ' + (block ? yield : progname), progname)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Set the log lever for this logger instance.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# logger.level = :info
|
26
|
+
#
|
27
|
+
# @param [Symbol] level
|
28
|
+
#
|
29
|
+
def level=(level)
|
30
|
+
@level = ::Logger.const_get(level.to_s.upcase)
|
31
|
+
rescue NameError
|
32
|
+
raise "'#{level.inspect}' does not appear to be a valid log level!"
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def format_message(severity, _datetime, progname, msg)
|
38
|
+
left = if progname
|
39
|
+
"[#{progname}] #{severity[0]} | "
|
40
|
+
else
|
41
|
+
"#{severity[0]} | "
|
42
|
+
end
|
43
|
+
|
44
|
+
"#{left.rjust(30)}#{msg}\n"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013-2014 Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module Omnibus
|
18
|
+
module Logging
|
19
|
+
def self.included(base)
|
20
|
+
base.send(:include, InstanceMethods)
|
21
|
+
base.send(:extend, ClassMethods)
|
22
|
+
end
|
23
|
+
|
24
|
+
module ClassMethods
|
25
|
+
private
|
26
|
+
|
27
|
+
#
|
28
|
+
# A helpful DSL method for logging an action.
|
29
|
+
#
|
30
|
+
# @return [Logger]
|
31
|
+
#
|
32
|
+
def log
|
33
|
+
Omnibus.logger
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# The key to log with.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
#
|
41
|
+
def log_key
|
42
|
+
@log_key ||= name.split('::')[1..-1].join('::')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module InstanceMethods
|
47
|
+
private
|
48
|
+
|
49
|
+
# @see (ClassMethods#log)
|
50
|
+
def log
|
51
|
+
self.class.send(:log)
|
52
|
+
end
|
53
|
+
|
54
|
+
# @see (ClassMethods#log_key)
|
55
|
+
def log_key
|
56
|
+
self.class.send(:log_key)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2014 Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module Omnibus
|
18
|
+
class NullBuilder < Builder
|
19
|
+
def build
|
20
|
+
log.info(log_key) { "Nothing to build for #{name}" }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/omnibus/ohai.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2012-2014 Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'ohai'
|
18
|
+
|
19
|
+
module Omnibus
|
20
|
+
class Ohai
|
21
|
+
class << self
|
22
|
+
def method_missing(m, *args, &block)
|
23
|
+
ohai.send(m, *args, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def ohai
|
29
|
+
return @ohai if @ohai
|
30
|
+
|
31
|
+
@ohai = ::Ohai::System.new
|
32
|
+
@ohai.require_plugin('os')
|
33
|
+
@ohai.require_plugin('platform')
|
34
|
+
@ohai.require_plugin('linux/cpu') if @ohai.os == 'linux'
|
35
|
+
@ohai.require_plugin('kernel')
|
36
|
+
@ohai
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module Omnibus
|
43
|
+
class OhaiWithWarning < Ohai
|
44
|
+
include Logging
|
45
|
+
|
46
|
+
class << self
|
47
|
+
def method_missing(m, *args, &block)
|
48
|
+
bad_boy = caller[2]
|
49
|
+
|
50
|
+
unless warned[bad_boy]
|
51
|
+
log.deprecated('OHAI') do
|
52
|
+
"OHAI constant. Please use Ohai instead: #{bad_boy}"
|
53
|
+
end
|
54
|
+
warned[bad_boy] = true
|
55
|
+
end
|
56
|
+
|
57
|
+
Ohai.send(m, *args, &block)
|
58
|
+
end
|
59
|
+
|
60
|
+
def warned
|
61
|
+
@warned ||= {}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# @todo remove in the next major release
|
69
|
+
#
|
70
|
+
OHAI = Omnibus::OhaiWithWarning
|
data/lib/omnibus/overrides.rb
CHANGED
@@ -1,67 +1,88 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2014 Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
1
17
|
require 'pp'
|
2
18
|
|
3
19
|
module Omnibus
|
4
20
|
module Overrides
|
21
|
+
include Logging
|
22
|
+
|
5
23
|
DEFAULT_OVERRIDE_FILE_NAME = 'omnibus.overrides'
|
6
24
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
25
|
+
class << self
|
26
|
+
# Parses a file of override information into a Hash.
|
27
|
+
#
|
28
|
+
# Each line of the file must be of the form
|
29
|
+
#
|
30
|
+
#
|
31
|
+
# <package_name> <version>
|
32
|
+
#
|
33
|
+
# where the two pieces of data are separated by whitespace.
|
34
|
+
#
|
35
|
+
# @param file [String] the path to an overrides file
|
36
|
+
# @return [Hash, nil]
|
37
|
+
def parse_file(file)
|
38
|
+
if file
|
39
|
+
File.readlines(file).reduce({}) do |acc, line|
|
40
|
+
info = line.split
|
22
41
|
|
23
|
-
|
24
|
-
|
25
|
-
|
42
|
+
unless info.count == 2
|
43
|
+
raise ArgumentError, "Invalid overrides line: '#{line.chomp}'"
|
44
|
+
end
|
26
45
|
|
27
|
-
|
46
|
+
package, version = info
|
28
47
|
|
29
|
-
|
30
|
-
|
31
|
-
|
48
|
+
if acc[package]
|
49
|
+
raise ArgumentError, "Multiple overrides present for '#{package}' in overrides file #{file}!"
|
50
|
+
end
|
32
51
|
|
33
|
-
|
34
|
-
|
52
|
+
acc[package] = version
|
53
|
+
acc
|
54
|
+
end
|
55
|
+
else
|
56
|
+
nil
|
35
57
|
end
|
36
|
-
else
|
37
|
-
nil
|
38
58
|
end
|
39
|
-
end
|
40
59
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
60
|
+
# Return the full path to an overrides file, or +nil+ if no such
|
61
|
+
# file exists.
|
62
|
+
def resolve_override_file
|
63
|
+
file = ENV['OMNIBUS_OVERRIDE_FILE'] || DEFAULT_OVERRIDE_FILE_NAME
|
64
|
+
path = File.expand_path(file)
|
65
|
+
File.exist?(path) ? path : nil
|
66
|
+
end
|
48
67
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
68
|
+
# Return a hash of override information. If no such information
|
69
|
+
# can be found, the hash will be empty
|
70
|
+
#
|
71
|
+
# @return [Hash]
|
72
|
+
def overrides
|
73
|
+
file = resolve_override_file
|
74
|
+
overrides = parse_file(file)
|
56
75
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
76
|
+
if overrides
|
77
|
+
log.info(log_key) do
|
78
|
+
out = "Using overrides from #{resolve_override_file}\n"
|
79
|
+
out << overrides.pretty_inspect
|
80
|
+
out
|
81
|
+
end
|
82
|
+
end
|
63
83
|
|
64
|
-
|
84
|
+
overrides || {}
|
85
|
+
end
|
65
86
|
end
|
66
87
|
end
|
67
88
|
end
|