From f07d6a8e6fc7bb2507f96fd5f8f500727029e2b0 Mon Sep 17 00:00:00 2001 From: Ossi Herrala Date: Tue, 30 Apr 2013 11:43:14 +0000 Subject: [PATCH] Add support to extract only specified pattern of files from tar archive. --- util/manifests/init.pp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/util/manifests/init.pp b/util/manifests/init.pp index 84d7995..aaed088 100644 --- a/util/manifests/init.pp +++ b/util/manifests/init.pp @@ -14,6 +14,10 @@ # $preserve: # Preserve owner and permissions. Defaults to false. # +# $pattern: +# The pathnames or shell-style globbing patterns indicate which +# items in the archive should be processed. +# # === Sample usage # #util::extract::tar { "/usr/local/src/moin-1.8.8": @@ -21,7 +25,7 @@ # source => "/usr/local/src/moin-1.8.8.tar.gz", #} # -define util::extract::tar($source, $ensure=present, $strip=0, $preserve=false) { +define util::extract::tar($source, $ensure=present, $strip=0, $preserve=false, $pattern="") { include gnu::tar @@ -59,9 +63,9 @@ define util::extract::tar($source, $ensure=present, $strip=0, $preserve=false) { } if $preserve { - $command = "/bin/sh -c 'umask 022; ${cat} ${source} | ${tar} xf - --strip-components=${strip} -C ${name}'" + $command = "/bin/sh -c 'umask 022; ${cat} ${source} | ${tar} xf - --strip-components=${strip} -C ${name} ${pattern}'" } else { - $command = "/bin/sh -c 'umask 022; ${cat} ${source} | ${tar} xf - --strip-components=${strip} -C ${name} --no-same-owner --no-same-permissions'" + $command = "/bin/sh -c 'umask 022; ${cat} ${source} | ${tar} xf - --strip-components=${strip} -C ${name} ${pattern} --no-same-owner --no-same-permissions'" } exec { "tar-extract-${name}":