omnibus 3.2.2 → 4.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (302) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +140 -10
  3. data/CHANGELOG.md +181 -8
  4. data/README.md +63 -35
  5. data/Rakefile +1 -1
  6. data/docs/omnibus-build-cache.md b/data/docs/Build → Cache.md +0 -0
  7. data/docs/Building on Debian.md +59 -0
  8. data/docs/Building on OSX.md +61 -35
  9. data/docs/Building on RHEL.md +74 -0
  10. data/docs/Building on Windows.md +40 -81
  11. data/features/commands/build.feature +1 -2
  12. data/features/commands/clean.feature +1 -1
  13. data/lib/omnibus.rb +111 -204
  14. data/lib/omnibus/build_version.rb +3 -20
  15. data/lib/omnibus/build_version_dsl.rb +2 -3
  16. data/lib/omnibus/builder.rb +103 -211
  17. data/lib/omnibus/cleaner.rb +5 -7
  18. data/lib/omnibus/cli.rb +1 -4
  19. data/lib/omnibus/cli/base.rb +9 -16
  20. data/lib/omnibus/compressor.rb +60 -0
  21. data/{spec/data/complicated/config/software/version-manifest.rb → lib/omnibus/compressors/base.rb} +17 -12
  22. data/lib/omnibus/compressors/dmg.rb +312 -0
  23. data/lib/omnibus/{null_builder.rb → compressors/null.rb} +10 -4
  24. data/lib/omnibus/compressors/tgz.rb +141 -0
  25. data/lib/omnibus/config.rb +89 -83
  26. data/lib/omnibus/core_extensions.rb +1 -0
  27. data/lib/omnibus/core_extensions/open_uri.rb +58 -0
  28. data/lib/omnibus/digestable.rb +9 -3
  29. data/lib/omnibus/exceptions.rb +116 -175
  30. data/lib/omnibus/fetcher.rb +97 -138
  31. data/lib/omnibus/fetchers/git_fetcher.rb +130 -165
  32. data/lib/omnibus/fetchers/net_fetcher.rb +205 -164
  33. data/lib/omnibus/fetchers/{s3_cache_fetcher.rb → null_fetcher.rb} +27 -17
  34. data/lib/omnibus/fetchers/path_fetcher.rb +74 -32
  35. data/lib/omnibus/file_syncer.rb +149 -0
  36. data/lib/omnibus/generator.rb +103 -32
  37. data/lib/omnibus/generator_files/.kitchen.yml.erb +5 -1
  38. data/lib/omnibus/generator_files/Gemfile.erb +13 -7
  39. data/lib/omnibus/generator_files/config/projects/project.rb.erb +28 -0
  40. data/lib/omnibus/generator_files/config/software/zlib.rb.erb +55 -0
  41. data/lib/omnibus/generator_files/omnibus.rb.erb +5 -7
  42. data/lib/omnibus/git_cache.rb +11 -13
  43. data/lib/omnibus/logger.rb +76 -22
  44. data/lib/omnibus/logging.rb +1 -1
  45. data/lib/omnibus/metadata.rb +264 -0
  46. data/lib/omnibus/ohai.rb +0 -51
  47. data/lib/omnibus/package.rb +4 -228
  48. data/lib/omnibus/packager.rb +71 -0
  49. data/lib/omnibus/packagers/base.rb +118 -176
  50. data/lib/omnibus/packagers/bff.rb +136 -0
  51. data/lib/omnibus/packagers/deb.rb +389 -0
  52. data/lib/omnibus/packagers/makeself.rb +114 -0
  53. data/lib/omnibus/packagers/msi.rb +346 -0
  54. data/lib/omnibus/packagers/pkg.rb +278 -0
  55. data/lib/omnibus/packagers/rpm.rb +438 -0
  56. data/lib/omnibus/packagers/solaris.rb +110 -0
  57. data/lib/omnibus/project.rb +263 -666
  58. data/lib/omnibus/publisher.rb +3 -3
  59. data/lib/omnibus/s3_cache.rb +21 -30
  60. data/lib/omnibus/software.rb +132 -271
  61. data/lib/omnibus/templating.rb +66 -0
  62. data/lib/omnibus/thread_pool.rb +109 -0
  63. data/lib/omnibus/util.rb +137 -15
  64. data/lib/omnibus/version.rb +1 -1
  65. data/omnibus.gemspec +2 -2
  66. data/resources/bff/gen.template.erb +22 -0
  67. data/resources/bff/postinstall.sh +0 -0
  68. data/resources/bff/unpostinstall.sh +0 -0
  69. data/resources/deb/conffiles.erb +3 -0
  70. data/resources/deb/control.erb +25 -0
  71. data/resources/deb/md5sums.erb +3 -0
  72. data/{lib/omnibus/generator_files/mac_dmg → resources/dmg}/background.png +0 -0
  73. data/resources/dmg/create_dmg.osascript.erb +17 -0
  74. data/{lib/omnibus/generator_files/mac_dmg → resources/dmg}/icon.png +0 -0
  75. data/{bin → resources/makeself}/makeself-header.sh +0 -0
  76. data/{bin → resources/makeself}/makeself.sh +0 -0
  77. data/{lib/omnibus/generator_files/package_scripts/makeselfinst.erb → resources/makeself/post_extract.sh.erb} +4 -4
  78. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/LICENSE.rtf +0 -0
  79. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/banner_background.bmp +0 -0
  80. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/dialog_background.bmp +0 -0
  81. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project.ico +0 -0
  82. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project_16x16.ico +0 -0
  83. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project_32x32.ico +0 -0
  84. data/{spec/fixtures/sample/files/windows_msi/Resources/localization-en-us.wxl → resources/msi/localization-en-us.wxl.erb} +3 -4
  85. data/resources/msi/parameters.wxi.erb +9 -0
  86. data/{lib/omnibus/generator_files/windows_msi → resources/msi}/source.wxs.erb +14 -15
  87. data/{lib/omnibus/generator_files/mac_pkg → resources/pkg}/background.png +0 -0
  88. data/resources/pkg/distribution.xml.erb +21 -0
  89. data/resources/pkg/license.html.erb +3 -0
  90. data/resources/pkg/welcome.html.erb +7 -0
  91. data/resources/rpm/rpmmacros.erb +3 -0
  92. data/resources/rpm/signing.erb +40 -0
  93. data/resources/rpm/spec.erb +70 -0
  94. data/spec/functional/builder_spec.rb +90 -111
  95. data/spec/functional/fetchers/git_fetcher_spec.rb +130 -0
  96. data/spec/functional/fetchers/net_fetcher_spec.rb +110 -0
  97. data/spec/functional/fetchers/path_fetcher_spec.rb +97 -0
  98. data/spec/functional/file_syncer_spec.rb +206 -0
  99. data/spec/functional/templating_spec.rb +73 -0
  100. data/spec/spec_helper.rb +31 -94
  101. data/spec/support/env_helpers.rb +20 -0
  102. data/spec/support/examples.rb +56 -0
  103. data/spec/support/file_helpers.rb +46 -0
  104. data/spec/support/git_helpers.rb +107 -0
  105. data/spec/support/logging_helpers.rb +33 -0
  106. data/spec/support/matchers.rb +36 -0
  107. data/spec/support/ohai_helpers.rb +22 -0
  108. data/spec/support/path_helpers.rb +19 -0
  109. data/spec/support/shell_helpers.rb +14 -0
  110. data/spec/unit/build_version_dsl_spec.rb +0 -17
  111. data/spec/unit/build_version_spec.rb +1 -19
  112. data/spec/unit/builder_spec.rb +158 -46
  113. data/spec/unit/compressor_spec.rb +45 -0
  114. data/spec/unit/compressors/base_spec.rb +26 -0
  115. data/spec/unit/compressors/dmg_spec.rb +291 -0
  116. data/spec/unit/compressors/null_spec.rb +23 -0
  117. data/spec/unit/compressors/tgz_spec.rb +67 -0
  118. data/spec/unit/config_spec.rb +27 -34
  119. data/spec/unit/digestable_spec.rb +4 -4
  120. data/spec/unit/fetchers/git_fetcher_spec.rb +110 -39
  121. data/spec/unit/fetchers/net_fetcher_spec.rb +182 -72
  122. data/spec/unit/fetchers/path_fetcher_spec.rb +111 -0
  123. data/spec/unit/generator_spec.rb +137 -0
  124. data/spec/unit/git_cache_spec.rb +24 -34
  125. data/spec/unit/library_spec.rb +21 -82
  126. data/spec/unit/metadata_spec.rb +207 -0
  127. data/spec/unit/ohai_spec.rb +0 -7
  128. data/spec/unit/omnibus_spec.rb +41 -36
  129. data/spec/unit/package_spec.rb +1 -216
  130. data/spec/unit/packagers/base_spec.rb +76 -190
  131. data/spec/unit/packagers/bff_spec.rb +160 -0
  132. data/spec/unit/packagers/deb_spec.rb +324 -0
  133. data/spec/unit/packagers/makeself_spec.rb +80 -0
  134. data/spec/unit/packagers/msi_spec.rb +267 -0
  135. data/spec/unit/packagers/pkg_spec.rb +219 -0
  136. data/spec/unit/packagers/rpm_spec.rb +328 -0
  137. data/spec/unit/project_spec.rb +217 -80
  138. data/spec/unit/publisher_spec.rb +6 -2
  139. data/spec/unit/publishers/artifactory_publisher_spec.rb +1 -1
  140. data/spec/unit/publishers/s3_publisher_spec.rb +1 -1
  141. data/spec/unit/s3_cacher_spec.rb +22 -5
  142. data/spec/unit/software_spec.rb +89 -232
  143. data/spec/unit/util_spec.rb +188 -0
  144. metadata +159 -402
  145. data/features/commands/_deprecated.feature +0 -84
  146. data/lib/omnibus/cleanroom.rb +0 -141
  147. data/lib/omnibus/cli/deprecated.rb +0 -132
  148. data/lib/omnibus/generator_files/mac_pkg/license.html.erb +0 -1
  149. data/lib/omnibus/generator_files/mac_pkg/welcome.html.erb +0 -9
  150. data/lib/omnibus/generator_files/project.rb.erb +0 -20
  151. data/lib/omnibus/generator_files/software/c-example.rb.erb +0 -42
  152. data/lib/omnibus/generator_files/software/erlang-example.rb.erb +0 -38
  153. data/lib/omnibus/generator_files/software/ruby-example.rb.erb +0 -24
  154. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +0 -20
  155. data/lib/omnibus/generator_files/windows_msi/parameters.wxi.erb +0 -9
  156. data/lib/omnibus/packagers/mac_dmg.rb +0 -235
  157. data/lib/omnibus/packagers/mac_pkg.rb +0 -176
  158. data/lib/omnibus/packagers/windows_msi.rb +0 -109
  159. data/spec/data/complicated/config/patches/bzip2/makefile_take_env_vars.patch +0 -15
  160. data/spec/data/complicated/config/patches/couchdb/patch_for_couchjs_stack.patch +0 -19
  161. data/spec/data/complicated/config/patches/gd/gd-2.0.33-configure-libpng.patch +0 -100
  162. data/spec/data/complicated/config/patches/keepalived/keepalived-1.2.9_opscode_centos_5.patch +0 -15
  163. data/spec/data/complicated/config/patches/libedit/freebsd-vi-fix.patch +0 -24
  164. data/spec/data/complicated/config/patches/libiconv/libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch +0 -29
  165. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-makefile-dest-fix.patch +0 -35
  166. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-malloc-fix.patch +0 -13
  167. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-shared_lib_plus_plus-1.patch +0 -1035
  168. data/spec/data/complicated/config/patches/logrotate/logrotate_basedir_override.patch +0 -12
  169. data/spec/data/complicated/config/patches/ncurses/ncurses-5.9-solaris-xopen_source_extended-detection.patch +0 -11
  170. data/spec/data/complicated/config/patches/ncurses/ncurses-clang.patch +0 -42
  171. data/spec/data/complicated/config/patches/ncurses/patch-aa +0 -23
  172. data/spec/data/complicated/config/patches/ncurses/patch-ab +0 -44
  173. data/spec/data/complicated/config/patches/ncurses/patch-ac +0 -40
  174. data/spec/data/complicated/config/patches/ncurses/patch-ad +0 -12
  175. data/spec/data/complicated/config/patches/ncurses/patch-aix-configure +0 -23
  176. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesf.h +0 -22
  177. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesm.h +0 -22
  178. data/spec/data/complicated/config/patches/nrpe/fix_for_runit.patch +0 -64
  179. data/spec/data/complicated/config/patches/openssl/openssl-1.0.1f-do-not-build-docs.patch +0 -101
  180. data/spec/data/complicated/config/patches/postgresql/postgresql-9.1.2-configure-ncurses-fix.patch +0 -12
  181. data/spec/data/complicated/config/patches/ruby/patch-configure +0 -103
  182. data/spec/data/complicated/config/patches/ruby/ruby-aix-configure.patch +0 -10
  183. data/spec/data/complicated/config/patches/ruby/ruby-openssl-1.0.1c.patch +0 -42
  184. data/spec/data/complicated/config/patches/ruby/ruby_aix_1_9_3_448_ssl_EAGAIN.patch +0 -57
  185. data/spec/data/complicated/config/patches/ruby/rvm-cflags.patch +0 -27
  186. data/spec/data/complicated/config/projects/angrychef.rb +0 -32
  187. data/spec/data/complicated/config/projects/chef-windows.rb +0 -32
  188. data/spec/data/complicated/config/projects/chef.rb +0 -32
  189. data/spec/data/complicated/config/projects/chefdk-windows.rb +0 -41
  190. data/spec/data/complicated/config/projects/chefdk.rb +0 -44
  191. data/spec/data/complicated/config/software/appbundler.rb +0 -25
  192. data/spec/data/complicated/config/software/autoconf.rb +0 -35
  193. data/spec/data/complicated/config/software/automake.rb +0 -39
  194. data/spec/data/complicated/config/software/berkshelf.rb +0 -44
  195. data/spec/data/complicated/config/software/bundler.rb +0 -25
  196. data/spec/data/complicated/config/software/bzip2.rb +0 -46
  197. data/spec/data/complicated/config/software/cacerts.rb +0 -44
  198. data/spec/data/complicated/config/software/chef-client-msi.rb +0 -87
  199. data/spec/data/complicated/config/software/chef-gem.rb +0 -26
  200. data/spec/data/complicated/config/software/chef-vault.rb +0 -43
  201. data/spec/data/complicated/config/software/chef-windows.rb +0 -158
  202. data/spec/data/complicated/config/software/chef.rb +0 -170
  203. data/spec/data/complicated/config/software/chefdk.rb +0 -103
  204. data/spec/data/complicated/config/software/couchdb.rb +0 -53
  205. data/spec/data/complicated/config/software/curl.rb +0 -48
  206. data/spec/data/complicated/config/software/erlang.rb +0 -65
  207. data/spec/data/complicated/config/software/expat.rb +0 -21
  208. data/spec/data/complicated/config/software/fcgi.rb +0 -56
  209. data/spec/data/complicated/config/software/fcgiwrap.rb +0 -41
  210. data/spec/data/complicated/config/software/gd.rb +0 -56
  211. data/spec/data/complicated/config/software/gdbm.rb +0 -40
  212. data/spec/data/complicated/config/software/gecode.rb +0 -48
  213. data/spec/data/complicated/config/software/git.rb +0 -40
  214. data/spec/data/complicated/config/software/help2man.rb +0 -30
  215. data/spec/data/complicated/config/software/icu.rb +0 -40
  216. data/spec/data/complicated/config/software/jre.rb +0 -48
  217. data/spec/data/complicated/config/software/keepalived.rb +0 -43
  218. data/spec/data/complicated/config/software/libarchive.rb +0 -50
  219. data/spec/data/complicated/config/software/libedit.rb +0 -69
  220. data/spec/data/complicated/config/software/libffi.rb +0 -71
  221. data/spec/data/complicated/config/software/libgcc.rb +0 -39
  222. data/spec/data/complicated/config/software/libiconv.rb +0 -55
  223. data/spec/data/complicated/config/software/libjpeg.rb +0 -39
  224. data/spec/data/complicated/config/software/libpng.rb +0 -38
  225. data/spec/data/complicated/config/software/libtool.rb +0 -52
  226. data/spec/data/complicated/config/software/libwrap.rb +0 -50
  227. data/spec/data/complicated/config/software/libxml2.rb +0 -51
  228. data/spec/data/complicated/config/software/libxslt.rb +0 -52
  229. data/spec/data/complicated/config/software/libyaml-windows.rb +0 -43
  230. data/spec/data/complicated/config/software/libyaml.rb +0 -62
  231. data/spec/data/complicated/config/software/logrotate.rb +0 -41
  232. data/spec/data/complicated/config/software/makedepend.rb +0 -73
  233. data/spec/data/complicated/config/software/mysql2.rb +0 -42
  234. data/spec/data/complicated/config/software/nagios-plugins.rb +0 -53
  235. data/spec/data/complicated/config/software/nagios.rb +0 -66
  236. data/spec/data/complicated/config/software/ncurses.rb +0 -149
  237. data/spec/data/complicated/config/software/nginx.rb +0 -40
  238. data/spec/data/complicated/config/software/nodejs.rb +0 -44
  239. data/spec/data/complicated/config/software/nokogiri.rb +0 -55
  240. data/spec/data/complicated/config/software/nrpe.rb +0 -61
  241. data/spec/data/complicated/config/software/ohai.rb +0 -64
  242. data/spec/data/complicated/config/software/omnibus-ctl.rb +0 -34
  243. data/spec/data/complicated/config/software/openresty.rb +0 -67
  244. data/spec/data/complicated/config/software/openssl.rb +0 -158
  245. data/spec/data/complicated/config/software/pcre.rb +0 -42
  246. data/spec/data/complicated/config/software/perl-extutils-embed.rb +0 -15
  247. data/spec/data/complicated/config/software/perl-extutils-makemaker.rb +0 -15
  248. data/spec/data/complicated/config/software/perl.rb +0 -48
  249. data/spec/data/complicated/config/software/perl_pg_driver.rb +0 -12
  250. data/spec/data/complicated/config/software/php.rb +0 -41
  251. data/spec/data/complicated/config/software/pip.rb +0 -30
  252. data/spec/data/complicated/config/software/pkg-config.rb +0 -66
  253. data/spec/data/complicated/config/software/popt.rb +0 -47
  254. data/spec/data/complicated/config/software/postgresql.rb +0 -51
  255. data/spec/data/complicated/config/software/preparation.rb +0 -30
  256. data/spec/data/complicated/config/software/pygments.rb +0 -25
  257. data/spec/data/complicated/config/software/python.rb +0 -49
  258. data/spec/data/complicated/config/software/rabbitmq.rb +0 -36
  259. data/spec/data/complicated/config/software/rebar.rb +0 -36
  260. data/spec/data/complicated/config/software/redis.rb +0 -33
  261. data/spec/data/complicated/config/software/rsync.rb +0 -48
  262. data/spec/data/complicated/config/software/ruby-windows-devkit.rb +0 -30
  263. data/spec/data/complicated/config/software/ruby-windows.rb +0 -30
  264. data/spec/data/complicated/config/software/ruby.rb +0 -162
  265. data/spec/data/complicated/config/software/rubygems-customization.rb +0 -57
  266. data/spec/data/complicated/config/software/rubygems.rb +0 -37
  267. data/spec/data/complicated/config/software/runit.rb +0 -118
  268. data/spec/data/complicated/config/software/server-jre.rb +0 -46
  269. data/spec/data/complicated/config/software/setuptools.rb +0 -30
  270. data/spec/data/complicated/config/software/spawn-fcgi.rb +0 -40
  271. data/spec/data/complicated/config/software/sphinx.rb +0 -26
  272. data/spec/data/complicated/config/software/spidermonkey.rb +0 -60
  273. data/spec/data/complicated/config/software/sqitch.rb +0 -24
  274. data/spec/data/complicated/config/software/test-kitchen.rb +0 -39
  275. data/spec/data/complicated/config/software/unicorn.rb +0 -27
  276. data/spec/data/complicated/config/software/util-macros.rb +0 -46
  277. data/spec/data/complicated/config/software/xproto.rb +0 -46
  278. data/spec/data/complicated/config/software/yajl.rb +0 -30
  279. data/spec/data/complicated/config/software/zlib.rb +0 -67
  280. data/spec/data/overrides/bad_line.overrides +0 -3
  281. data/spec/data/overrides/good.overrides +0 -5
  282. data/spec/data/overrides/with_dupes.overrides +0 -4
  283. data/spec/data/projects/chefdk.rb +0 -41
  284. data/spec/data/projects/sample.rb +0 -13
  285. data/spec/data/software/erchef.rb +0 -42
  286. data/spec/data/software/zlib.rb +0 -67
  287. data/spec/fixtures/sample/files/mac_dmg/Resources/background.png +0 -0
  288. data/spec/fixtures/sample/files/mac_dmg/Resources/icon.png +0 -0
  289. data/spec/fixtures/sample/files/mac_pkg/Resources/background.png +0 -0
  290. data/spec/fixtures/sample/files/mac_pkg/Resources/license.html +0 -1
  291. data/spec/fixtures/sample/files/mac_pkg/Resources/welcome.html +0 -9
  292. data/spec/fixtures/sample/files/windows_msi/Resources/assets/LICENSE.rtf +0 -8
  293. data/spec/fixtures/sample/files/windows_msi/Resources/assets/banner_background.bmp +0 -0
  294. data/spec/fixtures/sample/files/windows_msi/Resources/assets/dialog_background.bmp +0 -0
  295. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project.ico +0 -0
  296. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_16x16.ico +0 -0
  297. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_32x32.ico +0 -0
  298. data/spec/fixtures/sample/files/windows_msi/Resources/parameters.wxi.erb +0 -9
  299. data/spec/fixtures/sample/files/windows_msi/Resources/source.wxs +0 -74
  300. data/spec/integration/packagers/mac_spec.rb +0 -58
  301. data/spec/integration/packagers/windows_spec.rb +0 -70
  302. data/spec/unit/packagers/mac_pkg_spec.rb +0 -151
