summaryrefslogtreecommitdiff
path: root/modules/pacman/manifests/hook.pp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/pacman/manifests/hook.pp')
-rw-r--r--modules/pacman/manifests/hook.pp80
1 files changed, 0 insertions, 80 deletions
diff --git a/modules/pacman/manifests/hook.pp b/modules/pacman/manifests/hook.pp
deleted file mode 100644
index f8478e6..0000000
--- a/modules/pacman/manifests/hook.pp
+++ /dev/null
@@ -1,80 +0,0 @@
-
-type Pacman::Operation = Enum['Install', 'Upgrade', 'Remove']
-# type Variant[Type, Array[Type, 1]] = Variant[Type, Array[Type, 1]]
-
-type Pacman::Trigger = Struct[{
- type => Enum['Path', 'Package'],
- operation => Variant[Pacman::Operation, Array[Pacman::Operation, 1]],
- target => Variant[String, Array[String, 1]],
-}]
-
-define pacman::hook (
- 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,
-) {
-
- require ::pacman
-
- if ($abortOnFail and $when != 'PreTransation') {
- fail('abortOnFail only valid when "when" => "PreTransation"')
- }
-
- # Normalize triggers to list
- $triggers = ($trigger ? {
- Array => $trigger,
- default => [$trigger],
- }).map |$trigger| {
- # Normalize contents of each trigger, making
- {
- type => $trigger['type'],
- operation => $trigger['operation'] ? {
- Array => $trigger['operation'],
- default => [$trigger['operation']],
- },
- target => $trigger['target'] ? {
- Array => $trigger['target'],
- default => [$trigger['target']],
- }
- }
- }
-
- $triggers.each |$trigger| {
- if $trigger['type'] == 'Path' {
- $trigger['target'].each |$target| {
- if $target[0] == '/' {
- fail("Target paths shouldn't start with '/' ${target} in trigger ${name}")
- }
- }
- }
- }
-
- $str = epp('pacman/hook.epp', {
- description => $description,
- depends => $depends ? {
- Optional => [],
- Array => $depends,
- default => [$depends],
- },
- triggers => $triggers,
- exec => $exec,
- when => $when,
- abortOnFail => $abortOnFail,
- needsTargets => $needsTargets,
- })
-
- $chksum = $str.md5()
-
- file { $chksum:
- ensure => 'present',
- content => $str,
- path => "${pacman::hooks_path}/${priority}-${name}.hook",
- checksum => 'md5',
- checksum_value => $chksum,
- }
-}