3 # Test logic for config file migration, harvesting, cleanup as
4 # part of a packaged install.
6 # Copyright (c) 2012 Ken McDonell. All Rights Reserved.
10 echo "QA output created by $seq"
12 # get standard environment, filters and checks
17 status
=1 # failure is the default!
18 $sudo rm -rf $tmp.
* $seq.full
19 trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
21 # ... copied directly from ../debian/cleanconfigs
24 # Function to do all of the configuration file migration work
29 # Usage: _clean_configs [-v] new_dir old_dir ...
31 # Across all the files in the new_dir and old_dir args, match
32 # names and pick the most recently modified version and leave
33 # this (same mode and modification date) in new_dir
35 # -v option is verbose mode for debugging
39 if [ $# -gt 0 -a X
"$1" = "X-v" ]
47 echo >&2 "Usage: _clean_configs [-v] new_dir old_dir ..."
54 $verbose && echo >&2 + mkdir
-p "$_new"
61 [ "$_dir" = "$_new" ] && continue
64 ( cd "$_dir" ; find .
-type f
-print ) \
65 |
sed -e 's/^\.\///' \
69 if [ -f "$_new/$_file" ]
71 # file exists in both directories, pick the more
72 # recently modified one
74 _try
=`find "$_dir/$_file" -newer "$_new/$_file" -print`
75 [ -n "$_try" ] && _want
=true
81 _dest
=`dirname $_new/$_file`
84 $verbose && >&2 echo + mkdir
"$_dest"
87 $_verbose && echo >&2 + cp -p "$_dir/$_file" "$_new/$_file"
88 cp -p "$_dir/$_file" "$_new/$_file"
100 | LC_COLLATE
=POSIX
sort
109 $PCP_ECHO_PROG $PCP_ECHO_N "$x: ""$PCP_ECHO_C"
115 # real QA test starts here
116 echo "Usage cases ..."
118 _clean_configs
"one_arg"
119 _clean_configs
-v "-v+one_arg"
121 echo; echo "No dirs exist"
122 _clean_configs
-v $tmp.new old1 old2
2>&1 | _filter
124 echo; echo "Empty new dir, harvest all, no name matches"
127 echo foo
>$tmp.old
1/foo
128 echo bar
>$tmp.old
1/bar
129 echo mumble
>$tmp.old
2/mumble
130 echo fumble
>$tmp.old
2/fumble
131 echo stumble
>$tmp.old
2/stumble
132 _clean_configs
-v $tmp.new
$tmp.old1
$tmp.old2
2>&1 | _filter
135 yesterday
=`pmdate -1d %Y%m%d%H%M`
136 echo; echo "All names match, some older files"
137 touch -t $yesterday $tmp.new
/mumble
138 echo "newer mumble" >$tmp.old
2/mumble
139 touch -t $yesterday $tmp.old
1/bar
140 echo "newer bar" >$tmp.new
/bar
141 _clean_configs
-v $tmp.new
$tmp.old1
$tmp.old2
2>&1 | _filter
144 echo; echo "Hybid cases"
145 echo "older bar" >$tmp.old
2/bar
146 touch -t $yesterday $tmp.old
2/bar
148 echo "older foo" >$tmp.old
1/foo
149 touch -t $yesterday $tmp.old
1/foo
150 echo foo
>$tmp.old
2/foo
152 _clean_configs
-v $tmp.new
$tmp.old1
$tmp.old2
2>&1 | _filter