From d89d3f0374a4e3027203df6ebcf21f690f263fc6 Mon Sep 17 00:00:00 2001 From: Daniel Schauenberg Date: Fri, 1 Jan 2021 22:58:01 +0100 Subject: adapt to FreeBSD pkgng sysexit changes Signed-off-by: Daniel Schauenberg --- lib/chef/provider/package/freebsd/pkgng.rb | 4 +++- spec/unit/provider/package/freebsd/pkgng_spec.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/chef/provider/package/freebsd/pkgng.rb b/lib/chef/provider/package/freebsd/pkgng.rb index 87acb3a830..077464b5c2 100644 --- a/lib/chef/provider/package/freebsd/pkgng.rb +++ b/lib/chef/provider/package/freebsd/pkgng.rb @@ -42,7 +42,9 @@ class Chef end def current_installed_version - pkg_info = shell_out!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70]) + # pkgng up to version 1.15.99.7 returns 70 for pkg not found, + # later versions return 1 + pkg_info = shell_out!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 1, 70]) pkg_info.stdout[/^Version +: (.+)$/, 1] end diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb index bc78a178eb..ce5d58b7dc 100644 --- a/spec/unit/provider/package/freebsd/pkgng_spec.rb +++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb @@ -66,7 +66,7 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should query pkg database" do - expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info) + expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 1, 70], timeout: 900).and_return(@pkg_info) expect(@provider.current_installed_version).to eq("3.1.7") end end -- cgit v1.2.1