summaryrefslogtreecommitdiffstats
path: root/tests/packagediff.test
blob: c726beaa4a69317b0fcfd07be29958e59bbb0ff2 (plain)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
set -u
. "$TESTSDIR"/test.inc

mkdir conf db pool fakes old
mkdir -p dists/sourcedistribution/main/binary-coal

cp "$SRCDIR/docs/pdiff.example" conf/pdiff.py
cat > conf/distributions <<EOF
Codename: sourcedistribution
Architectures: coal
Components: main
DebIndices: Packages Release . pdiff.py

Codename: test
Architectures: coal
Components: main
Update: fromsource
EOF

testrun - -b . export sourcedistribution 3<<EOF
stdout
-v1*=Exporting sourcedistribution...
-v6*= exporting 'sourcedistribution|main|coal'...
-v6*=  creating './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
EOF

dodo test -f dists/sourcedistribution/main/binary-coal/Packages
dodo test -f dists/sourcedistribution/main/binary-coal/Release
dodo test \! -e dists/sourcedistribution/main/binary-coal/Packages.diff

testrun - -b . _addpackage sourcedistribution fakes/1 a  3<<EOF
stderr
*=_addpackage needs -C and -A and -T set!
-v0*=There have been errors!
returns 255
EOF

testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a  3<<EOF
stderr
*=Error 2 opening 'fakes/1': No such file or directory!
-v0*=There have been errors!
return 254
EOF

touch fakes/1

# TODO: getting a warning here would be nice...
testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a  3<<EOF
EOF
testrun - --nothingiserror -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a  3<<EOF
returns 1
EOF

cat > fakes/1 <<EOF
Package: 5dchess
Priority: extra
Section: games
Installed-Size: 400000
Maintainer: test <nobody@nowhere>
Architecture: coal
Version: 0.0-1
Filename: pool/main/5/5dchess/5dchess_0.0-1_coal.deb
MD5sum: $EMPTYMD5ONLY
Size: 0
Description: the lazy fox
 jumps over the quick brown dog.

Package: a
Priority: critical
Section: required
Installed-Size: 1
Maintainer: test <nobody@nowhere>
Architecture: all
Version: 1
Filename: pool/main/a/a/a_1_all.deb
MD5sum: $EMPTYMD5ONLY
Size: 0
Description: the lazy fox
 jumps over the quick brown dog.

Package: b
Source: baa
Priority: critical
Section: required
Installed-Size: 1
Maintainer: test <nobody@nowhere>
Architecture: coal
Version: 2
Filename: pool/main/b/baa/b_2_coal.deb
MD5sum: $EMPTYMD5ONLY
Size: 0
Description: the lazy fox
 jumps over the quick brown dog.
EOF

cat > fakes/2 <<EOF
Package: a
Priority: critical
Section: required
Installed-Size: 2
Maintainer: test <nobody@nowhere>
Architecture: all
Version: 2
Filename: pool/main/a/a/a_2_all.deb
MD5sum: $EMPTYMD5ONLY
Size: 0
Description: the lazy fox
 jumps over the quick brown dog.
EOF

testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a  3<<EOF
*=Error: package a version 1 lists file pool/main/a/a/a_1_all.deb not yet in the pool!
-v0*=There have been errors!
returns 249
EOF

cat > addchecksums.rules <<EOF
stdout
$(ofa 'pool/main/a/a/a_1_all.deb')
$(ofa 'pool/main/a/a/a_2_all.deb')
$(ofa 'pool/main/b/baa/b_2_coal.deb')
$(ofa 'pool/main/5/5dchess/5dchess_0.0-1_coal.deb')
-v0*=4 files were added but not used.
-v0*=The next deleteunreferenced call will delete them.
EOF

testrun addchecksums -b . _addchecksums <<EOF
pool/main/b/baa/b_2_coal.deb $EMPTYMD5
pool/main/a/a/a_1_all.deb $EMPTYMD5
pool/main/a/a/a_2_all.deb $EMPTYMD5
pool/main/5/5dchess/5dchess_0.0-1_coal.deb $EMPTYMD5
EOF

testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a  3<<EOF
stdout
-v1*=Adding 'a' '1' to 'sourcedistribution|main|coal'.
$(opa 'a' x 'sourcedistribution' 'main' 'coal' 'deb')
-v0*=Exporting indices...
-v6*= looking for changes in 'sourcedistribution|main|coal'...
-v6*=  replacing './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
=making diffs between ./dists/sourcedistribution/main/binary-coal/Packages and ./dists/sourcedistribution/main/binary-coal/Packages.new: 
=generating diff
EOF
sleep 1
testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 5dchess  3<<EOF
stdout
-v1*=Adding '5dchess' '0.0-1' to 'sourcedistribution|main|coal'.
$(opa '5dchess' x 'sourcedistribution' 'main' 'coal' 'deb')
-v0*=Exporting indices...
-v6*= looking for changes in 'sourcedistribution|main|coal'...
-v6*=  replacing './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
=making diffs between ./dists/sourcedistribution/main/binary-coal/Packages and ./dists/sourcedistribution/main/binary-coal/Packages.new: 
=generating diff
=This was too fast, diffile already there, waiting a bit...
EOF
sleep 1
cp dists/sourcedistribution/main/binary-coal/Packages old/1
testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/2 a 3<<EOF
stderr
*=./pool/main/a/a/a_1_all.deb not found, forgetting anyway
stdout
-v1*=Adding 'a' '2' to 'sourcedistribution|main|coal'.
$(opu 'a' x x 'sourcedistribution' 'main' 'coal' 'deb')
-v0*=Exporting indices...
-v6*= looking for changes in 'sourcedistribution|main|coal'...
-v6*=  replacing './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
=making diffs between ./dists/sourcedistribution/main/binary-coal/Packages and ./dists/sourcedistribution/main/binary-coal/Packages.new: 
=generating diff
=This was too fast, diffile already there, waiting a bit...
-v0*=Deleting files no longer referenced...
$(ofd 'pool/main/a/a/a_1_all.deb')
EOF
cp dists/sourcedistribution/main/binary-coal/Packages old/2
sleep 1
testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 b 3<<EOF
stdout
-v1*=Adding 'b' '2' to 'sourcedistribution|main|coal'.
$(opa 'b' x 'sourcedistribution' 'main' 'coal' 'deb')
-v0*=Exporting indices...
-v6*= looking for changes in 'sourcedistribution|main|coal'...
-v6*=  replacing './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
=making diffs between ./dists/sourcedistribution/main/binary-coal/Packages and ./dists/sourcedistribution/main/binary-coal/Packages.new: 
=generating diff
=This was too fast, diffile already there, waiting a bit...
EOF

