omnibus 5.5.0 → 5.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  3. data/.travis.yml +2 -1
  4. data/CHANGELOG.md +37 -0
  5. data/Gemfile +5 -4
  6. data/MAINTAINERS.md +12 -17
  7. data/README.md +98 -107
  8. data/appveyor.yml +1 -1
  9. data/lib/omnibus.rb +4 -4
  10. data/lib/omnibus/builder.rb +42 -9
  11. data/lib/omnibus/cli.rb +5 -0
  12. data/lib/omnibus/cli/base.rb +1 -1
  13. data/lib/omnibus/cli/publish.rb +5 -3
  14. data/lib/omnibus/compressors/dmg.rb +2 -2
  15. data/lib/omnibus/config.rb +42 -5
  16. data/lib/omnibus/core_extensions/open_uri.rb +1 -0
  17. data/lib/omnibus/download_helpers.rb +4 -4
  18. data/lib/omnibus/fetchers/git_fetcher.rb +15 -5
  19. data/lib/omnibus/fetchers/net_fetcher.rb +1 -1
  20. data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
  21. data/lib/omnibus/file_syncer.rb +2 -2
  22. data/lib/omnibus/generator_files/omnibus.rb.erb +1 -0
  23. data/lib/omnibus/git_cache.rb +31 -13
  24. data/lib/omnibus/health_check.rb +1 -173
  25. data/lib/omnibus/licensing.rb +48 -7
  26. data/lib/omnibus/manifest.rb +3 -5
  27. data/lib/omnibus/manifest_entry.rb +1 -1
  28. data/lib/omnibus/metadata.rb +2 -1
  29. data/lib/omnibus/packager.rb +3 -1
  30. data/lib/omnibus/packagers/appx.rb +3 -3
  31. data/lib/omnibus/packagers/base.rb +9 -0
  32. data/lib/omnibus/packagers/bff.rb +4 -6
  33. data/lib/omnibus/packagers/deb.rb +95 -1
  34. data/lib/omnibus/packagers/ips.rb +50 -4
  35. data/lib/omnibus/packagers/pkgsrc.rb +112 -0
  36. data/lib/omnibus/packagers/rpm.rb +72 -3
  37. data/lib/omnibus/packagers/solaris.rb +0 -4
  38. data/lib/omnibus/packagers/windows_base.rb +1 -1
  39. data/lib/omnibus/project.rb +13 -3
  40. data/lib/omnibus/publishers/artifactory_publisher.rb +4 -6
  41. data/lib/omnibus/publishers/s3_publisher.rb +8 -3
  42. data/lib/omnibus/reports.rb +1 -1
  43. data/lib/omnibus/s3_cache.rb +18 -5
  44. data/lib/omnibus/s3_helpers.rb +45 -8
  45. data/lib/omnibus/software.rb +55 -37
  46. data/lib/omnibus/sugarable.rb +4 -0
  47. data/lib/omnibus/templating.rb +29 -13
  48. data/lib/omnibus/util.rb +81 -2
  49. data/lib/omnibus/version.rb +1 -1
  50. data/lib/omnibus/whitelist.rb +228 -0
  51. data/omnibus.gemspec +9 -8
  52. data/resources/dmg/create_dmg.osascript.erb +33 -13
  53. data/resources/ips/doc-transform.erb +2 -0
  54. data/resources/rpm/spec.erb +1 -2
  55. data/spec/functional/builder_spec.rb +21 -21
  56. data/spec/functional/fetchers/git_fetcher_spec.rb +6 -6
  57. data/spec/functional/fetchers/net_fetcher_spec.rb +7 -7
  58. data/spec/functional/fetchers/path_fetcher_spec.rb +5 -5
  59. data/spec/functional/file_syncer_spec.rb +6 -6
  60. data/spec/functional/licensing_spec.rb +29 -16
  61. data/spec/functional/templating_spec.rb +23 -22
  62. data/spec/support/git_helpers.rb +30 -24
  63. data/spec/unit/build_version_spec.rb +1 -1
  64. data/spec/unit/builder_spec.rb +36 -24
  65. data/spec/unit/changelogprinter_spec.rb +10 -8
  66. data/spec/unit/cleanroom_spec.rb +6 -6
  67. data/spec/unit/compressors/dmg_spec.rb +23 -37
  68. data/spec/unit/compressors/null_spec.rb +2 -2
  69. data/spec/unit/compressors/tgz_spec.rb +2 -2
  70. data/spec/unit/config_spec.rb +2 -1
  71. data/spec/unit/digestable_spec.rb +2 -2
  72. data/spec/unit/fetchers/git_fetcher_spec.rb +5 -5
  73. data/spec/unit/fetchers/net_fetcher_spec.rb +46 -6
  74. data/spec/unit/fetchers/path_fetcher_spec.rb +5 -5
  75. data/spec/unit/file_syncer_spec.rb +19 -0
  76. data/spec/unit/git_cache_spec.rb +76 -22
  77. data/spec/unit/health_check_spec.rb +1 -1
  78. data/spec/unit/library_spec.rb +2 -2
  79. data/spec/unit/manifest_spec.rb +6 -6
  80. data/spec/unit/metadata_spec.rb +4 -4
  81. data/spec/unit/omnibus_spec.rb +4 -4
  82. data/spec/unit/package_spec.rb +6 -6
  83. data/spec/unit/packagers/appx_spec.rb +16 -12
  84. data/spec/unit/packagers/base_spec.rb +5 -5
  85. data/spec/unit/packagers/bff_spec.rb +45 -15
  86. data/spec/unit/packagers/deb_spec.rb +95 -17
  87. data/spec/unit/packagers/ips_spec.rb +61 -17
  88. data/spec/unit/packagers/makeself_spec.rb +5 -5
  89. data/spec/unit/packagers/msi_spec.rb +43 -43
  90. data/spec/unit/packagers/pkg_spec.rb +15 -15
  91. data/spec/unit/packagers/pkgsrc_spec.rb +77 -0
  92. data/spec/unit/packagers/rpm_spec.rb +94 -17
  93. data/spec/unit/packagers/solaris_spec.rb +11 -11
  94. data/spec/unit/project_spec.rb +53 -22
  95. data/spec/unit/publisher_spec.rb +2 -2
  96. data/spec/unit/publishers/artifactory_publisher_spec.rb +7 -3
  97. data/spec/unit/publishers/s3_publisher_spec.rb +1 -1
  98. data/spec/unit/s3_helpers_spec.rb +41 -3
  99. data/spec/unit/software_spec.rb +115 -37
  100. data/spec/unit/sugarable_spec.rb +23 -3
  101. data/spec/unit/util_spec.rb +42 -11
  102. metadata +49 -29
