omnibus 2.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +2 -0
  3. data/.travis.yml +0 -2
  4. data/CHANGELOG.md +26 -6
  5. data/Gemfile +7 -0
  6. data/Guardfile +10 -0
  7. data/README.md +103 -160
  8. data/Rakefile +6 -1
  9. data/docs/Building on OSX.md +66 -0
  10. data/docs/omnibus-build-cache.md +75 -0
  11. data/lib/omnibus.rb +9 -13
  12. data/lib/omnibus/artifact.rb +1 -13
  13. data/lib/omnibus/assets/README-logo.png +0 -0
  14. data/lib/omnibus/assets/logo.psd +0 -0
  15. data/lib/omnibus/builder.rb +1 -0
  16. data/lib/omnibus/cli/application.rb +17 -4
  17. data/lib/omnibus/cli/build.rb +6 -4
  18. data/lib/omnibus/config.rb +33 -0
  19. data/lib/omnibus/exceptions.rb +20 -14
  20. data/lib/omnibus/health_check.rb +2 -0
  21. data/lib/omnibus/install_path_cache.rb +106 -0
  22. data/lib/omnibus/library.rb +18 -1
  23. data/lib/omnibus/packagers/base.rb +228 -0
  24. data/lib/omnibus/packagers/mac_dmg.rb +215 -0
  25. data/lib/omnibus/packagers/mac_pkg.rb +129 -253
  26. data/lib/omnibus/project.rb +89 -95
  27. data/lib/omnibus/s3_cacher.rb +4 -7
  28. data/lib/omnibus/software.rb +47 -83
  29. data/lib/omnibus/sugar.rb +49 -0
  30. data/lib/omnibus/templates/.kitchen.yml.erb +3 -0
  31. data/lib/omnibus/templates/Berksfile.erb +4 -0
  32. data/lib/omnibus/templates/Gemfile.erb +1 -1
  33. data/lib/omnibus/templates/mac_dmg/background.png +0 -0
  34. data/lib/omnibus/templates/mac_dmg/icon.png +0 -0
  35. data/lib/omnibus/templates/mac_pkg/background.png +0 -0
  36. data/lib/omnibus/templates/mac_pkg/license.html.erb +1 -0
  37. data/lib/omnibus/templates/mac_pkg/welcome.html.erb +9 -0
  38. data/lib/omnibus/templates/omnibus.rb.example.erb +31 -4
  39. data/lib/omnibus/version.rb +1 -1
  40. data/omnibus.gemspec +5 -4
  41. data/spec/fixtures/sample/files/mac_dmg/Resources/background.png +0 -0
  42. data/spec/fixtures/sample/files/mac_dmg/Resources/icon.png +0 -0
  43. data/spec/fixtures/sample/files/mac_pkg/Resources/background.png +0 -0
  44. data/spec/fixtures/sample/files/mac_pkg/Resources/license.html +1 -0
  45. data/spec/fixtures/sample/files/mac_pkg/Resources/welcome.html +9 -0
  46. data/{functional/fixtures/mac_pkg/package-scripts/functional-test-project → spec/fixtures/sample/package-scripts/sample}/postinstall +0 -0
  47. data/spec/functional/packagers/mac_spec.rb +74 -0
  48. data/spec/spec_helper.rb +14 -3
  49. data/spec/sugar_spec.rb +20 -0
  50. data/spec/{artifact_spec.rb → unit/artifact_spec.rb} +2 -3
  51. data/spec/{build_version_spec.rb → unit/build_version_spec.rb} +0 -0
  52. data/spec/{config_spec.rb → unit/config_spec.rb} +4 -0
  53. data/spec/{fetchers → unit/fetchers}/git_fetcher_spec.rb +0 -0
  54. data/spec/{fetchers → unit/fetchers}/net_fetcher_spec.rb +0 -0
  55. data/spec/unit/install_path_cache_spec.rb +175 -0
  56. data/spec/unit/library_spec.rb +67 -0
  57. data/spec/{omnibus_spec.rb → unit/omnibus_spec.rb} +0 -0
  58. data/spec/{overrides_spec.rb → unit/overrides_spec.rb} +0 -0
  59. data/spec/{package_release_spec.rb → unit/package_release_spec.rb} +0 -0
  60. data/spec/unit/packagers/base_spec.rb +221 -0
  61. data/spec/unit/packagers/mac_pkg_spec.rb +163 -0
  62. data/spec/{project_spec.rb → unit/project_spec.rb} +0 -14
  63. data/spec/{s3_cacher_spec.rb → unit/s3_cacher_spec.rb} +0 -0
  64. data/spec/{software_spec.rb → unit/software_spec.rb} +0 -1
  65. metadata +122 -103
  66. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
  67. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +0 -1
  68. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +0 -1
  69. data/functional/packagers/mac_pkg_spec.rb +0 -72
  70. data/lib/omnibus/clean_tasks.rb +0 -28
  71. data/spec/packagers/mac_pkg_spec.rb +0 -262
