summaryrefslogtreecommitdiff
path: root/omnibus
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-03-06 12:55:35 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-03-06 12:55:35 -0800
commit5386eb2ffb70416b59bcf763339551df3a01f593 (patch)
treee1f53b5c2173b495db01f4ec019ddcf7ed0744c1 /omnibus
parentf1718d033e0d7e0cce1674de1d10eee3c8ac656c (diff)
downloadchef-5386eb2ffb70416b59bcf763339551df3a01f593.tar.gz
build ohai from gitlcg/ohai-from-git
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'omnibus')
-rw-r--r--omnibus/config/software/chef-gem-ohai.rb10
-rw-r--r--omnibus/config/software/chef.rb1
-rw-r--r--omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb39
3 files changed, 49 insertions, 1 deletions
diff --git a/omnibus/config/software/chef-gem-ohai.rb b/omnibus/config/software/chef-gem-ohai.rb
new file mode 100644
index 0000000000..7ee7ff4909
--- /dev/null
+++ b/omnibus/config/software/chef-gem-ohai.rb
@@ -0,0 +1,10 @@
+# gem installs this gem from the version specified in chef's Gemfile.lock
+# so we can take advantage of omnibus's caching. Just duplicate this file and
+# add the new software def to chef software def if you want to separate
+# another gem's installation.
+require_relative "../../files/chef-gem/build-chef-gem/gem-install-software-def"
+BuildChefGem::GemInstallSoftwareDef.define(self, __FILE__)
+
+license "Apache-2.0"
+license_file "https://github.com/chef/ohai/blob/master/LICENSE"
+skip_transitive_dependency_licensing true
diff --git a/omnibus/config/software/chef.rb b/omnibus/config/software/chef.rb
index c53a2339ae..4f7319bda1 100644
--- a/omnibus/config/software/chef.rb
+++ b/omnibus/config/software/chef.rb
@@ -38,6 +38,7 @@ dependency "bundler"
# Install all the native gems separately
# Worst offenders first to take best advantage of cache:
dependency "chef-gem-ffi-yajl"
+dependency "chef-gem-ohai"
dependency "chef-gem-nokogiri"
dependency "chef-gem-libyajl2"
dependency "chef-gem-ruby-prof"
diff --git a/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb b/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb
index 3022bf448e..ea6c32e94a 100644
--- a/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb
+++ b/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb
@@ -21,8 +21,40 @@ module BuildChefGem
attr_reader :software, :software_filename
+ # XXX: why are we programmatically defining config that is already expressed as code-as-configuration?
+
def define
+ # this has to come first because gem_metadata depends on it
software.name "#{File.basename(software_filename)[0..-4]}"
+ if installing_from_git?
+ define_git
+ else
+ define_gem
+ end
+ end
+
+ def define_git
+ software.default_version gem_metadata[:ref]
+
+ # If the source directory for building stuff changes, tell omnibus to de-cache us
+ software.source git: gem_metadata[:git]
+
+ # ruby and bundler and friends
+ software.dependency "ruby"
+ software.dependency "rubygems"
+
+ software.relative_path gem_name
+
+ gem_name = self.gem_name
+
+ software.build do
+ extend BuildChefGem
+ gem "build #{gem_name}.gemspec", env: env
+ gem "install #{gem_name}*.gem --no-ri --no-rdoc", env: env
+ end
+ end
+
+ def define_gem
software.default_version gem_version
# If the source directory for building stuff changes, tell omnibus to
@@ -44,7 +76,8 @@ module BuildChefGem
if gem_version == "<skip>"
if gem_metadata
block do
- log.info(log_key) { "#{gem_name} has source #{gem_metadata} in #{lockfile_path}. We only cache rubygems.org installs in omnibus to keep things simple. The chef step will build #{gem_name} ..." }
+ raise "can we just remove this use case? what is it for?"
+ #log.info(log_key) { "#{gem_name} has source #{gem_metadata} in #{lockfile_path}. We only cache rubygems.org installs in omnibus to keep things simple. The chef step will build #{gem_name} ..." }
end
else
block do
@@ -105,6 +138,10 @@ module BuildChefGem
end
end
+ def installing_from_git?
+ gem_metadata && gem_metadata[:git] && gem_metadata[:ref]
+ end
+
def gem_version
@gem_version ||= begin
if gem_metadata && URI(gem_metadata[:source]) == URI("https://rubygems.org/")