@@ -0,0 +1,110 @@
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 Packager::Solaris < Packager::Base
19
+ id :solaris
20
+
21
+ setup do
22
+ remove_directory('/tmp/pkgmk')
23
+ create_directory('/tmp/pkgmk')
24
+ end
25
+
26
+ build do
27
+ Dir.chdir(staging_dir) do
28
+ shellout! "cd #{install_dirname} && find #{install_basename} -print > /tmp/pkgmk/files"
29
+ end
30
+
31
+ write_prototype_content
32
+
33
+ write_pkginfo_content
34
+
35
+ copy_file("#{project.package_scripts_path}/postinst", '/tmp/pkgmk/postinstall')
36
+ copy_file("#{project.package_scripts_path}/postrm", '/tmp/pkgmk/postremove')
37
+
38
+ Dir.chdir(staging_dir) do
39
+ shellout! "pkgmk -o -r #{install_dirname} -d /tmp/pkgmk -f /tmp/pkgmk/Prototype"
40
+ shellout! "pkgchk -vd /tmp/pkgmk #{project.name}"
41
+ shellout! "pkgtrans /tmp/pkgmk /var/cache/omnibus/pkg/#{package_name} #{project.name}"
42
+ end
43
+ end
44
+
45
+ # @see Base#package_name
46
+ def package_name
47
+ "#{project.name}-#{pkgmk_version}.#{Ohai['kernel']['machine']}.solaris"
48
+ end
49
+
50
+ def pkgmk_version
51
+ "#{project.build_version}-#{project.build_iteration}"
52
+ end
53
+
54
+ def install_dirname
55
+ File.dirname(project.install_dir)
56
+ end
57
+
58
+ def install_basename
59
+ File.basename(project.install_dir)
60
+ end
61
+
62
+ #
63
+ # Generate a Prototype file for solaris build
64
+ #
65
+ def write_prototype_content
66
+ prototype_content = <<-EOF.gsub(/^ {8}/, '')
67
+ i pkginfo
68
+ i postinstall
69
+ i postremove
70
+ EOF
71
+
72
+ # generate list of control files
73
+ File.open '/tmp/pkgmk/Prototype', 'w+' do |f|
74
+ f.write prototype_content
75
+ end
76
+
77
+ Dir.chdir(staging_dir) do
78
+ # generate the prototype's file list
79
+ shellout! "cd #{install_dirname} && pkgproto < /tmp/pkgmk/files > /tmp/pkgmk/Prototype.files"
80
+
81
+ # fix up the user and group in the file list to root
82
+ shellout! "awk '{ $5 = \"root\"; $6 = \"root\"; print }' < /tmp/pkgmk/Prototype.files >> /tmp/pkgmk/Prototype"
83
+ end
84
+ end
85
+
86
+ #
87
+ # Generate a pkginfo file for solaris build
88
+ #
89
+ def write_pkginfo_content
90
+ pkginfo_content = <<-EOF.gsub(/^ {8}/, '')
91
+ CLASSES=none
92
+ TZ=PST
93
+ PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
94
+ BASEDIR=#{install_dirname}
95
+ PKG=#{project.name}
96
+ NAME=#{project.name}
97
+ ARCH=#{`uname -p`.chomp}
98
+ VERSION=#{pkgmk_version}
99
+ CATEGORY=application
100
+ DESC=#{project.description}
101
+ VENDOR=#{project.maintainer}
102
+ EMAIL=#{project.maintainer}
103
+ PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
104
+ EOF
105
+ File.open '/tmp/pkgmk/pkginfo', 'w+' do |f|
106
+ f.write pkginfo_content
107
+ end
108
+ end
109
+ end
110
+ end
@@ -19,26 +19,42 @@ require 'time'
19
19
  require 'json'
