omnibus 4.1.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +22 -0
  4. data/MAINTAINERS.md +2 -1
  5. data/README.md +1 -1
  6. data/lib/omnibus/builder.rb +2 -17
  7. data/lib/omnibus/cli/publish.rb +4 -0
  8. data/lib/omnibus/exceptions.rb +12 -0
  9. data/lib/omnibus/fetchers/net_fetcher.rb +4 -0
  10. data/lib/omnibus/manifest.rb +1 -1
  11. data/lib/omnibus/metadata.rb +13 -4
  12. data/lib/omnibus/packager.rb +1 -0
  13. data/lib/omnibus/packagers/base.rb +1 -0
  14. data/lib/omnibus/packagers/bff.rb +1 -1
  15. data/lib/omnibus/packagers/deb.rb +4 -0
  16. data/lib/omnibus/packagers/msi.rb +168 -55
  17. data/lib/omnibus/packagers/rpm.rb +41 -29
  18. data/lib/omnibus/packagers/solaris.rb +76 -25
  19. data/lib/omnibus/publisher.rb +4 -0
  20. data/lib/omnibus/publishers/artifactory_publisher.rb +19 -8
  21. data/lib/omnibus/sugarable.rb +5 -0
  22. data/lib/omnibus/version.rb +1 -1
  23. data/omnibus.gemspec +1 -1
  24. data/resources/msi/CustomActionFastMsi.CA.dll +0 -0
  25. data/resources/msi/localization-en-us.wxl.erb +4 -0
  26. data/resources/msi/source.wxs.erb +46 -9
  27. data/resources/rpm/spec.erb +0 -1
  28. data/spec/functional/builder_spec.rb +109 -113
  29. data/spec/functional/fetchers/net_fetcher_spec.rb +10 -0
  30. data/spec/unit/metadata_spec.rb +39 -4
  31. data/spec/unit/packagers/bff_spec.rb +9 -0
  32. data/spec/unit/packagers/deb_spec.rb +17 -5
  33. data/spec/unit/packagers/msi_spec.rb +175 -3
  34. data/spec/unit/packagers/rpm_spec.rb +50 -3
  35. data/spec/unit/packagers/solaris_spec.rb +234 -0
  36. data/spec/unit/publisher_spec.rb +14 -0
  37. data/spec/unit/publishers/artifactory_publisher_spec.rb +72 -3
  38. data/spec/unit/sugarable_spec.rb +16 -0
  39. metadata +7 -4
@@ -282,27 +282,27 @@ module Omnibus
282
282
  render_template(resource_path('spec.erb'),
283
283
  destination: spec_file,
284
284
  variables: {
285
- name: safe_base_package_name,
286
- version: safe_version,
287
- iteration: safe_build_iteration,
288
- vendor: vendor,
289
- license: license,
290
- dist_tag: dist_tag,
291
- architecture: safe_architecture,
292
- maintainer: project.maintainer,
293
- homepage: project.homepage,
294
- description: project.description,
295
- priority: priority,
296
- category: category,
297
- conflicts: project.conflicts,
298
- replaces: project.replaces,
299
- dependencies: project.runtime_dependencies,
300
- user: project.package_user,
301
- group: project.package_group,
302
- scripts: scripts,
303
- config_files: config_files,
304
- files: files,
305
- build_dir: build_dir,
285
+ name: safe_base_package_name,
286
+ version: safe_version,
287
+ iteration: safe_build_iteration,
288
+ vendor: vendor,
289
+ license: license,
290
+ dist_tag: dist_tag,
291
+ maintainer: project.maintainer,
292
+ homepage: project.homepage,
293
+ description: project.description,
294
+ priority: priority,
295
+ category: category,
296
+ conflicts: project.conflicts,
297
+ replaces: project.replaces,
298
+ dependencies: project.runtime_dependencies,
299
+ user: project.package_user,
300
+ group: project.package_group,
301
+ scripts: scripts,
302
+ config_files: config_files,
303
+ files: files,
304
+ build_dir: build_dir,
305
+ platform_family: Ohai['platform_family']
306
306
  }
307
307
  )