@@ -0,0 +1,66 @@
1
+ Building Omnibus Packages for Mac OSX
2
+ =====================================
3
+ This document details the steps and configurables for building omnibus packages
4
+ on Mac OSX. Unlike Linux-based systems, the process for building a `.pkg` and
5
+ a `.dmg` requires some manual preparation of assets.
6
+
7
+
8
+ Building a .pkg
9
+ ---------------
10
+ In Mac OSX, a `.pkg` is a special file that is read by Installer.app that
11
+ contains the set of instructions for installating a piece of software on a
12
+ target system.
13
+
14
+ ### Requirements
15
+ The omnibus generator will create some stock files in `files/mac_pkg`:
16
+
17
+ - `background.png` - the background image for the installer. We recommend this
18
+ image has a light background color (otherwise, the text will be difficult to
19
+ read).
20
+ - `license.html` - the full HTML document for the license
21
+ - `welcome.html` - the full HTML document for the welcome screen
22
+
23
+ You should use these stock files and templates as a starting point for building
24
+ your custom pkg.
25
+
26
+
27
+ Building a .dmg
28
+ ---------------
29
+ In Mac OSX, a `.dmg` is a compressed wrapper around a collection of resources,
30
+ often including a `.pkg`. The possibilities for creating and customizing a DMG
31
+ are endless, but Omnibus provides a "basic" starter case that will generate a
32
+ pretty DMG that contains the `.pkg` file it creates.
33
+
34
+ The following tunables are available:
35
+
36
+ - `dmg_window_bounds` - the starting and ending (x,y) coordinates for the opened
37
+ DMG
38
+ - `dmg_pkg_position` - the (x,y) coordinate for the `.pkg` file inside the
39
+ opened DMG window
40
+
41
+ ### Requirements
42
+ The omnibus generator will create some stock files in `files/mac_dmg`:
43
+
44
+ - `background.png` - the background image to use for the DMG. We recommend using
45
+ a high-resolution image that is slightly larger than the final length of your
46
+ window (as determined by the `dmg_window_bounds`)
47
+ - `icon.png` - a 1024x1024 @ 300 icon to use for the DMG. We will automatically
48
+ create an icns and scale to smaller sizes
49
+
50
+ You should use these stock files and templates as a starting point for building
51
+ your custom dmg.
52
+
53
+ ### Disabling dmg building
54
+ DMG creation is enabled by default, but you can disable DMG creation by setting
55
+ the `build_dmg` omnibus configuration option to false:
56
+
57
+ ```ruby
58
+ # omnibus.rb
59
+ build_dmg false
60
+ ```
61
+
62
+ And run as you normally would:
63
+
64
+ ```bash
65
+ $ ./bin/omnibus build project <name>
66
+ ```
@@ -0,0 +1,75 @@
1
+ # The Omnibus Build Cache #
2
+
3
+ The omnibus project includes a project build caching mechanism that
4
+ reduces the time it takes to rebuild a project when only a few
5
+ components need to be rebuilt.
6
+
7
+ The cache uses git to snapshot the project tree after each software
8
+ component build. The entire contents of the project's `install_path`
9
+ is included in the snaphot.
10
+
11
+ When rebuilding, omnibus walks the linearized component list and
12
+ replays the cache until the first item is encountered that needs to be
13
+ rebuilt. Items are rebuilt if the code changes (different version or
14
+ different git SHA) or if the build instructions change (edit to
15
+ config/software/$COMPONENT).
16
+
17
+ ## Location of Cache Data ##
18
+
19
+ The default location of the cache (which is just a bare git
20
+ repository) is
21
+ `/var/cache/omnibus/cache/install_path/$INSTALL_PATH`. You can
22
+ customize the location of the cache in the `omnibus.rb` config file
23
+ using the key `install_path_cache_dir`. For example:
24
+
25
+ install_path_cache_dir "/opt/ominbus-caches"
26
+
27
+ ## How It Works ##
28
+
29
+ Omnibus begins by loading all projects (see
30
+ `lib/omnibus.rb#expand_software`). The dependencies of each project
31
+ are loaded using `recursively_load_dependency` to capture the
32
+ transitive dependencies of a given project dependency. The result is
33
+ that each project has a list of components in "install order" such
34
+ that all dependencies come before the things that depend on
35
+ them. Components are de-duplicated on the way in and not added if
36
+ already present (which will occur when two components share a common
37
+ dependency).
38
+
39
+ The actual build order is determined by `library.rb#build_order` which
40
+ does a small reordering to ensure that components that are explicitly
41
+ listed in the project file come last. Since the first cache miss
42
+ causes the system to rebuild everything further to the right in the
43
+ component list, you want to have your most frequently changed
44
+ components last to minimize rebuild churn.
45
+
46
+ Lightweight git tags are used as cache keys. After building a
47
+ component, a tag name is computed in `install_path_cache.rb#tag`. The
48
+ tag name has the format `#{name}-#{version}-#{digest}` where name and
49
+ version map to the component that was just built and digest is a
50
+ SHA256 value. The digest is computed by string-ifying the name/version
51
+ pairs of all components built prior to this component (keeping the
52
+ order of course) and prepending the entire contents of the component's
53
+ `config/software/$NAME.rb` file. Important aspects of the cache key
54
+ scheme:
55
+
56
+ * A change in the order or in the name/version of component built
57
+ before the component will invalidate the cache key.
58
+ * A change in the component's software config (build instructions)
59
+ invalidates the cache. This is done conservatively; the entire file
60
+ contents are included in the digest computation so even a whitespace
61
+ change will invalidate the key.
62
+ * A change in the version of the component itself will invalidate the
63
+ key.
64
+
65
+ You can inspect the cache keys like this:
66
+
67
+ git --git-dir=$CACHE_PATH tag -l
68
+
69
+ You can manually remove a cache entry using `git tag --delete
70
+ $TAG`. In theory, you can share the cache among build slaves using
71
+ `git clone/fetch`.
72
+
73
+ When running a build vm on OS X, note that you will likely run into
74
+ trouble if you attempt to locate your cache on your local
75
+ filesystem if it is not case sensitive.
data/lib/omnibus.rb CHANGED
@@ -32,6 +32,7 @@ require 'omnibus/project'
32
32
  require 'omnibus/fetchers'
