Skip to content

Commit b3aacd2

Browse files
authored
Merge pull request #9287 from bastelfreak/pacman
package: pacman provider: Add purgeable feature
2 parents 12cc9e6 + 08eaa3d commit b3aacd2

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Diff for: lib/puppet/provider/package/pacman.rb

+12-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def self.yaourt?
2525
has_feature :uninstall_options
2626
has_feature :upgradeable
2727
has_feature :virtual_packages
28+
has_feature :purgeable
2829

2930
# Checks if a given name is a group
3031
def self.group?(name)
@@ -191,6 +192,16 @@ def self.to_resource_hash(name, version)
191192

192193
# Removes a package from the system.
193194
def uninstall
195+
remove_package(false)
196+
end
197+
198+
def purge
199+
remove_package(true)
200+
end
201+
202+
private
203+
204+
def remove_package(purge_configs = false)
194205
resource_name = @resource[:name]
195206

196207
is_group = self.class.group?(resource_name)
@@ -201,6 +212,7 @@ def uninstall
201212
cmd += uninstall_options if @resource[:uninstall_options]
202213
cmd << "-R"
203214
cmd << '-s' if is_group
215+
cmd << '--nosave' if purge_configs
204216
cmd << resource_name
205217

206218
if self.class.yaourt?
@@ -210,8 +222,6 @@ def uninstall
210222
end
211223
end
212224

213-
private
214-
215225
def install_options
216226
join_options(@resource[:install_options])
217227
end

Diff for: spec/unit/provider/package/pacman_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@
168168
end
169169
end
170170

171+
describe "when purging" do
172+
it "should call pacman to remove the right package and configs quietly" do
173+
args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-R", "--nosave", resource[:name]]
174+
expect(executor).to receive(:execute).with(args, no_extra_options).and_return("")
175+
provider.purge
176+
end
177+
end
178+
171179
describe "when uninstalling" do
172180
it "should call pacman to remove the right package quietly" do
173181
args = ["/usr/bin/pacman", "--noconfirm", "--noprogressbar", "-R", resource[:name]]

0 commit comments

Comments
 (0)