diff options
author | Kartik Null Cating-Subramanian <ksubramanian@chef.io> | 2016-01-08 13:22:45 -0800 |
---|---|---|
committer | Kartik Null Cating-Subramanian <ksubramanian@chef.io> | 2016-01-08 13:22:45 -0800 |
commit | 5a0031d962402221b580df270e8802b71d5ea1f0 (patch) | |
tree | c57c56e8115c04e14f40ecad2b83c2d8f0f99fcf /omnibus/files | |
parent | c9d7e017de225db3e8b8610dc7e2f41242dbe730 (diff) | |
parent | 286c306edfb9c5b90a6c1f382defb9efd1580e96 (diff) | |
download | chef-5a0031d962402221b580df270e8802b71d5ea1f0.tar.gz |
Import all of omnibus-chef under the omnibus directory
Diffstat (limited to 'omnibus/files')
5 files changed, 207 insertions, 0 deletions
diff --git a/omnibus/files/chefdk-env-customization/windows/chefdk_env_customization.rb b/omnibus/files/chefdk-env-customization/windows/chefdk_env_customization.rb new file mode 100644 index 0000000000..34bbec4349 --- /dev/null +++ b/omnibus/files/chefdk-env-customization/windows/chefdk_env_customization.rb @@ -0,0 +1,54 @@ +## Environment hacks for running Ruby with ChefDK ## +# ENV['HOME'] is not set by default on Windows. We need to set this to +# something sensible since a lot of Ruby code depends on it. It is important +# for this directory to exist and be available, so we are introducing logic +# here to pick a working HOME +# +# You can find this file in the repo at https://github.com/chef/omnibus-chef + +if !ENV['HOME'] || !File.exists?(ENV['HOME']) + old_home = ENV['HOME'] + found = false + alternate_homes = [] + alternate_homes << "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" if ENV['HOMEDRIVE'] + alternate_homes << "#{ENV['USERPROFILE']}" if ENV['USERPROFILE'] + + alternate_homes.each do |path| + if File.exists?(path) + ENV['HOME'] = path + found = true + break + end + end + + STDERR.puts <<-EOF +The HOME (#{old_home}) environment variable was not set, or was set to +an inaccessible location. Because this can prevent you from running many +of the programs included with ChefDK, we will attempt to find another +suitable location. + + EOF + + if found + STDERR.puts <<-EOF +Falling back to using #{ENV['HOME']} as the home directory. If you would like +to use another directory as HOME, please set the HOME environment variable. + EOF + else + STDERR.puts <<-EOF +Could not find a suitable HOME directory. Tried: +#{alternate_homes.join("\n")} + +Some Ruby binaries may not function correctly. You can set the HOME +environment variable to a directory that exists to try to solve this. + EOF + end + + STDERR.puts <<-EOF + +If you would not like ChefDK to try to fix the HOME environment variable, +check the CHEFDK_ENV_FIX environment variable. Setting this value to 0 +prevent this modification to your HOME environment variable. + + EOF +end diff --git a/omnibus/files/mapfiles/solaris b/omnibus/files/mapfiles/solaris new file mode 100644 index 0000000000..b33e54dcae --- /dev/null +++ b/omnibus/files/mapfiles/solaris @@ -0,0 +1,19 @@ +$mapfile_version 2 +DEPEND_VERSIONS libnsl.so { + ALLOW = SUNW_1.1; + ALLOW = SUNWprivate_1.1; +}; +DEPEND_VERSIONS libsocket.so { + ALLOW = SUNW_1.4; + ALLOW = SUNWprivate_1.1; +}; +DEPEND_VERSIONS libdl.so { + ALLOW = SUNW_1.22.1; + ALLOW = SUNW_1.4; + ALLOW = SUNWprivate_1.1; +}; +DEPEND_VERSIONS libc.so { + ALLOW = SUNW_1.22.1; + ALLOW = SUNW_1.4; + ALLOW = SUNWprivate_1.1; +}; diff --git a/omnibus/files/openssl-customization/windows/ssl_env_hack.rb b/omnibus/files/openssl-customization/windows/ssl_env_hack.rb new file mode 100644 index 0000000000..221854437e --- /dev/null +++ b/omnibus/files/openssl-customization/windows/ssl_env_hack.rb @@ -0,0 +1,34 @@ +# +# Copyright:: Copyright (c) 2014 Chef Software, 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. +# + +# This script sets the SSL_CERT_FILE environment variable to the CA cert bundle +# that ships with omnibus packages of Chef and Chef DK. If this environment +# variable is already configured, this script is a no-op. +# +# This is required to make Chef tools use https URLs out of the box. + +unless ENV.key?("SSL_CERT_FILE") + base_dirs = File.dirname(__FILE__).split(File::SEPARATOR) + + (base_dirs.length - 1).downto(0) do |i| + candidate_ca_bundle = File.join(base_dirs[0..i] + [ "ssl/certs/cacert.pem" ]) + if File.exist?(candidate_ca_bundle) + ENV["SSL_CERT_FILE"] = candidate_ca_bundle + break + end + end +end diff --git a/omnibus/files/rubygems-customization/default/operating_system.rb b/omnibus/files/rubygems-customization/default/operating_system.rb new file mode 100644 index 0000000000..993e182fe3 --- /dev/null +++ b/omnibus/files/rubygems-customization/default/operating_system.rb @@ -0,0 +1,27 @@ +## Rubygems Customization ## +# Customize rubygems install behavior and locations to keep user gems isolated +# from the stuff we bundle with omnibus and any other ruby installations on the +# system. + +# Always install and update new gems in "user install mode" +Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["install"] = "--user --no-document" +Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["update"] = "--user --no-document" + +module Gem + + ## + # Override user_dir to live inside of ~/.chefdk + + class << self + # Remove method before redefining so we avoid a ruby warning + remove_method :user_dir + + def user_dir + parts = [Gem.user_home, '.chefdk', 'gem', ruby_engine] + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + File.join parts + end + end + +end + diff --git a/omnibus/files/rubygems-customization/windows/operating_system.rb b/omnibus/files/rubygems-customization/windows/operating_system.rb new file mode 100644 index 0000000000..301b70c4a6 --- /dev/null +++ b/omnibus/files/rubygems-customization/windows/operating_system.rb @@ -0,0 +1,73 @@ +## Rubygems Customization ## +# Customize rubygems install behavior and locations to keep user gems isolated +# from the stuff we bundle with omnibus and any other ruby installations on the +# system. + +# Always install and update new gems in "user install mode" +Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["install"] = "--user" +Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["update"] = "--user" + +# We will inject our hacks in if the user will allow it. +begin + if (ENV['CHEFDK_ENV_FIX'] || '0').to_i != 0 + require 'chefdk_env_customization' + end +rescue + nil +end + +module Gem + + ## + # Override user_dir to live inside of ~/.chefdk + + def self.user_dir + chefdk_home_set = !([nil, ''].include? ENV['CHEFDK_HOME']) + # We call expand_path here because it converts \ -> / + # Rubygems seems to require that we not use \ + default_home = File.join(File.expand_path(ENV['LOCALAPPDATA']), 'chefdk') + + chefdk_home = if chefdk_home_set + ENV['CHEFDK_HOME'] + else + old_home = File.join(Gem.user_home, '.chefdk') + if File.exists?(old_home) + Gem.ui.alert_warning <<-EOF + + ChefDK now defaults to using #{default_home} instead of #{old_home}. + Since #{old_home} exists on your machine, ChefDK will continue + to make use of it. Please set the environment variable CHEFDK_HOME + to #{old_home} to remove this warning. This warning will be removed + in the next major version bump of ChefDK. + EOF + old_home + else + default_home + end + end + + # Prevents multiple warnings + ENV['CHEFDK_HOME'] = chefdk_home + + parts = [chefdk_home, 'gem', ruby_engine] + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + File.join parts + end + +end + +# :DK-BEG: override 'gem install' to enable RubyInstaller DevKit usage +Gem.pre_install do |gem_installer| + unless gem_installer.spec.extensions.empty? + unless ENV['PATH'].include?('C:\\opscode\\chefdk\\embedded\\mingw\\bin') then + Gem.ui.say 'Temporarily enhancing PATH to include DevKit...' if Gem.configuration.verbose + ENV['PATH'] = 'C:\\opscode\\chefdk\\embedded\\bin;C:\\opscode\\chefdk\\embedded\\mingw\\bin;' + ENV['PATH'] + end + ENV['RI_DEVKIT'] = 'C:\\opscode\\chefdk\\embedded' + ENV['CC'] = 'gcc' + ENV['CXX'] = 'g++' + ENV['CPP'] = 'cpp' + end +end +# :DK-END: + |