33
33
  require 'omnibus/health_check'
34
34
  require 'omnibus/build_version'
35
+ require 'omnibus/sugar'
35
36
  require 'omnibus/overrides'
36
37
  require 'omnibus/version'
37
38
 
@@ -40,6 +41,12 @@ require 'pathname'
40
41
  module Omnibus
41
42
  DEFAULT_CONFIG_FILENAME = 'omnibus.rb'.freeze
42
43
 
44
+ module Packager
45
+ autoload :Base, 'omnibus/packagers/base'
46
+ autoload :MacDmg, 'omnibus/packagers/mac_dmg'
47
+ autoload :MacPkg, 'omnibus/packagers/mac_pkg'
48
+ end
49
+
43
50
  # Configure Omnibus.
44
51
  #
45
52
  # After this has been called, the {Omnibus::Config} object is
@@ -83,7 +90,6 @@ module Omnibus
83
90
  def self.process_configuration
84
91
  Config.validate
85
92
  process_dsl_files
86
- generate_extra_rake_tasks
87
93
  end
88
94
 
89
95
  # All {Omnibus::Project} instances that have been created.
@@ -222,17 +228,6 @@ module Omnibus
222
228
  expand_software(overrides, final_software_map)
223
229
  end
224
230
 
225
- # Creates some additional Rake tasks beyond those generated in the
226
- # process of reading in the DSL files.
227
- #
228
- # @return [void]
229
- #
230
- # @todo Not so sure I like how this is being done, but at least it
231
- # isolates the Rake stuff.
232
- def self.generate_extra_rake_tasks
233
- require 'omnibus/clean_tasks'
234
- end
235
-
236
231
  # Return a list of all the Ruby files (i.e., those with an "rb"
