omnibus 2.0.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +2 -0
  3. data/.travis.yml +0 -2
  4. data/CHANGELOG.md +26 -6
  5. data/Gemfile +7 -0
  6. data/Guardfile +10 -0
  7. data/README.md +103 -160
  8. data/Rakefile +6 -1
  9. data/docs/Building on OSX.md +66 -0
  10. data/docs/omnibus-build-cache.md +75 -0
  11. data/lib/omnibus.rb +9 -13
  12. data/lib/omnibus/artifact.rb +1 -13
  13. data/lib/omnibus/assets/README-logo.png +0 -0
  14. data/lib/omnibus/assets/logo.psd +0 -0
  15. data/lib/omnibus/builder.rb +1 -0
  16. data/lib/omnibus/cli/application.rb +17 -4
  17. data/lib/omnibus/cli/build.rb +6 -4
  18. data/lib/omnibus/config.rb +33 -0
  19. data/lib/omnibus/exceptions.rb +20 -14
  20. data/lib/omnibus/health_check.rb +2 -0
  21. data/lib/omnibus/install_path_cache.rb +106 -0
  22. data/lib/omnibus/library.rb +18 -1
  23. data/lib/omnibus/packagers/base.rb +228 -0
  24. data/lib/omnibus/packagers/mac_dmg.rb +215 -0
  25. data/lib/omnibus/packagers/mac_pkg.rb +129 -253
  26. data/lib/omnibus/project.rb +89 -95
  27. data/lib/omnibus/s3_cacher.rb +4 -7
  28. data/lib/omnibus/software.rb +47 -83
  29. data/lib/omnibus/sugar.rb +49 -0
  30. data/lib/omnibus/templates/.kitchen.yml.erb +3 -0
  31. data/lib/omnibus/templates/Berksfile.erb +4 -0
  32. data/lib/omnibus/templates/Gemfile.erb +1 -1
  33. data/lib/omnibus/templates/mac_dmg/background.png +0 -0
  34. data/lib/omnibus/templates/mac_dmg/icon.png +0 -0
  35. data/lib/omnibus/templates/mac_pkg/background.png +0 -0
  36. data/lib/omnibus/templates/mac_pkg/license.html.erb +1 -0
  37. data/lib/omnibus/templates/mac_pkg/welcome.html.erb +9 -0
  38. data/lib/omnibus/templates/omnibus.rb.example.erb +31 -4
  39. data/lib/omnibus/version.rb +1 -1
  40. data/omnibus.gemspec +5 -4
  41. data/spec/fixtures/sample/files/mac_dmg/Resources/background.png +0 -0
  42. data/spec/fixtures/sample/files/mac_dmg/Resources/icon.png +0 -0
  43. data/spec/fixtures/sample/files/mac_pkg/Resources/background.png +0 -0
  44. data/spec/fixtures/sample/files/mac_pkg/Resources/license.html +1 -0
  45. data/spec/fixtures/sample/files/mac_pkg/Resources/welcome.html +9 -0
  46. data/{functional/fixtures/mac_pkg/package-scripts/functional-test-project → spec/fixtures/sample/package-scripts/sample}/postinstall +0 -0
  47. data/spec/functional/packagers/mac_spec.rb +74 -0
  48. data/spec/spec_helper.rb +14 -3
  49. data/spec/sugar_spec.rb +20 -0
  50. data/spec/{artifact_spec.rb → unit/artifact_spec.rb} +2 -3
  51. data/spec/{build_version_spec.rb → unit/build_version_spec.rb} +0 -0
  52. data/spec/{config_spec.rb → unit/config_spec.rb} +4 -0
  53. data/spec/{fetchers → unit/fetchers}/git_fetcher_spec.rb +0 -0
  54. data/spec/{fetchers → unit/fetchers}/net_fetcher_spec.rb +0 -0
  55. data/spec/unit/install_path_cache_spec.rb +175 -0
  56. data/spec/unit/library_spec.rb +67 -0
  57. data/spec/{omnibus_spec.rb → unit/omnibus_spec.rb} +0 -0
  58. data/spec/{overrides_spec.rb → unit/overrides_spec.rb} +0 -0
  59. data/spec/{package_release_spec.rb → unit/package_release_spec.rb} +0 -0
  60. data/spec/unit/packagers/base_spec.rb +221 -0
  61. data/spec/unit/packagers/mac_pkg_spec.rb +163 -0
  62. data/spec/{project_spec.rb → unit/project_spec.rb} +0 -14
  63. data/spec/{s3_cacher_spec.rb → unit/s3_cacher_spec.rb} +0 -0
  64. data/spec/{software_spec.rb → unit/software_spec.rb} +0 -1
  65. metadata +122 -103
  66. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
  67. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +0 -1
  68. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +0 -1
  69. data/functional/packagers/mac_pkg_spec.rb +0 -72
  70. data/lib/omnibus/clean_tasks.rb +0 -28
  71. data/spec/packagers/mac_pkg_spec.rb +0 -262
