summaryrefslogtreecommitdiffstats
path: root/modules/package/manifests/makepkg.pp
blob: 0938d3428f40225a4fe342839ef662a01b39e5af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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.zst
        ",
        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";
      }
    }
    default: {
      fail("unimplemented ensure $ensure")
    }
  }
}