@@ -166,6 +166,86 @@ module Omnibus
166
166
  end
167
167
  expose :section
168
168
 
169
+ #
170
+ # Compression algorithm (gzip, xz, none) to use (-Z).
171
+ #
172
+ # @example
173
+ # compression_type :xz
174
+ #
175
+ # @param [Symbol] val
176
+ # type of compression (:gzip, :xz, :none)
177
+ #
178
+ # @return [Symbol]
179
+ # type of compression for this package
180
+ #
181
+ def compression_type(val = NULL)
182
+ if null?(val)
183
+ @compression_type || :gzip
184
+ else
185
+ unless val.is_a?(Symbol) && [:gzip, :xz, :none].member?(val)
186
+ raise InvalidValue.new(:compression_type, "be a Symbol (:gzip, :xz, or :none)")
187
+ end
188
+
189
+ @compression_type = val
190
+ end
191
+ end
192
+ expose :compression_type
193
+
194
+ #
195
+ # Compression level (1-9) to use (-Z).
196
+ #
197
+ # @example
198
+ # compression_level 1
199
+ #
200
+ # @param [Integer] val
201
+ # level of compression (1, .., 9)
202
+ #
203
+ # @return [Integer]
204
+ # level of compression for this package
205
+ #
206
+ def compression_level(val = NULL)
207
+ if null?(val)
208
+ @compression_level || 9
209
+ else
210
+ unless val.is_a?(Integer) && 1 <= val && 9 >= val
211
+ raise InvalidValue.new(:compression_level, "be an Integer between 1 and 9")
212
+ end
213
+
214
+ @compression_level = val
215
+ end
216
+ end
217
+ expose :compression_level
218
+
219
+ #
220
+ # Compression strategy to use (-Z).
221
+ # For gzip: :filtered, :huffman, :rle, or :fixed;
222
+ # for xz: :extreme
223
+ # (nil means parameter will not be passsed to dpkg-deb)
224
+ #
225
+ # @example
226
+ # compression_strategy :extreme
227
+ #
228
+ # @param [Symbol] val
229
+ # compression strategy
230
+ #
231
+ # @return [Symbol]
232
+ # compression strategy for this package
233
+ #
234
+ def compression_strategy(val = NULL)
235
+ if null?(val)
236
+ @compression_strategy
237
+ else
238
+ unless val.is_a?(Symbol) &&
239
+ [:filtered, :huffman, :rle, :fixed, :extreme].member?(val)
240
+ raise InvalidValue.new(:compression_strategy, "be a Symbol (:filtered, "\
241
+ ":huffman, :rle, :fixed, or :extreme)")
242
+ end
243
+
244
+ @compression_strategy = val
245
+ end
246
+ end
247
+ expose :compression_strategy
248
+
169
249
  #
