omnibus 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -0
  3. data/.travis.yml +3 -11
  4. data/CHANGELOG.md +50 -0
  5. data/MAINTAINERS.md +26 -0
  6. data/README.md +61 -4
  7. data/appveyor.yml +35 -0
  8. data/docs/Build Cache.md +28 -3
  9. data/docs/Building on RHEL.md +1 -1
  10. data/features/commands/publish.feature +4 -9
  11. data/features/step_definitions/generator_steps.rb +14 -1
  12. data/features/support/env.rb +5 -3
  13. data/lib/omnibus.rb +10 -0
  14. data/lib/omnibus/build_version.rb +34 -25
  15. data/lib/omnibus/build_version_dsl.rb +43 -4
  16. data/lib/omnibus/builder.rb +30 -11
  17. data/lib/omnibus/changelog.rb +52 -0
  18. data/lib/omnibus/changelog_printer.rb +77 -0
  19. data/lib/omnibus/cli.rb +37 -2
  20. data/lib/omnibus/cli/changelog.rb +149 -0
  21. data/lib/omnibus/cli/publish.rb +30 -10
  22. data/lib/omnibus/config.rb +41 -2
  23. data/lib/omnibus/digestable.rb +6 -1
  24. data/lib/omnibus/exceptions.rb +15 -1
  25. data/lib/omnibus/fetcher.rb +78 -34
  26. data/lib/omnibus/fetchers/git_fetcher.rb +84 -42
  27. data/lib/omnibus/fetchers/net_fetcher.rb +64 -13
  28. data/lib/omnibus/fetchers/null_fetcher.rb +8 -1
  29. data/lib/omnibus/fetchers/path_fetcher.rb +24 -1
  30. data/lib/omnibus/file_syncer.rb +52 -1
  31. data/lib/omnibus/generator.rb +22 -21
  32. data/lib/omnibus/generator_files/.kitchen.yml.erb +8 -12
  33. data/lib/omnibus/generator_files/Berksfile.erb +4 -4
  34. data/lib/omnibus/generator_files/Gemfile.erb +3 -3
  35. data/lib/omnibus/generator_files/README.md.erb +17 -0
  36. data/lib/omnibus/generator_files/omnibus.rb.erb +6 -0
  37. data/lib/omnibus/git_repository.rb +43 -0
  38. data/lib/omnibus/health_check.rb +5 -1
  39. data/lib/omnibus/manifest.rb +134 -0
  40. data/lib/omnibus/manifest_diff.rb +88 -0
  41. data/lib/omnibus/manifest_entry.rb +43 -0
  42. data/lib/omnibus/metadata.rb +19 -1
  43. data/lib/omnibus/package.rb +9 -0
  44. data/lib/omnibus/packagers/base.rb +1 -1
  45. data/lib/omnibus/packagers/bff.rb +5 -5
  46. data/lib/omnibus/packagers/deb.rb +11 -4
  47. data/lib/omnibus/packagers/msi.rb +243 -2
  48. data/lib/omnibus/packagers/rpm.rb +68 -14
  49. data/lib/omnibus/packagers/solaris.rb +17 -23
  50. data/lib/omnibus/project.rb +129 -16
  51. data/lib/omnibus/publisher.rb +62 -49
  52. data/lib/omnibus/publishers/artifactory_publisher.rb +96 -5
  53. data/lib/omnibus/publishers/s3_publisher.rb +20 -25
  54. data/lib/omnibus/s3_cache.rb +13 -34
  55. data/lib/omnibus/s3_helpers.rb +119 -0
  56. data/lib/omnibus/semantic_version.rb +57 -0
  57. data/lib/omnibus/software.rb +87 -28
  58. data/lib/omnibus/sugarable.rb +18 -0
  59. data/lib/omnibus/templating.rb +8 -1
  60. data/lib/omnibus/version.rb +1 -1
  61. data/omnibus.gemspec +10 -7
  62. data/resources/bff/gen.template.erb +1 -1
  63. data/resources/msi/bundle.wxs.erb +17 -0
  64. data/resources/msi/localization-en-us.wxl.erb +1 -1
  65. data/resources/rpm/spec.erb +1 -1
  66. data/spec/functional/builder_spec.rb +15 -7
  67. data/spec/functional/fetchers/git_fetcher_spec.rb +44 -12
  68. data/spec/functional/fetchers/net_fetcher_spec.rb +171 -20
  69. data/spec/functional/fetchers/path_fetcher_spec.rb +16 -1
  70. data/spec/functional/file_syncer_spec.rb +58 -5
  71. data/spec/functional/templating_spec.rb +17 -6
  72. data/spec/spec_helper.rb +17 -0
  73. data/spec/support/file_helpers.rb +12 -2
  74. data/spec/support/git_helpers.rb +23 -18
  75. data/spec/support/matchers.rb +22 -0
  76. data/spec/support/output_helpers.rb +29 -0
  77. data/spec/unit/build_version_dsl_spec.rb +31 -4
  78. data/spec/unit/build_version_spec.rb +11 -4
  79. data/spec/unit/builder_spec.rb +33 -0
  80. data/spec/unit/changelog_spec.rb +55 -0
  81. data/spec/unit/cleanroom_spec.rb +1 -1
  82. data/spec/unit/compressors/dmg_spec.rb +3 -3
  83. data/spec/unit/compressors/tgz_spec.rb +3 -3
  84. data/spec/unit/config_spec.rb +3 -1
  85. data/spec/unit/fetcher_spec.rb +35 -0
  86. data/spec/unit/fetchers/git_fetcher_spec.rb +28 -14
  87. data/spec/unit/fetchers/net_fetcher_spec.rb +178 -24
  88. data/spec/unit/fetchers/path_fetcher_spec.rb +8 -7
  89. data/spec/unit/generator_spec.rb +22 -21
  90. data/spec/unit/git_repository_spec.rb +60 -0
  91. data/spec/unit/manifest_diff_spec.rb +75 -0
  92. data/spec/unit/manifest_spec.rb +116 -0
  93. data/spec/unit/metadata_spec.rb +11 -0
  94. data/spec/unit/omnibus_spec.rb +9 -6
  95. data/spec/unit/package_spec.rb +1 -1
  96. data/spec/unit/packagers/base_spec.rb +8 -18
  97. data/spec/unit/packagers/bff_spec.rb +9 -5
  98. data/spec/unit/packagers/deb_spec.rb +44 -12
  99. data/spec/unit/packagers/makeself_spec.rb +4 -4
  100. data/spec/unit/packagers/msi_spec.rb +122 -6
  101. data/spec/unit/packagers/pkg_spec.rb +3 -3
  102. data/spec/unit/packagers/rpm_spec.rb +37 -12
  103. data/spec/unit/project_spec.rb +18 -1
  104. data/spec/unit/publisher_spec.rb +65 -0
  105. data/spec/unit/publishers/artifactory_publisher_spec.rb +26 -20
  106. data/spec/unit/publishers/s3_publisher_spec.rb +14 -30
  107. data/spec/unit/s3_cacher_spec.rb +1 -1
  108. data/spec/unit/s3_helpers_spec.rb +32 -0
  109. data/spec/unit/semantic_version_spec.rb +55 -0
  110. data/spec/unit/software_spec.rb +112 -4
  111. metadata +86 -16
