]> gitweb.fluxo.info Git - puppet-concat.git/commitdiff
Parametrize warning message
authormartin f. krafft <madduck@madduck.net>
Mon, 4 Oct 2010 21:02:32 +0000 (23:02 +0200)
committerR.I.Pienaar <rip@devco.net>
Mon, 4 Oct 2010 21:46:18 +0000 (22:46 +0100)
The concat warn parameter can now be any string (and needs to include
the appropriate commenting character) and will then override the default
(which still gets printed when warn=>true).

Signed-off-by: martin f. krafft <madduck@madduck.net>
files/concatfragments.sh [changed mode: 0755->0644]
manifests/fragment.pp [changed mode: 0755->0644]
manifests/init.pp [changed mode: 0755->0644]
manifests/setup.pp [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 570853e..b486047
@@ -47,12 +47,12 @@ SORTARG="-z"
 
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
-while getopts "o:s:d:tnwf" options; do
+while getopts "o:s:d:tnw:f" options; do
        case $options in
                o ) OUTFILE=$OPTARG;;
                d ) WORKDIR=$OPTARG;;
                n ) SORTARG="-zn";;
-               w ) WARN="true";;
+               w ) WARNMSG="$OPTARG";;
                f ) FORCE="true";;
                t ) TEST="true";;
                * ) echo "Specify output file with -o and fragments directory with -d"
@@ -101,10 +101,10 @@ fi
 
 cd ${WORKDIR}
 
-if [ x${WARN} = "x" ]; then
-       cat /dev/null > "fragments.concat"
+if [ x${WARNMSG} = "x" ]; then
+       : > "fragments.concat"
 else
-       echo '# This file is managed by Puppet. DO NOT EDIT.' > "fragments.concat"
+       echo -e "$WARNMSG" > "fragments.concat"
 fi
 
 # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 41a65ba..b94411c
@@ -93,11 +93,18 @@ define concat($mode = 0644, $owner = "root", $group = "root", $warn = "false", $
     $version     = $concat::setup::majorversion
     $fragdir     = "${concatdir}/${safe_name}"
     $concat_name = "fragments.concat.out"
+    $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.'
 
     case $warn {
-       'true',true,yes,on: { $warnflag = "-w" }
-        'false',false,no,off: { $warnflag = "" }
-        default: { fail("Improper 'warn' value given to concat: $warn") }
+        'true',true,yes,on:   { $warnmsg = "$default_warn_message" }
+        'false',false,no,off: { $warnmsg = "" }
+        default:              { $warnmsg = "$warn" }
+    }
+
+    $warnmsg_escaped = regsubst($warnmsg, "'", "'\\\\''", 'G')
+    $warnflag = $warnmsg_escaped ? {
+        ''      => '',
+        default => "-w '$warnmsg_escaped'"
     }
 
     case $force {
old mode 100755 (executable)
new mode 100644 (file)