170
250
  # @!endgroup
171
251
  # --------------------------------------------------
@@ -291,7 +371,21 @@ module Omnibus
291
371
 
292
372
  # Execute the build command
293
373
  Dir.chdir(Config.package_dir) do
294
- shellout!("fakeroot dpkg-deb -z9 -Zgzip -D --build #{staging_dir} #{package_name}")
374
+ shellout!("fakeroot dpkg-deb #{compression_params} -D --build #{staging_dir} #{package_name}")
375
+ end
376
+ end
377
+
378
+ #
379
+ # Return the parameters passed to dpkg-deb for setting the compression
380
+ # according to configuration.
381
+ #
382
+ # @return [String]
383
+ #
384
+ def compression_params
385
+ if compression_strategy
386
+ "-z#{compression_level} -Z#{compression_type} -S#{compression_strategy}"
387
+ else
388
+ "-z#{compression_level} -Z#{compression_type}"
295
389
  end
296
390
  end
297
391
 
@@ -28,6 +28,7 @@ module Omnibus
28
28
  destination = File.join(source_dir, project.install_dir)
29
29
  FileSyncer.sync(project.install_dir, destination, exclude: exclusions)
30
30
  write_transform_file
31
+ write_versionlock_file
31
32
  end
32
33
 
33
34
  build do
@@ -81,8 +82,7 @@ module Omnibus
81
82
  # @see Base#package_name
82
83
  #
83
84
  def package_name
84
- version = project.build_version.split(/[^\d]/)[0..2].join(".")
85
- "#{safe_base_package_name}-#{version}-#{project.build_iteration}.#{safe_architecture}.p5p"
85
+ "#{safe_base_package_name}-#{project.build_version}-#{project.build_iteration}.#{safe_architecture}.p5p"
86
86
  end
87
87
 
88
88
  #
@@ -105,6 +105,15 @@ module Omnibus
105
105
  @transform_file ||= File.join(staging_dir, "doc-transform")
106
106
  end
107
107
 
108
+ #
109
+ # The full path to the version-lock file on disk.
110
+ #
111
+ # @return [String]
112
+ #
113
+ def versionlock_file
114
+ @versionlock_file ||= File.join(staging_dir, "version-lock")
115
+ end
116
+
108
117
  #
