diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-07-18 22:36:58 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-07-18 22:36:58 +0200 |
commit | d63fd52b0ab06bdbabe20c93191e8997f00cf4f0 (patch) | |
tree | 40c5b58f0ba540a9abca5270c7737100b66face7 /manifests | |
parent | Add way to manage pacman hooks. (diff) | |
download | pacman-d63fd52b0ab06bdbabe20c93191e8997f00cf4f0.tar.gz pacman-d63fd52b0ab06bdbabe20c93191e8997f00cf4f0.tar.xz |
Pacman hook paths shouldn't start with '/'.
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/hook.pp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/manifests/hook.pp b/manifests/hook.pp index 940ae5f..f8478e6 100644 --- a/manifests/hook.pp +++ b/manifests/hook.pp @@ -25,9 +25,33 @@ define pacman::hook ( fail('abortOnFail only valid when "when" => "PreTransation"') } - $triggers = $trigger ? { + # 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', { @@ -37,19 +61,7 @@ define pacman::hook ( Array => $depends, default => [$depends], }, - triggers => $triggers.map |$trigger| { - { - type => $trigger['type'], - operation => $trigger['operation'] ? { - Array => $trigger['operation'], - default => [$trigger['operation']], - }, - target => $trigger['target'] ? { - Array => $trigger['target'], - default => [$trigger['target']], - } - } - }, + triggers => $triggers, exec => $exec, when => $when, abortOnFail => $abortOnFail, |