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/lib/omnibus/artifact.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
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
|
module Omnibus
|
2
18
|
class Artifact
|
3
19
|
attr_reader :path
|
@@ -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.
|
@@ -16,7 +15,6 @@
|
|
16
15
|
#
|
17
16
|
|
18
17
|
require 'time'
|
19
|
-
require 'omnibus/util'
|
20
18
|
|
21
19
|
module Omnibus
|
22
20
|
# Provides methods for generating Omnibus project build version
|
@@ -30,7 +28,8 @@ module Omnibus
|
|
30
28
|
# @todo Rename this class to reflect its absolute dependence on running in a
|
31
29
|
# Git repository.
|
32
30
|
class BuildVersion
|
33
|
-
include
|
31
|
+
include Logging
|
32
|
+
include Util
|
34
33
|
|
35
34
|
# Formatting string for the timestamp component of our SemVer build specifier.
|
36
35
|
#
|
@@ -38,10 +37,26 @@ module Omnibus
|
|
38
37
|
# @see Time#strftime
|
39
38
|
TIMESTAMP_FORMAT = '%Y%m%d%H%M%S'
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
class << self
|
41
|
+
# @deprecated Use {#semver} or {#git_describe} instead
|
42
|
+
def full
|
43
|
+
log.deprecated(log_key) do
|
44
|
+
'BuildVersion.full. Please use BuildVersion.semver or ' \
|
45
|
+
'BuildVersion.git_describe instead.'
|
46
|
+
end
|
47
|
+
|
48
|
+
new.git_describe
|
49
|
+
end
|
50
|
+
|
51
|
+
# @see (BuildVersion#git_describe)
|
52
|
+
def git_describe
|
53
|
+
new.git_describe
|
54
|
+
end
|
55
|
+
|
56
|
+
# @see (BuildVersion#semver)
|
57
|
+
def semver
|
58
|
+
new.semver
|
59
|
+
end
|
45
60
|
end
|
46
61
|
|
47
62
|
# Create a new BuildVersion
|
@@ -129,17 +144,18 @@ module Omnibus
|
|
129
144
|
# @return [String]
|
130
145
|
def git_describe
|
131
146
|
@git_describe ||= begin
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
147
|
+
cmd = quiet_shellout('git describe --tags', cwd: @path)
|
148
|
+
|
149
|
+
if cmd.exitstatus == 0
|
150
|
+
cmd.stdout.chomp
|
151
|
+
else
|
152
|
+
log.warn(log_key) do
|
153
|
+
"Could not extract version information from 'git describe'! " \
|
154
|
+
"Setting version to 0.0.0."
|
155
|
+
end
|
156
|
+
'0.0.0'
|
157
|
+
end
|
158
|
+
end
|
143
159
|
end
|
144
160
|
|
145
161
|
# @!endgroup
|
@@ -244,7 +260,7 @@ module Omnibus
|
|
244
260
|
# same build will share the same timestamp.
|
245
261
|
def build_start_time
|
246
262
|
@build_start_time ||= begin
|
247
|
-
if
|
263
|
+
if ENV['BUILD_ID']
|
248
264
|
begin
|
249
265
|
Time.strptime(ENV['BUILD_ID'], '%Y-%m-%d_%H-%M-%S')
|
250
266
|
rescue ArgumentError
|
@@ -273,6 +289,9 @@ module Omnibus
|
|
273
289
|
version_regexp.match(git_describe)[1..3]
|
274
290
|
end
|
275
291
|
|
292
|
+
#
|
293
|
+
# @todo Remove this environment variable madness and just use the CLI
|
294
|
+
#
|
276
295
|
def append_timestamp?
|
277
296
|
if ENV['OMNIBUS_APPEND_TIMESTAMP'] && (ENV['OMNIBUS_APPEND_TIMESTAMP'] =~ (/^(false|f|no|n|0)$/i))
|
278
297
|
false
|
@@ -0,0 +1,136 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
module Omnibus
|
19
|
+
class BuildVersionDSL
|
20
|
+
include Logging
|
21
|
+
|
22
|
+
# DSL to construct a build_version during the build.
|
23
|
+
#
|
24
|
+
# @see Omnibus::Project#build_version
|
25
|
+
attr_reader :build_version
|
26
|
+
attr_reader :source_type
|
27
|
+
attr_reader :source_options
|
28
|
+
attr_reader :output_method
|
29
|
+
|
30
|
+
def initialize(version_string = nil, &block)
|
31
|
+
@build_version = nil
|
32
|
+
@source_type = nil
|
33
|
+
@source_options = nil
|
34
|
+
@output_method = nil
|
35
|
+
|
36
|
+
if version_string
|
37
|
+
@build_version = version_string
|
38
|
+
elsif block_given?
|
39
|
+
instance_eval(&block)
|
40
|
+
construct_build_version unless from_dependency?
|
41
|
+
else
|
42
|
+
raise "Please give me the build_version or tell me how to construct it"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# DSL method to set the source of the build_version
|
47
|
+
#
|
48
|
+
# @param source_type [Symbol] Can be set to :git or :version
|
49
|
+
# @param source_options [Hash] Options for the given source_type.
|
50
|
+
# @return [void]
|
51
|
+
def source(source_type, source_options = {})
|
52
|
+
@source_type = source_type
|
53
|
+
@source_options = source_options
|
54
|
+
end
|
55
|
+
|
56
|
+
# DSL method to set the output_format of the build_version. Only honored
|
57
|
+
# when source_type is set to :git
|
58
|
+
#
|
59
|
+
# @param source_type [Symbol] Can be set to any method on Omnibus::BuildVersion
|
60
|
+
# @return [void]
|
61
|
+
def output_format(output_method)
|
62
|
+
@output_method = output_method
|
63
|
+
end
|
64
|
+
|
65
|
+
# Callback that is called by software objects to determine the version.
|
66
|
+
#
|
67
|
+
# @param dependency [Omnibus::Software] Software object that is making the callback.
|
68
|
+
# @return [void]
|
69
|
+
def resolve(dependency)
|
70
|
+
if from_dependency? && version_dependency == dependency.name
|
71
|
+
construct_build_version(dependency)
|
72
|
+
log.info(log_key) { "Build Version is set to '#{build_version}'" }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Explains the build_version. Either gives its value or gives information about
|
77
|
+
# how it will be constructed.
|
78
|
+
#
|
79
|
+
# @return [String]
|
80
|
+
def explain
|
81
|
+
if build_version
|
82
|
+
"Build Version: #{@build_version}"
|
83
|
+
else
|
84
|
+
if from_dependency?
|
85
|
+
"Build Version will be determined from software '#{version_dependency}'"
|
86
|
+
else
|
87
|
+
"Build Version is not determined yet."
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
# Helper function to determine if build_version will be determined from a
|
95
|
+
# dependency.
|
96
|
+
#
|
97
|
+
# @return [Boolean]
|
98
|
+
def from_dependency?
|
99
|
+
source_options && version_dependency
|
100
|
+
end
|
101
|
+
|
102
|
+
# The name of the dependency that the build_version will be determined from.
|
103
|
+
#
|
104
|
+
# @return [String]
|
105
|
+
def version_dependency
|
106
|
+
source_options[:from_dependency]
|
107
|
+
end
|
108
|
+
|
109
|
+
# Determines the build_version based on source_type, output_method.
|
110
|
+
#
|
111
|
+
# @param version_source [Omnibus::Software] Software object from which the
|
112
|
+
# build version will be determined from. Default is nil.
|
113
|
+
# @return [void]
|
114
|
+
def construct_build_version(version_source = nil)
|
115
|
+
case source_type
|
116
|
+
when :git
|
117
|
+
version = if version_source
|
118
|
+
Omnibus::BuildVersion.new(version_source.project_dir)
|
119
|
+
else
|
120
|
+
Omnibus::BuildVersion.new
|
121
|
+
end
|
122
|
+
|
123
|
+
output = output_method || :semver
|
124
|
+
@build_version = version.send(output)
|
125
|
+
when :version
|
126
|
+
if version_source
|
127
|
+
@build_version = version_source.version
|
128
|
+
else
|
129
|
+
raise "Please tell me the source to get the version from"
|
130
|
+
end
|
131
|
+
else
|
132
|
+
raise "I don't know how to construct a build_version using source '#{source_type}'"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
data/lib/omnibus/builder.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.
|
@@ -16,12 +15,12 @@
|
|
16
15
|
#
|
17
16
|
|
18
17
|
require 'forwardable'
|
19
|
-
require 'omnibus/exceptions'
|
20
|
-
require 'omnibus/install_path_cache'
|
21
18
|
require 'ostruct'
|
22
19
|
|
23
20
|
module Omnibus
|
24
21
|
class Builder
|
22
|
+
include Logging
|
23
|
+
|
25
24
|
# Proxies method calls to either a Builder object or the Software that the
|
26
25
|
# builder belongs to. Provides compatibility with our DSL where we never
|
27
26
|
# yield objects to blocks and hopefully hides some of the confusion that
|
@@ -66,6 +65,7 @@ module Omnibus
|
|
66
65
|
end
|
67
66
|
|
68
67
|
# @todo code duplication with {Fetcher::ErrorReporter}
|
68
|
+
# @todo make this use the logger
|
69
69
|
class ErrorReporter
|
70
70
|
# @todo fetcher isn't even used
|
71
71
|
def initialize(error, fetcher)
|
@@ -134,7 +134,7 @@ module Omnibus
|
|
134
134
|
source = candidate_paths.find { |path| File.exist?(path) }
|
135
135
|
|
136
136
|
unless source
|
137
|
-
|
137
|
+
raise MissingPatch.new(args[:source], candidate_paths)
|
138
138
|
end
|
139
139
|
|
140
140
|
plevel = args[:plevel] || 1
|
@@ -154,7 +154,7 @@ module Omnibus
|
|
154
154
|
source_path = File.expand_path("#{Omnibus.project_root}/config/templates/#{name}/#{args[:source]}")
|
155
155
|
|
156
156
|
unless File.exist?(source_path)
|
157
|
-
|
157
|
+
raise MissingTemplate.new(args[:source], "#{Omnibus.project_root}/config/templates/#{name}")
|
158
158
|
end
|
159
159
|
|
160
160
|
block do
|
@@ -202,15 +202,17 @@ module Omnibus
|
|
202
202
|
@software.install_dir
|
203
203
|
end
|
204
204
|
|
205
|
-
def log(message)
|
206
|
-
puts "[builder:#{name}] #{message}"
|
207
|
-
end
|
208
|
-
|
209
205
|
def build
|
210
|
-
log
|
211
|
-
|
212
|
-
|
213
|
-
|
206
|
+
log.info(log_key) { 'Starting...' }
|
207
|
+
|
208
|
+
if @software.overridden?
|
209
|
+
log.info(log_key) do
|
210
|
+
"Version overridden from #{@software.default_version} to "\
|
211
|
+
"#{@software.version}"
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
time_it('Build') do
|
214
216
|
@build_commands.each do |cmd|
|
215
217
|
execute(cmd)
|
216
218
|
end
|
@@ -260,7 +262,9 @@ module Omnibus
|
|
260
262
|
cmd_string = cmd_args[0..-2].join(' ')
|
261
263
|
cmd_opts_for_display = to_kv_str(cmd_args.last)
|
262
264
|
|
263
|
-
log
|
265
|
+
log.debug(log_key) do
|
266
|
+
"Executing: `#{cmd_string}` with #{cmd_opts_for_display}"
|
267
|
+
end
|
264
268
|
|
265
269
|
shell = Mixlib::ShellOut.new(*cmd)
|
266
270
|
shell.environment['HOME'] = '/tmp' unless ENV['HOME']
|
@@ -281,7 +285,10 @@ module Omnibus
|
|
281
285
|
else
|
282
286
|
time_to_sleep = 5 * (2**retries)
|
283
287
|
retries += 1
|
284
|
-
log
|
288
|
+
log.debug(log_key) do
|
289
|
+
"Failed to execute cmd `#{cmd}` #{retries} time(s). " \
|
290
|
+
"Retrying in #{time_to_sleep}s."
|
291
|
+
end
|
285
292
|
sleep(time_to_sleep)
|
286
293
|
retry
|
287
294
|
end
|
@@ -295,7 +302,7 @@ module Omnibus
|
|
295
302
|
# command as a string w/ opts
|
296
303
|
["#{str} #{cmd_args.first}", cmd_args.last]
|
297
304
|
elsif cmd_args.size == 0
|
298
|
-
|
305
|
+
raise ArgumentError, "I don't even"
|
299
306
|
else
|
300
307
|
# cmd given as argv array
|
301
308
|
cmd_args.dup.unshift(str)
|
@@ -318,11 +325,11 @@ module Omnibus
|
|
318
325
|
yield
|
319
326
|
rescue Exception
|
320
327
|
elapsed = Time.now - start
|
321
|
-
log "#{what} failed
|
328
|
+
log.warn(log_key) { "#{what} failed! (#{elapsed.to_f}s)" }
|
322
329
|
raise
|
323
330
|
else
|
324
331
|
elapsed = Time.now - start
|
325
|
-
log "#{what} succeeded
|
332
|
+
log.info(log_key) { "#{what} succeeded! (#{elapsed.to_f}s)" }
|
326
333
|
end
|
327
334
|
|
328
335
|
# Convert a hash to a string in the form `key=value`. It should work with
|
@@ -339,11 +346,9 @@ module Omnibus
|
|
339
346
|
kv_pair_strs << "#{k}=#{val_str}"
|
340
347
|
end.join(join_str)
|
341
348
|
end
|
342
|
-
end
|
343
349
|
|
344
|
-
|
345
|
-
|
346
|
-
log "Nothing to build for #{name}"
|
350
|
+
def log_key
|
351
|
+
@log_key ||= "#{super}: #{name}"
|
347
352
|
end
|
348
353
|
end
|
349
354
|
end
|
@@ -0,0 +1,72 @@
|
|
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 'thor'
|
18
|
+
|
19
|
+
module Omnibus
|
20
|
+
class Cleaner < Thor::Group
|
21
|
+
include Thor::Actions
|
22
|
+
|
23
|
+
namespace :clean
|
24
|
+
|
25
|
+
argument :name,
|
26
|
+
banner: 'NAME',
|
27
|
+
desc: 'The name of the Omnibus project',
|
28
|
+
type: :string,
|
29
|
+
required: true
|
30
|
+
|
31
|
+
class_option :purge,
|
32
|
+
desc: 'Purge the packages and caches',
|
33
|
+
type: :boolean,
|
34
|
+
default: false
|
35
|
+
|
36
|
+
def initialize(*)
|
37
|
+
super
|
38
|
+
|
39
|
+
@project = Omnibus.project(name)
|
40
|
+
raise ProjectNotFound.new(name) unless @project
|
41
|
+
end
|
42
|
+
|
43
|
+
def clean_source_dir
|
44
|
+
Dir.glob("#{Omnibus.config.source_dir}/**/*").each(&method(:remove_file))
|
45
|
+
end
|
46
|
+
|
47
|
+
def clean_build_dir
|
48
|
+
Dir.glob("#{Omnibus.config.build_dir}/**/*").each(&method(:remove_file))
|
49
|
+
end
|
50
|
+
|
51
|
+
def clean_package_dir
|
52
|
+
return unless purge?
|
53
|
+
Dir.glob("#{Omnibus.config.package_dir}/**/*").each(&method(:remove_file))
|
54
|
+
end
|
55
|
+
|
56
|
+
def clean_cache_dir
|
57
|
+
return unless purge?
|
58
|
+
Dir.glob("#{Omnibus.config.cache_dir}/**/*").each(&method(:remove_file))
|
59
|
+
end
|
60
|
+
|
61
|
+
def clean_install_dir
|
62
|
+
return unless purge?
|
63
|
+
remove_file(@project.install_path)
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def purge?
|
69
|
+
!!options[:purge]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|