1 # Function to do all of the configuration file migration work
6 # Usage: _clean_configs [-v] new_dir old_dir ...
8 # Across all the files in the new_dir and old_dir args, match
9 # names and pick the most recently modified version and leave
10 # this (same mode and modification date) in new_dir
12 # -v option is verbose mode for debugging
16 if [ $# -gt 0 -a X"$1" = "X-v" ]
24 echo >&2 "Usage: _clean_configs [-v] new_dir old_dir ..."
31 $verbose && echo >&2 + mkdir -p "$_new"
38 [ "$_dir" = "$_new" ] && continue
41 ( cd "$_dir" ; find . -type f -print ) \
42 | sed -e 's/^\.\///' \
46 if [ -f "$_new/$_file" ]
48 # file exists in both directories, pick the more
49 # recently modified one
51 _try=`find "$_dir/$_file" -newer "$_new/$_file" -print`
52 [ -n "$_try" ] && _want=true
58 _dest=`dirname $_new/$_file`
61 $verbose && >&2 echo + mkdir "$_dest"
64 $_verbose && echo >&2 + cp -p "$_dir/$_file" "$_new/$_file"
65 cp -p "$_dir/$_file" "$_new/$_file"