omnibus 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/features/commands/_deprecated.feature +20 -0
- data/lib/omnibus/build_version.rb +8 -22
- data/lib/omnibus/builder.rb +1 -1
- data/lib/omnibus/cli/deprecated.rb +17 -0
- data/lib/omnibus/config.rb +20 -13
- data/lib/omnibus/fetchers/git_fetcher.rb +6 -6
- data/lib/omnibus/fetchers/net_fetcher.rb +1 -1
- data/lib/omnibus/fetchers/path_fetcher.rb +2 -2
- data/lib/omnibus/generator_files/omnibus.rb.example.erb +6 -0
- data/lib/omnibus/generator_files/project.rb.erb +1 -1
- data/lib/omnibus/generator_files/software/c-example.rb.erb +1 -1
- data/lib/omnibus/generator_files/software/erlang-example.rb.erb +1 -1
- data/lib/omnibus/generator_files/software/ruby-example.rb.erb +1 -1
- data/lib/omnibus/install_path_cache.rb +6 -6
- data/lib/omnibus/logger.rb +73 -0
- data/lib/omnibus/project.rb +1 -2
- data/lib/omnibus/util.rb +44 -34
- data/lib/omnibus/version.rb +1 -1
- data/spec/unit/build_version_spec.rb +11 -43
- data/spec/unit/config_spec.rb +34 -2
- data/spec/unit/install_path_cache_spec.rb +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47494584e1a03e4d60e11d7e184ef6fdacfb3fcf
|
4
|
+
data.tar.gz: 6afbd1c06cb80f127ed9d1ef153e6cc66e41a41f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 909e063a81130bc42ddcda0ec238276768b40a12089b26e9ef98ae422ab1ec19cc2b9a888964ef22930d7ce77293dfd2696d4dd8b8d9a2a8ec617d8c88e38f1f
|
7
|
+
data.tar.gz: 627dbb3379bf4642618770455455a977cdf7256c6d97c0e88d50ec999defc77ad532616cb782fe41295fc227613ee672df82718e1b530b837623ac6b5f33e19b
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
Omnibus Ruby CHANGELOG
|
2
2
|
======================
|
3
3
|
|
4
|
+
v3.1.1 (May 20, 2014)
|
5
|
+
---------------------
|
6
|
+
- Update project generators to use new APIs. The old project generators created a project that issued deprecation warnings!
|
7
|
+
- Stream build output to the debug logger. Specifying `--log-level debug` now includes **all** the build output as if you had run the command manually.
|
8
|
+
- Deprecate the `OMNIBUS_APPEND_TIMESTAMP` environment variable in favor of the command line flag. This is only a deprecation, but the `OMNIBUS_APPEND_TIMESTAMP` will be removed in the next major release.
|
9
|
+
- Fix a bug in `windows_safe_path` to always return a string
|
10
|
+
- Add a `Config.base_dir` configuration value for easy tuning
|
11
|
+
- Remove the use of `Omnibus.root` in `BuildVersion#initializer`. This removes the many deprecation warnings that print on each software load.
|
12
|
+
- Output the current command in debug output when shelling out
|
13
|
+
- Output the current environment in debug output when shelling out
|
14
|
+
- Change the information that is displayed at different log levels with respect to shelling out. In `warn` mode, Omnibus will only display warnings/deprecations; you will not see any build commands or output. In `info` mode, Omnibus will display the commands and environment that are being used; you will not see the output from the build (unless it fails). In `debug` mode, Omnibus will display the commands, environment, and output (livestream) from commands.
|
15
|
+
|
16
|
+
|
4
17
|
v3.1.0 (May 14, 2014)
|
5
18
|
-------------------------
|
6
19
|
### New Features
|
@@ -44,3 +44,23 @@ Feature: Backwards-compatible deprecated commands
|
|
44
44
|
"""
|
45
45
|
The project generator has been renamed to 'omnibus new'. Please use 'omnibus new' in the future.
|
46
46
|
"""
|
47
|
+
|
48
|
+
Scenario: When OMNIBUS_APPEND_TIMESTAMP is given (true)
|
49
|
+
* I set the environment variables to:
|
50
|
+
| variable | value |
|
51
|
+
| OMNIBUS_APPEND_TIMESTAMP | true |
|
52
|
+
* I run `omnibus build hamlet`
|
53
|
+
* the output should contain:
|
54
|
+
"""
|
55
|
+
The environment variable 'OMNIBUS_APPEND_TIMESTAMP' is deprecated. Please use '--override append_timestamp:true' instead.
|
56
|
+
"""
|
57
|
+
|
58
|
+
Scenario: When OMNIBUS_APPEND_TIMESTAMP is given (false)
|
59
|
+
* I set the environment variables to:
|
60
|
+
| variable | value |
|
61
|
+
| OMNIBUS_APPEND_TIMESTAMP | false |
|
62
|
+
* I run `omnibus build hamlet`
|
63
|
+
* the output should contain:
|
64
|
+
"""
|
65
|
+
The environment variable 'OMNIBUS_APPEND_TIMESTAMP' is deprecated. Please use '--override append_timestamp:false' instead.
|
66
|
+
"""
|
@@ -62,7 +62,7 @@ module Omnibus
|
|
62
62
|
# Create a new BuildVersion
|
63
63
|
#
|
64
64
|
# @param [String] path Path from which to read git version information
|
65
|
-
def initialize(path = Omnibus.
|
65
|
+
def initialize(path = Omnibus.project_root)
|
66
66
|
@path = path
|
67
67
|
end
|
68
68
|
|
@@ -79,12 +79,9 @@ module Omnibus
|
|
79
79
|
#
|
80
80
|
# MAJOR.MINOR.PATCH-PRERELEASE+TIMESTAMP.git.COMMITS_SINCE.GIT_SHA
|
81
81
|
#
|
82
|
-
# By default, a timestamp is incorporated into the build component
|
83
|
-
#
|
84
|
-
# {Omnibus::
|
85
|
-
# disabled by setting the environment variable
|
86
|
-
# `OMNIBUS_APPEND_TIMESTAMP` to a "falsey" value (e.g. "false",
|
87
|
-
# "f", "no", "n", "0")
|
82
|
+
# By default, a timestamp is incorporated into the build component of
|
83
|
+
# version string (see {Omnibus::BuildVersion::TIMESTAMP_FORMAT}). This
|
84
|
+
# option is configurable via the {Omnibus::Config}.
|
88
85
|
#
|
89
86
|
# @example 11.0.0-alpha.1+20121218164140.git.207.694b062
|
90
87
|
# @return [String]
|
@@ -114,7 +111,9 @@ module Omnibus
|
|
114
111
|
# variable to a 'falsey' value (ie false, f, no, n or 0).
|
115
112
|
#
|
116
113
|
# format: YYYYMMDDHHMMSS example: 20130131123345
|
117
|
-
|
114
|
+
if Config.append_timestamp
|
115
|
+
build_version_items << build_start_time.strftime(TIMESTAMP_FORMAT)
|
116
|
+
end
|
118
117
|
|
119
118
|
# We'll append the git describe information unless we are sitting right
|
120
119
|
# on an annotated tag.
|
@@ -144,7 +143,7 @@ module Omnibus
|
|
144
143
|
# @return [String]
|
145
144
|
def git_describe
|
146
145
|
@git_describe ||= begin
|
147
|
-
cmd =
|
146
|
+
cmd = shellout('git describe --tags', cwd: @path)
|
148
147
|
|
149
148
|
if cmd.exitstatus == 0
|
150
149
|
cmd.stdout.chomp
|
@@ -288,18 +287,5 @@ module Omnibus
|
|
288
287
|
version_regexp = /^(\d+)\.(\d+)\.(\d+)/
|
289
288
|
version_regexp.match(git_describe)[1..3]
|
290
289
|
end
|
291
|
-
|
292
|
-
#
|
293
|
-
# @todo Remove this environment variable madness and just use the CLI
|
294
|
-
#
|
295
|
-
def append_timestamp?
|
296
|
-
if ENV['OMNIBUS_APPEND_TIMESTAMP'] && (ENV['OMNIBUS_APPEND_TIMESTAMP'] =~ (/^(false|f|no|n|0)$/i))
|
297
|
-
false
|
298
|
-
elsif ENV['OMNIBUS_APPEND_TIMESTAMP'] && (ENV['OMNIBUS_APPEND_TIMESTAMP'] =~ (/^(true|t|yes|y|1)$/i))
|
299
|
-
true
|
300
|
-
else
|
301
|
-
Omnibus::Config.append_timestamp
|
302
|
-
end
|
303
|
-
end
|
304
290
|
end
|
305
291
|
end
|
data/lib/omnibus/builder.rb
CHANGED
@@ -251,7 +251,7 @@ module Omnibus
|
|
251
251
|
cwd: project_dir,
|
252
252
|
timeout: 5400,
|
253
253
|
}
|
254
|
-
options[:live_stream] =
|
254
|
+
options[:live_stream] = log.live_stream(:debug)
|
255
255
|
if cmd_args.last.is_a? Hash
|
256
256
|
cmd_options = cmd_args.last
|
257
257
|
cmd_args[cmd_args.size - 1] = options.merge(cmd_options)
|
@@ -23,8 +23,25 @@
|
|
23
23
|
module Omnibus
|
24
24
|
class Command::Base
|
25
25
|
class << self
|
26
|
+
include Util
|
27
|
+
|
26
28
|
alias_method :old_dispatch, :dispatch
|
27
29
|
def dispatch(m, args, options, config)
|
30
|
+
# Handle OMNIBUS_APPEND_TIMESTAMP environment
|
31
|
+
if ENV.key?('OMNIBUS_APPEND_TIMESTAMP')
|
32
|
+
value = ENV.delete('OMNIBUS_APPEND_TIMESTAMP')
|
33
|
+
|
34
|
+
if truthy?(value)
|
35
|
+
warn("The environment variable 'OMNIBUS_APPEND_TIMESTAMP' is deprecated. Please use '--override append_timestamp:true' instead.")
|
36
|
+
args += %(--override append_timestamp:true)
|
37
|
+
elsif falsey?(value)
|
38
|
+
warn("The environment variable 'OMNIBUS_APPEND_TIMESTAMP' is deprecated. Please use '--override append_timestamp:false' instead.")
|
39
|
+
args += %(--override append_timestamp:false)
|
40
|
+
else
|
41
|
+
raise "Unknown value for OMNIBUS_APPEND_TIMESTAMP: #{value.inspect}!"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
28
45
|
# Handle old --timestamp
|
29
46
|
if args.include?('--timestamp') || args.include?('-t')
|
30
47
|
warn("The '--timestamp' option has been deprecated! Please use '--override append_timestamp:true' instead.")
|
data/lib/omnibus/config.rb
CHANGED
@@ -25,19 +25,26 @@ module Omnibus
|
|
25
25
|
# it out twice, which I'm doing now for benefit of viewers of the Yard docs.
|
26
26
|
class Config
|
27
27
|
extend Mixlib::Config
|
28
|
+
extend Util
|
28
29
|
|
29
|
-
#
|
30
|
-
|
31
|
-
|
30
|
+
# @!group Directory Configuration Parameters
|
31
|
+
|
32
|
+
# @!attribute [rw] base_dir
|
33
|
+
# The "base" directory where Omnibus will store it's data. Other paths are
|
34
|
+
# dynamically constructed from this value.
|
35
|
+
#
|
36
|
+
# Defaults to `"C:\omnibus-ruby"` on Windows
|
37
|
+
# Defaults to `"/var/cache/omnibus"` on other platforms
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
default(:base_dir) do
|
32
41
|
if Ohai.platform == 'windows'
|
33
|
-
|
42
|
+
'C:\\omnibus-ruby'
|
34
43
|
else
|
35
|
-
|
44
|
+
'/var/cache/omnibus'
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
39
|
-
# @!group Directory Configuration Parameters
|
40
|
-
|
41
48
|
# @!attribute [rw] cache_dir
|
42
49
|
# The absolute path to the directory on the virtual machine where
|
43
50
|
# code will be cached.
|
@@ -45,7 +52,7 @@ module Omnibus
|
|
45
52
|
# Defaults to `"/var/cache/omnibus/cache"`.
|
46
53
|
#
|
47
54
|
# @return [String]
|
48
|
-
default(:cache_dir) {
|
55
|
+
default(:cache_dir) { windows_safe_path(base_dir, 'cache') }
|
49
56
|
|
50
57
|
# @!attribute [rw] install_path_cache_dir
|
51
58
|
# The absolute path to the directory on the virtual machine where
|
@@ -54,7 +61,7 @@ module Omnibus
|
|
54
61
|
# Defaults to `"/var/cache/omnibus/cache/install_path"`.
|
55
62
|
#
|
56
63
|
# @return [String]
|
57
|
-
default(:install_path_cache_dir) {
|
64
|
+
default(:install_path_cache_dir) { windows_safe_path(base_dir, 'cache', 'install_path') }
|
58
65
|
|
59
66
|
# @!attribute [rw] source_dir
|
60
67
|
# The absolute path to the directory on the virtual machine where
|
@@ -63,7 +70,7 @@ module Omnibus
|
|
63
70
|
# Defaults to `"/var/cache/omnibus/src"`.
|
64
71
|
#
|
65
72
|
# @return [String]
|
66
|
-
default(:source_dir) {
|
73
|
+
default(:source_dir) { windows_safe_path(base_dir, 'src') }
|
67
74
|
|
68
75
|
# @!attribute [rw] build_dir
|
69
76
|
# The absolute path to the directory on the virtual machine where
|
@@ -72,7 +79,7 @@ module Omnibus
|
|
72
79
|
# Defaults to `"/var/cache/omnibus/build"`.
|
73
80
|
#
|
74
81
|
# @return [String]
|
75
|
-
default(:build_dir) {
|
82
|
+
default(:build_dir) { windows_safe_path(base_dir, 'build') }
|
76
83
|
|
77
84
|
# @!attribute [rw] package_dir
|
78
85
|
# The absolute path to the directory on the virtual machine where
|
@@ -81,7 +88,7 @@ module Omnibus
|
|
81
88
|
# Defaults to `"/var/cache/omnibus/pkg"`.
|
82
89
|
#
|
83
90
|
# @return [String]
|
84
|
-
default(:package_dir) {
|
91
|
+
default(:package_dir) { windows_safe_path(base_dir, 'pkg') }
|
85
92
|
|
86
93
|
# @!attribute [rw] package_tmp
|
87
94
|
# The absolute path to the directory on the virtual machine where
|
@@ -92,7 +99,7 @@ module Omnibus
|
|
92
99
|
# Defaults to `"/var/cache/omnibus/pkg-tmp"`.
|
93
100
|
#
|
94
101
|
# @return [String]
|
95
|
-
default(:package_tmp) {
|
102
|
+
default(:package_tmp) { windows_safe_path(base_dir, 'pkg-tmp') }
|
96
103
|
|
97
104
|
# @!attribute [rw] project_dir
|
98
105
|
# The relative path of the directory containing {Omnibus::Project}
|
@@ -44,7 +44,7 @@ module Omnibus
|
|
44
44
|
def clean
|
45
45
|
if existing_git_clone?
|
46
46
|
log.info(log_key) { 'Cleaning existing build' }
|
47
|
-
|
47
|
+
shellout!('git clean -fdx', cwd: project_dir)
|
48
48
|
end
|
49
49
|
rescue Exception => e
|
50
50
|
ErrorReporter.new(e, self).explain("Failed to clean git repository '#{@source[:git]}'")
|
@@ -91,12 +91,12 @@ module Omnibus
|
|
91
91
|
|
92
92
|
def clone
|
93
93
|
log.info(log_key) { 'Cloning the source from git' }
|
94
|
-
|
94
|
+
shellout!("git clone #{@source[:git]} #{project_dir}")
|
95
95
|
end
|
96
96
|
|
97
97
|
def checkout
|
98
98
|
sha_ref = target_revision
|
99
|
-
|
99
|
+
shellout!("git checkout #{sha_ref}", cwd: project_dir)
|
100
100
|
end
|
101
101
|
|
102
102
|
def fetch_updates
|
@@ -107,7 +107,7 @@ module Omnibus
|
|
107
107
|
fetch_cmd = "git fetch origin && " \
|
108
108
|
"git fetch origin --tags && " \
|
109
109
|
"git reset --hard #{target_revision}"
|
110
|
-
|
110
|
+
shellout!(fetch_cmd, cwd: project_dir)
|
111
111
|
end
|
112
112
|
|
113
113
|
def existing_git_clone?
|
@@ -121,7 +121,7 @@ module Omnibus
|
|
121
121
|
def current_revision
|
122
122
|
return @current_rev if @current_rev
|
123
123
|
|
124
|
-
cmd =
|
124
|
+
cmd = shellout!('git rev-parse HEAD', cwd: project_dir)
|
125
125
|
stdout = cmd.stdout
|
126
126
|
|
127
127
|
@current_rev = sha_hash?(stdout) ? stdout : nil
|
@@ -148,7 +148,7 @@ module Omnibus
|
|
148
148
|
# allows us to return the SHA of the tagged commit for annotated
|
149
149
|
# tags. We take care to only return exact matches in
|
150
150
|
# process_remote_list.
|
151
|
-
cmd =
|
151
|
+
cmd = shellout!("git ls-remote origin #{ref}*", cwd: project_dir)
|
152
152
|
commit_ref = process_remote_list(cmd.stdout, ref)
|
153
153
|
|
154
154
|
unless commit_ref
|
@@ -37,10 +37,10 @@ module Omnibus
|
|
37
37
|
# Robocopy's return code is 1 if it succesfully copies over the
|
38
38
|
# files and 0 if the files are already existing at the destination
|
39
39
|
sync_cmd = "robocopy #{@source[:path]}\\ #{@project_dir}\\ /MIR /S"
|
40
|
-
|
40
|
+
shellout!(sync_cmd, returns: [0, 1])
|
41
41
|
else
|
42
42
|
sync_cmd = "rsync --delete -a #{@source[:path]}/ #{@project_dir}/"
|
43
|
-
|
43
|
+
shellout!(sync_cmd)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -13,6 +13,12 @@
|
|
13
13
|
# project configuration to build at +./local/omnibus/build+ instead of
|
14
14
|
# +<%= config[:install_path] %>+
|
15
15
|
#
|
16
|
+
# Uncomment this line to change the default base directory to "local"
|
17
|
+
# -------------------------------------------------------------------
|
18
|
+
# base_dir './local'
|
19
|
+
#
|
20
|
+
# Alternatively you can tune the individual values
|
21
|
+
# ------------------------------------------------
|
16
22
|
# cache_dir './local/omnibus/cache'
|
17
23
|
# install_path_cache_dir './local/omnibus/cache/install_path'
|
18
24
|
# source_dir './local/omnibus/src'
|
@@ -39,7 +39,7 @@ module Omnibus
|
|
39
39
|
# Creates the full path if it does not exist already
|
40
40
|
def create_cache_path
|
41
41
|
FileUtils.mkdir_p(File.dirname(cache_path))
|
42
|
-
|
42
|
+
shellout!("git --git-dir=#{cache_path} init -q") unless cache_path_exists?
|
43
43
|
true
|
44
44
|
end
|
45
45
|
|
@@ -74,20 +74,20 @@ module Omnibus
|
|
74
74
|
# Create an incremental install path cache for the software step
|
75
75
|
def incremental
|
76
76
|
create_cache_path
|
77
|
-
|
77
|
+
shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} add -A -f))
|
78
78
|
begin
|
79
|
-
|
79
|
+
shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} commit -q -m "Backup of #{tag}"))
|
80
80
|
rescue Mixlib::ShellOut::ShellCommandFailed => e
|
81
81
|
if e.message !~ /nothing to commit/
|
82
82
|
raise
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
85
|
+
shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -f "#{tag}"))
|
86
86
|
end
|
87
87
|
|
88
88
|
def restore
|
89
89
|
create_cache_path
|
90
|
-
cmd =
|
90
|
+
cmd = shellout(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -l "#{tag}"))
|
91
91
|
|
92
92
|
restore_me = false
|
93
93
|
cmd.stdout.each_line do |line|
|
@@ -95,7 +95,7 @@ module Omnibus
|
|
95
95
|
end
|
96
96
|
|
97
97
|
if restore_me
|
98
|
-
|
98
|
+
shellout!(%Q(git --git-dir=#{cache_path} --work-tree=#{@install_path} checkout -f "#{tag}"))
|
99
99
|
true
|
100
100
|
else
|
101
101
|
false
|
data/lib/omnibus/logger.rb
CHANGED
@@ -32,6 +32,18 @@ module Omnibus
|
|
32
32
|
raise "'#{level.inspect}' does not appear to be a valid log level!"
|
33
33
|
end
|
34
34
|
|
35
|
+
#
|
36
|
+
# The live stream for this logger.
|
37
|
+
#
|
38
|
+
# @param [Symbol] level
|
39
|
+
#
|
40
|
+
# @return [LiveStream]
|
41
|
+
#
|
42
|
+
def live_stream(level = :debug)
|
43
|
+
@live_streams ||= {}
|
44
|
+
@live_streams[level.to_sym] ||= LiveStream.new(self, level)
|
45
|
+
end
|
46
|
+
|
35
47
|
private
|
36
48
|
|
37
49
|
def format_message(severity, _datetime, progname, msg)
|
@@ -43,5 +55,66 @@ module Omnibus
|
|
43
55
|
|
44
56
|
"#{left.rjust(30)}#{msg}\n"
|
45
57
|
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# This is a magical wrapper around the logger that chunks data to not look
|
61
|
+
# like absolute shit.
|
62
|
+
#
|
63
|
+
class LiveStream
|
64
|
+
#
|
65
|
+
# Create a new LiveStream logger.
|
66
|
+
#
|
67
|
+
# @param [Logger] log
|
68
|
+
# the logger object responsible for logging
|
69
|
+
# @param [Symbol] level
|
70
|
+
# the log level
|
71
|
+
#
|
72
|
+
def initialize(log, level = :debug)
|
73
|
+
@log = log
|
74
|
+
@level = level
|
75
|
+
@buffer = ''
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# The live stream operator must respond to <<.
|
80
|
+
#
|
81
|
+
# @param [String] data
|
82
|
+
#
|
83
|
+
def <<(data)
|
84
|
+
log_lines(data)
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
#
|
90
|
+
# Log the lines in the data, keeping the "rest" in the buffer.
|
91
|
+
#
|
92
|
+
# @param [String] data
|
93
|
+
#
|
94
|
+
def log_lines(data)
|
95
|
+
if (leftover = @buffer)
|
96
|
+
@buffer = nil
|
97
|
+
log_lines(leftover + data)
|
98
|
+
else
|
99
|
+
if (newline_index = data.index("\n"))
|
100
|
+
line = data.slice!(0...newline_index)
|
101
|
+
data.slice!(0)
|
102
|
+
log_line(line)
|
103
|
+
log_lines(data)
|
104
|
+
else
|
105
|
+
@buffer = data
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# Log an individual line.
|
112
|
+
#
|
113
|
+
# @param [String] data
|
114
|
+
#
|
115
|
+
def log_line(data)
|
116
|
+
@log.public_send(@level) { data }
|
117
|
+
end
|
118
|
+
end
|
46
119
|
end
|
47
120
|
end
|
data/lib/omnibus/project.rb
CHANGED
@@ -226,8 +226,7 @@ module Omnibus
|
|
226
226
|
# must be set in order to build a project)
|
227
227
|
def install_path(val = NULL_ARG)
|
228
228
|
unless val.equal?(NULL_ARG)
|
229
|
-
@install_path =
|
230
|
-
windows_safe_path!(@install_path)
|
229
|
+
@install_path = windows_safe_path(val)
|
231
230
|
end
|
232
231
|
@install_path || raise(MissingProjectConfiguration.new('install_path', '/opt/chef'))
|
233
232
|
end
|
data/lib/omnibus/util.rb
CHANGED
@@ -17,10 +17,19 @@
|
|
17
17
|
require 'mixlib/shellout'
|
18
18
|
|
19
19
|
module Omnibus
|
20
|
-
#
|
21
|
-
# @author Seth Chisamore (<schisamo@getchef.com>)
|
22
|
-
#
|
23
20
|
module Util
|
21
|
+
#
|
22
|
+
# The default shellout options.
|
23
|
+
#
|
24
|
+
# @return [Hash]
|
25
|
+
#
|
26
|
+
SHELLOUT_OPTIONS = {
|
27
|
+
live_stream: Omnibus.logger.live_stream(:debug),
|
28
|
+
timeout: 7200, # 2 hours
|
29
|
+
environment: {},
|
30
|
+
}.freeze
|
31
|
+
|
32
|
+
#
|
24
33
|
# Shells out and runs +command+.
|
25
34
|
#
|
26
35
|
# @overload shellout(command, options = {})
|
@@ -37,14 +46,20 @@ module Omnibus
|
|
37
46
|
#
|
38
47
|
def shellout(*args)
|
39
48
|
options = args.last.kind_of?(Hash) ? args.pop : {}
|
49
|
+
options = SHELLOUT_OPTIONS.merge(options)
|
50
|
+
|
51
|
+
# Log any environment options given
|
52
|
+
unless options[:environment].empty?
|
53
|
+
Omnibus.logger.info { 'Environment:' }
|
54
|
+
options[:environment].each do |key, value|
|
55
|
+
Omnibus.logger.info { " #{key.to_s.upcase}=#{value.inspect}" }
|
56
|
+
end
|
57
|
+
end
|
40
58
|
|
41
|
-
|
42
|
-
|
43
|
-
timeout: 7200, # 2 hours
|
44
|
-
environment: {},
|
45
|
-
}
|
59
|
+
# Log the actual command
|
60
|
+
Omnibus.logger.info { "$ #{args.join(' ')}" }
|
46
61
|
|
47
|
-
cmd = Mixlib::ShellOut.new(*args,
|
62
|
+
cmd = Mixlib::ShellOut.new(*args, options)
|
48
63
|
cmd.run_command
|
49
64
|
cmd
|
50
65
|
end
|
@@ -63,38 +78,33 @@ module Omnibus
|
|
63
78
|
cmd
|
64
79
|
end
|
65
80
|
|
81
|
+
# Return true if the given value appears to be "truthy".
|
66
82
|
#
|
67
|
-
#
|
68
|
-
|
69
|
-
|
70
|
-
#
|
71
|
-
def quiet_shellout(*args)
|
72
|
-
options = args.last.kind_of?(Hash) ? args.pop : {}
|
73
|
-
options[:live_stream] = nil
|
74
|
-
args << options
|
75
|
-
shellout(*args)
|
83
|
+
# @param [#to_s] value
|
84
|
+
def truthy?(value)
|
85
|
+
value && value.to_s =~ /^(true|t|yes|y|1)$/i
|
76
86
|
end
|
77
87
|
|
88
|
+
# Return true if the given value appears to be "falsey".
|
78
89
|
#
|
79
|
-
#
|
80
|
-
|
81
|
-
|
82
|
-
# @see (Util#shellout!)
|
83
|
-
#
|
84
|
-
def quiet_shellout!(*args)
|
85
|
-
options = args.last.kind_of?(Hash) ? args.pop : {}
|
86
|
-
options[:live_stream] = nil
|
87
|
-
args << options
|
88
|
-
shellout!(*args)
|
90
|
+
# @param [#to_s] value
|
91
|
+
def falsey?(value)
|
92
|
+
value && value.to_s =~ /^(false|f|no|n|0)$/i
|
89
93
|
end
|
90
94
|
|
91
|
-
#
|
92
|
-
#
|
93
|
-
# @
|
94
|
-
#
|
95
|
+
# @param [Array<String>] pieces
|
96
|
+
# the pieces of the path to join and fix
|
97
|
+
# @return [String]
|
98
|
+
# the path with applied changes
|
95
99
|
#
|
96
|
-
def windows_safe_path
|
97
|
-
path.
|
100
|
+
def windows_safe_path(*pieces)
|
101
|
+
path = File.expand_path(File.join(*pieces))
|
102
|
+
|
103
|
+
if File::ALT_SEPARATOR
|
104
|
+
path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
|
105
|
+
else
|
106
|
+
path
|
107
|
+
end
|
98
108
|
end
|
99
109
|
end
|
100
110
|
end
|
data/lib/omnibus/version.rb
CHANGED
@@ -139,56 +139,24 @@ module Omnibus
|
|
139
139
|
describe 'appending a timestamp' do
|
140
140
|
let(:git_describe) { '11.0.0-alpha-3-207-g694b062' }
|
141
141
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
describe "ENV['OMNIBUS_APPEND_TIMESTAMP'] is set" do
|
147
|
-
['true', 't', 'yes', 'y', 1].each do |truthy|
|
148
|
-
context "to #{truthy}" do
|
149
|
-
before { stub_env('OMNIBUS_APPEND_TIMESTAMP', truthy) }
|
150
|
-
|
151
|
-
it 'appends a timestamp' do
|
152
|
-
expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
['false', 'f', 'no', 'n', 0].each do |falsey|
|
158
|
-
context "to #{falsey}" do
|
159
|
-
before { stub_env('OMNIBUS_APPEND_TIMESTAMP', falsey) }
|
160
|
-
|
161
|
-
it 'does not append a timestamp' do
|
162
|
-
expect(build_version.semver).to match(/11.0.0-alpha.3\+git.207.694b062/)
|
163
|
-
end
|
164
|
-
end
|
142
|
+
context 'by default' do
|
143
|
+
it 'appends a timestamp' do
|
144
|
+
expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
|
165
145
|
end
|
166
146
|
end
|
167
147
|
|
168
|
-
|
169
|
-
|
170
|
-
before { Config.stub(:append_timestamp).and_return(true) }
|
148
|
+
context 'when Config.append_timestamp is true' do
|
149
|
+
before { Config.stub(:append_timestamp).and_return(true) }
|
171
150
|
|
172
|
-
|
173
|
-
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
context 'is false' do
|
178
|
-
before { Config.stub(:append_timestamp).and_return(false) }
|
179
|
-
it 'does not append a timestamp' do
|
180
|
-
expect(build_version.semver).to match(/11.0.0-alpha.3\+git.207.694b062/)
|
181
|
-
end
|
151
|
+
it 'appends a timestamp' do
|
152
|
+
expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
|
182
153
|
end
|
183
154
|
end
|
184
155
|
|
185
|
-
|
186
|
-
before
|
187
|
-
stub_env('OMNIBUS_APPEND_TIMESTAMP', 'false')
|
188
|
-
Config.stub(:append_timestamp).and_return(true)
|
189
|
-
end
|
156
|
+
context 'when Config.append_timestamp is false' do
|
157
|
+
before { Config.stub(:append_timestamp).and_return(false) }
|
190
158
|
|
191
|
-
it
|
159
|
+
it 'does not append a timestamp' do
|
192
160
|
expect(build_version.semver).to match(/11.0.0-alpha.3\+git.207.694b062/)
|
193
161
|
end
|
194
162
|
end
|
@@ -236,7 +204,7 @@ module Omnibus
|
|
236
204
|
|
237
205
|
it 'runs `git describe` at an alternate path' do
|
238
206
|
expect(build_version).to receive(:shellout)
|
239
|
-
.with('git describe --tags',
|
207
|
+
.with('git describe --tags', cwd: path)
|
240
208
|
.and_return(double('ouput', stdout: git_describe, exitstatus: 0))
|
241
209
|
build_version.git_describe
|
242
210
|
end
|
data/spec/unit/config_spec.rb
CHANGED
@@ -6,9 +6,26 @@ module Omnibus
|
|
6
6
|
expect(described_class).to be_a(Mixlib::Config)
|
7
7
|
end
|
8
8
|
|
9
|
+
it 'extends Util' do
|
10
|
+
expect(described_class).to be_a(Util)
|
11
|
+
end
|
12
|
+
|
9
13
|
before do
|
14
|
+
# Don't expand paths on the build system. Otherwise, you will end up with
|
15
|
+
# paths like +\\Users\\you\\Development\\omnibus-ruby\\C:\\omnibus-ruby+
|
16
|
+
# when testing on "other" operating systems
|
17
|
+
File.stub(:expand_path) { |arg| arg }
|
18
|
+
|
19
|
+
# Make sure we have a clean config
|
20
|
+
described_class.reset
|
21
|
+
|
22
|
+
# Prevent Ohai from running
|
23
|
+
Ohai.stub(:platform).and_return('linux')
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
# Make sure future tests are clean
|
10
28
|
described_class.reset
|
11
|
-
stub_ohai(platform: 'linux')
|
12
29
|
end
|
13
30
|
|
14
31
|
shared_examples 'a configurable' do |id, default|
|
@@ -21,6 +38,7 @@ module Omnibus
|
|
21
38
|
end
|
22
39
|
end
|
23
40
|
|
41
|
+
include_examples 'a configurable', :base_dir, '/var/cache/omnibus'
|
24
42
|
include_examples 'a configurable', :cache_dir, '/var/cache/omnibus/cache'
|
25
43
|
include_examples 'a configurable', :install_path_cache_dir, '/var/cache/omnibus/cache/install_path'
|
26
44
|
include_examples 'a configurable', :source_dir, '/var/cache/omnibus/src'
|
@@ -46,10 +64,13 @@ module Omnibus
|
|
46
64
|
|
47
65
|
context 'on Windows' do
|
48
66
|
before do
|
49
|
-
|
67
|
+
Ohai.stub(:platform).and_return('windows')
|
68
|
+
|
69
|
+
# This is not defined on Linuxy Rubies
|
50
70
|
stub_const('File::ALT_SEPARATOR', '\\')
|
51
71
|
end
|
52
72
|
|
73
|
+
include_examples 'a configurable', :base_dir, 'C:\\omnibus-ruby'
|
53
74
|
include_examples 'a configurable', :cache_dir, 'C:\\omnibus-ruby\\cache'
|
54
75
|
include_examples 'a configurable', :install_path_cache_dir, 'C:\\omnibus-ruby\\cache\\install_path'
|
55
76
|
include_examples 'a configurable', :source_dir, 'C:\\omnibus-ruby\\src'
|
@@ -57,5 +78,16 @@ module Omnibus
|
|
57
78
|
include_examples 'a configurable', :package_dir, 'C:\\omnibus-ruby\\pkg'
|
58
79
|
include_examples 'a configurable', :package_tmp, 'C:\\omnibus-ruby\\pkg-tmp'
|
59
80
|
end
|
81
|
+
|
82
|
+
context 'when base_dir is changed' do
|
83
|
+
before { described_class.base_dir = '/foo/bar' }
|
84
|
+
|
85
|
+
include_examples 'a configurable', :cache_dir, '/foo/bar/cache'
|
86
|
+
include_examples 'a configurable', :install_path_cache_dir, '/foo/bar/cache/install_path'
|
87
|
+
include_examples 'a configurable', :source_dir, '/foo/bar/src'
|
88
|
+
include_examples 'a configurable', :build_dir, '/foo/bar/build'
|
89
|
+
include_examples 'a configurable', :package_dir, '/foo/bar/pkg'
|
90
|
+
include_examples 'a configurable', :package_tmp, '/foo/bar/pkg-tmp'
|
91
|
+
end
|
60
92
|
end
|
61
93
|
end
|
@@ -105,7 +105,7 @@ module Omnibus
|
|
105
105
|
.and_return(false)
|
106
106
|
expect(FileUtils).to receive(:mkdir_p)
|
107
107
|
.with(File.dirname(ipc.cache_path))
|
108
|
-
expect(ipc).to receive(:
|
108
|
+
expect(ipc).to receive(:shellout!)
|
109
109
|
.with("git --git-dir=#{cache_path} init -q")
|
110
110
|
ipc.create_cache_path
|
111
111
|
end
|
@@ -117,7 +117,7 @@ module Omnibus
|
|
117
117
|
allow(File).to receive(:directory?)
|
118
118
|
.with(File.dirname(ipc.cache_path))
|
119
119
|
.and_return(true)
|
120
|
-
expect(ipc).to_not receive(:
|
120
|
+
expect(ipc).to_not receive(:shellout!)
|
121
121
|
.with("git --git-dir=#{cache_path} init -q")
|
122
122
|
ipc.create_cache_path
|
123
123
|
end
|
@@ -125,7 +125,7 @@ module Omnibus
|
|
125
125
|
|
126
126
|
describe '#incremental' do
|
127
127
|
before(:each) do
|
128
|
-
allow(ipc).to receive(:
|
128
|
+
allow(ipc).to receive(:shellout!)
|
129
129
|
allow(ipc).to receive(:create_cache_path)
|
130
130
|
end
|
131
131
|
|
@@ -135,19 +135,19 @@ module Omnibus
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'adds all the changes to git' do
|
138
|
-
expect(ipc).to receive(:
|
138
|
+
expect(ipc).to receive(:shellout!)
|
139
139
|
.with("git --git-dir=#{cache_path} --work-tree=#{install_path} add -A -f")
|
140
140
|
ipc.incremental
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'commits the backup for the software' do
|
144
|
-
expect(ipc).to receive(:
|
144
|
+
expect(ipc).to receive(:shellout!)
|
145
145
|
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} commit -q -m "Backup of #{ipc.tag}"))
|
146
146
|
ipc.incremental
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'tags the software backup' do
|
150
|
-
expect(ipc).to receive(:
|
150
|
+
expect(ipc).to receive(:shellout!)
|
151
151
|
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -f "#{ipc.tag}"))
|
152
152
|
ipc.incremental
|
153
153
|
end
|
@@ -164,10 +164,10 @@ module Omnibus
|
|
164
164
|
end
|
165
165
|
|
166
166
|
before(:each) do
|
167
|
-
allow(ipc).to receive(:
|
167
|
+
allow(ipc).to receive(:shellout)
|
168
168
|
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l "#{ipc.tag}"))
|
169
169
|
.and_return(tag_cmd)
|
170
|
-
allow(ipc).to receive(:
|
170
|
+
allow(ipc).to receive(:shellout!)
|
171
171
|
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f "#{ipc.tag}"))
|
172
172
|
allow(ipc).to receive(:create_cache_path)
|
173
173
|
end
|
@@ -178,10 +178,10 @@ module Omnibus
|
|
178
178
|
end
|
179
179
|
|
180
180
|
it 'checks for a tag with the software and version, and if it finds it, checks it out' do
|
181
|
-
expect(ipc).to receive(:
|
181
|
+
expect(ipc).to receive(:shellout)
|
182
182
|
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l "#{ipc.tag}"))
|
183
183
|
.and_return(tag_cmd)
|
184
|
-
expect(ipc).to receive(:
|
184
|
+
expect(ipc).to receive(:shellout!)
|
185
185
|
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f "#{ipc.tag}"))
|
186
186
|
ipc.restore
|
187
187
|
end
|
@@ -190,10 +190,10 @@ module Omnibus
|
|
190
190
|
let(:git_tag_output) { "\n" }
|
191
191
|
|
192
192
|
it 'does nothing' do
|
193
|
-
expect(ipc).to receive(:
|
193
|
+
expect(ipc).to receive(:shellout)
|
194
194
|
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l "#{ipc.tag}"))
|
195
195
|
.and_return(tag_cmd)
|
196
|
-
expect(ipc).to_not receive(:
|
196
|
+
expect(ipc).to_not receive(:shellout!)
|
197
197
|
.with(%Q(git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f "#{ipc.tag}"))
|
198
198
|
ipc.restore
|
199
199
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omnibus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-sugar
|