diff options
author | Tim Smith <tsmith@chef.io> | 2019-11-18 18:29:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-18 18:29:20 -0800 |
commit | 9e8d474db403a33112aa54450f3daf83a92e1fdc (patch) | |
tree | 067ad1c1616d0174d24c6e0df5f965cdc68b8f74 | |
parent | 5d5a1aeeb5d5585548a8bacb06fa7a57d3ecc660 (diff) | |
parent | 505bea56b3456645730b93c6f2525dbd775d52a5 (diff) | |
download | chef-9e8d474db403a33112aa54450f3daf83a92e1fdc.tar.gz |
Merge pull request #9111 from chef/lcg/fix-build-essential-rhel
Fix failures in build_essential on rhel platforms
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/default.rb | 6 | ||||
-rw-r--r-- | lib/chef/resource/build_essential.rb | 37 | ||||
-rw-r--r-- | spec/unit/provider_resolver_spec.rb | 7 |
3 files changed, 34 insertions, 16 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb index f49cccd9a5..0af35f8c7a 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb @@ -2,7 +2,7 @@ # Cookbook:: end_to_end # Recipe:: default # -# Copyright:: 2014-2019, Chef Software, Inc. +# Copyright:: 2014-2019, Chef Software Inc. # hostname "chef-bk-ci.chef.io" @@ -36,7 +36,9 @@ yum_repository "epel" do only_if { platform_family?("rhel") } end -build_essential +build_essential do + raise_if_unsupported true +end include_recipe "::packages" diff --git a/lib/chef/resource/build_essential.rb b/lib/chef/resource/build_essential.rb index 8d93e57aab..963481b5ee 100644 --- a/lib/chef/resource/build_essential.rb +++ b/lib/chef/resource/build_essential.rb @@ -45,24 +45,28 @@ class Chef description: "Install the build essential packages at compile time.", default: false, desired_state: false + property :raise_if_unsupported, [TrueClass, FalseClass], + description: "Raise a hard error on platforms where this resource is unsupported.", + default: false, desired_state: false # FIXME: make this default to true + action :install do description "Install build essential packages" - case node["platform_family"] - when "debian" + case + when debian? package %w{ autoconf binutils-doc bison build-essential flex gettext ncurses-dev } - when fedora_derived? - package %w{ autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch } + when fedora_derived? + package %w{ autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch } # Ensure GCC 4 is available on older pre-6 EL - package %w{ gcc44 gcc44-c++ } if platform_family?("rhel") && node["platform_version"].to_i < 6 - when "freebsd" + package %w{ gcc44 gcc44-c++ } if platform_family?("rhel") && node["platform_version"].to_i < 6 + when freebsd? package "devel/gmake" package "devel/autoconf" package "devel/m4" package "devel/gettext" - when "mac_os_x" + when macos? unless xcode_cli_installed? # This script was graciously borrowed and modified from Tim Sutton's # osx-vm-templates at https://github.com/timsutton/osx-vm-templates/blob/b001475df54a9808d3d56d06e71b8fa3001fff42/scripts/xcode-cli-tools.sh @@ -80,7 +84,7 @@ class Chef EOH end end - when "omnios" + when omnios? package "developer/gcc48" package "developer/object-file" package "developer/linker" @@ -93,7 +97,7 @@ class Chef # $PATH, so add it to the running process environment # http://omnios.omniti.com/wiki.php/DevEnv ENV["PATH"] = "#{ENV["PATH"]}:/opt/gcc-4.7.2/bin" - when "solaris2" + when solaris2? package "autoconf" package "automake" package "bison" @@ -111,21 +115,28 @@ class Chef package "make" package "pkg-config" package "ucb" - when "smartos" + when smartos? package "autoconf" package "binutils" package "build-essential" package "gcc47" package "gmake" package "pkg-config" - when "suse" + when suse? package %w{ autoconf bison flex gcc gcc-c++ kernel-default-devel make m4 } package %w{ gcc48 gcc48-c++ } if node["platform_version"].to_i < 12 else - Chef::Log.warn <<-EOH + if new_resource.raise_if_unsupported + raise <<-EOH + The build_essential resource does not currently support the '#{node["platform_family"]}' + platform family. Skipping... + EOH + else + Chef::Log.warn <<-EOH The build_essential resource does not currently support the '#{node["platform_family"]}' platform family. Skipping... - EOH + EOH + end end end diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb index c8eb18b5b6..2eadcd0d1c 100644 --- a/spec/unit/provider_resolver_spec.rb +++ b/spec/unit/provider_resolver_spec.rb @@ -1,6 +1,6 @@ # # Author:: Lamont Granquist (<lamont@chef.io>) -# Copyright:: Copyright 2014-2018, Chef Software Inc. +# Copyright:: Copyright 2014-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -132,6 +132,10 @@ describe Chef::ProviderResolver do expect(expected_provider).to receive(:new).with(resource, run_context).and_return(provider) expect(resolved_provider).to eql(expected_provider) end + elsif expected_resource + it "'#{name}' resolves to resource #{expected_resource}", *tags do + expect(resource.class).to eql(expected_resource) + end else it "'#{name}' fails to resolve (since #{name.inspect} is unsupported on #{platform} #{platform_version})", *tags do Chef::Config[:treat_deprecation_warnings_as_errors] = false @@ -583,6 +587,7 @@ describe Chef::ProviderResolver do windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ], windows_user: [ Chef::Resource::User::WindowsUser, Chef::Provider::User::Windows ], yum_package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ], + build_essential: [ Chef::Resource::BuildEssential ], "linux" => { "debian" => { |