diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-11-18 14:53:40 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-11-18 14:53:40 -0800 |
commit | dee1de9611aef8a8366bff0da2ace2dc7a4646b5 (patch) | |
tree | d847b54698ab2065ed8c51fd2a30ddf0be6cf305 | |
parent | 5d5a1aeeb5d5585548a8bacb06fa7a57d3ecc660 (diff) | |
download | chef-dee1de9611aef8a8366bff0da2ace2dc7a4646b5.tar.gz |
build build_essential for rhel
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/default.rb | 6 | ||||
-rw-r--r-- | lib/chef/resource/build_essential.rb | 34 | ||||
-rw-r--r-- | spec/unit/provider_resolver_spec.rb | 7 |
3 files changed, 33 insertions, 14 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..6cef29da8c 100644 --- a/lib/chef/resource/build_essential.rb +++ b/lib/chef/resource/build_essential.rb @@ -45,24 +45,29 @@ 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? + when false # rubocop:disable Lint/LiteralAsCondition + # 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" + 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 +85,7 @@ class Chef EOH end end - when "omnios" + when omnios? package "developer/gcc48" package "developer/object-file" package "developer/linker" @@ -93,7 +98,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 +116,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..b27044cc1b 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 @@ -674,6 +678,7 @@ describe Chef::ProviderResolver do # service: [ Chef::Resource::SystemdService, Chef::Provider::Service::Systemd ], package: [ Chef::Resource::DnfPackage, Chef::Provider::Package::Dnf ], ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Redhat ], + build_essential: [ Chef::Resource::BuildEssential ], %w{amazon xcp xenserver ibm_powerkvm cloudlinux parallels} => { "3.1.4" => { |