diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
commit | 47e6e7c84f008a53061e661f31ae96629bc694ef (patch) | |
tree | 648a07f3b5b9d67ce19b0fd72e8caa1175c98f1a /build/cleanconfigs | |
download | pcp-47e6e7c84f008a53061e661f31ae96629bc694ef.tar.gz |
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'build/cleanconfigs')
-rw-r--r-- | build/cleanconfigs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/build/cleanconfigs b/build/cleanconfigs new file mode 100644 index 0000000..e9c539d --- /dev/null +++ b/build/cleanconfigs @@ -0,0 +1,71 @@ +# Function to do all of the configuration file migration work +# +_clean_configs() +{ + # + # Usage: _clean_configs [-v] new_dir old_dir ... + # + # Across all the files in the new_dir and old_dir args, match + # names and pick the most recently modified version and leave + # this (same mode and modification date) in new_dir + # + # -v option is verbose mode for debugging + # + + _verbose=false + if [ $# -gt 0 -a X"$1" = "X-v" ] + then + _verbose=true + shift + fi + + if [ $# -lt 2 ] + then + echo >&2 "Usage: _clean_configs [-v] new_dir old_dir ..." + return + fi + + _new="$1" + if [ ! -d "$_new" ] + then + $verbose && echo >&2 + mkdir -p "$_new" + mkdir -p "$_new" + fi + + shift + for _dir + do + [ "$_dir" = "$_new" ] && continue + if [ -d "$_dir" ] + then + ( cd "$_dir" ; find . -type f -print ) \ + | sed -e 's/^\.\///' \ + | while read _file + do + _want=false + if [ -f "$_new/$_file" ] + then + # file exists in both directories, pick the more + # recently modified one + # + _try=`find "$_dir/$_file" -newer "$_new/$_file" -print` + [ -n "$_try" ] && _want=true + else + _want=true + fi + if $_want + then + _dest=`dirname $_new/$_file` + if [ ! -d "$_dest" ] + then + $verbose && >&2 echo + mkdir "$_dest" + mkdir "$_dest" + fi + $_verbose && echo >&2 + cp -p "$_dir/$_file" "$_new/$_file" + cp -p "$_dir/$_file" "$_new/$_file" + fi + done + fi + done +} + |