From bf33ac997636c4b6c199cfff1e171ffaff437c91 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 13 Nov 2018 00:19:06 -0500 Subject: actually, let's make this shared again --- modules/package/manifests/cargo.pp | 39 ++++++++++++++++++++++++++++++++++ modules/package/manifests/makepkg.pp | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 modules/package/manifests/cargo.pp create mode 100644 modules/package/manifests/makepkg.pp (limited to 'modules/package') 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"; + } + } + } +} -- cgit v1.2.3-54-g00ecf