summaryrefslogtreecommitdiffstats
path: root/modules/package
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-11-13 00:19:06 -0500
committerJesse Luehrs <doy@tozt.net>2018-11-13 00:19:06 -0500
commitbf33ac997636c4b6c199cfff1e171ffaff437c91 (patch)
tree2f3d94f0ad3fddde69fec83c4d65356d60dea479 /modules/package
parentb5fe67cdda8f05ffe814a923b1a69f7169b9db5c (diff)
downloadpuppet-tozt-bf33ac997636c4b6c199cfff1e171ffaff437c91.tar.gz
puppet-tozt-bf33ac997636c4b6c199cfff1e171ffaff437c91.zip
actually, let's make this shared again
Diffstat (limited to 'modules/package')
-rw-r--r--modules/package/manifests/cargo.pp39
-rw-r--r--modules/package/manifests/makepkg.pp41
2 files changed, 80 insertions, 0 deletions
diff --git a/modules/package/manifests/cargo.pp b/modules/package/manifests/cargo.pp
new file mode 100644
index 0000000..2f599b9
--- /dev/null
+++ b/modules/package/manifests/cargo.pp
@@ -0,0 +1,39 @@
+define package::cargo($package, $user, $ensure, $home=undef) {
+ $_home = $home ? {
+ undef => $user ? {
+ 'root' => '/root',
+ default => "/home/$user",
+ },
+ default => $home,
+ }
+
+ case $ensure {
+ 'installed': {
+ exec { "cargo install $package for $user":
+ provider => "shell",
+ command => "cargo install $package",
+ unless => "cargo install --list | grep -q '^$package'",
+ user => $user,
+ timeout => 3600,
+ require => [
+ User[$user],
+ Rust::User[$user],
+ File["${_home}/.cargo"],
+ ];
+ }
+ }
+ 'absent': {
+ exec { "cargo uninstall $package for $user":
+ provider => "shell",
+ command => "cargo uninstall $package",
+ onlyif => "cargo install --list | grep -q '^$package'",
+ user => $user,
+ require => [
+ User[$user],
+ Rust::User[$user],
+ File["${_home}/.cargo"],
+ ];
+ }
+ }
+ }
+}
diff --git a/modules/package/manifests/makepkg.pp b/modules/package/manifests/makepkg.pp
new file mode 100644
index 0000000..c9d0318
--- /dev/null
+++ b/modules/package/manifests/makepkg.pp
@@ -0,0 +1,41 @@
+define package::makepkg($ensure, $build_user, $asdeps=false) {
+ if $asdeps {
+ $extra_cmdline = " --asdeps"
+ }
+ else {
+ $extra_cmdline = ""
+ }
+
+ include c_toolchain
+ include git
+
+ case $ensure {
+ 'installed': {
+ exec { "makepkg install $name":
+ provider => "shell",
+ command => "
+ cd /tmp
+ rm -rf 'makepkg-$name'
+ su $build_user -c 'git clone https://aur.archlinux.org/$name.git makepkg-$name'
+ cd 'makepkg-$name'
+ su $build_user -c makepkg
+ pacman -U --noconfirm --needed $extra_cmdline $name-*.pkg.tar.xz
+ ",
+ unless => "pacman -Q $name > /dev/null 2>&1",
+ path => "/usr/bin",
+ require => [
+ Class["git"],
+ Class["c_toolchain"],
+ ];
+ }
+ }
+ 'absent': {
+ exec { "makepkg uninstall $name":
+ provider => "shell",
+ command => "pacman --noconfirm -Rsn $name",
+ onlyif => "pacman -Q $name > /dev/null 2>&1",
+ path => "/usr/bin";
+ }
+ }
+ }
+}