From 0478d65d21f1de3b2abdb07027ef3a2f2c94ffb4 Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Tue, 26 Oct 2010 11:47:13 +0300 Subject: [PATCH] Added util::patch. --- util/manifests/init.pp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/util/manifests/init.pp b/util/manifests/init.pp index 2cd7d84..6bb5bb0 100644 --- a/util/manifests/init.pp +++ b/util/manifests/init.pp @@ -40,3 +40,35 @@ define util::extract::tar($source, $strip=0) { } } + + +# Apply patch. +# +# === Parameters +# +# $name: +# Destination directory. +# $source: +# Patch file. +# $strip: +# Remove the specified number of leading path elements. +# Defaults to 0. +# +# === Sample usage +# +# util::patch { "/usr/local/src/moin-1.8.8": +# strip => 1, +# source => "/usr/local/src/moin.patch", +# } +# +define util::patch($source, $strip=0) { + + exec { "patch-${name}-${source}": + path => "/bin:/usr/bin:/sbin:/usr/sbin", + cwd => "${name}", + command => "patch -N -t -p${strip} < ${source}", + onlyif => "patch --dry-run -N -t -p${strip} < ${source}", + require => [ File["${name}"], File["${source}"], ], + } + +}