summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-12-01 16:30:07 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-12-13 13:31:50 -0800
commit9f188c35fd34f297080ced5fcc0ce1c7c8b0e09c (patch)
tree72261f405109c6ae5679e06822c8bf4039e68a6d
parent3493a98fb4f48476c4af86b5d58bfc7a66d149d9 (diff)
downloadchef-9f188c35fd34f297080ced5fcc0ce1c7c8b0e09c.tar.gz
support source property and local installs
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/provider/package/dnf.rb43
-rw-r--r--spec/functional/resource/dnf_package_spec.rb566
2 files changed, 329 insertions, 280 deletions
diff --git a/lib/chef/provider/package/dnf.rb b/lib/chef/provider/package/dnf.rb
index f599b3786e..8ae8324c42 100644
--- a/lib/chef/provider/package/dnf.rb
+++ b/lib/chef/provider/package/dnf.rb
@@ -17,6 +17,7 @@
require "chef/provider/package"
require "chef/resource/dnf_package"
require "chef/mixin/which"
+require "chef/mixin/get_source_from_package"
require "timeout"
class Chef
@@ -24,6 +25,7 @@ class Chef
class Package
class Dnf < Chef::Provider::Package
extend Chef::Mixin::Which
+ include Chef::Mixin::GetSourceFromPackage
class Version
attr_accessor :name
@@ -141,6 +143,7 @@ class Chef
end
use_multipackage_api
+ use_package_name_for_source
provides :package, platform_family: %w{rhel fedora} do
which("dnf")
@@ -157,12 +160,19 @@ class Chef
@current_resource = Chef::Resource::DnfPackage.new(new_resource.name)
current_resource.package_name(new_resource.package_name)
-
current_resource.version(get_current_versions)
current_resource
end
+ def define_resource_requirements
+ # FIXME:
+ #unless ::File.exist?(new_resource.source)
+ # raise Chef::Exceptions::Package, "Package #{new_resource.name} not found: #{new_resource.source}"
+ #end
+ super
+ end
+
def candidate_version
package_name_array.map do |pkg|
available_version(pkg).version_with_arch
@@ -176,8 +186,12 @@ class Chef
end
def install_package(names, versions)
- resolved_names = names.map { |name| available_version(name).to_s }
- dnf(new_resource.options, "-y install", resolved_names)
+ if new_resource.source
+ dnf(new_resource.options, "-y install", new_resource.source)
+ else
+ resolved_names = names.map { |name| available_version(name).to_s }
+ dnf(new_resource.options, "-y install", resolved_names)
+ end
flushcache_after
end
@@ -206,17 +220,36 @@ class Chef
end
end
+ def resolve_source_to_version_obj
+ shell_out_with_timeout!("rpm -qp --queryformat '%{NAME} %{EPOCH}:%{VERSION}-%{RELEASE} %{ARCH}\n' #{new_resource.source}").stdout.each_line do |line|
+ case line
+ when /^(\S+)\s+(\S+)\s+(\S+)$/
+ return Version.new($1, $2, $3)
+ end
+ end
+ end
+
# @returns Array<Version>
def available_version(package_name)
@available_version ||= {}
- @available_version[package_name] ||= python_helper.whatavailable(package_name, desired_name_versions[package_name], desired_name_archs[package_name])
+
+ if new_resource.source
+ @available_version[package_name] ||= resolve_source_to_version_obj
+ else
+ @available_version[package_name] ||= python_helper.whatavailable(package_name, desired_name_versions[package_name], desired_name_archs[package_name])
+ end
+
@available_version[package_name]
end
# @returns Array<Version>
def installed_version(package_name)
@installed_version ||= {}
- @installed_version[package_name] ||= python_helper.whatinstalled(package_name, desired_name_versions[package_name], desired_name_archs[package_name])
+ if new_resource.source
+ @installed_version[package_name] ||= python_helper.whatinstalled(resolve_source_to_version_obj.name, desired_name_versions[package_name], desired_name_archs[package_name])
+ else
+ @installed_version[package_name] ||= python_helper.whatinstalled(package_name, desired_name_versions[package_name], desired_name_archs[package_name])
+ end
@installed_version[package_name]
end
diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb
index 1dd5eda181..a3766226dd 100644
--- a/spec/functional/resource/dnf_package_spec.rb
+++ b/spec/functional/resource/dnf_package_spec.rb
@@ -62,287 +62,303 @@ gpgcheck=0
let(:package_name) { "chef_rpm" }
let(:dnf_package) { Chef::Resource::DnfPackage.new(package_name, run_context) }
- 1.times do |i|
- describe ":install" do
- context "vanilla use case" do
- let(:package_name) { "chef_rpm" }
- it "installs if the package is not installed #{i}" do
- flush_cache
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
-
- it "does not install if the package is installed #{i}" do
- preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
-
- it "does not install if the prior version package is installed #{i}" do
- preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
- end
-
- it "does not install if the i686 package is installed #{i}" do
- skip "FIXME: do nothing, or install the x86_64 version?"
- preinstall("chef_rpm-1.10-1.fc24.i686.rpm")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.i686")
- end
-
- it "does not install if the prior version i686 package is installed #{i}" do
- skip "FIXME: do nothing, or install the x86_64 version?"
- preinstall("chef_rpm-1.2-1.fc24.i686.rpm")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.i686")
- end
- end
-
- context "with versions or globs in the name" do
- it "works with a version" do
- flush_cache
- dnf_package.package_name("chef_rpm-1.10")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
-
- it "works with an older version" do
- flush_cache
- dnf_package.package_name("chef_rpm-1.2")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
- end
-
- it "works with an evr" do
- flush_cache
- dnf_package.package_name("chef_rpm-0:1.2-1.fc24")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
- end
-
- it "works with a version glob" do
- flush_cache
- dnf_package.package_name("chef_rpm-1*")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
-
- it "works with a name glob + version glob" do
- flush_cache
- dnf_package.package_name("chef_rp*-1*")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
- end
-
- # version only matches the actual dnf version, does not work with epoch or release or combined evr
- context "with version property" do
- it "matches the full version" do
- flush_cache
- dnf_package.package_name("chef_rpm")
- dnf_package.version("1.10")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
-
- it "matches with a glob" do
- flush_cache
- dnf_package.package_name("chef_rpm")
- dnf_package.version("1*")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
- end
-
- context "downgrades" do
- it "just work with DNF" do
- preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
- dnf_package.version("1.2")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
- end
-
- it "throws a deprecation warning with allow_downgrade" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(Chef).to receive(:deprecated).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/)
- preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
- dnf_package.version("1.2")
- dnf_package.run_action(:install)
- dnf_package.allow_downgrade true
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
- end
- end
-
- context "with arch property" do
- end
-
- context "with constraints" do
- it "with nothing installed, it installs the latest version" do
- flush_cache
- dnf_package.package_name("chef_rpm >= 1.2")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
-
- it "when it is met, it does nothing" do
- preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
- dnf_package.package_name("chef_rpm >= 1.2")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
- end
-
- it "when it is met, it does nothing" do
- preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
- dnf_package.package_name("chef_rpm >= 1.2")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
-
- it "with nothing intalled, it installs the latest version" do
- flush_cache
- dnf_package.package_name("chef_rpm > 1.2")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
-
- it "when it is not met by an installed rpm, it upgrades" do
- preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
- dnf_package.package_name("chef_rpm > 1.2")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
-
- it "when it is met by an installed rpm, it does nothing" do
- preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
- dnf_package.package_name("chef_rpm > 1.2")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
- end
+ describe ":install" do
+ context "vanilla use case" do
+ let(:package_name) { "chef_rpm" }
+ it "installs if the package is not installed" do
+ flush_cache
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
+ it "does not install if the package is installed" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
+ it "does not install if the prior version package is installed" do
+ preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+
+ it "does not install if the i686 package is installed" do
+ skip "FIXME: do nothing, or install the x86_64 version?"
+ preinstall("chef_rpm-1.10-1.fc24.i686.rpm")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.i686")
+ end
+
+ it "does not install if the prior version i686 package is installed" do
+ skip "FIXME: do nothing, or install the x86_64 version?"
+ preinstall("chef_rpm-1.2-1.fc24.i686.rpm")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.i686")
+ end
+ end
+
+ context "with versions or globs in the name" do
+ it "works with a version" do
+ flush_cache
+ dnf_package.package_name("chef_rpm-1.10")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
+ it "works with an older version" do
+ flush_cache
+ dnf_package.package_name("chef_rpm-1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+
+ it "works with an evr" do
+ flush_cache
+ dnf_package.package_name("chef_rpm-0:1.2-1.fc24")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+
+ it "works with a version glob" do
+ flush_cache
+ dnf_package.package_name("chef_rpm-1*")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
+ it "works with a name glob + version glob" do
+ flush_cache
+ dnf_package.package_name("chef_rp*-1*")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+ end
+
+ # version only matches the actual dnf version, does not work with epoch or release or combined evr
+ context "with version property" do
+ it "matches the full version" do
+ flush_cache
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version("1.10")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
+ it "matches with a glob" do
+ flush_cache
+ dnf_package.package_name("chef_rpm")
+ dnf_package.version("1*")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+ end
+
+ context "downgrades" do
+ it "just work with DNF" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.version("1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+
+ it "throws a deprecation warning with allow_downgrade" do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ expect(Chef).to receive(:deprecated).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/)
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.version("1.2")
+ dnf_package.run_action(:install)
+ dnf_package.allow_downgrade true
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+ end
+
+ context "with arch property" do
+ end
+
+ context "with constraints" do
+ it "with nothing installed, it installs the latest version" do
+ flush_cache
+ dnf_package.package_name("chef_rpm >= 1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
+ it "when it is met, it does nothing" do
+ preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
+ dnf_package.package_name("chef_rpm >= 1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+
+ it "when it is met, it does nothing" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.package_name("chef_rpm >= 1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
+ it "with nothing intalled, it installs the latest version" do
+ flush_cache
+ dnf_package.package_name("chef_rpm > 1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
+ it "when it is not met by an installed rpm, it upgrades" do
+ preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
+ dnf_package.package_name("chef_rpm > 1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+
+ it "when it is met by an installed rpm, it does nothing" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.package_name("chef_rpm > 1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.x86_64")
+ end
+ end
+
+ context "with source arguments" do
+ it "installs the package when using the source argument" do
+ dnf_package.name "something"
+ dnf_package.package_name "somethingelse"
+ dnf_package.source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+
+ it "installs the package when the name is a path to a file" do
+ dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+ end
+ end
+
+ describe ":upgrade" do
+ context "downgrades" do
+ it "just work with DNF" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.version("1.2")
+ dnf_package.run_action(:install)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
+ end
+
+ it "throws a deprecation warning with allow_downgrade" do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ expect(Chef).to receive(:deprecated).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/)
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.version("1.2")
+ dnf_package.run_action(:install)
+ dnf_package.allow_downgrade true
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
end
end
+ end
+
+ describe ":remove" do
+ context "vanilla use case" do
+ let(:package_name) { "chef_rpm" }
+ it "does nothing if the package is not installed" do
+ flush_cache
+ expect(dnf_package.updated_by_last_action?).to be false
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
+ end
+
+ it "removes the package if the package is installed" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
+ end
+
+ it "removes the package if the prior version package is installed" do
+ preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
+ end
+
+ it "removes the package if the i686 package is installed" do
+ skip "FIXME: should this be fixed or is the current behavior correct?"
+ preinstall("chef_rpm-1.10-1.fc24.i686.rpm")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
+ end
- describe ":upgrade" do
- context "downgrades" do
- it "just work with DNF" do
- preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
- dnf_package.version("1.2")
- dnf_package.run_action(:install)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
- end
-
- it "throws a deprecation warning with allow_downgrade" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(Chef).to receive(:deprecated).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/)
- preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
- dnf_package.version("1.2")
- dnf_package.run_action(:install)
- dnf_package.allow_downgrade true
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.x86_64")
- end
+ it "removes the package if the prior version i686 package is installed" do
+ skip "FIXME: should this be fixed or is the current behavior correct?"
+ preinstall("chef_rpm-1.2-1.fc24.i686.rpm")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
end
end
- describe ":remove" do
- context "vanilla use case" do
- let(:package_name) { "chef_rpm" }
- it "does nothing if the package is not installed #{i}" do
- flush_cache
- expect(dnf_package.updated_by_last_action?).to be false
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
- end
-
- it "removes the package if the package is installed #{i}" do
- preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
- end
-
- it "removes the package if the prior version package is installed #{i}" do
- preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
- end
-
- it "removes the package if the i686 package is installed #{i}" do
- skip "FIXME: should this be fixed or is the current behavior correct?"
- preinstall("chef_rpm-1.10-1.fc24.i686.rpm")
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
- end
-
- it "removes the package if the prior version i686 package is installed #{i}" do
- skip "FIXME: should this be fixed or is the current behavior correct?"
- preinstall("chef_rpm-1.2-1.fc24.i686.rpm")
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
- end
- end
-
- context "with 64-bit arch" do
- let(:package_name) { "chef_rpm.x86_64" }
- it "does nothing if the package is not installed #{i}" do
- flush_cache
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
- end
-
- it "removes the package if the package is installed #{i}" do
- preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
- end
-
- it "removes the package if the prior version package is installed #{i}" do
- preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be true
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
- end
-
- it "does nothing if the i686 package is installed #{i}" do
- preinstall("chef_rpm-1.10-1.fc24.i686.rpm")
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.i686")
- end
-
- it "does nothing if the prior version i686 package is installed #{i}" do
- preinstall("chef_rpm-1.2-1.fc24.i686.rpm")
- dnf_package.run_action(:remove)
- expect(dnf_package.updated_by_last_action?).to be false
- expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.i686")
- end
+ context "with 64-bit arch" do
+ let(:package_name) { "chef_rpm.x86_64" }
+ it "does nothing if the package is not installed" do
+ flush_cache
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
+ end
+
+ it "removes the package if the package is installed" do
+ preinstall("chef_rpm-1.10-1.fc24.x86_64.rpm")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
+ end
+
+ it "removes the package if the prior version package is installed" do
+ preinstall("chef_rpm-1.2-1.fc24.x86_64.rpm")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be true
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("package chef_rpm is not installed")
+ end
+
+ it "does nothing if the i686 package is installed" do
+ preinstall("chef_rpm-1.10-1.fc24.i686.rpm")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.10-1.fc24.i686")
+ end
+
+ it "does nothing if the prior version i686 package is installed" do
+ preinstall("chef_rpm-1.2-1.fc24.i686.rpm")
+ dnf_package.run_action(:remove)
+ expect(dnf_package.updated_by_last_action?).to be false
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.fc24.i686")
end
end
end