237
232
  # extension) in the given directory
238
233
  #
@@ -301,11 +296,12 @@ module Omnibus
301
296
  end
302
297
 
303
298
  dep_software = Omnibus::Software.load(dep_file, project, overrides)
304
- project.library.component_added(dep_software)
305
299
 
306
300
  # load any transitive deps for the component into the library also
307
301
  dep_software.dependencies.each do |dep|
308
302
  recursively_load_dependency(dep, project, overrides, software_map)
309
303
  end
304
+
305
+ project.library.component_added(dep_software)
310
306
  end
311
307
  end
@@ -97,9 +97,7 @@ module Omnibus
97
97
  'version' => build_version,
98
98
  'basename' => File.basename(path),
99
99
  'md5' => md5,
100
- 'sha1' => sha1,
101
100
  'sha256' => sha256,
102
- 'sha512' => sha512,
103
101
  }
104
102
  end
105
103
 
@@ -131,21 +129,11 @@ module Omnibus
131
129
  @md5 ||= digest(Digest::MD5)
132
130
  end
133
131
 
134
- # @return [String] hex encoded SHA1 of the package
135
- def sha1
136
- @sha1 ||= digest(Digest::SHA1)
137
- end
138
-
139
- # @return [String] hex encoded SHA-256 of the package
132
+ # @return [String] hex encoded SHA2-256 of the package
140
133
  def sha256
141
134
  @sha256 ||= digest(Digest::SHA256)
142
135
  end
143
136
 
144
- # @return [String] hex encoded SHA-512 of the package
145
- def sha512
146
- @sha512 ||= digest(Digest::SHA512)
147
- end
148
-
149
137
  private
150
138
 
151
139
  def digest(digest_class)
Binary file
Binary file
@@ -17,6 +17,7 @@
17
17
 
18
18
  require 'forwardable'
19
19
  require 'omnibus/exceptions'
20
+ require 'omnibus/install_path_cache'
20
21
  require 'ostruct'
21
22
 
22
23
  module Omnibus
@@ -77,9 +77,9 @@ module Omnibus
77
77
  template(File.join('software', 'ruby-example.rb.erb'), File.join(config_software, 'ruby-example.rb'), opts)
78
78
 
79
79
  # Kitchen build environment
80
- template(File.join('.kitchen.local.yml.erb'), File.join(target, '.kitchen.local.yml'), opts)
81
- template(File.join('.kitchen.yml.erb'), File.join(target, '.kitchen.yml'), opts)
82
- template(File.join('Berksfile.erb'), File.join(target, 'Berksfile'), opts)
80
+ template('.kitchen.local.yml.erb', File.join(target, '.kitchen.local.yml'), opts)
81
+ template('.kitchen.yml.erb', File.join(target, '.kitchen.yml'), opts)
82
+ template('Berksfile.erb', File.join(target, 'Berksfile'), opts)
83
83
 
84
84
  # render out stub packge scripts
85
85
  %w(makeselfinst preinst prerm postinst postrm).each do |package_script|
@@ -88,8 +88,21 @@ module Omnibus
88
88
  # render the package script
89
89
  template(template_path, script_path, opts)
90
90
  # ensure the package script is executable
91
- FileUtils.chmod(0755, script_path)
91
+ chmod(script_path, 0755)
92
92
  end
93
+
94
+ # mac pkg stock assets
95
+ mac_pkg_resources = File.expand_path("#{target}/files/mac_pkg/Resources")
96
+ empty_directory(mac_pkg_resources)
97
+ template(File.join('mac_pkg', 'license.html.erb'), File.join("#{mac_pkg_resources}", 'license.html'), opts)
98
+ template(File.join('mac_pkg', 'welcome.html.erb'), File.join("#{mac_pkg_resources}", 'welcome.html'), opts)
99
+ copy_file(File.join('mac_pkg', 'background.png'), File.join("#{mac_pkg_resources}", 'background.png'))
100
+
101
+ # mac dmg stock assets
102
+ mac_dmg_resources = File.expand_path("#{target}/files/mac_dmg/Resources")
103
+ empty_directory(mac_dmg_resources)
104
+ copy_file(File.join('mac_dmg', 'background.png'), File.join("#{mac_dmg_resources}", 'background.png'))
105
+ copy_file(File.join('mac_dmg', 'icon.png'), File.join("#{mac_dmg_resources}", 'icon.png'))
93
106
  end