@@ -63,6 +63,23 @@ Full help for the Omnibus command line interface can be accessed with the
63
63
  $ bin/omnibus help
64
64
  ```
65
65
 
66
+ Version Manifest
67
+ ----------------
68
+
69
+ Git-based software definitions may specify branches as their
70
+ default_version. In this case, the exact git revision to use will be
71
+ determined at build-time unless a project override (see below) or
72
+ external version manifest is used. To generate a version manifest use
73
+ the `omnibus manifest` command:
74
+
75
+ ```
76
+ omnibus manifest PROJECT -l warn
77
+ ```
78
+
79
+ This will output a JSON-formatted manifest containing the resolved
80
+ version of every software definition.
81
+
82
+
66
83
  Kitchen-based Build Environment
67
84
  -------------------------------
68
85
  Every Omnibus project ships will a project-specific
@@ -40,8 +40,14 @@
40
40
  # solaris_compiler 'gcc'
41
41
  # build_retries 5
42
42
  # fetcher_read_timeout 120
43
+ # fetcher_retries 5
43
44
 
44
45
  # Load additional software
45
46
  # ------------------------------
46
47
  # software_gems ['omnibus-software', 'my-company-software']
47
48
  # local_software_dirs ['/path/to/local/software']
49
+
50
+ # Windows architecture defaults
51
+ # ------------------------------
52
+ windows_arch %w{x86 x64}.include?((ENV['OMNIBUS_WINDOWS_ARCH'] || '').downcase) ?
53
+ ENV['OMNIBUS_WINDOWS_ARCH'].downcase.to_sym : :x86
@@ -0,0 +1,43 @@
1
+ require 'omnibus/util'
2
+
3
+ module Omnibus
4
+ class GitRepository
5
+ include Util
6
+
7
+ def initialize(path='./')
8
+ @repo_path = path
9
+ end
10
+
11
+ def authors(start_ref, end_ref)
12
+ formatted_log_between(start_ref, end_ref, '%aN').lines.map(&:chomp).uniq
13
+ end
14
+
15
+ def commit_messages(start_ref, end_ref)
16
+ formatted_log_between(start_ref, end_ref, '%B').lines.to_a
17
+ end
18
+
19
+ def revision
20
+ git("rev-parse HEAD").strip
21
+ end
22
+
23
+ def latest_tag
24
+ git('describe --abbrev=0').chomp
25
+ end
26
+
27
+ def file_at_revision(path, revision)
28
+ git("show #{revision}:#{path}")
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :repo_path
34
+
35
+ def formatted_log_between(start_ref, end_ref, format)
36
+ git("log #{start_ref}..#{end_ref} --pretty=\"format:#{format}\"")
37
+ end
38
+
39
+ def git(cmd)
40
+ shellout!("git #{cmd}", :cwd => repo_path).stdout
41
+ end
42
+ end
43
+ end
@@ -72,12 +72,14 @@ module Omnibus
72
72
  /libmd5\.so/,
73
73
  /libmd\.so/,
74
74
  /libmp\.so/,
75
+ /libresolv\.so/,
75
76
  /libscf\.so/,
76
77
  /libsec\.so/,
77
78
  /libsocket\.so/,
78
79
  /libssl.so/,
79
80
  /libthread.so/,
80
81
  /libuutil\.so/,
82
+ /libkstat\.so/,
81
83
  # solaris 11 libraries:
82
84
  /libc\.so\.1/,
83
85
  /libm\.so\.2/,
@@ -136,6 +138,8 @@ module Omnibus
136
138
  /libthr\.so/,
137
139
  /libutil\.so/,
138
140
  /libelf\.so/,
141
+ /libkvm\.so/,
142
+ /libprocstat\.so/,
139
143
  ].freeze
140
144
 
141
145
  class << self
@@ -177,7 +181,7 @@ module Omnibus
177
181
  log.warn(log_key) { 'Skipping health check on Windows' }
178
182
  return true
179
183
  end
180
-
184
+ log.info(log_key) {"Running health on #{project.name}"}
181
185
  bad_libs = case Ohai['platform']
182
186
  when 'mac_os_x'
183
187
  health_check_otool
@@ -0,0 +1,134 @@
1
+ #
2
+ # Copyright 2015 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'json'
18
+
19
+ module Omnibus
20
+ class Manifest
21
+ class InvalidManifestFormat < Exception; end
22
+ class NotAManifestEntry < Exception; end
23
+ class MissingManifestEntry < Exception; end
24
+
25
+ include Logging
26
+
27
+ LATEST_MANIFEST_FORMAT = 1
28
+
29
+ attr_reader :build_version, :build_git_revision
30
+ def initialize(version=nil, git_rev=nil)
31
+ @data = {}
32
+ @build_version = version
33
+ @build_git_revision = git_rev
34
+ end
35
+
36
+ def entry_for(name)
37
+ if @data.key?(name)
38
+ @data[name]
39
+ else
40
+ raise MissingManifestEntry, "No manifest entry found for #{name}"
41
+ end
42
+ end
43
+
44
+ def add(name, entry)
45
+ if ! entry.is_a? Omnibus::ManifestEntry
46
+ raise NotAManifestEntry, "#{entry} is not an Omnibus:ManifestEntry"
47
+ end
48
+
49
+ if @data.key?(name)
50
+ log.warn(log_key) { "Overritting existing manifest entry for #{name}" }
51
+ end
52
+
53
+ @data[name] = entry
54
+ self
55
+ end
56
+
57
+ def each
58
+ @data.each do |key, entry|
59
+ yield entry
60
+ end
61
+ end
62
+
63
+ def entry_names
64
+ @data.keys
65
+ end
66
+
67
+ def to_hash
68
+ software_hash = @data.inject({}) do |memo, (k,v)|
69
+ memo[k] = v.to_hash
70
+ memo
71
+ end
72
+ ret = {
73
+ 'manifest_format' => LATEST_MANIFEST_FORMAT,
74
+ 'software' => software_hash
75
+ }
76
+ ret['build_version'] = build_version if build_version
77
+ ret['build_git_revision'] = build_git_revision if build_git_revision
78
+ ret
79
+ end
80
+
81
+ #
82
+ # The JSON representation of this build manifest.
83
+ #
84
+ # @return [String]
85
+ #
86
+ def to_json
87
+ JSON.pretty_generate(to_hash)
88
+ end
89
+
90
+ #
91
+ # Class Methods
92
+ #
93
+
94
+ def self.from_hash(manifest_data)
95
+ case manifest_data['manifest_format'].to_i
96
+ when 1
97
+ from_hash_v1(manifest_data)
98
+ else
99
+ raise InvalidManifestFormat, "Unknown manifest fromat version: #{manifest_data['manifest_format']}"
100
+ end
101
+ end
102
+
103
+ def self.from_hash_v1(manifest_data)
104
+ m = Omnibus::Manifest.new(manifest_data['build_version'], manifest_data['build_git_revision'])
105
+ manifest_data['software'].each do |name, entry_data|
106
+ m.add(name, Omnibus::ManifestEntry.new(name, keys_to_syms(entry_data)))
107
+ end
108
+ m
109
+ end
110
+
111
+ def self.from_file(filename)
112
+ from_hash(JSON.parse(File.read(File.expand_path(filename))))
113
+ end
114
+
115
+ private
116
+
117
+ #
118
+ # Utility function to convert a Hash with String keys to a Hash
119
+ # with Symbol keys, recursively.
120
+ #
121
+ # @returns [Hash]
122
+ #
123
+ def self.keys_to_syms(h)
124
+ h.inject({}) do |memo, (k, v)|
125
+ memo[k.to_sym] = if v.is_a? Hash
126
+ keys_to_syms(v)
127
+ else
128
+ v
129
+ end
130
+ memo
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,88 @@
1
+ module Omnibus
2
+ class EmptyManifestDiff
3
+ def updated
4
+ []
5
+ end
6
+
7
+ def added
8
+ []
9
+ end
10
+
11
+ def removed
12
+ []
13
+ end
14
+
15
+ def empty?
16
+ true
17
+ end
18
+ end
19
+
20
+ class ManifestDiff
21
+ def initialize(first, second)
22
+ @first = first
23
+ @second = second
24
+ end
25
+
26
+ def updated
27
+ @updated ||=
28
+ begin
29
+ (first.entry_names & second.entry_names).collect do |name|
30
+ diff(first.entry_for(name), second.entry_for(name))
31
+ end.compact
32
+ end
33
+ end
34
+
35
+ def removed
36
+ @removed ||=
37
+ begin
38
+ (first.entry_names - second.entry_names).collect do |name|
39
+ removed_entry(first.entry_for(name))
40
+ end
41
+ end
42
+ end
43
+
44
+ def added
45
+ @added ||=
46
+ begin
47
+ (second.entry_names - first.entry_names).collect do |name|
48
+ new_entry(second.entry_for(name))
49
+ end
50
+ end
51
+ end
52
+
53
+ def empty?
54
+ updated.empty? && removed.empty? && added.empty?
55
+ end
56
+
57
+ private
58
+
59
+ attr_reader :first, :second
60
+
61
+ def new_entry(entry)
62
+ { name: entry.name,
63
+ new_version: entry.locked_version,
64
+ source_type: entry.source_type,
65
+ source: entry.locked_source }
66
+ end
67
+
68
+
69
+ def removed_entry(entry)
70
+ { name: entry.name,
71
+ old_version: entry.locked_version,
72
+ source_type: entry.source_type,
73
+ source: entry.locked_source }
74
+ end
75
+
76
+ def diff(a, b)
77
+ if a == b
78
+ nil
79
+ else
80
+ { name: b.name,
81
+ old_version: a.locked_version,
82
+ new_version: b.locked_version,
83
+ source_type: b.source_type,
84
+ source: b.locked_source }
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,43 @@
1
+ #
2
+ # Copyright 2014 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Omnibus
18
+ class ManifestEntry
19
+ attr_reader :locked_version, :locked_source, :source_type, :described_version, :name
20
+ def initialize(name, manifest_data)
21
+ @name = name
22
+ @locked_version = manifest_data[:locked_version]
23
+ @locked_source = manifest_data[:locked_source]
24
+ @source_type = manifest_data[:source_type]
25
+ @described_version = manifest_data[:described_version]
26
+ end
27
+
28
+ def to_hash
29
+ {
30
+ "locked_version" => @locked_version,
31
+ "locked_source" => @locked_source,
32
+ "source_type" => @source_type,
33
+ "described_version" => @described_version
34
+ }
35
+ end
36
+
37
+ def ==(other)
38
+ if other.is_a?(ManifestEntry)
39
+ (self.to_hash == other.to_hash) && (self.name == other.name)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -108,7 +108,11 @@ module Omnibus
108
108
  # @return [String]
109
109
  #
110
110
  def arch
111
- Ohai['kernel']['machine']
111
+ if (Ohai['platform'] == 'windows') && (Config.windows_arch.to_sym == :x86)
112
+ 'i386'
113
+ else
114
+ Ohai['kernel']['machine']
115
+ end
112
116
  end
113
117
 
114
118
  #
@@ -176,6 +180,10 @@ module Omnibus
176
180
  #
177
181
  # http://www.jrsoftware.org/ishelp/index.php?topic=winvernotes
178
182
  #
183
+ # Microsoft's version listing (more general than the above) is here:
184
+ #
185
+ # https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
186
+ #
179
187
  case platform_version
180
188
  when '5.0.2195', '2000' then '2000'
181
189
  when '5.1.2600', 'xp' then 'xp'
@@ -193,6 +201,7 @@ module Omnibus
193
201
  # version is the same as Windows 8.1. It's only here for completeness
194
202
  # and documentation.
195
203
  when /6\.3\.\d+/, '2012r2' then '2012r2'
204
+ when /^10\.0/ then '10'
196
205
  else
197
206
  raise UnknownPlatformVersion.new(platform, platform_version)
198
207
  end
@@ -253,6 +262,15 @@ module Omnibus
253
262
  true
254
263
  end
255
264
 
265
+ #
266
+ # Hash representation of this metadata.
267
+ #
268
+ # @return [Hash]
269
+ #
270
+ def to_hash
271
+ @data.dup
272
+ end
273
+
256
274
  #
257
275
  # The JSON representation of this metadata.
258
276
  #
@@ -103,6 +103,15 @@ module Omnibus
103
103
  @metadata ||= Metadata.for_package(self)
104
104
  end
105
105
 
106
+ #
107
+ # Set the metadata for this package
108
+ #
109
+ # @param [Metadata] metadata
110
+ #
111
+ def metadata=(metadata)
112
+ @metadata = metadata
113
+ end
114
+
106
115
  #
107
116
  # Validate the presence of the required components for the package.
108
117
  #