@@ -122,13 +122,10 @@ module Omnibus
122
122
 
123
123
  def bucket
124
124
  @bucket ||= begin
125
- if @client.exists?('/')
126
- @client.bucket
127
- else
128
- b = UberS3::Bucket.new(@client, @client.bucket)
129
- @client.connection.put('/')
130
- b
131
- end
125
+ b = UberS3::Bucket.new(@client, @client.bucket)
126
+ # creating the bucket is idempotent, make sure it's created:
127
+ @client.connection.put('/')
128
+ b
132
129
  end
133
130
  end
134
131
  end
@@ -26,13 +26,11 @@ require 'omnibus/fetcher'
26
26
  require 'omnibus/builder'
27
27
  require 'omnibus/config'
28
28
 
29
- require 'rake'
29
+ require 'fileutils'
30
30
 
31
31
  module Omnibus
32
32
  # Omnibus software DSL reader
33
33
  class Software
34
- include Rake::DSL
35
-
36
34
  NULL_ARG = Object.new
37
35
  UNINITIALIZED = Object.new
38
36
 
@@ -55,6 +53,8 @@ module Omnibus
55
53
 
56
54
  attr_reader :whitelist_files
57
55
 
56
+ attr_reader :source_config
57
+
58
58
  def self.load(filename, project, repo_overrides = {})
59
59
  new(IO.read(filename), filename, project, repo_overrides)
60
60
  end
@@ -91,8 +91,6 @@ module Omnibus
91
91
  @dependencies = []
92
92
  @whitelist_files = []
93
93
  instance_eval(io, filename, 0)
94
-
95
- render_tasks
96
94
  end
97
95
 
98
96
  # Retrieves the override_version
@@ -286,6 +284,7 @@ module Omnibus
286
284
 
287
285
  # @return [Boolean]
288
286
  def always_build?
287
+ return true if project.dirty_cache
289
288
  # Should do !!(@always_build)
290
289
  @always_build
291
290
  end
@@ -359,18 +358,6 @@ module Omnibus
359
358
  @relative_path ? "#{source_dir}/#{@relative_path}" : "#{source_dir}/#{@name}"
360
359
  end
361
360
 
362
- # @todo all the *_file methods should be next to each other for
363
- # better logical grouping
364
- def manifest_file
365
- manifest_file_from_name(@name)
366
- end
367
-
368
- # @todo Seems like this should be a private method, since it's
369
- # just used internally
370
- def manifest_file_from_name(software_name)
371
- "#{build_dir}/#{software_name}.manifest"
372
- end
373
-
374
361
  # The name of the sentinel file that marks the most recent fetch
375
362
  # time of the software
376
363
  #
@@ -431,6 +418,42 @@ module Omnibus
431
418
  OHAI.kernel['machine'] =~ /sun/ ? 'sparc' : 'intel'
432
419
  end
433
420
 
421
+ # Actually build the software package
422
+ def build_me
423
+ # Fetch the source
424
+ fetcher = fetch_me
425
+
426
+ # Build if we need to
427
+ if always_build?
428
+ execute_build(fetcher)
429
+ else
430
+ if Omnibus::InstallPathCache.new(install_dir, self).restore
431
+ true
432
+ else
433
+ execute_build(fetcher)
434
+ end
435
+ end
436
+ true
437
+ end
438
+
439
+ # Fetch the software
440
+ def fetch_me
441
+ # Create the directories we need
442
+ [build_dir, source_dir, cache_dir, project_dir].each do |dir|
443
+ FileUtils.mkdir_p dir
444
+ end
445
+
446
+ fetcher = Fetcher.for(self)
447
+
448
+ if !File.exist?(fetch_file) || fetcher.fetch_required?
449
+ # force build to run if we need to do an updated fetch
450
+ fetcher.fetch
451
+ touch fetch_file
452
+ end
453
+
454
+ fetcher
455
+ end
456
+
434
457
  private
