summaryrefslogtreecommitdiffstats
path: root/modules/package
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2017-11-05 18:42:44 -0500
committerJesse Luehrs <doy@tozt.net>2017-11-05 18:42:44 -0500
commit1cfde3e0957a988c3f3687fff8a1c6f0d85a3600 (patch)
tree8a2c547c3919f480ced772d42ad1e23f1185727f /modules/package
parent452cd9bcc9a66fcbc60e1e61eec6ae63a26453b1 (diff)
downloadpuppet-tozt-1cfde3e0957a988c3f3687fff8a1c6f0d85a3600.tar.gz
puppet-tozt-1cfde3e0957a988c3f3687fff8a1c6f0d85a3600.zip
support `ensure` for package::makepkg
Diffstat (limited to 'modules/package')
-rw-r--r--modules/package/manifests/makepkg.pp48
1 files changed, 30 insertions, 18 deletions
diff --git a/modules/package/manifests/makepkg.pp b/modules/package/manifests/makepkg.pp
index a874377..90d9d4d 100644
--- a/modules/package/manifests/makepkg.pp
+++ b/modules/package/manifests/makepkg.pp
@@ -1,4 +1,4 @@
-define package::makepkg($asdeps=false) {
+define package::makepkg($ensure, $asdeps=false) {
if $asdeps {
$extra_cmdline = " --asdeps"
}
@@ -6,22 +6,34 @@ define package::makepkg($asdeps=false) {
$extra_cmdline = ""
}
- exec { "install $name":
- provider => "shell",
- command => "
- cd /tmp
- rm -rf 'makepkg-$name'
- su doy -c 'git clone https://aur.archlinux.org/$name.git makepkg-$name'
- cd 'makepkg-$name'
- su doy -c makepkg
- pacman -U --noconfirm --needed $extra_cmdline $name-*.pkg.tar.xz
- ",
- unless => "pacman -Q $name > /dev/null 2>&1",
- path => "/usr/bin",
- require => [
- Tozt::User["doy"],
- Package["git"],
- Package["pkg-config"],
- ];
+ case $ensure {
+ 'installed': {
+ exec { "install $name":
+ provider => "shell",
+ command => "
+ cd /tmp
+ rm -rf 'makepkg-$name'
+ su doy -c 'git clone https://aur.archlinux.org/$name.git makepkg-$name'
+ cd 'makepkg-$name'
+ su doy -c makepkg
+ pacman -U --noconfirm --needed $extra_cmdline $name-*.pkg.tar.xz
+ ",
+ unless => "pacman -Q $name > /dev/null 2>&1",
+ path => "/usr/bin",
+ require => [
+ Tozt::User["doy"],
+ Package["git"],
+ Package["pkg-config"],
+ ];
+ }
+ }
+ 'absent': {
+ exec { "uninstall $name":
+ provider => "shell",
+ command => "pacman --noconfirm -Rsn $name",
+ onlyif => "pacman -Q $name > /dev/null 2>&1",
+ path => "/usr/bin";
+ }
+ }
}
}