109
118
  # The full path to the pkg metadata file on disk.
110
119
  #
@@ -178,6 +187,17 @@ module Omnibus
178
187
  end
179
188
  end
180
189
 
190
+ #
191
+ # A version-lock rule that `pkgmogrify' will apply to at the end of package
192
+ # manifest.
193
+ #
194
+ # @return [void]
195
+ #
196
+ def write_versionlock_file
197
+ transform_str = "<transform pkg depend -> default facet.version-lock.*> false>"
198
+ File.write("#{staging_dir}/version-lock", transform_str)
199
+ end
200
+
181
201
  #
182
202
  # A set of transform rules that `pkgmogrify' will apply to the package
183
203
  # manifest.
@@ -193,6 +213,24 @@ module Omnibus
193
213
  )
194
214
  end
195
215
 
216
+ #
217
+ # A set of symbolic links to installed commands that
218
+ #`pkgmogrify' will apply to the package manifest. Is called only when
219
+ # symlinks.erb template exists
220
+ # The resource exists locally. For example for project omnibus-toolchain
221
+ # resource_path("symlinks.erb") #=>
222
+ # {"/path/to/omnibus-toolchain/resources/omnibus-toolchain/ips/symlinks.erb"}
223
+ #
224
+ # @return [String]
225
+ #
226
+ def render_symlinks
227
+ render_template_content(resource_path("symlinks.erb"),
228
+ {
229
+ projectdir: project.install_dir,
230
+ }
231
+ )
232
+ end
233
+
196
234
  #
197
235
  # Generate package metadata
198
236
  #
@@ -212,6 +250,13 @@ module Omnibus
212
250
  }
213
251
  )
214
252
 
253
+ # Append the contents of symlinks.erb if it exists
254
+ if File.exists?(resource_path("symlinks.erb"))
255
+ File.open(pkg_metadata_file, "a") do |symlink|
256
+ symlink.write(render_symlinks)
257
+ end
258
+ end
259
+
215
260
  # Print the full contents of the rendered template file to generate package contents
216
261
  log.debug(log_key) { "Rendered Template:\n" + File.read(pkg_metadata_file) }
217
262
  end
@@ -235,6 +280,7 @@ module Omnibus
235
280
  shellout!("pkgdepend generate -md #{source_dir} #{pkg_manifest_file}.2 | pkgfmt > #{pkg_manifest_file}.3")
236
281
  shellout!("pkgmogrify -DARCH=`uname -p` #{pkg_manifest_file}.3 #{transform_file} | pkgfmt > #{pkg_manifest_file}.4")
237
282
  shellout!("pkgdepend resolve -m #{pkg_manifest_file}.4")
283
+ shellout!("pkgmogrify #{pkg_manifest_file}.4.res #{versionlock_file} > #{pkg_manifest_file}.5.res")
238
284
  end
239
285
 
240
286
  #
@@ -244,7 +290,7 @@ module Omnibus
244
290
  #
245
291
  def validate_pkg_manifest
246
292
  log.info(log_key) { "Validating package manifest" }
247
- shellout!("pkglint -c /tmp/lint-cache -r http://pkg.oracle.com/solaris/release #{pkg_manifest_file}.4.res")
293
+ shellout!("pkglint -c /tmp/lint-cache -r http://pkg.oracle.com/solaris/release #{pkg_manifest_file}.5.res")
248
294
  end
249
295
 
250
296
  #
@@ -264,7 +310,7 @@ module Omnibus
264
310
  #
265
311
  def publish_ips_pkg
266
312
  shellout!("pkgrepo -s #{repo_dir} set publisher/prefix=#{publisher_prefix}")
267
- shellout!("pkgsend publish -s #{repo_dir} -d #{source_dir} #{pkg_manifest_file}.4.res")
313
+ shellout!("pkgsend publish -s #{repo_dir} -d #{source_dir} #{pkg_manifest_file}.5.res")
268
314
  log.info(log_key) { "Published IPS package to repo: #{repo_dir}" }