308
308
  end
@@ -316,6 +316,7 @@ module Omnibus
316
316
  #
317
317
  def create_rpm_file
318
318
  command = %|fakeroot rpmbuild|
319
+ command << %| --target #{safe_architecture}|
319
320
  command << %| -bb|
320
321
  command << %| --buildroot #{staging_dir}/BUILD|
321
322
  command << %| --define '_topdir #{staging_dir}'|
@@ -494,16 +495,27 @@ module Omnibus
494
495
  # http://rpm.org/ticket/56
495
496
  #
496
497
  if version =~ /\-/
497
- converted = version.gsub('-', '~')
498
-
499
- log.warn(log_key) do
500
- "Tildes hold special significance in the RPM package versions. " \
501
- "They mark a version as lower priority in RPM's version compare " \
502
- "logic. We'll replace all dashes (-) with tildes (~) so pre-release" \
503
- "versions get sorted earlier then final versions. Converting" \
504
- "`#{project.build_version}' to `#{converted}'."
498
+ if Ohai['platform_family'] == 'wrlinux'
499
+ converted = version.gsub('-', '_') #WRL has an elderly RPM version
500
+ log.warn(log_key) do
501
+ "Omnibus replaces dashes (-) with tildes (~) so pre-release " \
502
+ "versions get sorted earlier than final versions. However, the " \
503
+ "version of rpmbuild on Wind River Linux does not support this. " \
504
+ "All dashes will be replaced with underscores (_). Converting " \
505
+ "`#{project.build_version}' to `#{converted}'."
506
+ end
507
+ else
508
+ converted = version.gsub('-', '~')
509
+ log.warn(log_key) do
510
+ "Tildes hold special significance in the RPM package versions. " \
511
+ "They mark a version as lower priority in RPM's version compare " \
512
+ "logic. We'll replace all dashes (-) with tildes (~) so pre-release" \
513
+ "versions get sorted earlier then final versions. Converting" \
514
+ "`#{project.build_version}' to `#{converted}'."
515
+ end
505
516
  end
506
517
 
518
+
507
519
  version = converted
508
520
  end
509
521
 
@@ -14,29 +14,32 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'socket'
18
+
17
19
  module Omnibus
18
20
  class Packager::Solaris < Packager::Base
21
+ # @return [Hash]
22
+ SCRIPT_MAP = {
23
+ # Default Omnibus naming
24
+ postinst: 'postinstall',
25
+ postrm: 'postremove',
26
+ # Default Solaris naming
27
+ postinstall: 'postinstall',
28
+ postremove: 'postremove',
29
+ }.freeze
30
+
19
31
  id :solaris
20
32
 
21
33
  build do
22
- shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path('files')}"
23
-
24
-
25
- write_prototype_content
26
-
27
- write_pkginfo_content
28
-
29
- copy_file("#{project.package_scripts_path}/postinst", staging_dir_path('postinstall'))
30
- copy_file("#{project.package_scripts_path}/postrm", staging_dir_path('postremove'))
31
-
32
- shellout! "pkgmk -o -r #{install_dirname} -d #{staging_dir} -f #{staging_dir_path('Prototype')}"
33
- shellout! "pkgchk -vd #{staging_dir} #{project.package_name}"
34
- shellout! "pkgtrans #{staging_dir} #{package_path} #{project.package_name}"
34
+ write_scripts
35
+ write_prototype_file
36
+ write_pkginfo_file
37
+ create_solaris_file
35
38
  end
36
39
 
37
40
  # @see Base#package_name
38
41
  def package_name
39
- "#{project.package_name}-#{pkgmk_version}.#{Ohai['kernel']['machine']}.solaris"
42
+ "#{project.package_name}-#{pkgmk_version}.#{safe_architecture}.solaris"
40
43
  end
41
44
 
42
45
  def pkgmk_version
