From 739dd06c9c90ce00d1bc7f6dea91aa1723da40d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 18 Jul 2021 22:36:58 +0200 Subject: Pacman hook paths shouldn't start with '/'. --- modules/pacman/manifests/hook.pp | 40 ++++++++++++++-------- .../profiles/manifests/workstation/archlinux.pp | 2 +- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/modules/pacman/manifests/hook.pp b/modules/pacman/manifests/hook.pp index 940ae5f..f8478e6 100644 --- a/modules/pacman/manifests/hook.pp +++ b/modules/pacman/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, diff --git a/modules/profiles/manifests/workstation/archlinux.pp b/modules/profiles/manifests/workstation/archlinux.pp index 29ef380..8534da0 100644 --- a/modules/profiles/manifests/workstation/archlinux.pp +++ b/modules/profiles/manifests/workstation/archlinux.pp @@ -21,7 +21,7 @@ class profiles::workstation::archlinux { trigger => { operation => 'Upgrade', type => 'Path', - target => '/usr/lib/systemd/user/*', + target => 'usr/lib/systemd/user/*', }, } } -- cgit v1.2.3