435
458
 
436
459
  # Apply overrides in the @overrides hash that mask instance variables
@@ -457,74 +480,15 @@ module Omnibus
457
480
  def execute_build(fetcher)
458
481
  fetcher.clean
459
482
  @builder.build
460
- touch manifest_file
483
+ puts "[software:#{name}] caching build"
484
+ Omnibus::InstallPathCache.new(install_dir, self).incremental
485
+ puts "[software:#{name}] has dirtied the cache"
486
+ project.dirty_cache = true
461
487
  end
462
488
 
463
- def render_tasks
464
- namespace "projects:#{@project.name}" do
465
- namespace :software do
466
- fetcher = Fetcher.for(self)
467
-
468
- #
469
- # set up inter-project dependencies
470
- #
471
- (@dependencies - [@name]).uniq.each do |dep|
472
- task @name => dep
473
- file manifest_file => manifest_file_from_name(dep)
474
- end
475
-
476
- directory source_dir
477
- directory cache_dir
478
- directory build_dir
479
- directory project_dir
480
- namespace @name do
481
- task fetch: [build_dir, source_dir, cache_dir, project_dir] do
482
- if !File.exist?(fetch_file) || fetcher.fetch_required?
483
- # force build to run if we need to do an updated fetch
484
- fetcher.fetch
485
- touch fetch_file
486
- end
487
- end
488
-
489
- task build: :fetch do
490
- if !always_build? && uptodate?(manifest_file, [fetch_file])
491
- # if any direct deps have been built for any reason, we will need to
492
- # clean/build ourselves
493
- (@dependencies - [@name]).uniq.each do |dep|
494
- unless uptodate?(manifest_file, [manifest_file_from_name(dep)])
495
- execute_build(fetcher)
496
- break
497
- end
498
- end
499
-
500
- else
501
- # if fetch has occurred, or the component is configured to
502
- # always build, do a clean and build.
503
- execute_build(fetcher)
504
- end
505
- end
506
- end
507
-
508
- #
509
- # make the manifest file dependent on the latest file in the
510
- # source tree in order to shrink the multi-thousand-node
511
- # dependency graph that Rake was generating
512
- #
513
- latest_file = FileList["#{project_dir}/**/*"].sort do |a, b|
514
- File.mtime(a) <=> File.mtime(b)
515
- end.last
516
-
517
- file manifest_file => (file latest_file)
518
-
519
- file fetch_file => "#{name}:fetch"
520
- file manifest_file => "#{name}:build"
521
-
522
- file fetch_file => (file @source_config)
523
- file manifest_file => (file fetch_file)
524
-
525
- desc "fetch and build #{@name} for #{@project.name}"
526
- task @name => manifest_file
527
- end
489
+ def touch(file)
490
+ File.open(file, 'w') do |f|
491
+ f.print ''
528
492
  end
529
493
  end
530
494
  end
@@ -0,0 +1,49 @@
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
+ require 'chef/sugar/architecture'
18
+ require 'chef/sugar/cloud'
19
+ # NOTE: We cannot include the constraints library because of the conflicting
20
+ # +version+ attribute would screw things up. You can still use the
21
+ # +Chef::Sugar::Constraint.version('1.2.3') for comparing versions.
22
+ #
23
+ # require 'chef/sugar/constraints'
24
+ require 'chef/sugar/ip'
25
+ require 'chef/sugar/platform'
26
+ require 'chef/sugar/platform_family'
27
+ require 'chef/sugar/ruby'
28
+ require 'chef/sugar/shell'
29
+ require 'chef/sugar/vagrant'
30
+
31
+ require 'omnibus/project'
32
+
33
+ module Omnibus
34
+ class Project
35
+ private
36
+
37
+ # This method is used by Chef Sugar to easily add the DSL. By mimicing
38
+ # Chef's +node+ object, we can easily include the existing DSL into
39
+ # Omnibus project as if it were Chef. Otherwise, we would need to rewrite
40
+ # all the DSL methods.
41
+ def node
42
+ OHAI
43
+ end
44
+ end
45
+ end
46
+
47
+ # Include everything in Omnibus
48
+ Omnibus::Project.send(:include, Chef::Sugar::DSL)
49
+ Omnibus::Software.send(:include, Chef::Sugar::DSL)
@@ -11,8 +11,11 @@ provisioner:
11
11
 
