summaryrefslogtreecommitdiff
path: root/manifests/arch_builder.pp
blob: ff02d93fa3ba873ca743f510b7bf4dde70a157d4 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Sets up an arch system for running my arch-builder script, which
# periodically fetches a list of packages, and builds them for
# inclusion in an arch repo.
class profiles::arch_builder (
  Hash $conf,
  Array $package_list,
  String $package_list_file = '/usr/local/aur/aur-packages.yaml',
) {
  include ::profiles::repo
  include ::profiles::sudo

  ensure_packages([
    'base',
    'base-devel',
    'python',
    'python-yaml',
    'python-pip',
    # Note that auracle git is NOT in the standard repos, and needs to
    # be manually bootstraped to work
    'auracle-git',
  ])


  ensure_packages([
    'coloredlogs',
    'graypy',
  ], { provider => 'pip', })

  $aur_builder = 'aur-builder'
  $aur_home = '/usr/local/aur'

  user { $aur_builder:
    system => true,
    home   => $aur_home,
    shell  => '/usr/bin/nologin',
  }

  file { '/etc/sudoers.d/aur_builder':
    content      => "${aur_builder} ALL=(ALL) NOPASSWD: /usr/bin/pacman\n",
    validate_cmd => '/usr/bin/visudo -cf %',
  }

  $conf_override = {
    'package-list' => $package_list_file,
  }

  $yaml_settings = {
    'header' => '# This file is controlled by Puppet',
  }

  file { '/etc/xdg/aur-runner':
    ensure => directory,
  } -> file { '/etc/xdg/aur-runner/config.yaml':
    content => hash2yaml($conf + $conf_override, $yaml_settings),
  }

  file { $package_list_file:
    ensure  => file,
    force   => true,
    content => hash2yaml({ 'packages' => $package_list }, $yaml_settings),
  }

  # TODO fetch actuall aur-runner...
  # https://git.hornquist.se/aur-runner/


  systemd::timer { 'aur-builder.timer':
    timer_source   => 'puppet:///modules/profiles/arch_builder.timer',
    service_source => 'puppet:///modules/profiles/arch_builder.service',
    enable         => true,
  }


  class { 'pacman::makepkg':
    makeflags => '-j4',
    packager  => 'Hugo Hörnquist (automatically) <>',
    dlagents  => {
      # Defaults, but with --silent added
      'file'  => '/usr/bin/curl --silent -gqC - -o %o %u',
      'ftp'   => '/usr/bin/curl --silent -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u',
      'http'  => '/usr/bin/curl --silent -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u',
      'https' => '/usr/bin/curl --silent -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u',
      # Defaults, but needed since partial overrides aren't currently
      # supported
      'rsync' => '/usr/bin/rsync --no-motd -z %u %o',
      'scp'   => '/usr/bin/scp -C %u %o',
    }

  }
}