Remove the gnu parameter from concat
Previously, the concatfragments.sh script was would default to using GNU-specific flags for find, sort, and xargs. This necessitated explicit passing of a "gnu = false" parameter to the concat define in order to successfully run the script without GNU-specific flags when working with systems that do not by default include GNU versions of the utilities (solaris, for example). This commit modifies the concatfragments script such that GNU versions of the utilities are not needed at all. It does this while preserving the original use case for the GNU flags, which was to allow special characters (like spaces) in the filenames, which it accomplished by using GNU flags to separate fields using null characters instead of newlines. In order to preserve backwards-compatibility with existing puppet installations that make use of the "gnu = false" parameter, the parameter list for the concat define has not been changed. Rather, the gnu parameter is now deprecated and ignored.
This commit is contained in:
parent
30c96286c9
commit
81d5ee80f3
2 changed files with 20 additions and 31 deletions
|
@ -26,7 +26,6 @@
|
|||
# is generated by puppet
|
||||
# -f Enables the creation of empty output files when no fragments are found
|
||||
# -n Sort the output numerically rather than the default alpha sort
|
||||
# -g Do NOT use the GNU entensions to find, xargs and sort; might cause problems on suitably funky filenames
|
||||
#
|
||||
# the command:
|
||||
#
|
||||
|
@ -44,10 +43,7 @@ WORKDIR=""
|
|||
TEST=""
|
||||
FORCE=""
|
||||
WARN=""
|
||||
SORT1="-z"
|
||||
SORT2=""
|
||||
FINDARG="-print0"
|
||||
XARGSARG="-0"
|
||||
SORTARG=""
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
|
||||
|
@ -55,22 +51,19 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
|||
## http://nexenta.org/projects/site/wiki/Personalities
|
||||
unset SUN_PERSONALITY
|
||||
|
||||
while getopts "o:s:d:tnw:fg" options; do
|
||||
while getopts "o:s:d:tnw:f" options; do
|
||||
case $options in
|
||||
o ) OUTFILE=$OPTARG;;
|
||||
d ) WORKDIR=$OPTARG;;
|
||||
n ) SORT2="-n";;
|
||||
n ) SORTARG="-n";;
|
||||
w ) WARNMSG="$OPTARG";;
|
||||
f ) FORCE="true";;
|
||||
t ) TEST="true";;
|
||||
g ) FINDARG="" ; XARGSARG="" ; SORT1="" ;;
|
||||
* ) echo "Specify output file with -o and fragments directory with -d"
|
||||
exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
SORTARG="$SORT1 $SORT2"
|
||||
|
||||
# do we have -o?
|
||||
if [ x${OUTFILE} = "x" ]; then
|
||||
echo "Please specify an output file with -o"
|
||||
|
@ -119,7 +112,9 @@ else
|
|||
fi
|
||||
|
||||
# find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir
|
||||
find fragments/ -type f -follow $FINDARG |sort ${SORTARG}|xargs $XARGSARG cat >>"fragments.concat"
|
||||
find fragments/ -type f -follow | sort ${SORTARG} | while read fragfile; do
|
||||
cat "$fragfile" >> "fragments.concat"
|
||||
done
|
||||
|
||||
if [ x${TEST} = "x" ]; then
|
||||
# This is a real run, copy the file to outfile
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
# ALIASES:
|
||||
# - The exec can notified using Exec["concat_/path/to/file"] or Exec["concat_/path/to/directory"]
|
||||
# - The final file can be referened as File["/path/to/file"] or File["concat_/path/to/file"]
|
||||
define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group, $warn = "false", $force = "false", $backup = "puppet", $gnu = "true", $order="alpha") {
|
||||
define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group, $warn = "false", $force = "false", $backup = "puppet", $gnu = undef, $order="alpha") {
|
||||
$safe_name = regsubst($name, '/', '_', 'G')
|
||||
$concatdir = $concat::setup::concatdir
|
||||
$version = $concat::setup::majorversion
|
||||
|
@ -113,12 +113,6 @@ define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group,
|
|||
default: { fail("Improper 'force' value given to concat: $force") }
|
||||
}
|
||||
|
||||
case $gnu {
|
||||
'true',true,yes,on: { $gnuflag = "" }
|
||||
'false',false,no,off: { $gnuflag = "-g" }
|
||||
default: { fail("Improper 'gnu' value given to concat: $gnu") }
|
||||
}
|
||||
|
||||
case $order {
|
||||
numeric: { $orderflag = "-n" }
|
||||
alpha: { $orderflag = "" }
|
||||
|
@ -168,8 +162,8 @@ define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group,
|
|||
subscribe => File[$fragdir],
|
||||
alias => "concat_${fragdir}",
|
||||
require => [ File[$fragdir], File["${fragdir}/fragments"], File["${fragdir}/fragments.concat"] ],
|
||||
unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag} ${gnuflag}",
|
||||
command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${gnuflag}",
|
||||
unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag}",
|
||||
command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag}",
|
||||
}
|
||||
if $::id == 'root' {
|
||||
Exec["concat_${name}"]{
|
||||
|
|
Loading…
Reference in a new issue