20
20
 
21
21
  module Omnibus
22
- #
23
- # Omnibus project DSL reader
24
- #
25
- # @todo It seems like there's a bit of a conflation between a "project" and a
26
- # "package" in this class... perhaps the package-building portions should be
27
- # extracted to a separate class.
28
- #
29
- #
30
22
  class Project
31
23
  class << self
32
24
  #
33
- # @param [String] filepath
34
- # the path to the project definition to load from disk
25
+ # @param [String] name
26
+ # the name to the project definition to load from disk
35
27
  #
36
- # @return [Software]
28
+ # @return [Project]
37
29
  #
38
- def load(filepath)
39
- instance = new(filepath)
40
- instance.evaluate_file(filepath)
41
- instance
30
+ def load(name)
31
+ loaded_projects[name] ||= begin
32
+ filepath = Omnibus.project_path(name)
33
+
34
+ if filepath.nil?
35
+ raise MissingProject.new(name)
36
+ else
37
+ log.internal(log_key) do
38
+ "Loading project `#{name}' from `#{filepath}'."
39
+ end
40
+ end
41
+
42
+ instance = new(filepath)
43
+ instance.evaluate_file(filepath)
44
+ instance.load_dependencies
45
+ instance
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ #
52
+ # The list of projects loaded thus far.
53
+ #
54
+ # @return [Hash<String, Project>]
55
+ #
56
+ def loaded_projects
57
+ @loaded_projects ||= {}
42
58
  end
