summaryrefslogtreecommitdiffstats
path: root/test/setup.test
blob: 69725ec66a12dea51fa865374265f187f5e19cda (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
$ mkdir dir

$ echo 1 > dir/foo.orig
$ echo 2 > dir/foo
$ diff -u dir/foo.orig dir/foo > foo.diff
$ diff -u dir/foo.orig dir/foo > revert.diff
$ diff -u dir/foo.orig dir/foo > again.diff
$ mv dir/foo.orig dir/foo
$ tar cf - dir | gzip > dir.tar.gz
$ mkdir dir/patches
$ echo crap > dir/patches/foo.diff
$ tar cf - dir | gzip > dir_with_patches.tar.gz
$ rm -rf dir

$ cat > series
< # Source: dir.tar.gz
< # Patchdir: dir
< #
< foo.diff -p1
< revert.diff -p1 -R
< again.diff
$ quilt setup series
> Unpacking archive dir.tar.gz
$ cd dir
$ ls -l patches series | sed -e 's:.* -> ::'
> ..
> ../series
$ quilt push -qa
> Applying patch patches/foo.diff
> Applying patch patches/revert.diff
> Applying patch patches/again.diff
> Now at patch patches/again.diff
$ cd ..
$ rm -rf dir

# Quilt setup should happily ignore patches and .pc directories
$ mkdir .pc patches
$ quilt setup series
> Unpacking archive dir.tar.gz
$ rm -rf dir .pc patches

$ quilt setup -d other series
> Unpacking archive dir.tar.gz
$ cd other/dir
$ ls -l patches series | sed -e 's:.* -> ::'
> ../..
> ../../series
$ quilt push -qa
> Applying patch patches/foo.diff
> Applying patch patches/revert.diff
> Applying patch patches/again.diff
> Now at patch patches/again.diff
$ cd ../..
$ rm -rf other
$ mkdir dir1
$ mv series dir1
$ cd dir1
$ quilt setup -d ../other series
> File dir.tar.gz not found
$ quilt setup --sourcedir .. -d ../other series
> Unpacking archive ../dir.tar.gz
$ cd ../other/dir
$ ls -l patches series | sed -e 's:.* -> ::'
> ../..
> ../../dir1/series
$ quilt push -qa
> Applying patch patches/foo.diff
> Applying patch patches/revert.diff
> Applying patch patches/again.diff
> Now at patch patches/again.diff
$ cd ../..
$ rm -rf "dir"

# Now test the cases where the directory already exists, or the tarball
# contains a patches directory
$ cat > series_with_patches
< # Source: dir_with_patches.tar.gz
< # Patchdir: dir
< #
< foo.diff
$ mkdir dir
$ quilt setup series_with_patches
> Directory dir exists
$ rmdir dir
$ quilt setup series_with_patches
> Unpacking archive dir_with_patches.tar.gz
> Directory dir/patches exists
> Trying alternative patches and series names...
$ cd dir
$ ls -l quilt_patches quilt_series | sed -e 's:.* -> ::'
> ..
> ../series_with_patches
$ quilt push -qa
> Applying patch quilt_patches/foo.diff
> Now at patch quilt_patches/foo.diff
$ cd ..
$ rm -rf "dir"

# Now a basic test with space in dir name
$ mkdir "space [dir]"
$ echo 1 > "space [dir]/foo.orig"
$ echo 2 > "space [dir]/foo"
# Recent versions of GNU diff will quote such file names, but old versions
# of GNU patch do not support that, so strip the quotes
$ diff -u "space [dir]/foo.orig" "space [dir]/foo" | sed -e 's:"::g' > foo.diff
$ cp foo.diff revert.diff
$ cp foo.diff again.diff
$ mv "space [dir]/foo.orig" "space [dir]/foo"
$ tar cf - "space [dir]" | gzip > "space [dir].tar.gz"
$ rm -rf "space [dir]"
$ cat > series
< # Source: space [dir].tar.gz
< # Patchdir: space [dir]
< #
< foo.diff -p1
< revert.diff -p1 -R
< again.diff
$ quilt setup series
> Unpacking archive space [dir].tar.gz
$ cd space\ [dir]
$ ls -l patches series | sed -e 's:.* -> ::'
> ..
> ../series
$ quilt push -qa
> Applying patch patches/foo.diff
> Applying patch patches/revert.diff
> Applying patch patches/again.diff
> Now at patch patches/again.diff
$ cd ..
$ rm -rf "space [dir]"