add a -g flag to concatfragments.sh to disable GNU extensions to find, sort and xargs; makes concat work on Solaris.
Add a $gnu parameter to make use of the aforementioned -g flag, and a $order parameter to make use of the -n flag in concatfragments.sh
This commit is contained in:
parent
40245d9fcc
commit
fa80fc2b31
2 changed files with 25 additions and 6 deletions
|
@ -26,6 +26,7 @@
|
|||
# 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:
|
||||
#
|
||||
|
@ -43,7 +44,10 @@ WORKDIR=""
|
|||
TEST=""
|
||||
FORCE=""
|
||||
WARN=""
|
||||
SORTARG="-z"
|
||||
SORT1="-z"
|
||||
SORT2=""
|
||||
FINDARG="-print0"
|
||||
XARGSARG="-0"
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
|
||||
|
@ -51,15 +55,18 @@ while getopts "o:s:d:tnw:f" options; do
|
|||
case $options in
|
||||
o ) OUTFILE=$OPTARG;;
|
||||
d ) WORKDIR=$OPTARG;;
|
||||
n ) SORTARG="-zn";;
|
||||
n ) SORT2="-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"
|
||||
|
@ -108,7 +115,7 @@ 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 -print0 |sort ${SORTARG}|xargs -0 cat >>"fragments.concat"
|
||||
find fragments/ -type f -follow $FINDARG |sort ${SORTARG}|xargs $XARGSARG cat >>"fragments.concat"
|
||||
|
||||
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 = "root", $group = "root", $warn = "false", $force = "false", $backup = "puppet") {
|
||||
define concat($mode = 0644, $owner = "root", $group = "root", $warn = "false", $force = "false", $backup = "puppet", $gnu = "true", $order="alpha") {
|
||||
$safe_name = regsubst($name, '/', '_', 'G')
|
||||
$concatdir = $concat::setup::concatdir
|
||||
$version = $concat::setup::majorversion
|
||||
|
@ -113,6 +113,18 @@ define concat($mode = 0644, $owner = "root", $group = "root", $warn = "false", $
|
|||
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 = "" }
|
||||
default: { fail("Improper 'order' value given to concat: $order") }
|
||||
}
|
||||
|
||||
File{
|
||||
owner => root,
|
||||
group => root,
|
||||
|
@ -158,7 +170,7 @@ define concat($mode = 0644, $owner = "root", $group = "root", $warn = "false", $
|
|||
subscribe => File[$fragdir],
|
||||
alias => "concat_${fragdir}",
|
||||
require => [ File["/usr/local/bin/concatfragments.sh"], File[$fragdir], File["${fragdir}/fragments"], File["${fragdir}/fragments.concat"] ],
|
||||
unless => "/usr/local/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag}",
|
||||
command => "/usr/local/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag}",
|
||||
unless => "/usr/local/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag} ${gnuflag}",
|
||||
command => "/usr/local/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${gnuflag}",
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue