omnibus.rb 3.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
# Copyright:: Copyright (c) 2012 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

18
19
20
21
require 'ohai'
o = Ohai::System.new
o.require_plugin('os')
o.require_plugin('platform')
Marc Paradise's avatar
Marc Paradise committed
22
o.require_plugin('linux/cpu') if o.os == 'linux'
23
24
OHAI = o

25
26
require 'omnibus/library'
require 'omnibus/reports'
27
require 'omnibus/config'
28
29
require 'omnibus/software'
require 'omnibus/project'
30
require 'omnibus/fetchers'
31
require 'omnibus/s3_cacher'
32
require 'omnibus/s3_tasks'
Stephen Delano's avatar
Stephen Delano committed
33
require 'omnibus/health_check'
34
require 'omnibus/clean_tasks'
Stephen Delano's avatar
Stephen Delano committed
35
require 'omnibus/build_version'
36
37

module Omnibus
38

39
40
  def self.root=(root)
    @root = root
41
42
  end

43
44
  def self.root
    @root
45
46
  end

47
48
49
50
51
52
53
54
55
  def self.gem_root=(root)
    @gem_root = root
  end

  def self.gem_root
    @gem_root
  end

  def self.setup(options = {})
56
    self.root = Dir.pwd
Noah Kantrowitz's avatar
Noah Kantrowitz committed
57
    self.gem_root = File.expand_path("../../", __FILE__)
58
    load_config
59
    yield self if block_given?
60
61
    # Load core software tasks
    software "#{gem_root}/config/software/*.rb" unless options[:no_core_software]
62
63
  end

64
65
66
  def self.config_path
    File.expand_path("omnibus.rb", root)
  end
67

68
69
70
71
72
73
  def self.load_config
    if File.exist?(config_path)
      TOPLEVEL_BINDING.eval(IO.read(config_path))
    else
      puts("No config file found in #{config_path}, exiting.")
      exit 1
74
75
76
    end
  end

77
78
79
80
81
82
83
  #--
  # Extra indirection so we don't need the Rake::DSL in the Omnibus module
  module Loader
    extend Rake::DSL

    def self.software(*path_specs)
      FileList[*path_specs].each do |f|
84
85
        Omnibus::Project.all_projects.each do |p|
          s = Omnibus::Software.load(f, p)
86
87
88
89
90
91
92
93
94
95
96
          # TODO: only load and register needed software for each project
          #
          # currently we are loading and registering every software
          # definition for every project and relying on the fact that
          # the depenendency tree for the project won't build the
          # unnecessary bits. What does happen, however, is that the
          # version manifest for a particular project will have the
          # versions for ALLTHETHINGS. Currently (04/05/12) this is
          # fine since chef-full is a subset of private-chef. This
          # should be fixed as soon as we have the extra time.
          Omnibus.component_added(s)
97
        end
98
99
100
101
102
      end
    end

    def self.projects(*path_specs)
      FileList[*path_specs].each do |f|
103
104
105
        p = Omnibus::Project.load(f)
        Omnibus::Project.all_projects << p
        p
106
107
108
109
110
111
112
113
114
115
116
      end
    end
  end

  def self.software(*path_specs)
    Loader.software(*path_specs)
  end

  def self.projects(*path_specs)
    Loader.projects(*path_specs)
  end
117
118
end