@@ -54,9 +54,8 @@ module Puppet
5454 feature :holdable , "The provider is capable of placing packages on hold
5555 such that they are not automatically upgraded as a result of
5656 other package dependencies unless explicit action is taken by
57- a user or another package. Held is considered a superset of
58- installed." ,
59- :methods => [ :hold ]
57+ a user or another package." ,
58+ :methods => [ :hold , :unhold ]
6059 feature :install_only , "The provider accepts options to only install packages never update (kernels, etc.)"
6160 feature :install_options , "The provider accepts options to be
6261 passed to the installer command."
@@ -102,7 +101,7 @@ module Puppet
102101 end
103102
104103 newvalue ( :held , :event => :package_held , :required_features => :holdable ) do
105- provider . hold
104+ provider . deprecated_hold
106105 end
107106
108107 # Alias the 'present' value.
@@ -623,5 +622,59 @@ def refresh
623622 provider . reinstall
624623 end
625624 end
625+
626+ newproperty ( :mark , :required_features => :holdable ) do
627+ mark_doc = 'Valid values are: hold/none'
628+ desc <<-EOT
629+ Set to hold to tell Debian apt/Solaris pkg to hold the package version
630+
631+ #{ mark_doc }
632+ Default is "none". Mark can be specified with or without `ensure`,
633+ if `ensure` is missing will default to "present".
634+
635+ Mark cannot be specified together with "purged", "absent" or "held"
636+ values for `ensure`.
637+ EOT
638+ newvalues ( :hold , :none )
639+ munge do |value |
640+ case value
641+ when "hold" , :hold
642+ :hold
643+ when "none" , :none
644+ :none
645+ else
646+ raise ArgumentError , _ ( 'Invalid hold value %{value}. %{doc}' ) % { value : value . inspect , doc : mark_doc }
647+ end
648+ end
649+
650+ def insync? ( is )
651+ @should [ 0 ] == is
652+ end
653+
654+ def should
655+ @should [ 0 ] if @should && @should . is_a? ( Array ) && @should . size == 1
656+ end
657+
658+ def retrieve
659+ provider . properties [ :mark ]
660+ end
661+
662+ def sync
663+ if @should [ 0 ] == :hold
664+ provider . hold
665+ else
666+ provider . unhold
667+ end
668+ end
669+ end
670+
671+ validate do
672+ if :held == @parameters [ :ensure ] . should
673+ warning '"ensure=>held" has been deprecated and will be removed in a future version, use "mark=hold" instead'
674+ end
675+ if @parameters [ :mark ] && [ :absent , :purged , :held ] . include? ( @parameters [ :ensure ] . should )
676+ raise ArgumentError , _ ( 'You cannot use "mark" property while "ensure" is one of ["absent", "purged", "held"]' )
677+ end
678+ end
626679 end
627680end
0 commit comments