diff options
author | Tim Smith <tsmith@chef.io> | 2018-10-29 10:10:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-29 10:10:08 -0700 |
commit | e8822955c5ece465615fa2e164989e248bba2dbd (patch) | |
tree | d84fef5d6d8c7a56eb44139635939003395824bb /lib | |
parent | 7260b8238e48019828617414d98b8ad04cf3b546 (diff) | |
parent | a7cf7f2ffdd63f816c20233627eca4b724482c91 (diff) | |
download | chef-e8822955c5ece465615fa2e164989e248bba2dbd.tar.gz |
Merge pull request #7789 from chef/freebsd
Remove deprecated support for FreeBSD pkg provider
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/package/freebsd/pkg.rb | 114 | ||||
-rw-r--r-- | lib/chef/provider/package/freebsd/port.rb | 6 | ||||
-rw-r--r-- | lib/chef/providers.rb | 1 | ||||
-rw-r--r-- | lib/chef/resource/freebsd_package.rb | 20 |
4 files changed, 2 insertions, 139 deletions
diff --git a/lib/chef/provider/package/freebsd/pkg.rb b/lib/chef/provider/package/freebsd/pkg.rb deleted file mode 100644 index c847ae5658..0000000000 --- a/lib/chef/provider/package/freebsd/pkg.rb +++ /dev/null @@ -1,114 +0,0 @@ -# -# Authors:: Bryan McLellan (btm@loftninjas.org) -# Matthew Landauer (matthew@openaustralia.org) -# Richard Manyanza (liseki@nyikacraftsmen.com) -# Copyright:: Copyright 2009-2016, Bryan McLellan, Matthew Landauer -# Copyright:: Copyright 2014-2016, Richard Manyanza -# 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. -# - -require "chef/provider/package/freebsd/base" -require "chef/util/path_helper" - -class Chef - class Provider - class Package - module Freebsd - class Pkg < Base - include PortsHelper - - def install_package(name, version) - unless current_resource.version - case new_resource.source - when /^http/, /^ftp/ - if new_resource.source =~ /\/$/ - shell_out!("pkg_add", "-r", package_name, env: { "PACKAGESITE" => new_resource.source, "LC_ALL" => nil }).status - else - shell_out!("pkg_add", "-r", package_name, env: { "PACKAGEROOT" => new_resource.source, "LC_ALL" => nil }).status - end - logger.trace("#{new_resource} installed from: #{new_resource.source}") - - when /^\// - shell_out!("pkg_add", file_candidate_version_path, env: { "PKG_PATH" => new_resource.source, "LC_ALL" => nil }).status - logger.trace("#{new_resource} installed from: #{new_resource.source}") - - else - shell_out!("pkg_add", "-r", latest_link_name, env: nil).status - end - end - end - - def remove_package(name, version) - shell_out!("pkg_delete", "#{package_name}-#{version || current_resource.version}", env: nil).status - end - - # The name of the package (without the version number) as understood by pkg_add and pkg_info. - def package_name - if supports_ports? - if makefile_variable_value("PKGNAME", port_path) =~ /^(.+)-[^-]+$/ - $1 - else - raise Chef::Exceptions::Package, "Unexpected form for PKGNAME variable in #{port_path}/Makefile" - end - else - new_resource.package_name - end - end - - def latest_link_name - makefile_variable_value("LATEST_LINK", port_path) - end - - def current_installed_version - pkg_info = shell_out!("pkg_info", "-E", "#{package_name}*", env: nil, returns: [0, 1]) - pkg_info.stdout[/^#{Regexp.escape(package_name)}-(.+)/, 1] - end - - def candidate_version - case new_resource.source - when /^http/, /^ftp/ - repo_candidate_version - when /^\// - file_candidate_version - else - ports_candidate_version - end - end - - def file_candidate_version_path - Dir[Chef::Util::PathHelper.escape_glob_dir("#{new_resource.source}/#{current_resource.package_name}") + "*"][-1].to_s - end - - def file_candidate_version - file_candidate_version_path.split(/-/).last.split(/.tbz/).first - end - - def repo_candidate_version - "0.0.0" - end - - def ports_candidate_version - makefile_variable_value("PORTVERSION", port_path) - end - - def port_path - port_dir new_resource.package_name - end - - end - end - end - end -end diff --git a/lib/chef/provider/package/freebsd/port.rb b/lib/chef/provider/package/freebsd/port.rb index 7a46bbaf97..e3174f7d8d 100644 --- a/lib/chef/provider/package/freebsd/port.rb +++ b/lib/chef/provider/package/freebsd/port.rb @@ -34,11 +34,7 @@ class Chef end def current_installed_version - pkg_info = if new_resource.supports_pkgng? - shell_out!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70]) - else - shell_out!("pkg_info", "-E", "#{new_resource.package_name}*", env: nil, returns: [0, 1]) - end + pkg_info = shell_out!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70]) pkg_info.stdout[/^#{Regexp.escape(new_resource.package_name)}-(.+)/, 1] end diff --git a/lib/chef/providers.rb b/lib/chef/providers.rb index cd265b0618..ac2462c0ca 100644 --- a/lib/chef/providers.rb +++ b/lib/chef/providers.rb @@ -66,7 +66,6 @@ require "chef/provider/package/chocolatey" require "chef/provider/package/dpkg" require "chef/provider/package/dnf" require "chef/provider/package/freebsd/port" -require "chef/provider/package/freebsd/pkg" require "chef/provider/package/freebsd/pkgng" require "chef/provider/package/homebrew" require "chef/provider/package/ips" diff --git a/lib/chef/resource/freebsd_package.rb b/lib/chef/resource/freebsd_package.rb index f5e4010ee7..0f92d7c229 100644 --- a/lib/chef/resource/freebsd_package.rb +++ b/lib/chef/resource/freebsd_package.rb @@ -20,7 +20,6 @@ require "chef/resource/package" require "chef/provider/package/freebsd/port" -require "chef/provider/package/freebsd/pkg" require "chef/provider/package/freebsd/pkgng" require "chef/mixin/shell_out" @@ -42,30 +41,13 @@ class Chef assign_provider end - # Is the system at least version 1000017 or is the make variable WITH_PKGNG set - # - # @return [Boolean] do we support pkgng - def supports_pkgng? - ships_with_pkgng? || !!shell_out!("make", "-V", "WITH_PKGNG", env: nil).stdout.match(/yes/i) - end - private - # It was not until __FreeBSD_version 1000017 that pkgng became - # the default binary package manager. See '/usr/ports/Mk/bsd.port.mk'. - def ships_with_pkgng? - node[:os_version].to_i >= 1000017 - end - def assign_provider @provider = if source.to_s =~ /^ports$/i Chef::Provider::Package::Freebsd::Port - elsif supports_pkgng? - Chef::Provider::Package::Freebsd::Pkgng else - Chef.deprecated(:freebsd_package_provider, "The freebsd_package provider for pkg (Chef::Provider::Package::Freebsd::Pkg) is deprecated and will be removed from Chef core in 15.0 (April 2019).") - - Chef::Provider::Package::Freebsd::Pkg + Chef::Provider::Package::Freebsd::Pkgng end end end |