dodo test -f dists/sourcedistribution/main/binary-coal/Packages
dodo test -f dists/sourcedistribution/main/binary-coal/Release
dodo test -d dists/sourcedistribution/main/binary-coal/Packages.diff
dodo test -f dists/sourcedistribution/main/binary-coal/Packages.diff/Index
testrun empty -b . dumpunreferenced

# now update from that one....
cat > conf/updates <<EOF
Name: fromsource
Suite: sourcedistribution
VerifyRelease: blindtrust
GetInRelease: no
DownloadListsAs: .diff
Method: file:$WORKDIR
EOF
mkdir lists
mkdir -p dists/test/main/binary-coal

cp old/2 lists/fromsource_sourcedistribution_main_coal_Packages

diffname="$(grep "^ $(sha1 old/2)" dists/sourcedistribution/main/binary-coal/Packages.diff/Index | sed -e 's/.* //')"

testrun - -b . update test 3<<EOF
stderr
-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/Release'
-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/Release'
-v2*=Copy file '$WORKDIR/dists/sourcedistribution/Release' to './lists/fromsource_sourcedistribution_Release'...
-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index'
-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index'
-v2*=Copy file '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index' to './lists/fromsource_sourcedistribution_main_coal_Packages.diffindex'...
-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz'
-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz'
-v2*=Uncompress '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz' into './lists/fromsource_sourcedistribution_main_coal_Packages.diff-${diffname}' using '/bin/gunzip'...
stdout
-v0*=Calculating packages to get...
-v3*=  processing updates for 'test|main|coal'
-v5*=  reading './lists/fromsource_sourcedistribution_main_coal_Packages'
-v0*=Getting packages...
-v1*=Shutting down aptmethods...
-v0*=Installing (and possibly deleting) packages...
$(opa '5dchess' x 'test' 'main' 'coal' 'deb')
$(opa 'a' x 'test' 'main' 'coal' 'deb')
$(opa 'b' x 'test' 'main' 'coal' 'deb')
-v0*=Exporting indices...
-v6*= looking for changes in 'test|main|coal'...
-v6*=  creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
EOF

dodiff dists/sourcedistribution/main/binary-coal/Packages lists/fromsource_sourcedistribution_main_coal_Packages

cp old/1 lists/fromsource_sourcedistribution_main_coal_Packages

diffname2="$(grep "^ $(sha1 old/1)" dists/sourcedistribution/main/binary-coal/Packages.diff/Index | sed -e 's/.* //')"
testrun - --noskipold -b . update test 3<<EOF
stderr
-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/Release'
-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/Release'
-v2*=Copy file '$WORKDIR/dists/sourcedistribution/Release' to './lists/fromsource_sourcedistribution_Release'...
-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index'
-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index'
-v2*=Copy file '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index' to './lists/fromsource_sourcedistribution_main_coal_Packages.diffindex'...
-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname2}.gz'
-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname2}.gz'
-v2*=Uncompress '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname2}.gz' into './lists/fromsource_sourcedistribution_main_coal_Packages.diff-${diffname2}' using '/bin/gunzip'...
-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz'
-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz'
-v2*=Uncompress '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz' into './lists/fromsource_sourcedistribution_main_coal_Packages.diff-${diffname}' using '/bin/gunzip'...
stdout
-v0*=Calculating packages to get...
-v3*=  processing updates for 'test|main|coal'
-v5*=  reading './lists/fromsource_sourcedistribution_main_coal_Packages'
EOF

dodiff dists/sourcedistribution/main/binary-coal/Packages lists/fromsource_sourcedistribution_main_coal_Packages

# Check without DownLoadListsAs and not index file
cat > conf/updates <<EOF
Name: fromsource
Suite: sourcedistribution
GetInRelease: no
VerifyRelease: blindtrust
Method: file:$WORKDIR
EOF
rm -r lists
mkdir lists
testrun - --noskipold -b . update test 3<<EOF
stderr
-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/Release'
-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/Release'
-v2*=Copy file '$WORKDIR/dists/sourcedistribution/Release' to './lists/fromsource_sourcedistribution_Release'...
-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages'
-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages'
-v2*=Copy file '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages' to './lists/fromsource_sourcedistribution_main_coal_Packages'...
stdout
-v0*=Calculating packages to get...
-v3*=  processing updates for 'test|main|coal'
-v5*=  reading './lists/fromsource_sourcedistribution_main_coal_Packages'
EOF

rm -r conf dists pool db fakes addchecksums.rules old lists
testsuccess