Skip to content

Commit ebf4a0a

Browse files
committed
package: pacman provider: Add purgeable feature
This small patch adds an option to the pacman provider to purge config files. From the manpage: ```console $ pacman -R -h | head -n6 usage: pacman {-R --remove} [options] <package(s)> options: -b, --dbpath <path> set an alternate database location -c, --cascade remove packages and all packages that depend on them -d, --nodeps skip dependency version checks (-dd to skip all checks) -n, --nosave remove configuration files ```
1 parent 500c601 commit ebf4a0a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-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

0 commit comments

Comments
 (0)