omnibus 5.5.0 → 5.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- data/.travis.yml +2 -1
- data/CHANGELOG.md +37 -0
- data/Gemfile +5 -4
- data/MAINTAINERS.md +12 -17
- data/README.md +98 -107
- data/appveyor.yml +1 -1
- data/lib/omnibus.rb +4 -4
- data/lib/omnibus/builder.rb +42 -9
- data/lib/omnibus/cli.rb +5 -0
- data/lib/omnibus/cli/base.rb +1 -1
- data/lib/omnibus/cli/publish.rb +5 -3
- data/lib/omnibus/compressors/dmg.rb +2 -2
- data/lib/omnibus/config.rb +42 -5
- data/lib/omnibus/core_extensions/open_uri.rb +1 -0
- data/lib/omnibus/download_helpers.rb +4 -4
- data/lib/omnibus/fetchers/git_fetcher.rb +15 -5
- data/lib/omnibus/fetchers/net_fetcher.rb +1 -1
- data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
- data/lib/omnibus/file_syncer.rb +2 -2
- data/lib/omnibus/generator_files/omnibus.rb.erb +1 -0
- data/lib/omnibus/git_cache.rb +31 -13
- data/lib/omnibus/health_check.rb +1 -173
- data/lib/omnibus/licensing.rb +48 -7
- data/lib/omnibus/manifest.rb +3 -5
- data/lib/omnibus/manifest_entry.rb +1 -1
- data/lib/omnibus/metadata.rb +2 -1
- data/lib/omnibus/packager.rb +3 -1
- data/lib/omnibus/packagers/appx.rb +3 -3
- data/lib/omnibus/packagers/base.rb +9 -0
- data/lib/omnibus/packagers/bff.rb +4 -6
- data/lib/omnibus/packagers/deb.rb +95 -1
- data/lib/omnibus/packagers/ips.rb +50 -4
- data/lib/omnibus/packagers/pkgsrc.rb +112 -0
- data/lib/omnibus/packagers/rpm.rb +72 -3
- data/lib/omnibus/packagers/solaris.rb +0 -4
- data/lib/omnibus/packagers/windows_base.rb +1 -1
- data/lib/omnibus/project.rb +13 -3
- data/lib/omnibus/publishers/artifactory_publisher.rb +4 -6
- data/lib/omnibus/publishers/s3_publisher.rb +8 -3
- data/lib/omnibus/reports.rb +1 -1
- data/lib/omnibus/s3_cache.rb +18 -5
- data/lib/omnibus/s3_helpers.rb +45 -8
- data/lib/omnibus/software.rb +55 -37
- data/lib/omnibus/sugarable.rb +4 -0
- data/lib/omnibus/templating.rb +29 -13
- data/lib/omnibus/util.rb +81 -2
- data/lib/omnibus/version.rb +1 -1
- data/lib/omnibus/whitelist.rb +228 -0
- data/omnibus.gemspec +9 -8
- data/resources/dmg/create_dmg.osascript.erb +33 -13
- data/resources/ips/doc-transform.erb +2 -0
- data/resources/rpm/spec.erb +1 -2
- data/spec/functional/builder_spec.rb +21 -21
- data/spec/functional/fetchers/git_fetcher_spec.rb +6 -6
- data/spec/functional/fetchers/net_fetcher_spec.rb +7 -7
- data/spec/functional/fetchers/path_fetcher_spec.rb +5 -5
- data/spec/functional/file_syncer_spec.rb +6 -6
- data/spec/functional/licensing_spec.rb +29 -16
- data/spec/functional/templating_spec.rb +23 -22
- data/spec/support/git_helpers.rb +30 -24
- data/spec/unit/build_version_spec.rb +1 -1
- data/spec/unit/builder_spec.rb +36 -24
- data/spec/unit/changelogprinter_spec.rb +10 -8
- data/spec/unit/cleanroom_spec.rb +6 -6
- data/spec/unit/compressors/dmg_spec.rb +23 -37
- data/spec/unit/compressors/null_spec.rb +2 -2
- data/spec/unit/compressors/tgz_spec.rb +2 -2
- data/spec/unit/config_spec.rb +2 -1
- data/spec/unit/digestable_spec.rb +2 -2
- data/spec/unit/fetchers/git_fetcher_spec.rb +5 -5
- data/spec/unit/fetchers/net_fetcher_spec.rb +46 -6
- data/spec/unit/fetchers/path_fetcher_spec.rb +5 -5
- data/spec/unit/file_syncer_spec.rb +19 -0
- data/spec/unit/git_cache_spec.rb +76 -22
- data/spec/unit/health_check_spec.rb +1 -1
- data/spec/unit/library_spec.rb +2 -2
- data/spec/unit/manifest_spec.rb +6 -6
- data/spec/unit/metadata_spec.rb +4 -4
- data/spec/unit/omnibus_spec.rb +4 -4
- data/spec/unit/package_spec.rb +6 -6
- data/spec/unit/packagers/appx_spec.rb +16 -12
- data/spec/unit/packagers/base_spec.rb +5 -5
- data/spec/unit/packagers/bff_spec.rb +45 -15
- data/spec/unit/packagers/deb_spec.rb +95 -17
- data/spec/unit/packagers/ips_spec.rb +61 -17
- data/spec/unit/packagers/makeself_spec.rb +5 -5
- data/spec/unit/packagers/msi_spec.rb +43 -43
- data/spec/unit/packagers/pkg_spec.rb +15 -15
- data/spec/unit/packagers/pkgsrc_spec.rb +77 -0
- data/spec/unit/packagers/rpm_spec.rb +94 -17
- data/spec/unit/packagers/solaris_spec.rb +11 -11
- data/spec/unit/project_spec.rb +53 -22
- data/spec/unit/publisher_spec.rb +2 -2
- data/spec/unit/publishers/artifactory_publisher_spec.rb +7 -3
- data/spec/unit/publishers/s3_publisher_spec.rb +1 -1
- data/spec/unit/s3_helpers_spec.rb +41 -3
- data/spec/unit/software_spec.rb +115 -37
- data/spec/unit/sugarable_spec.rb +23 -3
- data/spec/unit/util_spec.rb +42 -11
- metadata +49 -29
data/appveyor.yml
CHANGED
data/lib/omnibus.rb
CHANGED
@@ -19,7 +19,11 @@ require "omnibus/core_extensions"
|
|
19
19
|
require "cleanroom"
|
20
20
|
require "pathname"
|
21
21
|
|
22
|
+
require "omnibus/digestable"
|
22
23
|
require "omnibus/exceptions"
|
24
|
+
require "omnibus/sugarable"
|
25
|
+
require "omnibus/util"
|
26
|
+
require "omnibus/fetcher"
|
23
27
|
require "omnibus/version"
|
24
28
|
|
25
29
|
module Omnibus
|
@@ -36,9 +40,7 @@ module Omnibus
|
|
36
40
|
autoload :Cleaner, "omnibus/cleaner"
|
37
41
|
autoload :Compressor, "omnibus/compressor"
|
38
42
|
autoload :Config, "omnibus/config"
|
39
|
-
autoload :Digestable, "omnibus/digestable"
|
40
43
|
autoload :Error, "omnibus/exceptions"
|
41
|
-
autoload :Fetcher, "omnibus/fetcher"
|
42
44
|
autoload :FileSyncer, "omnibus/file_syncer"
|
43
45
|
autoload :Generator, "omnibus/generator"
|
44
46
|
autoload :GitCache, "omnibus/git_cache"
|
@@ -57,10 +59,8 @@ module Omnibus
|
|
57
59
|
autoload :Reports, "omnibus/reports"
|
58
60
|
autoload :S3Cache, "omnibus/s3_cache"
|
59
61
|
autoload :Software, "omnibus/software"
|
60
|
-
autoload :Sugarable, "omnibus/sugarable"
|
61
62
|
autoload :Templating, "omnibus/templating"
|
62
63
|
autoload :ThreadPool, "omnibus/thread_pool"
|
63
|
-
autoload :Util, "omnibus/util"
|
64
64
|
autoload :Licensing, "omnibus/licensing"
|
65
65
|
|
66
66
|
autoload :GitFetcher, "omnibus/fetchers/git_fetcher"
|
data/lib/omnibus/builder.rb
CHANGED
@@ -18,6 +18,7 @@ require "fileutils"
|
|
18
18
|
require "mixlib/shellout"
|
19
19
|
require "ostruct"
|
20
20
|
require "pathname"
|
21
|
+
require "omnibus/whitelist"
|
21
22
|
|
22
23
|
module Omnibus
|
23
24
|
class Builder
|
@@ -275,6 +276,21 @@ module Omnibus
|
|
275
276
|
end
|
276
277
|
expose :windows_safe_path
|
277
278
|
|
279
|
+
#
|
280
|
+
# (see Util#compiler_safe_path)
|
281
|
+
#
|
282
|
+
# Some compilers require paths to be formatted in certain ways. This helper
|
283
|
+
# takes in the standard Omnibus-style path and ensures that it is passed
|
284
|
+
# correctly.
|
285
|
+
#
|
286
|
+
# @example
|
287
|
+
# configure ["--prefix=#{compiler_safe_path(install_dir, "embedded")}"]
|
288
|
+
#
|
289
|
+
def compiler_safe_path(*pieces)
|
290
|
+
super
|
291
|
+
end
|
292
|
+
expose :compiler_safe_path
|
293
|
+
|
278
294
|
#
|
279
295
|
# @!endgroup
|
280
296
|
# --------------------------------------------------
|
@@ -547,6 +563,29 @@ module Omnibus
|
|
547
563
|
end
|
548
564
|
expose :delete
|
549
565
|
|
566
|
+
#
|
567
|
+
# Strip symbols from the given file or directory on the system. This method uses
|
568
|
+
# find and passes the matched files to strip through xargs, ignoring errors.
|
569
|
+
# So one may pass in a specific file/directory or a glob of files.
|
570
|
+
#
|
571
|
+
# @param [String] path
|
572
|
+
# the path of the file(s) to strip
|
573
|
+
#
|
574
|
+
# @return (see #command)
|
575
|
+
#
|
576
|
+
def strip(path)
|
577
|
+
regexp_ends = ".*(" + IGNORED_ENDINGS.map { |e| e.gsub(/\./, '\.') }.join("|") + ")$"
|
578
|
+
regexp_patterns = IGNORED_PATTERNS.map { |e| ".*" + e.gsub(/\//, '\/') + ".*" }.join("|")
|
579
|
+
regexp = regexp_ends + "|" + regexp_patterns
|
580
|
+
|
581
|
+
# Do not actually care if strip runs on non-strippable file, as its a no-op. Hence the `|| true` appended.
|
582
|
+
# Do want to avoid stripping files unneccessarily so as not to slow down build process.
|
583
|
+
find_command = "find #{path}/ -type f -regextype posix-extended ! -regex \"#{regexp}\" | xargs strip || true"
|
584
|
+
options = { in_msys_bash: true }
|
585
|
+
command(find_command, options)
|
586
|
+
end
|
587
|
+
expose :strip
|
588
|
+
|
550
589
|
#
|
551
590
|
# Copy the given source to the destination. This method accepts a single
|
552
591
|
# file or a file pattern to match.
|
@@ -796,14 +835,6 @@ module Omnibus
|
|
796
835
|
# Also make a clone of options so that we can mangle it safely below.
|
797
836
|
options = { cwd: software.project_dir }.merge(options)
|
798
837
|
|
799
|
-
if options.delete(:in_msys_bash) && windows?
|
800
|
-
# Mixlib will handle escaping characters for cmd but our command might
|
801
|
-
# contain '. For now, assume that won't happen because I don't know
|
802
|
-
# whether this command is going to be played via cmd or through
|
803
|
-
# ProcessCreate.
|
804
|
-
command_string = "bash -c \'#{command_string}\'"
|
805
|
-
end
|
806
|
-
|
807
838
|
# Set the log level to :info so users will see build commands
|
808
839
|
options[:log_level] ||= :info
|
809
840
|
|
@@ -856,7 +887,7 @@ module Omnibus
|
|
856
887
|
if tries <= 0
|
857
888
|
raise e
|
858
889
|
else
|
859
|
-
delay
|
890
|
+
delay *= 2
|
860
891
|
|
861
892
|
log.warn(log_key) do
|
862
893
|
label = "#{(Config.build_retries - tries) + 1}/#{Config.build_retries}"
|
@@ -963,6 +994,8 @@ module Omnibus
|
|
963
994
|
log.warn(log_key) { "Detected command `remove'. Consider using the `delete' DSL method." }
|
964
995
|
when /^rsync /i
|
965
996
|
log.warn(log_key) { "Detected command `rsync'. Consider using the `sync' DSL method." }
|
997
|
+
when /^strip /i
|
998
|
+
log.warn(log_key) { "Detected command `strip'. Consider using the `strip' DSL method." }
|
966
999
|
end
|
967
1000
|
end
|
968
1001
|
|
data/lib/omnibus/cli.rb
CHANGED
@@ -70,6 +70,10 @@ module Omnibus
|
|
70
70
|
desc: "Use the given manifest when downloading software sources.",
|
71
71
|
type: :string,
|
72
72
|
default: nil
|
73
|
+
method_option :populate_s3_cache,
|
74
|
+
desc: "Populate the S3 cache.",
|
75
|
+
type: :boolean,
|
76
|
+
default: false
|
73
77
|
desc "build PROJECT", "Build the given Omnibus project"
|
74
78
|
def build(name)
|
75
79
|
manifest = if @options[:use_manifest]
|
@@ -80,6 +84,7 @@ module Omnibus
|
|
80
84
|
|
81
85
|
project = Project.load(name, manifest)
|
82
86
|
say("Building #{project.name} #{project.build_version}...")
|
87
|
+
Omnibus::S3Cache.populate if @options[:populate_s3_cache] && !Omnibus::S3Cache.fetch_missing.empty?
|
83
88
|
project.download
|
84
89
|
project.build
|
85
90
|
|
data/lib/omnibus/cli/base.rb
CHANGED
@@ -26,7 +26,7 @@ module Omnibus
|
|
26
26
|
# Handle the case where Thor thinks a trailing --help is actually an
|
27
27
|
# argument and blows up...
|
28
28
|
if args.length > 1 && !(args & Thor::HELP_MAPPINGS).empty?
|
29
|
-
args
|
29
|
+
args -= Thor::HELP_MAPPINGS
|
30
30
|
args.insert(-2, "help")
|
31
31
|
end
|
32
32
|
|
data/lib/omnibus/cli/publish.rb
CHANGED
@@ -76,9 +76,11 @@ module Omnibus
|
|
76
76
|
default: {}
|
77
77
|
desc "artifactory REPOSITORY PATTERN", "Publish to an Artifactory instance"
|
78
78
|
def artifactory(repository, pattern)
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
if options[:version_manifest]
|
80
|
+
Omnibus.logger.deprecated("ArtifactoryPublisher") do
|
81
|
+
"The `--version-manifest' option has been deprecated. Version manifest data is now part of the `*.metadata.json' file"
|
82
|
+
end
|
83
|
+
end
|
82
84
|
|
83
85
|
options[:repository] = repository
|
84
86
|
publish(ArtifactoryPublisher, pattern, options)
|
@@ -118,7 +118,7 @@ module Omnibus
|
|
118
118
|
def clean_disks
|
119
119
|
log.info(log_key) { "Cleaning previously mounted disks" }
|
120
120
|
|
121
|
-
existing_disks = shellout!("mount | grep /Volumes/#{volume_name} | awk '{print $1}'")
|
121
|
+
existing_disks = shellout!("mount | grep \"/Volumes/#{volume_name}\" | awk '{print $1}'")
|
122
122
|
existing_disks.stdout.lines.each do |existing_disk|
|
123
123
|
existing_disk.chomp!
|
124
124
|
|
@@ -240,7 +240,7 @@ module Omnibus
|
|
240
240
|
|
241
241
|
Dir.chdir(staging_dir) do
|
242
242
|
shellout! <<-EOH.gsub(/^ {10}/, "")
|
243
|
-
chmod -Rf go-w /Volumes/#{volume_name}
|
243
|
+
chmod -Rf go-w "/Volumes/#{volume_name}"
|
244
244
|
sync
|
245
245
|
hdiutil detach "#{@device}"
|
246
246
|
hdiutil convert \\
|
data/lib/omnibus/config.rb
CHANGED
@@ -279,16 +279,29 @@ module Omnibus
|
|
279
279
|
#
|
280
280
|
# @return [String]
|
281
281
|
default(:s3_access_key) do
|
282
|
-
|
282
|
+
if s3_profile
|
283
|
+
nil
|
284
|
+
else
|
285
|
+
raise MissingRequiredAttribute.new(self, :s3_access_key, "'ABCD1234'")
|
286
|
+
end
|
283
287
|
end
|
284
288
|
|
285
289
|
# The S3 secret key to use with S3 caching.
|
286
290
|
#
|
287
|
-
# @return [String]
|
291
|
+
# @return [String, nil]
|
288
292
|
default(:s3_secret_key) do
|
289
|
-
|
293
|
+
if s3_profile
|
294
|
+
nil
|
295
|
+
else
|
296
|
+
raise MissingRequiredAttribute.new(self, :s3_secret_key, "'EFGH5678'")
|
297
|
+
end
|
290
298
|
end
|
291
299
|
|
300
|
+
# The AWS credentials profile to use with S3 caching.
|
301
|
+
#
|
302
|
+
# @return [String]
|
303
|
+
default(:s3_profile, nil)
|
304
|
+
|
292
305
|
# The region of the S3 bucket you want to cache software artifacts in.
|
293
306
|
# Defaults to 'us-east-1'
|
294
307
|
#
|
@@ -297,6 +310,16 @@ module Omnibus
|
|
297
310
|
"us-east-1"
|
298
311
|
end
|
299
312
|
|
313
|
+
# The HTTP or HTTPS endpoint to send requests to, when using non-standard endpoint
|
314
|
+
#
|
315
|
+
# @return [String, nil]
|
316
|
+
default(:s3_endpoint, nil)
|
317
|
+
|
318
|
+
# Enable or disable S3 Accelerate support
|
319
|
+
#
|
320
|
+
# @return [true, false]
|
321
|
+
default(:s3_accelerate, false)
|
322
|
+
|
300
323
|
# --------------------------------------------------
|
301
324
|
# @!endgroup
|
302
325
|
#
|
@@ -390,14 +413,22 @@ module Omnibus
|
|
390
413
|
#
|
391
414
|
# @return [String]
|
392
415
|
default(:publish_s3_access_key) do
|
393
|
-
|
416
|
+
if s3_profile
|
417
|
+
nil
|
418
|
+
else
|
419
|
+
raise MissingRequiredAttribute.new(self, :publish_s3_access_key, "'ABCD1234'")
|
420
|
+
end
|
394
421
|
end
|
395
422
|
|
396
423
|
# The S3 secret key to use for S3 artifact release
|
397
424
|
#
|
398
425
|
# @return [String]
|
399
426
|
default(:publish_s3_secret_key) do
|
400
|
-
|
427
|
+
if s3_profile
|
428
|
+
nil
|
429
|
+
else
|
430
|
+
raise MissingRequiredAttribute.new(self, :publish_s3_secret_key, "'EFGH5678'")
|
431
|
+
end
|
401
432
|
end
|
402
433
|
|
403
434
|
# --------------------------------------------------
|
@@ -471,6 +502,12 @@ module Omnibus
|
|
471
502
|
:x86
|
472
503
|
end
|
473
504
|
|
505
|
+
# Flag specifying whether the project should be built with FIPS
|
506
|
+
# compatability or not.
|
507
|
+
#
|
508
|
+
# @return [true, false]
|
509
|
+
default(:fips_mode, false)
|
510
|
+
|
474
511
|
# --------------------------------------------------
|
475
512
|
# @!endgroup
|
476
513
|
#
|
@@ -67,14 +67,14 @@ module Omnibus
|
|
67
67
|
rate_scale: ->(rate) { rate / 1024 }
|
68
68
|
)
|
69
69
|
|
70
|
-
options[:content_length_proc] = ->(total)
|
70
|
+
options[:content_length_proc] = ->(total) do
|
71
71
|
reported_total = total
|
72
72
|
progress_bar.total = total
|
73
|
-
|
74
|
-
options[:progress_proc] = ->(step)
|
73
|
+
end
|
74
|
+
options[:progress_proc] = ->(step) do
|
75
75
|
downloaded_amount = reported_total ? [step, reported_total].min : step
|
76
76
|
progress_bar.progress = downloaded_amount
|
77
|
-
|
77
|
+
end
|
78
78
|
end
|
79
79
|
|
80
80
|
file = open(from_url, options)
|
@@ -141,7 +141,9 @@ module Omnibus
|
|
141
141
|
# @return [void]
|
142
142
|
#
|
143
143
|
def git_clone
|
144
|
-
|
144
|
+
retry_block("git clone", [CommandTimeout, CommandFailed]) do
|
145
|
+
git("clone#{" --recursive" if clone_submodules?} #{source_url} .")
|
146
|
+
end
|
145
147
|
end
|
146
148
|
|
147
149
|
#
|
@@ -154,7 +156,11 @@ module Omnibus
|
|
154
156
|
# default when a sha1 is provided). git older than 1.7.5 doesn't
|
155
157
|
# support the --detach flag.
|
156
158
|
git("checkout #{resolved_version} -f -q")
|
157
|
-
|
159
|
+
if clone_submodules?
|
160
|
+
retry_block("git submodule update", [CommandTimeout, CommandFailed]) do
|
161
|
+
git("submodule update --recursive")
|
162
|
+
end
|
163
|
+
end
|
158
164
|
end
|
159
165
|
|
160
166
|
#
|
@@ -165,7 +171,9 @@ module Omnibus
|
|
165
171
|
def git_fetch
|
166
172
|
fetch_cmd = "fetch #{source_url} #{described_version}"
|
167
173
|
fetch_cmd << " --recurse-submodules=on-demand" if clone_submodules?
|
168
|
-
git
|
174
|
+
retry_block("git fetch", [CommandTimeout, CommandFailed]) do
|
175
|
+
git(fetch_cmd)
|
176
|
+
end
|
169
177
|
end
|
170
178
|
|
171
179
|
#
|
@@ -214,7 +222,6 @@ module Omnibus
|
|
214
222
|
end
|
215
223
|
|
216
224
|
# Class methods
|
217
|
-
public
|
218
225
|
|
219
226
|
# Return the SHA1 corresponding to a ref as determined by the remote source.
|
220
227
|
#
|
@@ -260,7 +267,10 @@ module Omnibus
|
|
260
267
|
# allows us to return the SHA of the tagged commit for annotated
|
261
268
|
# tags. We take care to only return exact matches in
|
262
269
|
# process_remote_list.
|
263
|
-
remote_list =
|
270
|
+
remote_list = retry_block("git ls-remote", [CommandTimeout, CommandFailed]) do
|
271
|
+
shellout!("git ls-remote \"#{source[:git]}\" \"#{ref}*\"").stdout
|
272
|
+
end
|
273
|
+
|
264
274
|
commit_ref = dereference_annotated_tag(remote_list, ref)
|
265
275
|
|
266
276
|
unless commit_ref
|
data/lib/omnibus/file_syncer.rb
CHANGED
@@ -34,6 +34,7 @@ module Omnibus
|
|
34
34
|
# the list of all files
|
35
35
|
#
|
36
36
|
def glob(pattern)
|
37
|
+
pattern = Pathname.new(pattern).cleanpath.to_s
|
37
38
|
Dir.glob(pattern, File::FNM_DOTMATCH).sort.reject do |file|
|
38
39
|
basename = File.basename(file)
|
39
40
|
IGNORED_FILES.include?(basename)
|
@@ -144,8 +145,7 @@ module Omnibus
|
|
144
145
|
end
|
145
146
|
end
|
146
147
|
else
|
147
|
-
raise
|
148
|
-
"Unknown file type: `File.ftype(source_file)' at `#{source_file}'!"
|
148
|
+
raise "Unknown file type: `File.ftype(source_file)' at `#{source_file}'!"
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
data/lib/omnibus/git_cache.rb
CHANGED
@@ -32,7 +32,7 @@ module Omnibus
|
|
32
32
|
# will not have the generated content, so these snapshots would be
|
33
33
|
# incompatible with the current omnibus codebase. Incrementing the serial
|
34
34
|
# number ensures these old shapshots will not be used in subsequent builds.
|
35
|
-
SERIAL_NUMBER =
|
35
|
+
SERIAL_NUMBER = 3
|
36
36
|
|
37
37
|
REQUIRED_GIT_FILES = %w{
|
38
38
|
HEAD
|
@@ -76,6 +76,9 @@ refs}.freeze
|
|
76
76
|
else
|
77
77
|
create_directory(File.dirname(cache_path))
|
78
78
|
git_cmd("init -q")
|
79
|
+
# On windows, git is very picky about single vs double quotes
|
80
|
+
git_cmd("config --local user.name \"Omnibus Git Cache\"")
|
81
|
+
git_cmd("config --local user.email \"omnibus@localhost\"")
|
79
82
|
true
|
80
83
|
end
|
81
84
|
end
|
@@ -140,23 +143,26 @@ refs}.freeze
|
|
140
143
|
|
141
144
|
create_cache_path
|
142
145
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
cmd.stdout.each_line do |line|
|
147
|
-
restore_me = true if tag == line.chomp
|
148
|
-
end
|
149
|
-
|
150
|
-
if restore_me
|
151
|
-
log.internal(log_key) { "Detected tag `#{tag}' can be restored, restoring" }
|
152
|
-
git_cmd(%Q{checkout -f "#{tag}"})
|
146
|
+
if has_tag(tag)
|
147
|
+
log.internal(log_key) { "Detected tag `#{tag}' can be restored, marking it for restoration" }
|
148
|
+
git_cmd(%Q{tag -f restore_here "#{tag}"})
|
153
149
|
true
|
150
|
+
elsif has_tag("restore_here")
|
151
|
+
log.internal(log_key) { "Could not find tag `#{tag}', restoring previous tag" }
|
152
|
+
restore_from_cache
|
153
|
+
false
|
154
154
|
else
|
155
|
-
log.internal(log_key) { "Could not find tag
|
155
|
+
log.internal(log_key) { "Could not find marker tag `restore_here', nothing to restore" }
|
156
156
|
false
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
+
def restore_from_cache
|
161
|
+
git_cmd("checkout -f restore_here")
|
162
|
+
ensure
|
163
|
+
git_cmd("tag -d restore_here")
|
164
|
+
end
|
165
|
+
|
160
166
|
#
|
161
167
|
# Git caching will attempt to version embedded git directories, partially
|
162
168
|
# versioning them. This causes failures on subsequent runs. This method
|
@@ -190,7 +196,14 @@ refs}.freeze
|
|
190
196
|
# @return [Mixlib::Shellout] the underlying command object.
|
191
197
|
#
|
192
198
|
def git_cmd(command)
|
193
|
-
shellout!(
|
199
|
+
shellout!([
|
200
|
+
"git",
|
201
|
+
"-c core.autocrlf=false",
|
202
|
+
"-c core.ignorecase=false",
|
203
|
+
"--git-dir=\"#{cache_path}\"",
|
204
|
+
"--work-tree=\"#{install_dir}\"",
|
205
|
+
command,
|
206
|
+
].join(" "))
|
194
207
|
end
|
195
208
|
|
196
209
|
#
|
@@ -210,5 +223,10 @@ refs}.freeze
|
|
210
223
|
def log_key
|
211
224
|
@log_key ||= "#{super}: #{software.name}"
|
212
225
|
end
|
226
|
+
|
227
|
+
def has_tag(tag)
|
228
|
+
cmd = git_cmd(%Q{tag -l "#{tag}"})
|
229
|
+
cmd.stdout.lines.any? { |line| tag == line.chomp }
|
230
|
+
end
|
213
231
|
end
|
214
232
|
end
|