12
12
  platforms:
13
13
  - name: ubuntu-12.04
14
+ run_list: apt::default
14
15
  - name: ubuntu-11.04
16
+ run_list: apt::default
15
17
  - name: ubuntu-10.04
18
+ run_list: apt::default
16
19
  - name: centos-5.10
17
20
  - name: centos-6.5
18
21
 
@@ -1,5 +1,9 @@
1
1
  source 'https://api.berkshelf.com'
2
2
 
3
+ # The apt cookbook is required to bring the apt cache up-to-date on Ubuntu
4
+ # systems, since the cache can become stale on older boxes.
5
+ cookbook 'apt', '~> 2.0'
6
+
3
7
  cookbook 'omnibus'
4
8
 
5
9
  # Uncomment to use the latest version of the Omnibus cookbook from GitHub
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
4
4
  gem 'berkshelf', '~> 3.0.0.beta'
5
5
 
6
6
  # Install omnibus software
7
- gem 'omnibus', '~> 2.0'
7
+ gem 'omnibus', '~> <%= Omnibus::VERSION.split('.')[0...-1].join('.') %>'
8
8
  gem 'omnibus-software', github: 'opscode/omnibus-software'
9
9
 
10
10
  # Use Test Kitchen with Vagrant for convering the build environment
@@ -0,0 +1 @@
1
+ All Rights Reserved
@@ -0,0 +1,9 @@
1
+ This will install <%= config[:name] %> on your Mac.
2
+
3
+ --------------------------------------------------
4
+
5
+ This is a basic welcome message that is generated for every Omnibus project. You should customize this message by editing the file at files/mac_pkg/welcome.html.
6
+
7
+ If you are not the developer of <%= config[:name] %>, the presence of this message is likely a bug and should be reported to the creator.
8
+
9
+ Thank you for choosing Omnibus! Have a fantastic day!
@@ -1,6 +1,33 @@
1
- # s3_access_key 'something'
2
- # s3_secret_key 'something'
3
- # s3_bucket 'some-bucket'
1
+ #
2
+ # This file is used to configure the <%= config[:name] %> project. It contains
3
+ # come minimal configuration examples for working with Omnibus. For a full list
4
+ # of configurable options, please see the documentation for +omnibus/config.rb+.
5
+ #
6
+
7
+ # Build internally
8
+ # ------------------------------
9
+ # By default, Omnibus uses system folders (like +/var+ and +/opt+) to build and
10
+ # cache compontents. If you would to build everything internally, you can
11
+ # uncomment the following options. This will prevent the need for root
12
+ # permissions in most cases. You will also need to update the <%= config[:name] %>
13
+ # project configuration to build at +./local/omnibus/build+ instead of
14
+ # +<%= config[:install_path] %>+
15
+ #
16
+ # cache_dir './local/omnibus/cache'
17
+ # install_path_cache_dir './local/omnibus/cache/install_path'
18
+ # source_dir './local/omnibus/src'
19
+ # build_dir './local/omnibus/build'
20
+ # package_dir './local/omnibus/pkg'
21
+ # package_tmp './local/omnibus/pkg-tmp'
22
+
23
+ # Enable S3 asset caching
24
+ # ------------------------------
4
25
  # use_s3_caching true
26
+ # s3_access_key 'something'
27
+ # s3_secret_key 'something'
28
+ # s3_bucket 'some-bucket'
29
+
30
+ # Customize compiler bits
31
+ # ------------------------------
5
32
  # solaris_compiler 'gcc'
6
- # build_retries 3
33
+ # build_retries 5
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module Omnibus
19
- VERSION = '2.0.2'
19
+ VERSION = '3.0.0'
20
20
  end
