Commit | Line | Data |
---|---|---|
ff570659 WD |
1 | #! /bin/sh |
2 | ||
3 | # Copyright (C) 2003 by Wayne Davison <wayned@samba.org> | |
4 | ||
5 | # This program is distributable under the terms of the GNU GPL see | |
6 | # COPYING). | |
7 | ||
8 | # Test rsync handling of exclude/include directives. | |
9 | ||
10 | # Test some of the more obscure wildcard handling of exclude/include | |
11 | # processing. | |
12 | ||
13 | . $srcdir/testsuite/rsync.fns | |
14 | ||
15 | set -x | |
16 | ||
17 | # Build some files/dirs/links to copy | |
18 | ||
19 | fromdir="$scratchdir/from" | |
20 | todir="$scratchdir/to" | |
21 | chkdir="$scratchdir/chk" | |
22 | ||
23 | makepath "$fromdir/foo/down/to/you" | |
24 | makepath "$fromdir/bar/down/to/foo/too" | |
25 | makepath "$fromdir/mid/for/foo/and/that/is/who" | |
26 | echo kept >"$fromdir/foo/file1" | |
27 | echo removed >"$fromdir/foo/file2" | |
28 | echo keeper >"$fromdir/bar/down/to/foo/file1" | |
29 | echo gone >"$fromdir/bar/down/to/foo/file3" | |
30 | echo lost >"$fromdir/bar/down/to/foo/file4" | |
31 | echo smashed >"$fromdir/bar/down/to/foo/to" | |
32 | echo expunged >"$fromdir/mid/for/foo/extra" | |
33 | echo retained >"$fromdir/mid/for/foo/keep" | |
34 | ln -s too "$fromdir/bar/down/to/foo/sym" | |
35 | ||
36 | # Setup our test exclude/include file. | |
37 | ||
38 | # XXX comments reflect up-coming fixed behavior! | |
39 | excl="$scratchdir/exclude-from" | |
40 | cat >"$excl" <<EOF | |
41 | # If the second line of these two lines does anything, it's a bug. | |
42 | + **/bar | |
43 | - /bar | |
44 | # This should match against the whole path, not just the name. | |
45 | + foo**too | |
46 | # This should float at the end of the path. | |
47 | - foo/*/ | |
48 | # Test some normal excludes. Competing lines are paired. | |
49 | + t[o]/ | |
50 | - to | |
51 | + file4 | |
52 | - file[2-9] | |
53 | - /mid/for/foo/extra | |
54 | EOF | |
55 | ||
56 | # Create the chk dir with what we expect to be excluded | |
57 | checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir" | |
58 | ||
59 | # Ensure that the following removes will tweak the directory times. | |
60 | sleep 1 | |
61 | ||
62 | # XXX Note modified to work with current broken behavior (to be fixed soon!) | |
63 | rm -r "$chkdir"/foo/down | |
64 | #rm -r "$chkdir"/mid/for/foo/and | |
65 | rm "$chkdir"/foo/file[235-9] | |
66 | #rm "$chkdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo/file[235-9] | |
67 | rm -r "$chkdir"/bar # XXX | |
68 | rm "$chkdir"/mid/for/foo/extra | |
69 | ||
70 | # Make sure that the tweaked dirs times migrate back but nothing else. | |
71 | $RSYNC -av --include='*/' --exclude='*' "$chkdir/" "$fromdir/" | |
72 | ||
73 | # Now, test if rsync excludes the same files | |
74 | ||
75 | checkit "$RSYNC -avv --exclude-from=$excl \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir" | |
76 | ||
77 | exit 0 | |
78 | # last [] may have failed but if we get here then we've won |