@@ -50,24 +53,42 @@ module Omnibus
50
53
  def install_basename
51
54
  File.basename(project.install_dir)
52
55
  end
53
-
56
+
54
57
  def staging_dir_path(file_name)
55
58
  File.join(staging_dir, file_name)
56
59
  end
57
60
 
61
+ #
62
+ # Copy all scripts in {Project#package_scripts_path} to the control
63
+ # directory of this repo.
64
+ #
65
+ # @return [void]
66
+ #
67
+ def write_scripts
68
+ SCRIPT_MAP.each do |source, destination|
69
+ source_path = File.join(project.package_scripts_path, source.to_s)
70
+
71
+ if File.file?(source_path)
72
+ destination_path = staging_dir_path(destination)
73
+ log.debug(log_key) { "Adding script `#{source}' to `#{destination_path}'" }
74
+ copy_file(source_path, destination_path)
75
+ end
76
+ end
77
+ end
78
+
58
79
  #
59
80
  # Generate a Prototype file for solaris build
60
81
  #
61
- def write_prototype_content
62
- prototype_content = <<-EOF.gsub(/^ {8}/, '')
63
- i pkginfo
64
- i postinstall
65
- i postremove
66
- EOF
82
+ def write_prototype_file
83
+ shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path('files')}"
67
84
 
68
85
  # generate list of control files
69
86
  File.open staging_dir_path('Prototype'), 'w+' do |f|
70
- f.write prototype_content
87
+ f.write <<-EOF.gsub(/^ {10}/, '')
88
+ i pkginfo
89
+ i postinstall
90
+ i postremove
91
+ EOF
71
92
  end
72
93
 
73
94
  # generate the prototype's file list
@@ -80,7 +101,10 @@ module Omnibus
80
101
  #
81
102
  # Generate a pkginfo file for solaris build
82
103
  #
83
- def write_pkginfo_content
104
+ def write_pkginfo_file
105
+ hostname = Socket.gethostname
106
+
107
+ # http://docs.oracle.com/cd/E19683-01/816-0219/6m6njqbat/index.html
84
108
  pkginfo_content = <<-EOF.gsub(/^ {8}/, '')
85
109
  CLASSES=none
86
110
  TZ=PST
@@ -88,17 +112,44 @@ module Omnibus
88
112
  BASEDIR=#{install_dirname}
89
113
  PKG=#{project.package_name}
90
114
  NAME=#{project.package_name}
91
- ARCH=#{`uname -p`.chomp}
115
+ ARCH=#{safe_architecture}
92
116
  VERSION=#{pkgmk_version}
93
117
  CATEGORY=application
94
118
  DESC=#{project.description}
95
119
  VENDOR=#{project.maintainer}
96
120
  EMAIL=#{project.maintainer}
97
- PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
121
+ PSTAMP=#{hostname}#{Time.now.utc.iso8601}
98
122
  EOF
99
123
  File.open staging_dir_path('pkginfo'), 'w+' do |f|
100
124
  f.write pkginfo_content
101
125
  end
102
126
  end
127
+
128
+ #
129
+ # Generate the Solaris file using +pkg*+.
130
+ #
131
+ # @return [void]
132
+ #
133
+ def create_solaris_file
134
+ shellout! "pkgmk -o -r #{install_dirname} -d #{staging_dir} -f #{staging_dir_path('Prototype')}"
135
+ shellout! "pkgchk -vd #{staging_dir} #{project.package_name}"
136
+ shellout! "pkgtrans #{staging_dir} #{package_path} #{project.package_name}"
137
+ end
138
+
139
+ #
140
+ # The architecture for this Solaris package.
141
+ #
142
+ # @return [String]
143
+ #
144
+ def safe_architecture
145
+ # The #i386? and #intel? helpers come from chef-sugar
146
+ if intel?
147
+ 'i386'
148
+ elsif sparc?
149
+ 'sparc'
150
+ else
151
+ Ohai['kernel']['machine']
152
+ end
153
+ end
103
154
  end