43
59
  end
44
60
 
@@ -66,7 +82,7 @@ module Omnibus
66
82
  # @example
67
83
  # name 'chef'
68
84
  #
69
- # @raise [MissingProjectConfiguration] if a value was not set before being
85
+ # @raise [MissingRequiredAttribute] if a value was not set before being
70
86
  # subsequently retrieved
71
87
  #
72
88
  # @param [String] val
@@ -76,7 +92,7 @@ module Omnibus
76
92
  #
77
93
  def name(val = NULL)
78
94
  if null?(val)
79
- @name || raise(MissingProjectConfiguration.new('name', 'my_project'))
95
+ @name || raise(MissingRequiredAttribute.new(self, :name, 'hamlet'))
80
96
  else
81
97
  @name = val
82
98
  end
@@ -104,76 +120,20 @@ module Omnibus
104
120
  end
105
121
  expose :friendly_name
106
122
 
107
- #
108
- # Set or retrieve the custom msi building parameters
109
- #
110
- # @example Using a hash
111
- # msi_parameters upgrade_code: 'ABCD-1234'
112
- #
113
- # @example Using a block
114
- # msi_parameters do
115
- # # some complex operation
116
- # { key: value }
117
- # end
118
- #
119
- # @param [Hash] val
120
- # the parameters to set
121
- # @param [Proc] block
122
- # block to run when building the msi that returns a hash
123
- #
124
- # @return [Hash]
125
- #
126
- def msi_parameters(val = NULL, &block)
127
- if block && !null?(val)
128
- raise Error, 'You cannot specify additional parameters to ' \
129
- '#msi_parameters when a block is given!'
130
- end
131
-
132
- if block
133
- @msi_parameters = block
134
- else
135
- if null?(val)
136
- if @msi_parameters.is_a?(Proc)
137
- @msi_parameters.call
138
- else
139
- @msi_parameters ||= {}
140
- end
141
- else
142
- @msi_parameters = val
143
- end
144
- end
145
- end
146
- expose :msi_parameters
147
-
148
- #
149
- # Set or retrieve the package name of the project. Defaults to the package
150
- # name defaults to the project name.
151
- #
152
- # @example
153
- # package_name 'com.chef.project'
154
- #
155
- # @param [String] val
156
- # the package name to set
157
- #
158
- # @return [String]
159
- #
160
- def package_name(val = NULL)
161
- if null?(val)
162
- @package_name || name
163
- else
164
- @package_name = val
165
- end
166
- end
167
- expose :package_name
168
-
169
123
  #
170
124
  # **[Required]** Set or retrieve the path at which the project should be
171
125
  # installed by the generated package.
172
126
  #
127
+ # Even on Windows-based systems, this path should be the Unix-like path,
128
+ # since that's what Ruby expects. In the event +\+ is used as a file
129
+ # separator, it will be replaced with +/+. This method also attempts to
130
+ # remove duplicate slashes which might be caused as a result of string
131
+ # interpolation.
132
+ #
173
133
  # @example
174
134
  # install_dir '/opt/chef'
175
135
  #
176
- # @raise [MissingProjectConfiguration] if a value was not set before being
136
+ # @raise [MissingRequiredAttribute] if a value was not set before being
177
137
  # subsequently retrieved
178
138
  #
179
139
  # @param [String] val
@@ -183,49 +143,32 @@ module Omnibus
183
143
  #
184
144
  def install_dir(val = NULL)
185
145
  if null?(val)
186
- @install_dir || raise(MissingProjectConfiguration.new('install_dir', '/opt/chef'))
146
+ @install_dir || raise(MissingRequiredAttribute.new(self, :install_dir, '/opt/chef'))
187
147
  else
188
- @install_dir = File.expand_path(val, Config.project_root)
148
+ @install_dir = val.gsub('\\', '/').squeeze('/').chomp('/')
189
149
  end
190
150
  end
191
151
  expose :install_dir
192
152
 
193
153
  #
194
- # @deprecated Use {#install_dir} instead.
195
- #
196
- # @example (see #install_dir)
197
- # @raise (see #install_dir)
198
- # @param (see #install_dir)
199
- # @return (see #install_dir)
200
- #
201
- def install_path(val = NULL)
202
- log.deprecated(log_key) do
203
- "install_path (DSL). Please use install_dir instead."
204
- end
205
-
206
- install_dir(val)
207
- end
208
- expose :install_path
209
-
210
- #
211
- # Path to the +/files+ directory in the omnibus project. This directory can
212
- # contain assets used for creating packages (e.g., Mac .pkg files and
213
- # Windows MSIs can be installed by GUI which can optionally be customized
214
- # with background images, license agreements, etc.)
215
- #
216
- # This method delegates to the {Config.project_root} module function so that
217
- # Packagers classes rely only on the Project object for their inputs.
154
+ # The default root where a project should be installed. On Windows-based
155
+ # systems, this value defaults to +C:+. On non-Windows systems, this value
156
+ # defaults to +/opt+.
218
157
  #
219
158
  # @example
220
- # patch = File.join(files_path, 'rubygems', 'patch.rb')
159
+ # install_dir "#{default_root}/chef" #=> Produces +C:/chef+ on Windows and
160
+ # #=> +/opt/chef+ on Linux
221
161
  #
222
162
  # @return [String]
223
- # path to the files directory
224
163
  #
225
- def files_path
226
- File.expand_path("#{Config.project_root}/files")
164
+ def default_root
165
+ if windows?
166
+ 'C:'
167
+ else
168
+ '/opt'
169
+ end
227
170
  end
228
- expose :files_path
171
+ expose :default_root
229
172
 
230
173
  #
231
174
  # **[Required]** Set or retrieve the the package maintainer.
@@ -233,7 +176,7 @@ module Omnibus
233
176
  # @example
234
177
  # maintainer 'Chef Software, Inc.'
235
178
  #
236
- # @raise [MissingProjectConfiguration] if a value was not set before being
179
+ # @raise [MissingRequiredAttribute] if a value was not set before being
237
180
  # subsequently retrieved
238
181
  #
239
182
  # @param [String] val
@@ -243,7 +186,7 @@ module Omnibus
243
186
  #
244
187
  def maintainer(val = NULL)
245
188
  if null?(val)
246
- @maintainer || raise(MissingProjectConfiguration.new('maintainer', 'Chef Software, Inc.'))
189
+ @maintainer || raise(MissingRequiredAttribute.new(self, :maintainer, 'Chef Software, Inc.'))
247
190
  else
248
191
  @maintainer = val
249
192
  end
@@ -256,7 +199,7 @@ module Omnibus
256
199
  # @example
257
200
  # homepage 'https://www.getchef.com'
258
201
  #
259
- # @raise [MissingProjectConfiguration] if a value was not set before being
202
+ # @raise [MissingRequiredAttribute] if a value was not set before being
260
203
  # subsequently retrieved
261
204
  #
262
205
  # @param [String] val
@@ -266,7 +209,7 @@ module Omnibus
266
209
  #
267
210
  def homepage(val = NULL)
268
211
  if null?(val)
269
- @homepage || raise(MissingProjectConfiguration.new('homepage', 'http://www.getchef.com'))
212
+ @homepage || raise(MissingRequiredAttribute.new(self, :homepage, 'https://www.getchef.com'))
270
213
  else
271
214
  @homepage = val
272
215
  end
@@ -279,9 +222,6 @@ module Omnibus
279
222
  # @example
280
223
  # description 'This is my description'
281
224
  #
282
- # Corresponds to the +--description+ flag of
283
- # {https://github.com/jordansissel/fpm fpm}.
284
- #
285
225
  # @param [String] val
286
226
  # the project description
287
227
  #
@@ -289,7 +229,7 @@ module Omnibus
289
229
  #
290
230
  def description(val = NULL)
291
231
  if null?(val)