269
315
 
270
316
  repo_info = shellout("pkg list -afv -g #{repo_dir}").stdout
@@ -0,0 +1,112 @@
1
+ #
2
+ # Copyright 2016 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 Packager::PKGSRC < Packager::Base
19
+ id :pkgsrc
20
+
21
+ PKGTOOLS_VERSION = "20091115".freeze
22
+
23
+ build do
24
+ write_buildinfo
25
+ write_buildver
26
+ write_comment
27
+ write_packlist
28
+ create_pkg
29
+ end
30
+
31
+ def build_info
32
+ staging_dir_path("build-info")
33
+ end
34
+
35
+ def build_ver
36
+ staging_dir_path("build-ver")
37
+ end
38
+
39
+ def comment_file
40
+ staging_dir_path("comment")
41
+ end
42
+
43
+ def pack_list
44
+ staging_dir_path("packlist")
45
+ end
46
+
47
+ def create_pkg
48
+ postinst = "#{project.package_scripts_path}/postinst"
49
+ postrm = "#{project.package_scripts_path}/postrm"
50
+
51
+ shellout! "cd #{Config.package_dir} && pkg_create -i #{postinst} -k #{postrm} -p #{project.install_dir} -b #{build_ver} -B #{build_info} -c #{comment_file} -d #{comment_file} -f #{pack_list} -I #{project.install_dir} -l -U #{package_name}"
52
+ end
53
+
54
+ def package_name
55
+ "#{project.package_name}-#{project.build_version}.tgz"
56
+ end
57
+
58
+ def write_buildver
59
+ File.open build_ver, "w+" do |f|
60
+ f.write"#{project.build_version}-#{project.build_iteration}"
61
+ end
62
+ end
63
+
64
+ def write_buildinfo
65
+ buildinfo_content = <<-EOF
66
+ MACHINE_ARCH=#{safe_architecture}
67
+ OPSYS=#{opsys}
68
+ OS_VERSION=#{os_version}
69
+ PKGTOOLS_VERSION=#{PKGTOOLS_VERSION}
70
+ EOF
71
+
72
+ File.open(build_info, "w+") do |f|
73
+ f.write(buildinfo_content)
74
+ end
75
+ end
76
+
77
+ def write_comment
78
+ File.open(comment_file, "w+") do |f|
79
+ f.write(project.description)
80
+ end
81
+ end
82
+
83
+ def write_packlist
84
+ File.open pack_list, "w+" do |f|
85
+ f.write "@pkgdir #{project.install_dir}\n@cwd #{project.install_dir}/\n"
86
+ end
87
+
88
+ shellout! "cd #{project.install_dir} && find . -type l -or -type f | sort >> #{pack_list}"
89
+ end
90
+
91
+ def opsys
92
+ Ohai["kernel"]["name"]
93
+ end
94
+
95
+ def os_version
96
+ Ohai["kernel"]["release"]
97
+ end
98
+
99
+ def safe_architecture
100
+ if smartos?
101
+ if Ohai["kernel"]["update"] == "86_64"
102
+ "x86_64"
103
+ else
104
+ "i386"
105
+ end
106
+ else
107
+ # FIXME: this undoubtedly will need filling out once we make this go for platforms that aren't SmartOS
108
+ Ohai["kernel"]["machine"]
109
+ end
110
+ end
111
+ end
112
+ end
@@ -227,6 +227,56 @@ module Omnibus
227
227
  end
228
228
  expose :dist_tag
229
229
 