94
107
 
95
108
  desc 'version', 'Display version information'
@@ -38,24 +38,26 @@ module Omnibus
38
38
  desc 'project PROJECT', 'Build the given Omnibus project'
39
39
  def project(project_name)
40
40
  project = load_project!(project_name)
41
- project_task_name = "projects:#{project.name}"
42
41
 
43
42
  unless options[:timestamp]
44
43
  say("I won't append a timestamp to the version identifier.", :yellow)
45
44
  end
46
45
  say("Building #{project.name} #{project.build_version}", :green)
47
46
 
48
- Rake::Task[project_task_name].invoke
47
+ project.build_me
49
48
  end
50
49
 
51
50
  desc 'software PROJECT SOFTWARE', 'Build the given software component'
52
51
  def software(project_name, software_name)
53
52
  project = load_project!(project_name)
54
- software_task_name = "projects:#{project.name}:software:#{software_name}"
53
+
54
+ software = project.library.components.find do |s|
55
+ s.name == software_name
56
+ end
55
57
 
56
58
  say("Building #{software_name} for #{project.name} project", :green)
57
59
 
58
- Rake::Task[software_task_name].invoke
60
+ software.build_me
59
61
  end
60
62
  end
61
63
  end
@@ -40,6 +40,15 @@ module Omnibus
40
40
  # @return [String]
41
41
  default :cache_dir, '/var/cache/omnibus/cache'
42
42
 
43
+ # @!attribute [rw] install_path_cache_dir
44
+ # The absolute path to the directory on the virtual machine where
45
+ # install paths will be progressively cached.
46
+ #
47
+ # Defaults to `"/var/cache/omnibus/cache/install_path"`.
48
+ #
49
+ # @return [String]
50
+ default :install_path_cache_dir, '/var/cache/omnibus/cache/install_path'
51
+
43
52
  # @!attribute [rw] source_dir
44
53
  # The absolute path to the directory on the virtual machine where
45
54
  # source code will be downloaded.
@@ -118,6 +127,30 @@ module Omnibus
118
127
 
119
128
  # @!endgroup
120
129
 
130
+ # @!group DMG configuration options
131
+
132
+ # @!attribute [rw] build_dmg
133
+ # Package OSX pkg files inside a DMG
134
+ #
135
+ # @return [Boolean]
136
+ default :build_dmg, true
137
+
138
+ # @!attribute [rw] dmg_window_bounds
139
+ # Indicate the starting x,y and ending x,y positions for the created DMG
140
+ # window.
141
+ #
142
+ # @return [String]
143
+ default :dmg_window_bounds, '100, 100, 750, 600'
144
+
145
+ # @!attribute [rw] dmg_pkg_position
146
+ # Indicate the starting x,y position where the .pkg file should live in
147
+ # the DMG window.
148
+ #
149
+ # @return [String]
150
+ default :dmg_pkg_position, '535, 50'
151
+
152
+ # @!endgroup
153
+
121
154
  # @!group S3 Caching Configuration Parameters
122
155
 
123
156
  # @!attribute [rw] use_s3_caching
@@ -1,4 +1,24 @@
1
1
  module Omnibus
2
+ class AbstractMethod < RuntimeError
3
+ def initialize(signature)
4
+ @signature = signature
5
+ end
6
+
7
+ def to_s
8
+ "'#{@signature}' is an abstract method and must be overridden!"
9
+ end
10
+ end
11
+
12
+ class MissingAsset < RuntimeError
13
+ def initialize(path)
14
+ @path = path
15
+ end
16
+
17
+ def to_s
18
+ "Missing asset! '#{@path}' is not present on disk."
19
+ end
20
+ end
21
+
2
22
  class InvalidS3Configuration < RuntimeError
3
23
  def initialize(s3_bucket, s3_access_key, s3_secret_key)
4
24
  @s3_bucket, @s3_access_key, @s3_secret_key = s3_bucket, s3_access_key, s3_secret_key
@@ -176,20 +196,6 @@ module Omnibus
176
196
  end
177
197
  end
178
198
 
