summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-03-21 15:23:28 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2023-03-21 15:49:27 +0100
commit841494767100e6abebde6e800796cf19e1f797e8 (patch)
treeadda2cb084de9b1cfa3da7ec03b5566f525d9fac /manifests
parentFix metadata. (diff)
downloadpacman-841494767100e6abebde6e800796cf19e1f797e8.tar.gz
pacman-841494767100e6abebde6e800796cf19e1f797e8.tar.xz
Basically rewrote everything.
Diffstat (limited to 'manifests')
-rw-r--r--manifests/hook.pp54
-rw-r--r--manifests/init.pp62
-rw-r--r--manifests/makepkg.pp55
-rw-r--r--manifests/repo.pp72
4 files changed, 175 insertions, 68 deletions
diff --git a/manifests/hook.pp b/manifests/hook.pp
index c71b6c5..a1fda6e 100644
--- a/manifests/hook.pp
+++ b/manifests/hook.pp
@@ -1,25 +1,35 @@
+# @summary A Pacman hook
+
+# @param ensure
+# @param priority
+# @param description
+# @param when
+# @param exec
+# @param depends
+# @param abort_on_fail
+# @param needs_targets
+# @param trigger
define pacman::hook (
+ Enum['PreTransation', 'PostTransaction'] $when,
+ String $exec,
+ Variant[Pacman::Trigger, Array[Pacman::Trigger, 1]] $trigger,
Enum['present', 'absent'] $ensure = 'present',
Integer $priority = 50,
Optional[String] $description = undef,
- Enum['PreTransation', 'PostTransaction'] $when,
- String $exec,
Optional[Variant[String, Array[String, 1]]] $depends = undef,
- Boolean $abortOnFail = false, # only for PreTransation
- Boolean $needsTargets = false,
- Variant[Pacman::Trigger, Array[Pacman::Trigger, 1]] $trigger,
+ Boolean $abort_on_fail = false, # only for PreTransation
+ Boolean $needs_targets = false,
) {
+ require pacman
- require ::pacman
-
- if ($abortOnFail and $when != 'PreTransation') {
- fail('abortOnFail only valid when "when" => "PreTransation"')
+ if ($abort_on_fail and $when != 'PreTransation') {
+ fail('abort_on_fail only valid when "when" => "PreTransation"')
}
# Normalize triggers to list
$triggers = ($trigger ? {
- Array => $trigger,
- default => [$trigger],
+ Array => $trigger,
+ default => [$trigger],
}).map |$trigger| {
# Normalize contents of each trigger, making
{
@@ -46,17 +56,17 @@ define pacman::hook (
}
$str = epp('pacman/hook.epp', {
- description => $description,
- depends => $depends ? {
- Optional => [],
- Array => $depends,
- default => [$depends],
- },
- triggers => $triggers,
- exec => $exec,
- when => $when,
- abortOnFail => $abortOnFail,
- needsTargets => $needsTargets,
+ description => $description,
+ depends => $depends ? {
+ Optional => [],
+ Array => $depends,
+ default => [$depends],
+ },
+ triggers => $triggers,
+ exec => $exec,
+ when => $when,
+ abort_on_fail => $abort_on_fail,
+ needs_targets => $needs_targets,
})
$chksum = $str.md5()
diff --git a/manifests/init.pp b/manifests/init.pp
index fb23328..4deaf9a 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,33 +1,54 @@
+# @summary Configures the Pacman package manager
+# @param hooks_path
+# Path for puppet added hooks
+# @param conf_path
+# Path for pacman configuration
+# @param ilovecandy
+# It's a secret to everybody.
+# @param parallel_downloads
+# @param mirrorlist
+# @param update
+# Should 'pacman -Sy' be run after changes to the configuration?
class pacman (
String $hooks_path = '/etc/pacman.d/hooks-puppet',
String $conf_path = '/etc/pacman.conf',
Boolean $ilovecandy = false,
+ Optional[Integer] $parallel_downloads = undef,
+ String $mirrorlist = "puppet:///modules/${module_name}/mirrorlist",
+ Boolean $update = false,
) {
+ $hooks_ = [$hooks_path]
+ $parallel_downloads_ = if versioncmp($facts['pacman-version'], '6.0.0') != -1 {
+ $parallel_downloads
+ } else {
+ false
+ }
- ini_setting { 'Pacman HookDir':
- path => $conf_path,
- section => 'options',
- setting => 'HookDir',
- value => $hooks_path,
+ concat { $conf_path:
+ ensure => present,
+ order => 'numeric',
+ backup => true,
+ }
+ if $update {
+ exec { 'pacman -Sy':
+ command => ['pacman', '-Sy'],
+ path => ['/bin', '/usr/bin'],
+ refreshonly => true,
+ subscribe => Concat[$conf_path],
+ }
}
- ini_setting { 'Pacman ILoveCandy':
- ensure => if ($ilovecandy) { present } else { absent },
- path => '/etc/pacman.conf',
- section => 'options',
- setting => 'ILoveCandy',
- key_val_separator => '',
- value => '',
+ concat::fragment { 'pacman.conf header':
+ target => $conf_path,
+ source => "puppet:///modules/${module_name}/header",
+ order => 0,
}
- if versioncmp($facts['pacman-version'], '6.0.0') >= 0 {
- ini_setting { 'Pacman parallel downloads':
- path => '/etc/pacman.conf',
- section => 'options',
- setting => 'ParallelDownloads',
- value => 8,
- }
+ concat::fragment { 'pacman.conf options':
+ target => $conf_path,
+ order => 1,
+ content => epp("${module_name}/pacman.conf.epp"),
}
file { $hooks_path:
@@ -37,8 +58,7 @@ class pacman (
}
file { '/etc/pacman.d/mirrorlist':
- ensure => present,
backup => true,
- source => 'puppet:///modules/pacman/mirrorlist',
+ source => $mirrorlist,
}
}
diff --git a/manifests/makepkg.pp b/manifests/makepkg.pp
index 789298a..2761caf 100644
--- a/manifests/makepkg.pp
+++ b/manifests/makepkg.pp
@@ -1,3 +1,50 @@
+# @summary Arch makepkg configuration
+#
+# Complete configuration of makepkg.conf(5)
+#
+# @param dlagents
+# @param vcsclients
+# @param carch
+# @param chost
+# @param cppflags
+# @param cflags
+# @param cxxflags
+# @param ldflags
+# @param rustflags
+# @param makeflags
+# @param debug_cflags
+# @param debug_cxxflags
+# @param debug_rustflags
+# @param buildenv
+# @param distcc_hosts
+# @param builddir
+# @param options
+# @param integrity_check
+# @param strip_binaries
+# @param strip_shared
+# @param strip_static
+# @param man_dirs
+# @param doc_dirs
+# @param purge_targets
+# @param dbgsrcdir
+# @param pkgdest
+# @param srcdest
+# @param srcpkgdest
+# @param logdest
+# @param packager
+# @param gpgkey
+# @param compressgz
+# @param compressbz2
+# @param compressxz
+# @param compresszst
+# @param compresslrz
+# @param compresslzo
+# @param compressz
+# @param compresslz4
+# @param compresslz
+# @param pkgext
+# @param srcext
+# @param pacman_auth
class pacman::makepkg (
# protocol: agent
Hash[String, String] $dlagents = {
@@ -49,13 +96,13 @@ class pacman::makepkg (
debug => false,
lto => false, # This is fairly new...
},
- Array[Pacman::ChecksumTypes] $integrity_check = [ 'sha256' ],
+ Array[Pacman::ChecksumTypes] $integrity_check = ['sha256'],
String $strip_binaries = '--strip-all',
String $strip_shared = '--strip-unneeded',
String $strip_static = '--strip-debug',
- Array[String] $man_dirs = [ '{usr{,/local}{,/share},opt/*}/{man,info}' ],
- Array[String] $doc_dirs = [ 'usr/{,local/}{,share/}{doc,gtk-doc}', 'opt/*/{doc,gtk-doc}' ],
- Array[String] $purge_targets = [ 'usr/{,share}/info/dir', '.packlist', '*.pod' ],
+ Array[String] $man_dirs = ['{usr{,/local}{,/share},opt/*}/{man,info}'],
+ Array[String] $doc_dirs = ['usr/{,local/}{,share/}{doc,gtk-doc}', 'opt/*/{doc,gtk-doc}'],
+ Array[String] $purge_targets = ['usr/{,share}/info/dir', '.packlist', '*.pod'],
String $dbgsrcdir = '/usr/src/debug',
Optional[String] $pkgdest = undef, # /home/packages
Optional[String] $srcdest = undef, # /home/soruces
diff --git a/manifests/repo.pp b/manifests/repo.pp
index 9d62417..8607853 100644
--- a/manifests/repo.pp
+++ b/manifests/repo.pp
@@ -1,29 +1,59 @@
+# @summary A Pacman repo
+#
+# @param ensure
+# @param repo_name
+# Name of repo, exposed to mirrorlists as $repo
+# @param siglevel
+# @param usage
+# @param include
+# A repolist to include, mutually exclusive with $server and $source
+# @param server
+# A direct server to use, mutually exclusive with $include and $source
+# @param source
+# A complete list of sources to pull from.
+# Should be a list of strings on the form "Include = ${include}" or
+# "Server = ${server}". Where include is a path to a mirrorlist, and
+# server is a direct url.
+#
+# Mutually exclusive with $include and $server.
define pacman::repo (
Enum['present', 'absent'] $ensure = 'present',
String $repo_name = $name,
- # String $include,
- String $server,
- String $sig_level,
+ Optional[Enum['Never', 'Optional', 'Required']] $siglevel = undef,
+ Optional[Enum['Sync', 'Search', 'Install', 'Upgrade', 'All']] $usage = undef,
+ Optional[String] $include = undef,
+ Optional[String] $server = undef,
+ Optional[Array[String,1]] $source = undef,
) {
- require ::pacman
+ require pacman
- # NOTE we don't trigger a package database refresh here, since
- # 'pacman -Sy' is strongly discouraged, while
- # 'pacman -Syu' does to much.
+ if $repo_name == 'local' {
+ fail('Repo name "local" is reserved by Pacman')
+ }
+
+ # Check that at mots one of the following are defined
+ # At least one is required, but that is checked bellow.
+ if [$include, $server, $source].filter |$x| { $x =~ NotUndef }.length > 1 {
+ fail('$include, $server, and $source mutually exclusive')
+ }
+
+ $source_ = if $source {
+ $source
+ } elsif $server {
+ ["Server = ${server}"]
+ } elsif $include {
+ ["Include = ${include}"]
+ } else {
+ fail('$source, $include, or $server required')
+ }
- ini_setting {
- default:
- ensure => $ensure,
- path => $::pacman::conf_path,
- section => $repo_name ,
- ;
- "Pacman repo [${repo_name}] server":
- setting => 'Server',
- value => $server ,
- ;
- "Pacman repo [${repo_name}] SigLevel":
- setting => 'SigLevel',
- value => $sig_level ,
- ;
+ concat::fragment { "pacman.conf - repo - ${repo_name}":
+ target => $pacman::conf_path,
+ content => epp("${module_name}/repo.epp", {
+ 'name' => $repo_name,
+ 'siglevel' => $siglevel,
+ 'usage' => $usage,
+ 'source' => $source_,
+ }),
}
}