230
+ #
231
+ # Set or return the compression type (:gzip, :bzip2, :xz) for this package
232
+ #
233
+ # @example
234
+ # compression_type :xz
235
+ #
236
+ # @param [Symbol] val
237
+ # the compression type
238
+ #
239
+ # @return [String]
240
+ # the compression type for this package
241
+ #
242
+ def compression_type(val = NULL)
243
+ if null?(val)
244
+ @compression_type || :gzip
245
+ else
246
+ unless val.is_a?(Symbol) && [:gzip, :bzip2, :xz].member?(val)
247
+ raise InvalidValue.new(:compression_type, "be a Symbol (:gzip, :bzip2, or :xz)")
248
+ end
249
+
250
+ @compression_type = val
251
+ end
252
+ end
253
+ expose :compression_type
254
+
255
+ #
256
+ # Set or return the compression level (1-9) for this package
257
+ #
258
+ # @example
259
+ # compression_level 6
260
+ #
261
+ # @param [Integer] val
262
+ # the compression level
263
+ #
264
+ # @return [Integer]
265
+ # the compression level for this package
266
+ #
267
+ def compression_level(val = NULL)
268
+ if null?(val)
269
+ @compression_level || 9
270
+ else
271
+ unless val.is_a?(Integer) && 1 <= val && 9 >= val
272
+ raise InvalidValue.new(:compression_level, "be an Integer (between 1 and 9)")
273
+ end
274
+
275
+ @compression_level = val
276
+ end
277
+ end
278
+ expose :compression_level
279
+
230
280
  #
231
281
  # @!endgroup
232
282
  # --------------------------------------------------
@@ -278,11 +328,11 @@ module Omnibus
278
328
  #
279
329
  def mark_filesystem_directories(fsdir)
280
330
  if fsdir.eql?("/") || fsdir.eql?("/usr/lib") || fsdir.eql?("/usr/share/empty")
281
- return "%dir %attr(0555,root,root) #{fsdir}"
331
+ "%dir %attr(0555,root,root) #{fsdir}"
282
332
  elsif filesystem_directories.include?(fsdir)
283
- return "%dir %attr(0755,root,root) #{fsdir}"
333
+ "%dir %attr(0755,root,root) #{fsdir}"
284
334
  else
285
- return "%dir #{fsdir}"
335
+ "%dir #{fsdir}"
286
336
  end
287
337
  end
288
338
 
@@ -332,10 +382,29 @@ module Omnibus
332
382
  files: files,
333
383
  build_dir: build_dir,
334
384
  platform_family: Ohai["platform_family"],
385
+ compression: compression,
335
386
  }
336
387
  )
337
388
  end
338
389
 
390
+ #
391
+ # Returns the RPM spec "_binary_payload" line corresponding to the
392
+ # compression configuration.
393
+ #
394
+ # @return [String]
395
+ #
396
+ def compression
397
+ compression_name = case compression_type
398
+ when :bzip2
399
+ "bzdio"
400
+ when :xz
401
+ "xzdio"
402
+ else # default to gzip
403
+ "gzdio"
404
+ end
405
+ "w#{compression_level}.#{compression_name}"
406
+ end
407
+
339
408
  #
340
409
  # Generate the RPM file using +rpmbuild+. Unlike debian,the +fakeroot+
341
410
  # command is not required for the package to be owned by +root:root+. The
@@ -54,10 +54,6 @@ module Omnibus
54
54
  File.basename(project.install_dir)
55
55
  end
56
56
 
57
- def staging_dir_path(file_name)
58
- File.join(staging_dir, file_name)
59
- end
60
-
61
57
  #
62
58
  # Copy all scripts in {Project#package_scripts_path} to the control
63
59
  # directory of this repo.
@@ -76,7 +76,7 @@ module Omnibus
76
76
  end
77
77
 
78
78
  @signing_identity[:store] = params[:store] || "My"
79
- @signing_identity[:algorithm] = params[:algorithm] || "SHA1"
79
+ @signing_identity[:algorithm] = params[:algorithm] || "SHA256"
80
80
  servers = params[:timestamp_servers] || DEFAULT_TIMESTAMP_SERVERS
81
81
  @signing_identity[:timestamp_servers] = [servers].flatten
82
82
  @signing_identity[:machine_store] = params[:machine_store] || false