179
- class MissingMacPkgResource < StandardError
180
- def initialize(missing_file_paths)
181
- @missing_file_paths = missing_file_paths
182
- end
183
-
184
- def to_s
185
- <<-E
186
- Your omnibus repo is missing the following files required to build Mac
187
- packages:
188
- #{@missing_file_paths.map { |p| "* #{p}" }.join("\n ")}
189
- E
190
- end
191
- end
192
-
193
199
  class UnresolvableGitReference < RuntimeError
194
200
  end
195
201
  end
@@ -66,6 +66,7 @@ module Omnibus
66
66
  /libcrypto.so/,
67
67
  /libcurses\.so/,
68
68
  /libdoor\.so/,
69
+ /libgcc_s\.so\.1/,
69
70
  /libgen\.so/,
70
71
  /libmd5\.so/,
71
72
  /libmd\.so/,
@@ -122,6 +123,7 @@ module Omnibus
122
123
  /libncurses\.5\.4\.dylib/,
123
124
  /libiconv/,
124
125
  /libstdc\+\+\.6\.dylib/,
126
+ /libc\+\+\.1\.dylib/,
125
127
  ]
126
128
 
127
129
  FREEBSD_WHITELIST_LIBS = [
@@ -0,0 +1,106 @@
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
+ require 'omnibus/util'
19
+ require 'omnibus/config'
20
+ require 'fileutils'
21
+ require 'digest'
22
+
23
+ module Omnibus
24
+ class InstallPathCache
25
+ include Util
26
+
27
+ def initialize(install_path, software)
28
+ @install_path = install_path
29
+ @software = software
30
+ end
31
+
32
+ # The path to the full install_path cache for the project
33
+ def cache_path
34
+ File.join(Omnibus::Config.install_path_cache_dir, @install_path)
35
+ end
36
+
37
+ # Whether the cache_path above exists
38
+ def cache_path_exists?
39
+ File.directory?(cache_path)
40
+ end
41
+
42
+ # Creates the full path if it does not exist already
43
+ def create_cache_path
44
+ FileUtils.mkdir_p(File.dirname(cache_path))
45
+ shellout!("git --git-dir=#{cache_path} init -q") unless cache_path_exists?
46
+ true
47
+ end
48
+
49
+ # Computes the tag for this cache entry
50
+ def tag
51
+ name = @software.name
52
+ version = @software.version
53
+
54
+ # Accumulate an array of all the software projects that come before
55
+ # the name and version we are tagging. So if you have
56
+ #
57
+ # build_order = [ 1, 2, 3, 4, 5 ]
58
+ #
59
+ # And we are tagging 3, you would get dep_list = [ 1, 2 ]
60
+ dep_list = @software.project.library.build_order.take_while do |dep|
61
+ if dep.name == @software.name && dep.version == @software.version
62
+ false
63
+ else
64
+ true
65
+ end
66
+ end
67
+ dep_string = dep_list.map { |i| "#{i.name}-#{i.version}" }.join('-')
68
+ # digest the content of the software's config so that changes to
69
+ # build params invalidate cache.
70
+ dep_string = IO.read(@software.source_config) + dep_string
71
+ digest = Digest::SHA256.hexdigest(dep_string)
72
+ "#{name}-#{version}-#{digest}"
73
+ end
74
+
75
+ # Create an incremental install path cache for the software step
76
+ def incremental
77
+ create_cache_path
78
+ shellout!("git --git-dir=#{cache_path} --work-tree=#{@install_path} add -A -f")
79
+ begin
80
+ shellout!("git --git-dir=#{cache_path} --work-tree=#{@install_path} commit -q -m 'Backup of #{tag}'")
81
+ rescue Mixlib::ShellOut::ShellCommandFailed => e
82
+ if e.message !~ /nothing to commit/
83
+ raise
84
+ end
85
+ end
86
+ shellout!("git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -f '#{tag}'")
87
+ end
88
+
89
+ def restore
90
+ create_cache_path
91
+ cmd = shellout("git --git-dir=#{cache_path} --work-tree=#{@install_path} tag -l #{tag}")
92
+
93
+ restore_me = false
94
+ cmd.stdout.each_line do |line|
95
+ restore_me = true if tag == line.chomp
96
+ end
97
+
98
+ if restore_me
99
+ shellout!("git --git-dir=#{cache_path} --work-tree=#{@install_path} checkout -f '#{tag}'")
100
+ true
101
+ else
102
+ false
103
+ end
104
+ end
105
+ end
106
+ end