292
- @description ||= "The full stack of #{name}"
232
+ @description || "The full stack of #{name}"
293
233
  else
294
234
  @description = val
295
235
  end
@@ -297,14 +237,11 @@ module Omnibus
297
237
  expose :description
298
238
 
299
239
  #
300
- # Set or retrieve the name of the package this package will replace.
301
- #
302
- # Ultimately used as the value for the +--replaces+ flag in
303
- # {https://github.com/jordansissel/fpm fpm}.
240
+ # Add to the list of packages this one replaces.
304
241
  #
305
242
  # This should only be used when renaming a package and obsoleting the old
306
- # name of the package. Setting this to the same name as package_name will
307
- # cause RPM upgrades to fail.
243
+ # name of the package. **Setting this to the same name as package_name will
244
+ # cause RPM upgrades to fail.**
308
245
  #
309
246
  # @example
310
247
  # replace 'the-old-package'
@@ -314,21 +251,15 @@ module Omnibus
314
251
  #
315
252
  # @return [String]
316
253
  #
317
- def replaces(val = NULL)
318
- if null?(val)
319
- @replaces
320
- else
321
- @replaces = val
322
- end
254
+ def replace(val = NULL)
255
+ replaces << val
256
+ replaces.dup
323
257
  end
324
- expose :replaces
258
+ expose :replace
325
259
 
326
260
  #
327
261
  # Add to the list of packages this one conflicts with.
328
262
  #
329
- # Specifying conflicts is optional. See the +--conflicts+ flag in
330
- # {https://github.com/jordansissel/fpm fpm}.
331
- #
332
263
  # @example
333
264
  # conflicts 'foo'
334
265
  # conflicts 'bar'
@@ -417,7 +348,7 @@ module Omnibus
417
348
  #
418
349
  def build_iteration(val = NULL)
419
350
  if null?(val)
420
- @build_iteration ||= 1
351
+ @build_iteration || 1
421
352
  else
422
353
  @build_iteration = val
423
354
  end
@@ -425,40 +356,74 @@ module Omnibus
425
356
  expose :build_iteration
426
357
 
427
358
  #
428
- # The identifer for the mac package.
359
+ # Add or override a customization for the packager with the given +id+. When
360
+ # given multiple blocks with the same +id+, they are evaluated _in order_,
361
+ # so the last block evaluated will take precedence over the previous ones.
429
362
  #
430
363
  # @example
431
- # mac_pkg_identifier 'com.getchef.chefdk'
364
+ # package :id do
365
+ # key 'value'
366
+ # end
432
367
  #
433
- # @param [String] val
434
- # the package identifier
368
+ # @param [Symbol] id
369
+ # the id of the packager to customize
435
370
  #
436
- # @return [String]
371
+ def package(id, &block)
372
+ unless block
373
+ raise InvalidValue.new(:package, 'have a block')
374
+ end
375
+
376
+ packagers[id] << block
377
+ end
378
+ expose :package
379
+
437
380
  #
438
- def mac_pkg_identifier(val = NULL)
439
- if null?(val)
440
- @mac_pkg_identifier
381
+ # Add or override a customization for the compressor with the given +id+.
382
+ # When given multiple blocks with the same +id+, they are evaluated
383
+ # _in order_, so the last block evaluated will take precedence over the
384
+ # previous ones.
385
+ #
386
+ # @example With customization
387
+ # compress :dmg do
388
+ # window_bounds '10, 20, 30, 40'
389
+ # end
390
+ #
391
+ # @example Without customization
392
+ # compress :tgz
393
+ #
394
+ # If multiple +compress+ blocks are specified, the "most prefered" one for
395
+ # the current system will be used.
396
+ #
397
+ # @param [Symbol] id
398
+ # the id of the compressor to customize
399
+ #
400
+ def compress(id, &block)
401
+ if block
402
+ compressors[id] << block
441
403
  else
442
- @mac_pkg_identifier = val
404
+ compressors[id] << Proc.new {}
443
405
  end
444
406
  end
445
- expose :mac_pkg_identifier
407
+ expose :compress
446
408
 
447
409
  #
448
- # Set or retrieve the +{deb/rpm/solaris}-user+ fpm argument. Defaults
449
- # to +root+ if not otherwise set.
410
+ # Set or retrieve the user the package should install as. This varies with
411
+ # operating system, and may be ignored if the underlying packager does not
412
+ # support it.
413
+ #
414
+ # Defaults to +"root"+.
450
415
  #
451
416
  # @example
452
417
  # package_user 'build'
453
418
  #
454
419
  # @param [String] val
455
- # the user to retrive for the fpm build
420
+ # the user to use for the package build
456
421
  #
457
422
  # @return [String]
458
423
  #
459
424
  def package_user(val = NULL)
460
425
  if null?(val)
461
- @package_user ||= 'root'
426
+ @package_user || 'root'
462
427
  else
463
428
  @package_user = val
464
429
  end
@@ -488,20 +453,24 @@ module Omnibus
488
453
  expose :override
489
454
 
490
455
  #
491
- # Set or retrieve the +{deb/rpm/solaris}+-group fpm argument. Defaults
492
- # to +root+ if not otherwise set.
456
+ # Set or retrieve the group the package should install as. This varies with
457
+ # operating system and may be ignored if the underlying packager does not
458
+ # support it.
459
+ #
460
+ # Defaults to +Ohai['root_group']+. If +Ohai['root_group']+ is +nil+, it
461
+ # defaults to +"root"+.
493
462
  #
494
463
  # @example
495
464
  # package_group 'build'
496
465
  #
497
466
  # @param [String] val
498
- # the group to retrive for the fpm build
467
+ # the group to use for the package build
499
468
  #
500
469
  # @return [String]
501
470
  #
502
471
  def package_group(val = NULL)
503
472
  if null?(val)
504
- @package_group ||= 'root'
473
+ @package_group || Ohai['root_group'] || 'root'
505
474
  else
506
475
  @package_group = val
507
476
  end
@@ -509,7 +478,7 @@ module Omnibus
509
478
  expose :package_group
510
479
 
511
480
  #
512
- # Set or retrieve the resources path to be used by packagers.
481
+ # Set or retrieve the path to the resources on disk for use in packagers.
513
482
  #
514
483
  # @example
515
484
  # resources_path '/path/to/resources'
@@ -521,7 +490,7 @@ module Omnibus
521
490
  #
522
491
  def resources_path(val = NULL)
523
492
  if null?(val)
524
- @resources_path
493
+ @resources_path || "#{Config.project_root}/resources/#{name}"
525
494
  else
526
495
  @resources_path = File.expand_path(val)
527
496
  end
@@ -529,28 +498,11 @@ module Omnibus
529
498
  expose :resources_path
530
499
 
531
500
  #
532
- # The path to the package scripts directory for this project.
533
- # These are optional scripts that can be bundled into the
534
- # resulting package for running at various points in the package
535
- # management lifecycle.
536
- #
537
- # Currently supported scripts include:
538
- #
539
- # * postinst
540
- #
541
- # A post-install script
542
- # * prerm
543
- #
544
- # A pre-uninstall script
545
- # * postrm
501
+ # The path to the package scripts directory for this project. These are
502
+ # optional scripts that can be bundled into the resulting package for
503
+ # running at various points in the package management lifecycle.
546
504
  #
547
- # A post-uninstall script
548
- #
549
- # Any scripts with these names that are present in the package
550
- # scripts directory will be incorporated into the package that is
551
- # built. This only applies to fpm-built packages.
552
- #
553
- # Additionally, there may be a +makeselfinst+ script.
505
+ # These scripts and their names vary with operating system.
554
506
  #
555
507
  # @return [String]
556
508
  #
@@ -592,9 +544,6 @@ module Omnibus
592
544
  # This is distinct from a build-time dependency, which should correspond to
593
545
  # a software definition.
594
546
  #
595
- # Corresponds to the +--depends+ flag of
596
- # {https://github.com/jordansissel/fpm fpm}.
597
- #
598
547
  # @example
599
548
  # runtime_dependency 'foo'
600
549
  #
@@ -611,13 +560,11 @@ module Omnibus
611
560
  expose :runtime_dependency
612
561
 
613
562
  #
614
- # Add a new exclusion pattern.
615
- #
616
- # Corresponds to the +--exclude+ flag of
617
- # {https://github.com/jordansissel/fpm fpm}.
563
+ # Add a new exclusion pattern for a list of files or folders to exclude
564
+ # when making the package.
618
565
  #
619
566
  # @example
620
- # exclude 'foo'
567
+ # exclude '.git'
621
568
  #
622
569
  # @param [String] pattern
623
570
  # the thing to exclude
@@ -650,11 +597,11 @@ module Omnibus
650
597
  expose :config_file
651
598
 
652
599
  #
653
- # Add other files or dirs outside of +install_dir+.
600
+ # Add other files or dirs outside of +install_dir+. These files retain their
601
+ # relative paths inside the scratch directory:
602
+ #
603
+ # /path/to/foo.txt #=> /tmp/package/path/to/foo.txt
654
604
  #
655
- # @note This option is currently only supported with FPM based package
656
- # builds such as RPM, DEB and .sh (makeselfinst). This is not supported
657
- # on Mac OSX packages, Windows MSI, AIX and Solaris
658
605
  #
659
606
  # @example
660
607
  # extra_package_file '/path/to/file'
@@ -672,134 +619,55 @@ module Omnibus
672
619
  expose :extra_package_file
673
620
 
674
621
  #
675
- # The platform version of the machine on which Omnibus is running, as
676
- # determined by Ohai.
677
- #
678
- # @deprecated Use +Ohai['platform_version']+ instead.
679
- #
680
- # @return [String]
681
- #
682
- def platform_version
683
- log.deprecated(log_key) do
684
- "platform_version (DSL). Please use Ohai['platform_version'] instead."
685
- end
686
-
687
- Ohai['platform_version']
688
- end
689
- expose :platform_version
690
-
691
- #
692
- # The platform of the machine on which Omnibus is running, as determined
693
- # by Ohai.
622
+ # A proxy method to the underlying Ohai system.
694
623
  #
695
- # @deprecated Use +Ohai['platform']+ instead.
624
+ # @example
625
+ # ohai['platform_family']
696
626
  #
697
- # @return [String]
627
+ # @return [Ohai]
698
628
  #
699
- def platform
700
- log.deprecated(log_key) do
701
- "platform (DSL). Please use Ohai['platform'] instead."
702
- end
703
-
704
- Ohai['platform']
629
+ def ohai
630
+ Ohai
705
631
  end
706
- expose :platform
632
+ expose :ohai
707
633
 
708
634
  #
709
- # The platform family of the machine on which Omnibus is running, as
710
- # determined by Ohai.
711
- #
712
- # @deprecated Use +Ohai['platform_family']+ instead.
713
- #
714
- # @return [String]
715
- #
716
- def platform_family
717
- log.deprecated(log_key) do
718
- "platform_family (DSL). Please use Ohai['platform_family'] instead."
719
- end
720
-
721
- Ohai['platform_family']
722
- end
723
- expose :platform_family
635
+ # @!endgroup
636
+ # --------------------------------------------------
724
637
 
725
638
  #
726
- # The machine which this project is running on.
727
- #
728
- # @deprecated Use +Ohai['kernel']['machine']+ instead.
729
- #
730
- # @return [String]
639
+ # @!group Public API
731
640
  #
732
- def machine
733
- log.deprecated(log_key) do
734
- "machine (DSL). Please use Ohai['kernel']['machine'] instead."
735
- end
736
-
737
- Ohai['kernel']['machine']
738
- end
739
- expose :machine
641
+ # In addition to the DSL methods, the following methods are considered to
642
+ # be the "public API" for a project.
643
+ # --------------------------------------------------
740
644
 
741
645
  #
742
- # Convenience method for accessing the global Omnibus configuration object.
743
- #
744
- # @deprecated Use {Config} instead
646
+ # Recursively load all the dependencies for this project.
745
647
  #
746
- # @return Config
648
+ # @return [true]
747
649
  #
748
- # @see Config
749
- #
750
- def config
751
- log.deprecated(log_key) do
752
- 'config (DSL). Please use Config.(thing) instead (capital C).'
650
+ def load_dependencies
651
+ dependencies.each do |dependency|
652
+ Software.load(self, dependency)
753
653
  end
754
654
 
755
- Config
655
+ true
756
656
  end
757
- expose :config
758
657
 
759
658
  #
760
659
  # The list of software dependencies for this project. These is the software
761
660
  # that comprises your project, and is distinct from runtime dependencies.
762
661
  #
763
- # @deprecated Use {#dependency} instead (as a setter; the getter will stay)
764
- #
765
- # @todo Remove the "setter" part of this method and unexpose it as part of
766
- # the DSL in the next major release
767
- #
768
662
  # @see #dependency
769
663
  #
770
664
  # @param [Array<String>]
771
665
  #
772
666
  # @return [Array<String>]
773
667
  #
774
- def dependencies(*args)
668
+ def dependencies
775
669
  @dependencies ||= []
776
-
777
- # Handle the case where an array or list of args were given
778
- flattened_args = Array(args).flatten
779
-
780
- if flattened_args.empty?
781
- @dependencies
782
- else
783
- log.deprecated(log_key) do
784
- "dependencies (DSL). Please specify each dependency on its own " \
785
- "line like `dependency '#{Array(val).first}'`."
786
- end
787
-
788
- @dependencies = flattened_args
789
- end
790
670
  end
791
- expose :dependencies
792
-
793
- #
794
- # @!endgroup
795
- # --------------------------------------------------
796
-
797
- #
798
- # @!group Public API
799
- #
800
- # In addition to the DSL methods, the following methods are considered to
801
- # be the "public API" for a project.
802
- # --------------------------------------------------
803
671
 
804
672
  #
805
673
  # The path (on disk) where this project came from. Warning: this can be
@@ -850,6 +718,15 @@ module Omnibus
850
718
  @conflicts ||= []
851
719
  end
852
720
 
721
+ #
722
+ # The list of things this project replaces with.
723
+ #
724
+ # @return [Array<String>]
725
+ #
726
+ def replaces
727
+ @replaces ||= []
728
+ end
729
+
853
730
  #
854
731
  # The list of exclusions for this project.
855
732
  #
@@ -868,6 +745,54 @@ module Omnibus
868
745
  @overrides ||= {}
869
746
  end
870
747
 
748
+ #
749
+ # The list of packagers, in the following format:
750
+ #
751
+ # {
752
+ # id: [#<Proc:0x001>, #<Proc:0x002>],
753
+ # # ...
754
+ # }
755
+ #
756
+ # @return [Hash<Symbol, Array<Proc>>]
757
+ # the packager blocks, indexed by key
758
+ #
759
+ def packagers
760
+ @packagers ||= Hash.new { |h, k| h[k] = [] }
761
+ end
762
+
763
+ #
764
+ # Instantiate a new instance of the best packager for this system.
765
+ #
766
+ # @return [~Packager::Base]
767
+ #
768
+ def packager
769
+ @packager ||= Packager.for_current_system.new(self)
770
+ end
771
+
772
+ #
773
+ # The list of compressors, in the following format:
774
+ #
775
+ # {
776
+ # id: [#<Proc:0x001>, #<Proc:0x002>],
777
+ # # ...
778
+ # }
779
+ #
780
+ # @return [Hash<Symbol, Array<Proc>>]
781
+ # the compressor blocks, indexed by key
782
+ #
783
+ def compressors
784
+ @compressors ||= Hash.new { |h, k| h[k] = [] }
785
+ end
786
+
787
+ #
788
+ # Instantiate a new instance of the best compressor for this system.
789
+ #
790
+ # @return [~Compressor::Base]
791
+ #
792
+ def compressor
793
+ @compressor ||= Compressor.for_current_system(compressors.keys).new(self)
794
+ end
795
+
871
796
  #
872
797
  # The DSL for this build version.
873
798
  #
@@ -929,43 +854,21 @@ module Omnibus
929
854
  self.name <=> other.name
930
855
  end
931
856
 
932
- # Defines the iteration for the package to be generated. Adheres
933
- # to the conventions of the platform for which the package is
934
- # being built.
935
857
  #
936
- # All iteration strings begin with the value set in {#build_iteration}
937
858
  #
938
- # @return [String]
939
- def iteration
940
- case Ohai['platform_family']
941
- when 'rhel'
942
- Ohai['platform_version'] =~ /^(\d+)/
943
- maj = Regexp.last_match[1]
944
- "#{build_iteration}.el#{maj}"
945
- when 'freebsd'
946
- Ohai['platform_version'] =~ /^(\d+)/
947
- maj = Regexp.last_match[1]
948
- "#{build_iteration}.#{Ohai['platform']}.#{maj}.#{Ohai['kernel']['machine']}"
949
- when 'windows'
950
- "#{build_iteration}.windows"
951
- when 'aix', 'debian', 'mac_os_x'
952
- "#{build_iteration}"
953
- else
954
- "#{build_iteration}.#{Ohai['platform']}.#{Ohai['platform_version']}"
955
- end
956
- end
957
-
859
+ #
958
860
  def build_me
959
- FileUtils.mkdir_p(Config.package_dir)
960
861
  FileUtils.rm_rf(install_dir)
961
862
  FileUtils.mkdir_p(install_dir)
962
863
 
963
864
  # Cache the build order so we don't re-compute
964
865
  softwares = library.build_order
965
866
 
966
- # Download all softwares first
967
- softwares.each do |software|
968
- software.fetch
867
+ # Download all softwares in parallel
868
+ ThreadPool.new(Config.workers) do |pool|
869
+ softwares.each do |software|
870
+ pool.schedule { software.fetch }
871
+ end
969
872
  end
