Skip to content

Commit ee97ee7

Browse files
committed
(PUP-10597) Remove deprecated held
1 parent 7c4baa6 commit ee97ee7

File tree

11 files changed

+21
-88
lines changed

11 files changed

+21
-88
lines changed

acceptance/tests/provider/package/dpkg_ensure_held_package_is_latest.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

acceptance/tests/provider/package/dpkg_ensure_held_package_should_preserve_version.rb

Lines changed: 0 additions & 22 deletions
This file was deleted.

acceptance/tests/provider/package/dpkg_hold_true_package_is_latest.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
test_name "dpkg ensure held package is latest installed" do
2-
confine :to, :platform => /debian-8-amd64/
1+
test_name "dpkg ensure hold package is latest installed" do
2+
confine :to, :platform => /debian-9-amd64/
33
tag 'audit:high'
44

55
require 'puppet/acceptance/common_utils'

acceptance/tests/provider/package/dpkg_hold_true_should_preserve_version.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
test_name "dpkg ensure held package should preserve version if package is already installed" do
2-
confine :to, :platform => /debian-8-amd64/
1+
test_name "dpkg ensure hold package should preserve version if package is already installed" do
2+
confine :to, :platform => /debian-9-amd64/
33
tag 'audit:high'
44

55
require 'puppet/acceptance/common_utils'
@@ -8,12 +8,12 @@
88

99
package = "openssl"
1010

11-
step "Ensure held should lock to specific installed version" do
11+
step "Ensure hold should lock to specific installed version" do
1212
existing_installed_version = on(agent.name, "dpkg -s #{package} | sed -n -e 's/Version: //p'").stdout
1313
existing_installed_version.delete!(' ')
1414

15-
package_manifest_held = resource_manifest('package', package, mark: "hold")
16-
apply_manifest_on(agent, package_manifest_held) do
15+
package_manifest_hold = resource_manifest('package', package, mark: "hold")
16+
apply_manifest_on(agent, package_manifest_hold) do
1717
installed_version = on(agent.name, "apt-cache policy #{package} | sed -n -e 's/Installed: //p'").stdout
1818
installed_version.delete!(' ')
1919
assert_match(existing_installed_version, installed_version)

acceptance/tests/resource/package/ips/should_be_holdable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
assert_match( /[email protected]/, result.stdout, "err: #{agent}")
5454
end
5555

56-
step "IPS: it should not upgrade current and dependent package if dependent package is held"
57-
apply_manifest_on(agent, 'package {mypkg : ensure=>"held", provider=>"pkg"}') do
56+
step "IPS: it should not upgrade current and dependent package if dependent package is hold"
57+
apply_manifest_on(agent, 'package {mypkg : ensure=>"present", mark=>"hold", provider=>"pkg"}') do
5858
assert_match( //, result.stdout, "err: #{agent}")
5959
end
6060
setup_fakeroot agent

lib/puppet/provider/package/dpkg.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,10 @@ def purge
173173
dpkg "--purge", @resource[:name]
174174
end
175175

176-
def deprecated_hold
176+
def hold
177177
if package_not_installed?
178178
self.install
179179
end
180-
hold
181-
end
182-
183-
def hold
184180
Tempfile.open('puppet_dpkg_set_selection') do |tmpfile|
185181
tmpfile.write("#{@resource[:name]} hold\n")
186182
tmpfile.flush

lib/puppet/provider/package/pkg.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ def self.parse_line(line)
114114
end).merge({:provider => self.name})
115115
end
116116

117-
def deprecated_hold
118-
hold
119-
end
120-
121117
def hold
122118
pkg(:freeze, @resource[:name])
123119
end

lib/puppet/provider/package/portage.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def qatom
112112
# do the search
113113
should = @resource[:ensure]
114114
case should
115-
# The terms present, absent, purged, held, installed, latest in :ensure
115+
# The terms present, absent, purged, installed, latest in :ensure
116116
# resolve as Symbols, and we do not need specific package version in this case
117117
when true, false, Symbol
118118
search = @resource[:name]

lib/puppet/type/package.rb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ module Puppet
106106
provider.purge
107107
end
108108

109-
newvalue(:held, :event => :package_held, :required_features => :holdable) do
110-
provider.deprecated_hold
111-
end
112-
113109
newvalue(:disabled, :required_features => :disableable) do
114110
provider.disable
115111
end
@@ -161,7 +157,7 @@ def insync?(is)
161157
@should.each { |should|
162158
case should
163159
when :present
164-
return true unless [:absent, :purged, :held, :disabled].include?(is)
160+
return true unless [:absent, :purged, :disabled].include?(is)
165161
when :latest
166162
# Short-circuit packages that are not present
167163
return false if is == :absent || is == :purged
@@ -657,8 +653,7 @@ def refresh
657653
if provider.reinstallable? &&
658654
@parameters[:reinstall_on_refresh].value == :true &&
659655
@parameters[:ensure].value != :purged &&
660-
@parameters[:ensure].value != :absent &&
661-
@parameters[:ensure].value != :held
656+
@parameters[:ensure].value != :absent
662657

663658
provider.reinstall
664659
end
@@ -673,7 +668,7 @@ def refresh
673668
Default is "none". Mark can be specified with or without `ensure`,
674669
if `ensure` is missing will default to "present".
675670
676-
Mark cannot be specified together with "purged", "absent" or "held"
671+
Mark cannot be specified together with "purged", or "absent"
677672
values for `ensure`.
678673
EOT
679674
newvalues(:hold, :none)
@@ -710,11 +705,8 @@ def sync
710705
end
711706

712707
validate do
713-
if :held == @parameters[:ensure].should
714-
warning '"ensure=>held" has been deprecated and will be removed in a future version, use "mark=hold" instead'
715-
end
716-
if @parameters[:mark] && [:absent, :purged, :held].include?(@parameters[:ensure].should)
717-
raise ArgumentError, _('You cannot use "mark" property while "ensure" is one of ["absent", "purged", "held"]')
708+
if @parameters[:mark] && [:absent, :purged].include?(@parameters[:ensure].should)
709+
raise ArgumentError, _('You cannot use "mark" property while "ensure" is one of ["absent", "purged"]')
718710
end
719711
end
720712
end

spec/unit/provider/package/dpkg_spec.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,24 +381,21 @@ def parser_test(dpkg_output_string, gold_hash, number_of_debug_logs = 0)
381381
allow(provider).to receive(:execute)
382382
allow(provider).to receive(:package_not_installed?).and_return(true)
383383
expect(provider).to receive(:install).once
384-
expect(provider).to receive(:hold)
385-
provider.deprecated_hold
384+
provider.hold
386385
end
387386

388-
it "skips install new package if hold is true" do
387+
it "install new package if hold is true and package not installed" do
389388
allow(provider).to receive(:execute)
390389
allow(provider).to receive(:package_not_installed?).and_return(true)
391390
expect(provider).to receive(:install).once
392-
expect(provider).to receive(:hold)
393-
provider.deprecated_hold
391+
provider.hold
394392
end
395393

396394
it "skips install new package if package is allready installed" do
397395
allow(provider).to receive(:execute)
398396
allow(provider).to receive(:package_not_installed?).and_return(false)
399397
expect(provider).not_to receive(:install)
400-
expect(provider).to receive(:hold)
401-
provider.deprecated_hold
398+
provider.hold
402399
end
403400

404401
it "executes dpkg --set-selections when holding" do

0 commit comments

Comments
 (0)