data/omnibus.gemspec CHANGED
@@ -21,16 +21,17 @@ Gem::Specification.new do |gem|
21
21
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
22
  gem.require_paths = ['lib']
23
23
 
24
+ gem.add_dependency 'chef-sugar', '~> 1.2'
24
25
  gem.add_dependency 'mixlib-shellout', '~> 1.3'
25
26
  gem.add_dependency 'mixlib-config', '~> 2.1'
26
27
  gem.add_dependency 'ohai', '~> 6.12'
27
- gem.add_dependency 'rake'
28
- gem.add_dependency 'fpm', '~> 0.4'
28
+ gem.add_dependency 'fpm', '~> 1.0.0'
29
29
  gem.add_dependency 'uber-s3'
30
30
  gem.add_dependency 'thor', '>= 0.16.0'
31
31
 
32
- gem.add_development_dependency 'rspec', '~> 2.14.1'
33
- gem.add_development_dependency 'rubocop', '~> 0.18.1'
32
+ gem.add_development_dependency 'rspec', '~> 2.14'
33
+ gem.add_development_dependency 'rubocop', '~> 0.18'
34
+ gem.add_development_dependency 'rake'
34
35
 
35
36
  gem.add_development_dependency 'bundler'
36
37
  end
@@ -0,0 +1 @@
1
+ All Rights Reserved
@@ -0,0 +1,9 @@
1
+ This will install on your Mac.
2
+
3
+ --------------------------------------------------
4
+
5
+ This is a basic welcome message that is generated for every Omnibus project. You should customize this message by editing the file at files/mac_pkg/welcome.html.
6
+
7
+ If you are not the developer of , the presence of this message is likely a bug and should be reported to the creator.
8
+
9
+ Thank you for choosing Omnibus! Have a fantastic day!
@@ -0,0 +1,74 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'spec_helper'
19
+
20
+ module Omnibus
21
+ describe Packager::MacDmg, :functional do
22
+ let(:name) { 'sample' }
23
+ let(:version) { '12.4.0' }
24
+
25
+ let(:project) do
26
+ Project.new(<<-EOH, __FILE__)
27
+ name '#{name}'
28
+ maintainer 'Chef'
29
+ homepage 'https://getchef.com'
30
+ build_version '#{version}'
31
+ install_path '#{tmp_path}/opt/#{name}'
32
+ mac_pkg_identifier 'test.pkg.#{name}'
33
+ EOH
34
+ end
35
+
36
+ let(:mac_packager) { Packager::MacPkg.new(project) }
37
+
38
+ before do
39
+ # Reset stale configuration
40
+ Omnibus.config.reset!
41
+
42
+ # Tell things to install into the cache directory
43
+ root = "#{tmp_path}/var/omnibus"
44
+ Omnibus.config.cache_dir "#{root}/cache"
45
+ Omnibus.config.install_path_cache_dir "#{root}/cache/install_path"
46
+ Omnibus.config.source_dir "#{root}/src"
47
+ Omnibus.config.build_dir "#{root}/build"
48
+ Omnibus.config.package_dir "#{root}/pkg"
49
+ Omnibus.config.package_tmp "#{root}/pkg-tmp"
50
+
51
+ # Enable DMG create
52
+ Omnibus.config.build_dmg true
53
+
54
+ # Point at our sample project fixture
55
+ Omnibus.config.project_root "#{fixtures_path}/sample"
56
+
57
+ # Create the target directory
58
+ FileUtils.mkdir_p(project.install_path)
59
+ end
60
+
61
+ it 'builds a pkg and a dmg' do
62
+ # Create the pkg resource
63
+ mac_packager.run!
64
+
65
+ # There is a tiny bit of hard-coding here, but I don't see a better
66
+ # solution for generating the package name
67
+ pkg = "#{project.package_dir}/#{name}-#{version}-1.mac_os_x.10.9.2.pkg"
68
+ dmg = "#{project.package_dir}/#{name}-#{version}-1.mac_os_x.10.9.2.dmg"
69
+
70
+ expect(File.exist?(pkg)).to be_true
71
+ expect(File.exist?(dmg)).to be_true
72
+ end
73
+ end
74
+ end