5 $0 FROM-DIR TO-DIR ENVIRONMENT
7 Copies files from one directory to another with possible
10 Files named FILE.spp will be transformed via the spp preprocessor
11 subject to environment definitions. Source FILE.copyimgspp results in
12 destination file FILE in the corresponding destination directory.
14 Files named FILE.copyimgsh are run as shell scripts in (i.e. via chdir)
15 the corresponding destination directory (and not copied).
17 First regular files are copied. Then transformations are preformed.
18 Finally, shell scripts are run.
26 FILTER=" -and -not -name '*~'";
27 FILTER="${FILTER} -and -not -name '.*~'";
28 FILTER="$FILTER -and -not -path '*/.git*'";
29 FILTER="$FILTER -and -not -path '*/.svn*'";
30 FILTER="$FILTER -and -not -path '*/.CVS*'";
32 FROM_FILES=`(cd $FROM_DIR; eval "find . -not -type d $FILTER")`;
33 FROM_DIRS=`(cd $FROM_DIR; eval "find . -type d $FILTER")`;
38 for f in $FROM_FILES; do
40 *.copyimgspp) SPP_FILES="$SPP_FILES $f" ;;
41 *.copyimgsh) SH_FILES="$SH_FILES $f" ;;
42 *) COPY_FILES="$COPY_FILES $f";;
46 # Make destination directories.
48 if [ "$FROM_DIRS" != "" ]; then
49 for d in $FROM_DIRS; do
55 if [ "$COPY_FILES" != "" ]; then
56 tar -cf - -C $FROM_DIR $COPY_FILES | tar --preserve-permissions -xf - -C $TO_DIR;
59 # Use spp to transform any spp files
60 if [ "$SPP_FILES" != "" ]; then
61 for f in $SPP_FILES; do
63 b=`basename $f .copyimgspp`;
66 spp -o $TO_DIR/$d/$b $FROM_DIR/$f || exit 1;
70 # Now that all files have been copied/created we run any shell scripts
71 ABS_FROM_DIR=`(cd $FROM_DIR; pwd)`;
72 if [ "$SH_FILES" != "" ]; then
73 # Allow directory to define some functions
74 if [ -f $FROM_DIR/copyimgsh-functions.sh ]; then
75 . $FROM_DIR/copyimgsh-functions.sh ;
77 for f in $SH_FILES; do
81 (cd $TO_DIR/$d; . $ABS_FROM_DIR/$d/$b) || exit 1;