104
155
  end
@@ -112,6 +112,10 @@ module Omnibus
112
112
  publish_packages.concat(build_packages)
113
113
  end
114
114
 
115
+ if publish_packages.empty?
116
+ log.info(log_key) { 'No packages found, skipping publish' }
117
+ end
118
+
115
119
  publish_packages
116
120
  end
117
121
  end
@@ -38,10 +38,7 @@ module Omnibus
38
38
  artifact_for(package).upload(
39
39
  repository,
40
40
  remote_path_for(package),
41
- metadata_for(package).merge(
42
- 'build.name' => package.metadata[:name],
43
- 'build.number' => package.metadata[:version],
44
- ),
41
+ default_properties.merge(metadata_properties_for(package)),
45
42
  )
46
43
  end
47
44
  rescue Artifactory::Error::HTTPError => e
@@ -120,11 +117,11 @@ module Omnibus
120
117
  name: 'omnibus',
121
118
  version: Omnibus::VERSION,
122
119
  },
123
- properties: {
120
+ properties: default_properties.merge(
124
121
  'omnibus.project' => name,
125
122
  'omnibus.version' => manifest.build_version,
126
123
  'omnibus.version_manifest' => manifest.to_json,
127
- },
124
+ ),
128
125
  modules: [
129
126
  {
130
127
  # com.getchef:chef-server:12.0.0
@@ -188,8 +185,8 @@ module Omnibus
188
185
  #
189
186
  # @return [Hash<String, String>]
190
187
  #
191
- def metadata_for(package)
192
- {
188
+ def metadata_properties_for(package)
189
+ metadata = {
193
190
  'omnibus.project' => package.metadata[:name],
194
191
  'omnibus.platform' => package.metadata[:platform],
195
192
  'omnibus.platform_version' => package.metadata[:platform_version],
@@ -201,6 +198,20 @@ module Omnibus
201
198
  'omnibus.sha256' => package.metadata[:sha256],
202
199
  'omnibus.sha512' => package.metadata[:sha512],
203
200
  }
201
+ metadata.merge!(
202
+ 'build.name' => package.metadata[:name],
203
+ 'build.number' => package.metadata[:version],
204
+ ) if build_record?
205
+ metadata
206
+ end
207
+
208
+ #
209
+ # Properties to attach to published artifacts (and build record).
210
+ #
211
+ # @return [Hash<String, String>]
212
+ #
213
+ def default_properties
214
+ @properties ||= @options[:properties] || {}
204
215
  end
205
216
 
206
217
  #
@@ -30,6 +30,11 @@ require 'chef/sugar/vagrant'
30
30
 
31
31
  module Omnibus
32
32
  module Sugarable
33
+ def self.extended(base)
34
+ base.send(:extend, Chef::Sugar::DSL)
35
+ base.send(:extend, Omnibus::Sugar)
36
+ end
37
+
33
38
  def self.included(base)
34
39
  base.send(:include, Chef::Sugar::DSL)
35
40
  base.send(:include, Omnibus::Sugar)
@@ -15,5 +15,5 @@
15
15
  #
16
16
 
17
17
  module Omnibus
18
- VERSION = '4.1.0'
18
+ VERSION = '5.0.0'
19
19
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.description = gem.summary
14
14
  gem.homepage = 'https://github.com/opscode/omnibus'
15
15
 
16
- gem.required_ruby_version = '>= 1.9.1'
16
+ gem.required_ruby_version = '>= 2'
17
17
 
18
18
  gem.files = `git ls-files`.split($/)
19
19
  gem.bindir = 'bin'
@@ -16,4 +16,8 @@
16
16
  <String Id="VerifyReadyDlgInstallTitle">{\WixUI_Font_Title_White}Ready to install [ProductName]</String>
17
17
 
18
18
  <String Id="FeatureMainName"><%= friendly_name %></String>
19
+
20
+ <String Id="MinimumOSVersionMessage">This package requires minimum OS version: Windows 7/Windows Server 2008 R2 or greater.</String>
21
+ <String Id="DowngradeErrorMessage">A newer version of [ProductName] is already installed.</String>
22
+ <String Id="FileExtractionProgress">Extracting files, please wait...</String>
19
23
  </WixLocalization>
@@ -12,23 +12,60 @@
12
12
  Version="$(var.VersionNumber)" Manufacturer="!(loc.ManufacturerName)" UpgradeCode="$(var.UpgradeCode)">
13
13
 
14
14
  <!--
15
- Define the minimum supported installer version (2.0).
16
- The install should be done for the whole machine not just the current user
15
+ Minimum installer version (2.0) - Window XP and above.
16
+ The install scope is per machine, not the current user
17
17
  -->
18
- <Package InstallerVersion="200" InstallPrivileges="elevated" Compressed="yes" InstallScope="perMachine" />
18
+ <Package InstallerVersion="200" InstallPrivileges="elevated"
19
+ Compressed="yes" InstallScope="perMachine" />
19
20
 
20
21
  <Media Id="1" Cabinet="Project.cab" EmbedCab="yes" CompressionLevel="high" />
21
22
 
22
- <!-- Major upgrade -->
23
- <Upgrade Id="$(var.UpgradeCode)">
24
- <UpgradeVersion OnlyDetect="yes" Minimum="$(var.VersionNumber)" IncludeMinimum="no" Property="NEWERVERSIONDETECTED" />
25
- <UpgradeVersion Minimum="0.0.0.0" IncludeMinimum="yes" Maximum="$(var.VersionNumber)" IncludeMaximum="yes" Property="OLDERVERSIONBEINGUPGRADED" />
26
- </Upgrade>
23
+ <!--
24
+ Uncomment launch condition below to check for minimum OS
25
+ 601 = Windows 7/Server 2008R2.
26
+ -->
27
+ <!-- Condition Message="!(loc.MinimumOSVersionMessage)">
28
+ <![CDATA[Installed OR VersionNT >= 601]]>
29
+ </Condition -->
30
+
31
+ <!-- We always do Major upgrades -->
32
+ <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeErrorMessage)" />
33
+
34
+ <!--
35
+ If fastmsi is set, custom actions will be invoked during install to unzip
36
+ project files, and during uninstall to remove the project folder
37
+ -->
38
+ <% if fastmsi %>
39
+ <SetProperty Id="FastUnzip"
40
+ Value="FASTZIPDIR=[INSTALLLOCATION];FASTZIPAPPNAME=chefdk"
41
+ Sequence="execute"
42
+ Before="FastUnzip" />
43
+
44
+ <CustomAction Id="FastUnzip"
45
+ BinaryKey="CustomActionFastMsiDLL"
46
+ DllEntry="FastUnzip"
47
+ Execute="deferred"
48
+ Return="check" />
49
+
50
+ <Binary Id="CustomActionFastMsiDLL"
51
+ SourceFile="CustomActionFastMsi.CA.dll" />
52
+
53
+ <CustomAction Id="Cleanup"
54
+ Directory="INSTALLLOCATION"
55
+ ExeCommand="cmd /C &quot;rd /S /Q chefdk&quot;"
56
+ Execute="deferred"
57
+ Return="ignore" />
27
58
 
28
59
  <InstallExecuteSequence>
29
- <RemoveExistingProducts After="InstallValidate" />
60
+ <Custom Action="FastUnzip" After="InstallFiles">NOT Installed</Custom>
61
+ <Custom Action="Cleanup" After="RemoveFiles">REMOVE~="ALL"</Custom>
30
62
  </InstallExecuteSequence>
31
63
 
64
+ <UI>
65
+ <ProgressText Action="FastUnzip">!(loc.FileExtractionProgress)</ProgressText>
66
+ </UI>
67
+ <% end %>
68
+
32
69
  <Directory Id="TARGETDIR" Name="SourceDir">
33
70
  <Directory Id="WINDOWSVOLUME">
34
71
  <% hierarchy.each.with_index do |(name, id), index| -%>
@@ -19,7 +19,6 @@ Name: <%= name %>
19
19
  Version: <%= version %>
20
20
  Release: <%= iteration %><%= dist_tag %>
21
21
  Summary: <%= description.split("\n").first.empty? ? "_" : description.split("\n").first %>
22
- BuildArch: <%= architecture %>
23
22
  AutoReqProv: no
24
23
  BuildRoot: %buildroot
25
24
  Prefix: /
@@ -15,18 +15,94 @@ module Omnibus
15
15
  # manner similar to one that omnibus provides, we would need to emulate
16
16
  # the fixup steps here as well, which is a pain the ass.
17
17
  #
18
- # So just don't run those tests on windows.
18
+ # Instead we write batch files that redirect to the batch files
19
+ # corresponding to the system installation and hope it all works out.
19
20
  def fake_embedded_bin(name)
20
- create_directory(embedded_bin_dir)
21
- name = 'ruby.exe' if windows? && name == 'ruby'
22
- create_link(Bundler.which(name), File.join(embedded_bin_dir, name))
21
+ if windows?
22
+ ext = (name == 'ruby') ? '.exe' : '.bat'
23
+ source = Bundler.which(name + ext)
24
+ raise "Could not find #{name} in bundler environment" unless source
25
+ File.open(File.join(embedded_bin_dir, name + '.bat'), 'w') do |f|
26
+ f.write <<-EOH.gsub(/^ {12}/, '')
27
+ @"#{source}" %*
28
+ EOH
29
+ end
30
+ else
31
+ source = Bundler.which(name)
32
+ raise "Could not find #{name} in bundler environment" unless source
33
+
34
+ target = File.join(embedded_bin_dir, name)
35
+ create_link(source, target) unless File.exists?(target)
36
+ end
37
+ end
38
+
39
+ def shellout_opts(subject)
40
+ # Pass GEM_HOME and GEM_PATH to subprocess so our fake bin works
41
+ options = {}
42
+ options[:env] = {
43
+ 'GEM_HOME' => ENV['GEM_HOME'],
44
+ 'GEM_PATH' => ENV['GEM_PATH'],
45
+ }
46
+ options[:env].merge!(subject.with_embedded_path)
47
+ options
48
+ end
49
+
50
+
51
+ def make_gemspec()
52
+ gemspec = File.join(project_dir, "#{project_name}.gemspec")
53
+ File.open(gemspec, 'w') do |f|
54
+ f.write <<-EOH.gsub(/^ {12}/, '')
55
+ Gem::Specification.new do |gem|
56
+ gem.name = '#{project_name}'
57
+ gem.version = '1.0.0'
58
+ gem.author = 'Chef Software, Inc.'
59
+ gem.email = 'info@getchef.com'
60
+ gem.description = 'Installs a thing'
61
+ gem.summary = gem.description
62
+ end
63
+ EOH
64
+ end
65
+ gemspec
66
+ end
67
+
68
+ def make_gemfile()
69
+ gemfile = File.join(project_dir, 'Gemfile')
70
+ File.open(gemfile, 'w') do |f|
71
+ f.write <<-EOH.gsub(/^ {12}/, '')
72
+ gemspec
73
+ EOH
74
+ end
75
+ gemfile
76
+ end
77
+
78
+ def make_gemfile_lock()
79
+ gemfile_lock = File.join(project_dir, 'Gemfile.lock')
80
+ File.open(gemfile_lock, 'w') do |f|
81
+ f.write <<-EOH.gsub(/^ {12}/, '')
82
+ PATH
83
+ remote: .
84
+ specs:
85
+ #{project_name} (1.0.0)
86
+
87
+ GEM
88
+ specs:
89
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ #{project_name}!
95
+ EOH
96
+ end
97
+ gemfile_lock
23
98
  end
24
99
 
25
100
  subject { described_class.new(software) }
101
+ let(:project_name) { 'example' }
102
+ let(:project_dir) { File.join(source_dir, project_name) }
26
103
 
27
104
  describe '#command' do
28
105
  it 'executes the command' do
29
- path = File.join(software.install_dir, 'file.txt')
30
106
  subject.command("echo 'Hello World!'")
31
107
 
32
108
  output = capture_logging { subject.build }
@@ -78,7 +154,7 @@ module Omnibus
78
154
 
79
155
  fake_embedded_bin('ruby')
80
156
 
81
- subject.ruby(ruby)
157
+ subject.ruby(ruby, env: subject.with_embedded_path)
82
158
  subject.build
83
159
 
84
160
  path = "#{software.install_dir}/test.txt"
@@ -87,140 +163,60 @@ module Omnibus
87
163
  end
88
164
  end
89
165
 
90
- describe '#gem', :not_supported_on_windows do
166
+ describe '#gem' do
91
167
  it 'executes the command as the embedded gem' do
92
- gemspec = File.join(tmp_path, 'example.gemspec')
93
- File.open(gemspec, 'w') do |f|
94
- f.write <<-EOH.gsub(/^ {12}/, '')
95
- Gem::Specification.new do |gem|
96
- gem.name = 'example'
97
- gem.version = '1.0.0'
98
- gem.author = 'Chef Software, Inc.'
99
- gem.email = 'info@getchef.com'
100
- gem.description = 'Installs a thing'
101
- gem.summary = gem.description
102
- end
103
- EOH
104
- end
105
-
168
+ make_gemspec
106
169
  fake_embedded_bin('gem')
170
+ gem_file = "#{project_name}-1.0.0.gem"
107
171
 
108
- subject.gem("build #{gemspec}")
109
- subject.gem("install #{project_dir}/example-1.0.0.gem")
172
+ subject.gem("build #{project_name}.gemspec", shellout_opts(subject))
173
+ subject.gem("install #{gem_file}", shellout_opts(subject))
110
174
  output = capture_logging { subject.build }
111
175
 
176
+ expect(File.join(project_dir, gem_file)).to be_a_file
112
177
  expect(output).to include('gem build')
113
178
  expect(output).to include('gem install')
179
+
114
180
  end
115
181
  end
116
182
 
117
- describe '#bundler', :not_supported_on_windows do
183
+ describe '#bundler' do
118
184
  it 'executes the command as the embedded bundler' do
119
- gemspec = File.join(tmp_path, 'example.gemspec')
120
- File.open(gemspec, 'w') do |f|
121
- f.write <<-EOH.gsub(/^ {12}/, '')
122
- Gem::Specification.new do |gem|
123
- gem.name = 'example'
124
- gem.version = '1.0.0'
125
- gem.author = 'Chef Software, Inc.'
126
- gem.email = 'info@getchef.com'
127
- gem.description = 'Installs a thing'
128
- gem.summary = gem.description
129
- end
130
- EOH
131
- end
132
-
133
- gemfile = File.join(tmp_path, 'Gemfile')
134
- File.open(gemfile, 'w') do |f|
135
- f.write <<-EOH.gsub(/^ {12}/, '')
136
- gemspec
137
- EOH
138
- end
139
-
185
+ make_gemspec
186
+ make_gemfile
140
187
  fake_embedded_bin('bundle')
141
188
 
142
- # Pass GEM_HOME and GEM_PATH to subprocess so our fake bin works
143
- options = {}
144
- options[:env] = {
145
- 'GEM_HOME' => ENV['GEM_HOME'],
146
- 'GEM_PATH' => ENV['GEM_PATH'],
147
- }
148
-
149
- subject.bundle('install', options)
189
+ subject.bundle('install', shellout_opts(subject))
150
190
  output = capture_logging { subject.build }
151
191
 
192
+ expect(File.join(project_dir, 'Gemfile.lock')).to be_a_file
152
193
  expect(output).to include('bundle install')
153
194
  end
154
195
  end
155
196
 
156
- describe '#appbundle', :not_supported_on_windows do
197
+ describe '#appbundle' do
157
198
  it 'executes the command as the embedded appbundler' do
199
+ make_gemspec
200
+ make_gemfile
201
+ make_gemfile_lock
158
202
 
159
- source_dir = "#{Omnibus::Config.source_dir}/example"
160
- embedded_app_dir = "#{software.install_dir}/embedded/apps/example"
161
- bin_dir = "#{software.install_dir}/bin"
162
-
163
- FileUtils.mkdir(source_dir)
164
-
165
- gemspec = File.join(source_dir, 'example.gemspec')
166
- File.open(gemspec, 'w') do |f|
167
- f.write <<-EOH.gsub(/^ {12}/, '')
168
- Gem::Specification.new do |gem|
169
- gem.name = 'example'
170
- gem.version = '1.0.0'
171
- gem.author = 'Chef Software, Inc.'
172
- gem.email = 'info@getchef.com'
173
- gem.description = 'Installs a thing'
174
- gem.summary = gem.description
175
- end
176
- EOH
177
- end
178
-
179
- gemfile = File.join(source_dir, 'Gemfile')
180
- File.open(gemfile, 'w') do |f|
181
- f.write <<-EOH.gsub(/^ {12}/, '')
182
- gemspec
183
- EOH
184
- end
185
-
186
- gemfile_lock = File.join(source_dir, 'Gemfile.lock')
187
- File.open(gemfile_lock, 'w') do |f|
188
- f.write <<-EOH.gsub(/^ {12}/, '')
189
- PATH
190
- remote: .
191
- specs:
192
- example (1.0.0)
193
-
194
- GEM
195
- specs:
196
-
197
- PLATFORMS
198
- ruby
199
-
200
- DEPENDENCIES
201
- example!
202
- EOH
203
- end
204
-
203
+ fake_embedded_bin('gem')
205
204
  fake_embedded_bin('appbundler')
206
205
 
207
- # Pass GEM_HOME and GEM_PATH to subprocess so our fake bin works
208
- options = {}
209
- options[:env] = {
210
- 'GEM_HOME' => ENV['GEM_HOME'],
211
- 'GEM_PATH' => ENV['GEM_PATH'],
212
- }
213
-
214
- subject.appbundle('example', options)
206
+ subject.gem("build #{project_name}.gemspec", shellout_opts(subject))
207
+ subject.gem("install #{project_name}-1.0.0.gem", shellout_opts(subject))
208
+ subject.appbundle(project_name, shellout_opts(subject))
215
209
  output = capture_logging { subject.build }
216
210
 
217
- expect(output).to include("/opt/chefdk/embedded/bin/appbundler '#{embedded_app_dir}' '#{bin_dir}'")
211
+ appbundler_path = File.join(embedded_bin_dir, 'appbundler')
212
+ appbundler_path.gsub!(/\//,'\\') if windows?
213
+ expect(output).to include("#{appbundler_path} '#{project_dir}' '#{bin_dir}'")
218
214
  end
219
215
  end
220
216
 
221
- describe '#rake', :not_supported_on_windows do
217
+ describe '#rake' do
222
218
  it 'executes the command as the embedded rake' do
223
- rakefile = File.join(tmp_path, 'Rakefile')
219
+ rakefile = File.join(project_dir, 'Rakefile')
224
220
  File.open(rakefile, 'w') do |f|
225
221
  f.write <<-EOH.gsub(/^ {12}/, '')
226
222
  task(:foo) { }
@@ -229,8 +225,8 @@ module Omnibus
229
225
 
230
226
  fake_embedded_bin('rake')
231
227
 
232
- subject.rake('-T')
233
- subject.rake('foo')
228
+ subject.rake('-T', shellout_opts(subject))
229
+ subject.rake('foo', shellout_opts(subject))
234
230
  output = capture_logging { subject.build }
235
231
 
236
232
  expect(output).to include('rake -T')