970
873
 
971
874
  # Now build each software
@@ -978,8 +881,14 @@ module Omnibus
978
881
 
979
882
  # Package
980
883
  package_me
884
+
885
+ # Compress
886
+ compress_me
981
887
  end
982
888
 
889
+ #
890
+ #
891
+ #
983
892
  def package_me
984
893
  destination = File.expand_path('pkg', Config.project_root)
985
894
 
@@ -988,45 +897,46 @@ module Omnibus
988
897
  FileUtils.mkdir_p(destination)
989
898
  end
990
899
 
991
- package_types.each do |pkg_type|
992
- if pkg_type == 'makeself'
993
- run_makeself
994
- elsif pkg_type == 'msi'
995
- run_msi
996
- elsif pkg_type == 'bff'
997
- run_bff
998
- elsif pkg_type == 'pkgmk'
999
- run_pkgmk
1000
- elsif pkg_type == 'mac_pkg'
1001
- run_mac_package_build
1002
- elsif pkg_type == 'mac_dmg'
1003
- # noop, since the dmg creation is handled by the packager
1004
- else # pkg_type == "fpm"
1005
- run_fpm(pkg_type)
1006
- end
900
+ # Evaluate any packager-specific blocks, in order.
901
+ packagers[packager.id].each do |block|
902
+ packager.evaluate(&block)
903
+ end
1007
904
 
1008
- render_metadata(pkg_type)
905
+ # Run the actual packager
906
+ packager.run!
1009
907
 
1010
- if Ohai['platform'] == 'windows'
1011
- FileUtils.cp(Dir["#{Config.package_dir}/*.msi*"], destination, preserve: true)
1012
- elsif Ohai['platform'] == 'aix'
1013
- FileUtils.cp(Dir["#{Config.package_dir}/*.bff*"], destination, preserve: true)
1014
- else
1015
- FileUtils.cp(Dir["#{Config.package_dir}/*"], destination, preserve: true)
1016
- end
1017
- end
908
+ # Copy the generated package and metadata back into the workspace
909
+ package_path = File.join(Config.package_dir, packager.package_name)
910
+ FileUtils.cp(package_path, destination)
911
+ FileUtils.cp("#{package_path}.metadata.json", destination)
1018
912
  end
1019
913
 
1020
- # Ensures that certain project information has been set
1021
914
  #
1022
- # @todo raise MissingProjectConfiguration instead of printing the warning
1023
- # in the next major release
1024
915
  #
1025
- # @return [void]
1026
- def validate
1027
- name && install_dir && maintainer && homepage
1028
- if package_name == replaces
1029
- log.warn { BadReplacesLine.new.message }
916
+ #
917
+ def compress_me
918
+ destination = File.expand_path('pkg', Config.project_root)
919
+
920
+ # Create the destination directory
921
+ unless File.directory?(destination)
922
+ FileUtils.mkdir_p(destination)
923
+ end
924
+
925
+ # Evaluate any compressor-specific blocks, in order.
926
+ compressors[compressor.id].each do |block|
927
+ compressor.evaluate(&block)
928
+ end
929
+
930
+ # Run the actual compressor
931
+ compressor.run!
932
+
933
+ # Copy the compressed package and metadata back into the workspace, if it
934
+ # exists
935
+ package_path = File.join(Config.package_dir, compressor.package_name)
936
+
937
+ if File.file?(package_path)
938
+ FileUtils.cp(package_path, destination)
939
+ FileUtils.cp("#{package_path}.metadata.json", destination)
1030
940
  end
1031
941
  end
1032
942
 
@@ -1066,28 +976,17 @@ module Omnibus
1066
976
  @shasum ||= begin
1067
977
  digest = Digest::SHA256.new
1068
978
 
1069
- log.info(log_key) { "Calculating shasum" }
1070
- log.debug(log_key) { "name: #{name.inspect}" }
1071
- log.debug(log_key) { "install_dir: #{install_dir.inspect}" }
1072
- log.debug(log_key) { "overrides: #{overrides.inspect}" }
1073
-
1074
979
  update_with_string(digest, name)
1075
980
  update_with_string(digest, install_dir)
1076
981
  update_with_string(digest, JSON.fast_generate(overrides))
1077
982
 
1078
983
  if filepath && File.exist?(filepath)
1079
- log.debug(log_key) { "filepath: #{filepath.inspect}" }
1080
984
  update_with_file_contents(digest, filepath)
1081
985
  else
1082
- log.debug(log_key) { "filepath: <DYNAMIC>" }
1083
986
  update_with_string(digest, '<DYNAMIC>')
1084
987
  end
1085
988
 
1086
- shasum = digest.hexdigest
1087
-
1088
- log.debug(log_key) { "shasum: #{shasum.inspect}" }
1089
-
1090
- shasum
989
+ digest.hexdigest
1091
990
  end
1092
991
  end
1093
992
 
@@ -1098,313 +997,11 @@ module Omnibus
1098
997
  private
1099
998
 
1100
999
  #
1101
- # Determine the package type(s) to be built, based on the platform
1102
- # family for which the package is being built.
1103
- #
1104
- # If specific types cannot be determined, default to +["makeself"]+.
1000
+ # The log key for this project, overriden to include the name of the
1001
+ # project for build output.
1105
1002
  #
1106
- # @return [Array<(String)>]
1003
+ # @return [String]
1107
1004
  #
