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
@@ -23,8 +23,7 @@ module Omnibus
|
|
23
23
|
# @see Omnibus::Project#build_version
|
24
24
|
#
|
25
25
|
# @note Requires a Git repository
|
26
|
-
#
|
27
|
-
# versions e.g., Omnibus::BuildVersion.semver.
|
26
|
+
#
|
28
27
|
# @todo Rename this class to reflect its absolute dependence on running in a
|
29
28
|
# Git repository.
|
30
29
|
class BuildVersion
|
@@ -38,16 +37,6 @@ module Omnibus
|
|
38
37
|
TIMESTAMP_FORMAT = '%Y%m%d%H%M%S'
|
39
38
|
|
40
39
|
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
40
|
# @see (BuildVersion#git_describe)
|
52
41
|
def git_describe
|
53
42
|
new.git_describe
|
@@ -61,7 +50,8 @@ module Omnibus
|
|
61
50
|
|
62
51
|
# Create a new BuildVersion
|
63
52
|
#
|
64
|
-
# @param [String] path
|
53
|
+
# @param [String] path
|
54
|
+
# Path from which to read git version information
|
65
55
|
def initialize(path = Config.project_root)
|
66
56
|
@path = path
|
67
57
|
end
|
@@ -231,13 +221,6 @@ module Omnibus
|
|
231
221
|
match ? match[1].to_i : 0
|
232
222
|
end
|
233
223
|
|
234
|
-
# @todo This method is never called in Omnibus. Is this even used
|
235
|
-
# (e.g., in the DSL files)?
|
236
|
-
def development_version?
|
237
|
-
patch = version_composition.last
|
238
|
-
patch.to_i.odd?
|
239
|
-
end
|
240
|
-
|
241
224
|
# Indicates whether the version represents a pre-release or not, as
|
242
225
|
# signalled by the presence of a pre-release tag in the version
|
243
226
|
# string.
|
@@ -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.
|
@@ -56,7 +55,7 @@ module Omnibus
|
|
56
55
|
# DSL method to set the output_format of the build_version. Only honored
|
57
56
|
# when source_type is set to :git
|
58
57
|
#
|
59
|
-
# @param
|
58
|
+
# @param output_method [Symbol] Can be set to any method on Omnibus::BuildVersion
|
60
59
|
# @return [void]
|
61
60
|
def output_format(output_method)
|
62
61
|
@output_method = output_method
|
data/lib/omnibus/builder.rb
CHANGED
@@ -21,13 +21,11 @@ require 'pathname'
|
|
21
21
|
|
22
22
|
module Omnibus
|
23
23
|
class Builder
|
24
|
-
# Files to be ignored during a directory globbing
|
25
|
-
IGNORED_FILES = %w(. ..).freeze
|
26
|
-
|
27
24
|
include Cleanroom
|
28
25
|
include Digestable
|
29
26
|
include Instrumentation
|
30
27
|
include Logging
|
28
|
+
include Templating
|
31
29
|
include Util
|
32
30
|
|
33
31
|
#
|
@@ -80,12 +78,50 @@ module Omnibus
|
|
80
78
|
# @return [void]
|
81
79
|
#
|
82
80
|
def command(command, options = {})
|
81
|
+
warn_for_shell_commands(command)
|
82
|
+
|
83
83
|
build_commands << BuildCommand.new("Execute: `#{command}'") do
|
84
|
-
|
84
|
+
shellout!(command, options)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
expose :command
|
88
88
|
|
89
|
+
#
|
90
|
+
# Execute the given make command. When present, this method will prefer the
|
91
|
+
# use of +gmake+ over +make+. If applicable, this method will also set
|
92
|
+
# the `MAKE=gmake` environment variable when gmake is to be preferred.
|
93
|
+
#
|
94
|
+
# @example With no arguments
|
95
|
+
# make
|
96
|
+
#
|
97
|
+
# @example With arguments
|
98
|
+
# make 'install'
|
99
|
+
#
|
100
|
+
# @example With custom make bin
|
101
|
+
# make 'install', bin: '/path/to/custom/make'
|
102
|
+
#
|
103
|
+
# @param (see #command)
|
104
|
+
# @return (see #command)
|
105
|
+
#
|
106
|
+
def make(*args)
|
107
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
108
|
+
command = args.join(' ')
|
109
|
+
|
110
|
+
make = if makebin = options.delete(:bin)
|
111
|
+
makebin
|
112
|
+
elsif Omnibus.which('gmake')
|
113
|
+
env = options.delete(:env) || {}
|
114
|
+
env = { 'MAKE' => 'gmake' }.merge(env)
|
115
|
+
options[:env] = env
|
116
|
+
'gmake'
|
117
|
+
else
|
118
|
+
'make'
|
119
|
+
end
|
120
|
+
|
121
|
+
command("#{make} #{command}".strip, options)
|
122
|
+
end
|
123
|
+
expose :make
|
124
|
+
|
89
125
|
#
|
90
126
|
# Apply the patch by the given name. This method will search all possible
|
91
127
|
# locations for a patch (such as {Config#software_gems}).
|
@@ -131,69 +167,32 @@ module Omnibus
|
|
131
167
|
patches << patch_path
|
132
168
|
|
133
169
|
build_commands << BuildCommand.new("Apply patch `#{source}'") do
|
134
|
-
|
170
|
+
shellout!(command, options)
|
135
171
|
end
|
136
172
|
end
|
137
173
|
expose :patch
|
138
174
|
|
139
175
|
#
|
140
|
-
# The maximum number of
|
141
|
-
# data is unavailable, +3+ is used.
|
142
|
-
#
|
143
|
-
# @todo Should this be moved to {Software}?
|
176
|
+
# The maximum number of workers suitable for this system.
|
144
177
|
#
|
145
|
-
# @
|
146
|
-
# command "make install -j #{workers}"
|
147
|
-
#
|
148
|
-
# @return [Fixnum]
|
178
|
+
# @see (Config#workers)
|
149
179
|
#
|
150
180
|
def workers
|
151
|
-
|
152
|
-
Ohai['cpu']['total'].to_i + 1
|
153
|
-
else
|
154
|
-
3
|
155
|
-
end
|
181
|
+
Config.workers
|
156
182
|
end
|
157
183
|
expose :workers
|
158
184
|
|
159
185
|
#
|
160
|
-
#
|
186
|
+
# (see Util#windows_safe_path)
|
161
187
|
#
|
162
|
-
#
|
163
|
-
#
|
164
|
-
# @param (see #max_build_jobs)
|
165
|
-
# @return (see #max_build_jobs)
|
166
|
-
#
|
167
|
-
def max_build_jobs
|
168
|
-
log.deprecated(log_key) do
|
169
|
-
"max_build_jobs (DSL). Please use `workers' instead."
|
170
|
-
end
|
171
|
-
|
172
|
-
workers
|
173
|
-
end
|
174
|
-
expose :max_build_jobs
|
175
|
-
|
176
|
-
#
|
177
|
-
# Convert the given path to be appropiate for shelling out on Windows. Most
|
178
|
-
# internal calls will wrap paths automatically, but the +command+ method is
|
179
|
-
# unable to do so.
|
188
|
+
# Most internal Ruby methods will handle this automatically, but the
|
189
|
+
# +command+ method is unable to do so.
|
180
190
|
#
|
181
191
|
# @example
|
182
192
|
# command "#{windows_safe_path(install_dir)}\\embedded\\bin\\gem"
|
183
193
|
#
|
184
|
-
# @param [String, Array<String>] pieces
|
185
|
-
# the pieces of the path to join and fix
|
186
|
-
# @return [String]
|
187
|
-
# the path with applied changes
|
188
|
-
#
|
189
194
|
def windows_safe_path(*pieces)
|
190
|
-
|
191
|
-
|
192
|
-
if File::ALT_SEPARATOR
|
193
|
-
path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
|
194
|
-
else
|
195
|
-
path
|
196
|
-
end
|
195
|
+
super
|
197
196
|
end
|
198
197
|
expose :windows_safe_path
|
199
198
|
|
@@ -220,7 +219,7 @@ module Omnibus
|
|
220
219
|
def ruby(command, options = {})
|
221
220
|
build_commands << BuildCommand.new("ruby `#{command}'") do
|
222
221
|
bin = windows_safe_path("#{install_dir}/embedded/bin/ruby")
|
223
|
-
|
222
|
+
shellout!("#{bin} #{command}", options)
|
224
223
|
end
|
225
224
|
end
|
226
225
|
expose :ruby
|
@@ -237,7 +236,7 @@ module Omnibus
|
|
237
236
|
def gem(command, options = {})
|
238
237
|
build_commands << BuildCommand.new("gem `#{command}'") do
|
239
238
|
bin = windows_safe_path("#{install_dir}/embedded/bin/gem")
|
240
|
-
|
239
|
+
shellout!("#{bin} #{command}", options)
|
241
240
|
end
|
242
241
|
end
|
243
242
|
expose :gem
|
@@ -257,7 +256,7 @@ module Omnibus
|
|
257
256
|
def bundle(command, options = {})
|
258
257
|
build_commands << BuildCommand.new("bundle `#{command}'") do
|
259
258
|
bin = windows_safe_path("#{install_dir}/embedded/bin/bundle")
|
260
|
-
|
259
|
+
shellout!("#{bin} #{command}", options)
|
261
260
|
end
|
262
261
|
end
|
263
262
|
expose :bundle
|
@@ -275,7 +274,7 @@ module Omnibus
|
|
275
274
|
def rake(command, options = {})
|
276
275
|
build_commands << BuildCommand.new("rake `#{command}'") do
|
277
276
|
bin = windows_safe_path("#{install_dir}/embedded/bin/rake")
|
278
|
-
|
277
|
+
shellout!("#{bin} #{command}", options)
|
279
278
|
end
|
280
279
|
end
|
281
280
|
expose :rake
|
@@ -285,8 +284,6 @@ module Omnibus
|
|
285
284
|
# no validation is performed. As a general rule, you should avoid this
|
286
285
|
# method unless you know what you are doing.
|
287
286
|
#
|
288
|
-
# TODO: the "name" does nothing right now
|
289
|
-
#
|
290
287
|
# @example
|
291
288
|
# block do
|
292
289
|
# # Some complex operation
|
@@ -351,15 +348,11 @@ module Omnibus
|
|
351
348
|
erbs << source_path
|
352
349
|
|
353
350
|
block "Render erb `#{source}'" do
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
file.write(result)
|
360
|
-
end
|
361
|
-
|
362
|
-
File.chmod(mode, dest)
|
351
|
+
render_template(source_path,
|
352
|
+
destination: dest,
|
353
|
+
mode: mode,
|
354
|
+
variables: vars,
|
355
|
+
)
|
363
356
|
end
|
364
357
|
end
|
365
358
|
expose :erb
|
@@ -374,7 +367,7 @@ module Omnibus
|
|
374
367
|
# The following DSL methods are available from within build blocks that
|
375
368
|
# mutate the file system.
|
376
369
|
#
|
377
|
-
# **These commands are run from inside {Software#
|
370
|
+
# **These commands are run from inside {Software#project_dir}, so exercise
|
378
371
|
# good judgement when using relative paths!**
|
379
372
|
# --------------------------------------------------
|
380
373
|
|
@@ -391,7 +384,7 @@ module Omnibus
|
|
391
384
|
#
|
392
385
|
def mkdir(directory, options = {})
|
393
386
|
build_commands << BuildCommand.new("mkdir `#{directory}'") do
|
394
|
-
Dir.chdir(software.
|
387
|
+
Dir.chdir(software.project_dir) do
|
395
388
|
FileUtils.mkdir_p(directory, options)
|
396
389
|
end
|
397
390
|
end
|
@@ -410,7 +403,7 @@ module Omnibus
|
|
410
403
|
#
|
411
404
|
def touch(file, options = {})
|
412
405
|
build_commands << BuildCommand.new("touch `#{file}'") do
|
413
|
-
Dir.chdir(software.
|
406
|
+
Dir.chdir(software.project_dir) do
|
414
407
|
parent = File.dirname(file)
|
415
408
|
FileUtils.mkdir_p(parent) unless File.directory?(parent)
|
416
409
|
|
@@ -433,8 +426,8 @@ module Omnibus
|
|
433
426
|
#
|
434
427
|
def delete(path, options = {})
|
435
428
|
build_commands << BuildCommand.new("delete `#{path}'") do
|
436
|
-
Dir.chdir(software.
|
437
|
-
glob(path).each do |file|
|
429
|
+
Dir.chdir(software.project_dir) do
|
430
|
+
FileSyncer.glob(path).each do |file|
|
438
431
|
FileUtils.rm_rf(file, options)
|
439
432
|
end
|
440
433
|
end
|
@@ -456,8 +449,8 @@ module Omnibus
|
|
456
449
|
#
|
457
450
|
def copy(source, destination, options = {})
|
458
451
|
build_commands << BuildCommand.new("copy `#{source}' to `#{destination}'") do
|
459
|
-
Dir.chdir(software.
|
460
|
-
glob(source).each do |file|
|
452
|
+
Dir.chdir(software.project_dir) do
|
453
|
+
FileSyncer.glob(source).each do |file|
|
461
454
|
FileUtils.cp_r(file, destination, options)
|
462
455
|
end
|
463
456
|
end
|
@@ -479,8 +472,8 @@ module Omnibus
|
|
479
472
|
#
|
480
473
|
def move(source, destination, options = {})
|
481
474
|
build_commands << BuildCommand.new("move `#{source}' to `#{destination}'") do
|
482
|
-
Dir.chdir(software.
|
483
|
-
glob(source).each do |file|
|
475
|
+
Dir.chdir(software.project_dir) do
|
476
|
+
FileSyncer.glob(source).each do |file|
|
484
477
|
FileUtils.mv(file, destination, options)
|
485
478
|
end
|
486
479
|
end
|
@@ -502,8 +495,8 @@ module Omnibus
|
|
502
495
|
#
|
503
496
|
def link(source, destination, options = {})
|
504
497
|
build_commands << BuildCommand.new("link `#{source}' to `#{destination}'") do
|
505
|
-
Dir.chdir(software.
|
506
|
-
glob(source).each do |file|
|
498
|
+
Dir.chdir(software.project_dir) do
|
499
|
+
FileSyncer.glob(source).each do |file|
|
507
500
|
FileUtils.ln_s(file, destination, options)
|
508
501
|
end
|
509
502
|
end
|
@@ -512,13 +505,7 @@ module Omnibus
|
|
512
505
|
expose :link
|
513
506
|
|
514
507
|
#
|
515
|
-
#
|
516
|
-
# in +destination+ that are not present in +source+.
|
517
|
-
#
|
518
|
-
# You can pass the option +:exclude+ option to ignore files and folders that
|
519
|
-
# match the given pattern(s). Note the exclude pattern behaves on paths
|
520
|
-
# relative to the given source. If you want to exclude a nested directory,
|
521
|
-
# you will need to use something like +**/directory+.
|
508
|
+
# (see FileSyncer.sync)
|
522
509
|
#
|
523
510
|
# @example
|
524
511
|
# sync "#{project_dir}/**/*.rb", "#{install_dir}/ruby_files"
|
@@ -526,61 +513,10 @@ module Omnibus
|
|
526
513
|
# @example
|
527
514
|
# sync project_dir, "#{install_dir}/files", exclude: '.git'
|
528
515
|
#
|
529
|
-
# @param [String] source
|
530
|
-
# the path on disk to sync from
|
531
|
-
# @param [String] destination
|
532
|
-
# the path on disk to sync to
|
533
|
-
#
|
534
|
-
# @option options [String, Array<String>] :exclude
|
535
|
-
# a file, folder, or globbing pattern of files to ignore when syncing
|
536
|
-
#
|
537
|
-
# @return (see #command)
|
538
|
-
#
|
539
516
|
def sync(source, destination, options = {})
|
540
517
|
build_commands << BuildCommand.new("sync `#{source}' to `#{destination}'") do
|
541
|
-
Dir.chdir(software.
|
542
|
-
|
543
|
-
unless File.directory?(source)
|
544
|
-
raise ArgumentError, "`source' must be a directory, but was a " \
|
545
|
-
"`#{File.ftype(source)}'! If you just want to sync a file, use " \
|
546
|
-
"the `copy' method instead."
|
547
|
-
end
|
548
|
-
|
549
|
-
# Reject any files that match the excludes pattern
|
550
|
-
excludes = Array(options[:exclude]).map do |exclude|
|
551
|
-
[exclude, "#{exclude}/*"]
|
552
|
-
end.flatten
|
553
|
-
|
554
|
-
source_files = all_files(source)
|
555
|
-
source_files = source_files.reject do |source_file|
|
556
|
-
basename = relative_path_for(source_file, source)
|
557
|
-
excludes.any? { |exclude| File.fnmatch?(exclude, basename, File::FNM_DOTMATCH) }
|
558
|
-
end
|
559
|
-
|
560
|
-
# Ensure the destination directory exists
|
561
|
-
FileUtils.mkdir_p(destination) unless File.directory?(destination)
|
562
|
-
|
563
|
-
# Copy over the filtered source files
|
564
|
-
FileUtils.cp_r(source_files, destination)
|
565
|
-
|
566
|
-
# Remove any files in the destination that are not in the source files
|
567
|
-
destination_files = all_files(destination)
|
568
|
-
|
569
|
-
# Calculate the relative paths of files so we can compare to the
|
570
|
-
# source.
|
571
|
-
relative_source_files = source_files.map do |file|
|
572
|
-
relative_path_for(file, source)
|
573
|
-
end
|
574
|
-
relative_destination_files = destination_files.map do |file|
|
575
|
-
relative_path_for(file, destination)
|
576
|
-
end
|
577
|
-
|
578
|
-
# Remove any extra files that are present in the destination, but are
|
579
|
-
# not in the source list
|
580
|
-
extra_files = relative_destination_files - relative_source_files
|
581
|
-
extra_files.each do |file|
|
582
|
-
FileUtils.rm_rf(File.join(destination, file))
|
583
|
-
end
|
518
|
+
Dir.chdir(software.project_dir) do
|
519
|
+
FileSyncer.sync(source, destination, options)
|
584
520
|
end
|
585
521
|
end
|
586
522
|
end
|
@@ -590,29 +526,6 @@ module Omnibus
|
|
590
526
|
# @!endgroup
|
591
527
|
# --------------------------------------------------
|
592
528
|
|
593
|
-
#
|
594
|
-
# @!group Deprecated DSL methods
|
595
|
-
#
|
596
|
-
# The following DSL methods are available from within build blocks, but are
|
597
|
-
# deprecated and will be removed in the next major release.
|
598
|
-
# --------------------------------------------------
|
599
|
-
|
600
|
-
#
|
601
|
-
# @deprecated Use {Config.project_root} instead
|
602
|
-
#
|
603
|
-
def project_root
|
604
|
-
Omnibus.logger.deprecated(log_key) do
|
605
|
-
'project_root (DSL). Please use Config.project_root instead.'
|
606
|
-
end
|
607
|
-
|
608
|
-
Config.project_root
|
609
|
-
end
|
610
|
-
expose :project_root
|
611
|
-
|
612
|
-
#
|
613
|
-
# @!endgroup
|
614
|
-
# --------------------------------------------------
|
615
|
-
|
616
529
|
#
|
617
530
|
# @!group Public API
|
618
531
|
#
|
@@ -715,12 +628,18 @@ module Omnibus
|
|
715
628
|
#
|
716
629
|
# @see (Util#shellout!)
|
717
630
|
#
|
718
|
-
def
|
631
|
+
def shellout!(command_string, options = {})
|
719
632
|
# Make sure the PWD is set to the correct directory
|
720
633
|
options = { cwd: software.project_dir }.merge(options)
|
721
634
|
|
635
|
+
# Set the log level to :info so users will see build commands
|
636
|
+
options[:log_level] ||= :info
|
637
|
+
|
638
|
+
# Set the live stream to :debug so users will see build output
|
639
|
+
options[:live_stream] ||= log.live_stream(:debug)
|
640
|
+
|
722
641
|
# Use Util's shellout
|
723
|
-
|
642
|
+
super(command_string, options)
|
724
643
|
end
|
725
644
|
|
726
645
|
#
|
@@ -748,8 +667,8 @@ module Omnibus
|
|
748
667
|
# Execute the given block with (n) reties defined by {Config#build_retries}.
|
749
668
|
# This method will only retry for the following exceptions:
|
750
669
|
#
|
751
|
-
# - +
|
752
|
-
# - +
|
670
|
+
# - +CommandFailed+
|
671
|
+
# - +CommandTimeout+
|
753
672
|
#
|
754
673
|
# @param [Proc] block
|
755
674
|
# the block to execute
|
@@ -757,10 +676,7 @@ module Omnibus
|
|
757
676
|
def with_retries(&block)
|
758
677
|
tries = Config.build_retries
|
759
678
|
delay = 5
|
760
|
-
exceptions = [
|
761
|
-
Mixlib::ShellOut::ShellCommandFailed,
|
762
|
-
Mixlib::ShellOut::CommandTimeout,
|
763
|
-
]
|
679
|
+
exceptions = [CommandFailed, CommandTimeout]
|
764
680
|
|
765
681
|
begin
|
766
682
|
block.call
|
@@ -827,9 +743,8 @@ module Omnibus
|
|
827
743
|
#
|
828
744
|
def find_file(path, source)
|
829
745
|
# Search for patches just like we search for software
|
830
|
-
candidate_paths = Omnibus.
|
831
|
-
|
832
|
-
"#{full_path}/#{software.name}/#{source}"
|
746
|
+
candidate_paths = Omnibus.possible_paths_for(path).map do |directory|
|
747
|
+
File.join(directory, software.name, source)
|
833
748
|
end
|
834
749
|
|
835
750
|
file = candidate_paths.find { |path| File.exist?(path) }
|
@@ -837,38 +752,6 @@ module Omnibus
|
|
837
752
|
[candidate_paths, file]
|
838
753
|
end
|
839
754
|
|
840
|
-
#
|
841
|
-
# Get all the regular files and directories at the given path. It is assumed
|
842
|
-
# this path is a fully-qualified path and/or executed from a proper relative
|
843
|
-
# path.
|
844
|
-
#
|
845
|
-
# @param [String] path
|
846
|
-
# the path to get all files from
|
847
|
-
#
|
848
|
-
# @return [Array<String>]
|
849
|
-
# the list of all files
|
850
|
-
#
|
851
|
-
def all_files(path)
|
852
|
-
Dir.glob("#{path}/**/*", File::FNM_DOTMATCH).reject do |file|
|
853
|
-
basename = File.basename(file)
|
854
|
-
IGNORED_FILES.include?(basename)
|
855
|
-
end
|
856
|
-
end
|
857
|
-
|
858
|
-
#
|
859
|
-
# The relative path of the given +path+ to the +parent+.
|
860
|
-
#
|
861
|
-
# @param [String] path
|
862
|
-
# the path to get relative with
|
863
|
-
# @param [String] parent
|
864
|
-
# the parent where the path is contained (hopefully)
|
865
|
-
#
|
866
|
-
# @return [String]
|
867
|
-
#
|
868
|
-
def relative_path_for(path, parent)
|
869
|
-
Pathname.new(path).relative_path_from(Pathname.new(parent)).to_s
|
870
|
-
end
|
871
|
-
|
872
755
|
#
|
873
756
|
# The log key for this class, overriden to incorporate the software name.
|
874
757
|
#
|
@@ -879,19 +762,28 @@ module Omnibus
|
|
879
762
|
end
|
880
763
|
|
881
764
|
#
|
882
|
-
#
|
883
|
-
#
|
765
|
+
# Inspect the given command and warn if the command "looks" like it is a
|
766
|
+
# shell command that has a DSL method. (like +command 'cp'+ versus +copy+).
|
884
767
|
#
|
885
|
-
# @param [String]
|
886
|
-
# the
|
768
|
+
# @param [String] command
|
769
|
+
# the command to check
|
887
770
|
#
|
888
|
-
# @return [
|
889
|
-
# the list of all files
|
771
|
+
# @return [void]
|
890
772
|
#
|
891
|
-
def
|
892
|
-
|
893
|
-
|
894
|
-
|
773
|
+
def warn_for_shell_commands(command)
|
774
|
+
case command
|
775
|
+
when /^cp /i
|
776
|
+
log.warn(log_key) { "Detected command `cp'. Consider using the `copy' DSL method." }
|
777
|
+
when /^rubocopy /i
|
778
|
+
log.warn(log_key) { "Detected command `rubocopy'. Consider using the `sync' DSL method." }
|
779
|
+
when /^mv /i
|
780
|
+
log.warn(log_key) { "Detected command `mv'. Consider using the `move' DSL method." }
|
781
|
+
when /^rm /i
|
782
|
+
log.warn(log_key) { "Detected command `rm'. Consider using the `delete' DSL method." }
|
783
|
+
when /^remove /i
|
784
|
+
log.warn(log_key) { "Detected command `remove'. Consider using the `delete' DSL method." }
|
785
|
+
when /^rsync /i
|
786
|
+
log.warn(log_key) { "Detected command `rsync'. Consider using the `sync' DSL method." }
|
895
787
|
end
|
896
788
|
end
|
897
789
|
|