1108
- def package_types
1109
- case Ohai['platform_family']
1110
- when 'debian'
1111
- %w(deb)
1112
- when 'fedora', 'rhel'
1113
- %w(rpm)
1114
- when 'aix'
1115
- %w(bff)
1116
- when 'solaris2'
1117
- %w(pkgmk)
1118
- when 'windows'
1119
- %w(msi)
1120
- when 'mac_os_x'
1121
- %w(mac_pkg mac_dmg)
1122
- else
1123
- %w(makeself)
1124
- end
1125
- end
1126
-
1127
- def render_metadata(pkg_type)
1128
- basename = output_package(pkg_type)
1129
- pkg_path = "#{Config.package_dir}/#{basename}"
1130
-
1131
- # Don't generate metadata for packages that haven't been created.
1132
- # TODO: Fix this and make it betterer
1133
- return unless File.exist?(pkg_path)
1134
-
1135
- package = Package.new(pkg_path)
1136
- Package::Metadata.generate(package,
1137
- name: name,
1138
- friendly_name: friendly_name,
1139
- homepage: homepage,
1140
- version: build_version,
1141
- iteration: build_iteration,
1142
- )
1143
- end
1144
-
1145
- # The basename of the resulting package file.
1146
- # @return [String] the basename of the package file
1147
- def output_package(pkg_type)
1148
- case pkg_type
1149
- when 'makeself'
1150
- "#{package_name}-#{build_version}_#{iteration}.sh"
1151
- when 'msi'
1152
- Packager::WindowsMsi.new(self).package_name
1153
- when 'bff'
1154
- "#{package_name}.#{bff_version}.bff"
1155
- when 'pkgmk'
1156
- "#{package_name}-#{build_version}-#{iteration}.solaris"
1157
- when 'mac_pkg'
1158
- Packager::MacPkg.new(self).package_name
1159
- when 'mac_dmg'
1160
- pkg = Packager::MacPkg.new(self)
1161
- Packager::MacDmg.new(pkg).package_name
1162
- else # fpm
1163
- require "fpm/package/#{pkg_type}"
1164
- pkg = FPM::Package.types[pkg_type].new
1165
- pkg.version = build_version
1166
- pkg.name = package_name
1167
- pkg.iteration = iteration
1168
- if pkg_type == 'solaris'
1169
- pkg.to_s('NAME.FULLVERSION.ARCH.TYPE')
1170
- else
1171
- pkg.to_s
1172
- end
1173
- end
1174
- end
1175
-
1176
- def bff_command
1177
- bff_command = ['sudo /usr/sbin/mkinstallp -d / -T /tmp/bff/gen.template']
1178
- [bff_command.join(' '), { returns: [0] }]
1179
- end
1180
-
1181
- # The {https://github.com/jordansissel/fpm fpm} command to
1182
- # generate a package for RedHat, Ubuntu, Solaris, etc. platforms.
1183
- #
1184
- # Does not execute the command, only assembles it.
1185
- #
1186
- # @return [Array<String>] the components of the fpm command; need
1187
- # to be joined with " " first.
1188
- #
1189
- # @todo Just make this return a String instead of an Array
1190
- # @todo Use the long option names (i.e., the double-dash ones) in
1191
- # the fpm command for maximum clarity.
1192
- def fpm_command(pkg_type)
1193
- command_and_opts = [
1194
- 'fpm',
1195
- '-s dir',
1196
- "-t #{pkg_type}",
1197
- "-v #{build_version}",
1198
- "-n #{package_name}",
1199
- "-p #{output_package(pkg_type)}",
1200
- "--iteration #{iteration}",
1201
- "-m '#{maintainer}'",
1202
- "--description '#{description}'",
1203
- "--url #{homepage}",
1204
- ]
1205
-
1206
- if File.exist?(File.join(package_scripts_path, 'preinst'))
1207
- command_and_opts << "--before-install '#{File.join(package_scripts_path, "preinst")}'"
1208
- end
1209
-
1210
- if File.exist?("#{package_scripts_path}/postinst")
1211
- command_and_opts << "--after-install '#{File.join(package_scripts_path, "postinst")}'"
1212
- end
1213
- # solaris packages don't support --pre-uninstall
1214
- if File.exist?("#{package_scripts_path}/prerm")
1215
- command_and_opts << "--before-remove '#{File.join(package_scripts_path, "prerm")}'"
1216
- end
1217
- # solaris packages don't support --post-uninstall
1218
- if File.exist?("#{package_scripts_path}/postrm")
1219
- command_and_opts << "--after-remove '#{File.join(package_scripts_path, "postrm")}'"
1220
- end
1221
-
1222
- exclusions.each do |pattern|
1223
- command_and_opts << "--exclude '#{pattern}'"
1224
- end
1225
-
1226
- config_files.each do |config_file|
1227
- command_and_opts << "--config-files '#{config_file}'"
1228
- end
1229
-
1230
- runtime_dependencies.each do |runtime_dep|
1231
- command_and_opts << "--depends '#{runtime_dep}'"
1232
- end
1233
-
1234
- conflicts.each do |conflict|
1235
- command_and_opts << "--conflicts '#{conflict}'"
1236
- end
1237
-
1238
- if package_user
1239
- %w(deb rpm solaris).each do |type|
1240
- command_and_opts << " --#{type}-user #{package_user}"
1241
- end
1242
- end
1243
-
1244
- if package_group
1245
- %w(deb rpm solaris).each do |type|
1246
- command_and_opts << " --#{type}-group #{package_group}"
1247
- end
1248
- end
1249
-
1250
- command_and_opts << " --replaces #{replaces}" if replaces
1251
-
1252
- # All project files must be appended to the command "last", but before
1253
- # the final install path
1254
- extra_package_files.each do |files|
1255
- command_and_opts << files
1256
- end
1257
-
1258
- # Install path must be the final entry in the command
1259
- command_and_opts << install_dir
1260
- command_and_opts
1261
- end
1262
-
1263
- # TODO: what's this do?
1264
- def makeself_command
1265
- command_and_opts = [
1266
- Omnibus.source_root.join('bin', 'makeself.sh'),
1267
- '--gzip',
1268
- install_dir,
1269
- output_package('makeself'),
1270
- "'The full stack of #{@name}'",
1271
- ]
1272
- command_and_opts << './makeselfinst' if File.exist?("#{package_scripts_path}/makeselfinst")
1273
- command_and_opts
1274
- end
1275
-
1276
- # Runs the makeself commands to make a self extracting archive package.
1277
- # As a (necessary) side-effect, sets
1278
- # @return void
1279
- def run_makeself
1280
- package_commands = []
1281
- # copy the makeself installer into package
1282
- if File.exist?("#{package_scripts_path}/makeselfinst")
1283
- package_commands << "cp #{package_scripts_path}/makeselfinst #{install_dir}/"
1284
- end
1285
-
1286
- # run the makeself program
1287
- package_commands << makeself_command.join(' ')
1288
-
1289
- # rm the makeself installer (for incremental builds)
1290
- package_commands << "rm -f #{install_dir}/makeselfinst"
1291
- package_commands.each { |cmd| run_package_command(cmd) }
1292
- end
1293
-
1294
- # Runs the necessary command to make an MSI. As a side-effect, sets +output_package+
1295
- # @return void
1296
- def run_msi
1297
- Packager::WindowsMsi.new(self).run!
1298
- end
1299
-
1300
- def bff_version
1301
- build_version.split(/[^\d]/)[0..2].join('.') + ".#{iteration}"
1302
- end
1303
-
1304
- def run_bff
1305
- FileUtils.rm_rf '/.info/*'
1306
- FileUtils.rm_rf '/tmp/bff'
1307
- FileUtils.mkdir '/tmp/bff'
1308
-
1309
- system "find #{install_dir} -print > /tmp/bff/file.list"
1310
-
1311
- system "cat #{package_scripts_path}/aix/opscode.chef.client.template | sed -e 's/TBS/#{bff_version}/' > /tmp/bff/gen.preamble"
1312
-
1313
- # @todo can we just use an erb template here?
1314
- system "cat /tmp/bff/gen.preamble /tmp/bff/file.list #{package_scripts_path}/aix/opscode.chef.client.template.last > /tmp/bff/gen.template"
1315
-
1316
- FileUtils.cp "#{package_scripts_path}/aix/unpostinstall.sh", "#{install_dir}/bin"
1317
- FileUtils.cp "#{package_scripts_path}/aix/postinstall.sh", "#{install_dir}/bin"
1318
-
1319
- run_package_command(bff_command)
1320
-
1321
- FileUtils.cp "/tmp/chef.#{bff_version}.bff", "/var/cache/omnibus/pkg/chef.#{bff_version}.bff"
1322
- end
1323
-
1324
- def pkgmk_version
1325
- "#{build_version}-#{iteration}"
1326
- end
1327
-
1328
- def run_pkgmk
1329
- install_dirname = File.dirname(install_dir)
1330
- install_basename = File.basename(install_dir)
1331
-
1332
- system 'sudo rm -rf /tmp/pkgmk'
1333
- FileUtils.mkdir '/tmp/pkgmk'
1334
-
1335
- system "cd #{install_dirname} && find #{install_basename} -print > /tmp/pkgmk/files"
1336
-
1337
- prototype_content = <<-EOF
1338
- i pkginfo
1339
- i postinstall
1340
- i postremove
1341
- EOF
1342
-
1343
- File.open '/tmp/pkgmk/Prototype', 'w+' do |f|
1344
- f.write prototype_content
1345
- end
1346
-
1347
- # generate the prototype's file list
1348
- system "cd #{install_dirname} && pkgproto < /tmp/pkgmk/files > /tmp/pkgmk/Prototype.files"
1349
-
1350
- # fix up the user and group in the file list to root
1351
- system "awk '{ $5 = \"root\"; $6 = \"root\"; print }' < /tmp/pkgmk/Prototype.files >> /tmp/pkgmk/Prototype"
1352
-
1353
- pkginfo_content = <<-EOF
1354
- CLASSES=none
1355
- TZ=PST
1356
- PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
1357
- BASEDIR=#{install_dirname}
1358
- PKG=#{package_name}
1359
- NAME=#{package_name}
1360
- ARCH=#{`uname -p`.chomp}
1361
- VERSION=#{pkgmk_version}
1362
- CATEGORY=application
1363
- DESC=#{description}
1364
- VENDOR=#{maintainer}
1365
- EMAIL=#{maintainer}
1366
- PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
1367
- EOF
1368
-
1369
- File.open '/tmp/pkgmk/pkginfo', 'w+' do |f|
1370
- f.write pkginfo_content
1371
- end
1372
-
1373
- FileUtils.cp "#{package_scripts_path}/postinst", '/tmp/pkgmk/postinstall'
1374
- FileUtils.cp "#{package_scripts_path}/postrm", '/tmp/pkgmk/postremove'
1375
-
1376
- shellout!("pkgmk -o -r #{install_dirname} -d /tmp/pkgmk -f /tmp/pkgmk/Prototype")
1377
-
1378
- system 'pkgchk -vd /tmp/pkgmk chef'
1379
-
1380
- system "pkgtrans /tmp/pkgmk /var/cache/omnibus/pkg/#{output_package("pkgmk")} chef"
1381
- end
1382
-
1383
- def run_mac_package_build
1384
- Packager::MacPkg.new(self).run!
1385
- end
1386
-
1387
- # Runs the necessary command to make a package with fpm. As a side-effect,
1388
- # sets +output_package+
1389
- # @return void
1390
- def run_fpm(pkg_type)
1391
- run_package_command(fpm_command(pkg_type).join(' '))
1392
- end
1393
-
1394
- # Executes the given command via mixlib-shellout.
1395
- # @return [Mixlib::ShellOut] returns the underlying Mixlib::ShellOut
1396
- # object, so the caller can inspect the stdout and stderr.
1397
- def run_package_command(cmd)
1398
- if cmd.is_a?(Array)
1399
- command = cmd[0]
1400
- cmd_options.merge!(cmd[1])
1401
- else
1402
- command = cmd
1403
- end
1404
-
1405
- shellout!(command, cwd: Config.package_dir)
1406
- end
1407
-
1408
1005
  def log_key
1409
1006
  @log_key ||= "#{super}: #{name}"
1410
1007
  end