summaryrefslogtreecommitdiffstats
path: root/t-func/deb-format.at
blob: 956100ce91bb488b5ed2c70aa2f10ca77265bba2 (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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
AT_TESTED([dpkg-deb])

AT_SETUP([dpkg-deb options])
AT_KEYWORDS([dpkg-deb command-line])
AT_CHECK([dpkg-deb --help], [], [ignore])
AT_CLEANUP

AT_SETUP([dpkg-deb .deb format])
AT_KEYWORDS([dpkg-deb deb])

DPKG_GEN_CONTROL([pkg-deb-format])
DPKG_MOD_CONTROL([pkg-deb-format],
                 [s/^Description:.*$/& - deb format support/])
AT_DATA([pkg-deb-format/file-templ], [test
])
AT_CHECK([
# Initialize the template package
mv pkg-deb-format pkg-templ
chmod -R u+w pkg-templ
find pkg-templ | xargs touch -t 197001010100.00
dpkg-deb --uniform-compression --root-owner-group -Znone -b pkg-templ >/dev/null

# Extract the base members
ar x pkg-templ.deb
gzip -c control.tar >control.tar.gz
gzip -c data.tar >data.tar.gz
xz -c control.tar >control.tar.xz
xz -c data.tar >data.tar.xz
bzip2 -c data.tar >data.tar.bz2
lzma -c data.tar >data.tar.lzma
touch _ignore
touch unknown
])

AT_CHECK([
# Test debian-binary with 2.x versions
cp pkg-templ.deb pkg-version-2x.deb
echo 2.999 >debian-binary
ar rc pkg-version-2x.deb debian-binary
ar t pkg-version-2x.deb
ar x pkg-templ.deb debian-binary
# XXX: Ideally we would have no need to strip trailing spaces.
dpkg-deb -I pkg-version-2x.deb | sed -e 's/ *$//'
], [], [debian-binary
control.tar
data.tar
 new Debian package, version 2.999.
 size 20674 bytes: control archive=10240 bytes.
     193 bytes,     7 lines      control
 Package: pkg-deb-format
 Version: 0.0-1
 Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
 Architecture: all
 Description: test package - deb format support
])

AT_CHECK([
# Test debian-binary with extra lines
cp pkg-templ.deb pkg-magic-extra.deb
echo "extra line" >>debian-binary
ar rc pkg-magic-extra.deb debian-binary
ar t pkg-magic-extra.deb
ar x pkg-templ.deb debian-binary
# XXX: Ideally we would have no need to strip trailing spaces.
dpkg-deb -I pkg-magic-extra.deb | sed -e 's/ *$//'
], [], [debian-binary
control.tar
data.tar
 new Debian package, version 2.0.
 size 20684 bytes: control archive=10240 bytes.
     193 bytes,     7 lines      control
 Package: pkg-deb-format
 Version: 0.0-1
 Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
 Architecture: all
 Description: test package - deb format support
])

AT_CHECK([
# Test missing debian-binary member
cp pkg-templ.deb pkg-missing-magic.deb
ar d pkg-missing-magic.deb debian-binary
ar t pkg-missing-magic.deb
dpkg-deb -I pkg-missing-magic.deb
], [2], [control.tar
data.tar
], [dpkg-deb: error: file 'pkg-missing-magic.deb' is not a Debian binary archive (try dpkg-split?)
])

AT_CHECK([
# Test missing control member
cp pkg-templ.deb pkg-missing-control.deb
ar d pkg-missing-control.deb control.tar
ar t pkg-missing-control.deb
dpkg-deb -I pkg-missing-control.deb
], [2], [debian-binary
data.tar
], [dpkg-deb: error: archive 'pkg-missing-control.deb' has premature member 'data.tar' before 'control.tar', giving up
])

AT_CHECK([
# Test missing data member
cp pkg-templ.deb pkg-missing-data.deb
ar d pkg-missing-data.deb data.tar
ar t pkg-missing-data.deb
dpkg-deb -c pkg-missing-data.deb
], [2], [debian-binary
control.tar
], [dpkg-deb: error: unexpected end of file in archive member header in pkg-missing-data.deb
])

AT_CHECK([
# Test mixed member (index 1)
cp pkg-templ.deb pkg-mixed-1-member.deb
ar ra debian-binary pkg-mixed-1-member.deb unknown
ar t pkg-mixed-1-member.deb
dpkg-deb -I pkg-mixed-1-member.deb
], [2], [debian-binary
unknown
control.tar
data.tar
], [dpkg-deb: error: archive 'pkg-mixed-1-member.deb' has premature member 'unknown' before 'control.tar', giving up
])

AT_CHECK([
# Test mixed member (index 2)
cp pkg-templ.deb pkg-mixed-2-member.deb
ar ra control.tar pkg-mixed-2-member.deb unknown
ar t pkg-mixed-2-member.deb
dpkg-deb -c pkg-mixed-2-member.deb
], [2], [debian-binary
control.tar
unknown
data.tar
], [dpkg-deb: error: archive 'pkg-mixed-2-member.deb' has premature member 'unknown' before 'data.tar', giving up
])

AT_CHECK([
# Test swapped control and data members
cp pkg-templ.deb pkg-swap-members.deb
ar ma data.tar pkg-swap-members.deb control.tar
ar t pkg-swap-members.deb
dpkg-deb -I pkg-swap-members.deb
], [2], [debian-binary
data.tar
control.tar
], [dpkg-deb: error: archive 'pkg-swap-members.deb' has premature member 'data.tar' before 'control.tar', giving up
])

AT_CHECK([
# Test extra member
cp pkg-templ.deb pkg-extra-member.deb
ar q pkg-extra-member.deb unknown
ar t pkg-extra-member.deb
# XXX: Ideally we would have no need to strip trailing spaces.
dpkg-deb -I pkg-extra-member.deb | sed -e 's/ *$//'
], [], [debian-binary
control.tar
data.tar
unknown
 new Debian package, version 2.0.
 size 20732 bytes: control archive=10240 bytes.
     193 bytes,     7 lines      control
 Package: pkg-deb-format
 Version: 0.0-1
 Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
 Architecture: all
 Description: test package - deb format support
])

AT_CHECK([
# Test _ member
cp pkg-templ.deb pkg-under-member.deb
ar ra debian-binary pkg-under-member.deb _ignore
ar t pkg-under-member.deb
# XXX: Ideally we would have no need to strip trailing spaces.
dpkg-deb -I pkg-under-member.deb | sed -e 's/ *$//'
], [], [debian-binary
_ignore
control.tar
data.tar
 new Debian package, version 2.0.
 size 20732 bytes: control archive=10240 bytes.
     193 bytes,     7 lines      control
 Package: pkg-deb-format
 Version: 0.0-1
 Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
 Architecture: all
 Description: test package - deb format support
])

AT_CHECK([
# Test data.tar.bad member
dd if=/dev/zero of=data.tar.bad bs=1K count=4 status=none
ar rc pkg-data-bad.deb debian-binary control.tar.gz data.tar.bad
ar t pkg-data-bad.deb
dpkg-deb -c pkg-data-bad.deb
], [2], [debian-binary
control.tar.gz
data.tar.bad
], [dpkg-deb: error: archive 'pkg-data-bad.deb' uses unknown compression for member 'data.tar.bad', giving up
])

AT_CHECK([
# Test control.tar member
ar rc pkg-control-none.deb debian-binary control.tar data.tar
ar t pkg-control-none.deb
# XXX: Ideally we would have no need to strip trailing spaces.
dpkg-deb -I pkg-control-none.deb | sed -e 's/ *$//'
], [], [debian-binary
control.tar
data.tar
 new Debian package, version 2.0.
 size 20672 bytes: control archive=10240 bytes.
     193 bytes,     7 lines      control
 Package: pkg-deb-format
 Version: 0.0-1
 Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
 Architecture: all
 Description: test package - deb format support
])

AT_CHECK([
# Test control.tar.xz member
ar rc pkg-control-xz.deb debian-binary control.tar.xz data.tar.xz
ar t pkg-control-xz.deb
dpkg-deb -c pkg-control-xz.deb
], [], [debian-binary
control.tar.xz
data.tar.xz
drwxr-xr-x root/root         0 1970-01-01 00:00 ./
-rw-r--r-- root/root         5 1970-01-01 00:00 ./file-templ
])

AT_CHECK([
# Test data.tar member
ar rc pkg-data-none.deb debian-binary control.tar.gz data.tar
ar t pkg-data-none.deb
dpkg-deb -c pkg-data-none.deb
], [], [debian-binary
control.tar.gz
data.tar
drwxr-xr-x root/root         0 1970-01-01 00:00 ./
-rw-r--r-- root/root         5 1970-01-01 00:00 ./file-templ
])

AT_CHECK([
# Test data.tar.gz member
ar rc pkg-data-gz.deb debian-binary control.tar.gz data.tar.gz
ar t pkg-data-gz.deb
dpkg-deb -c pkg-data-gz.deb
], [], [debian-binary
control.tar.gz
data.tar.gz
drwxr-xr-x root/root         0 1970-01-01 00:00 ./
-rw-r--r-- root/root         5 1970-01-01 00:00 ./file-templ
])

AT_CHECK([
# Test data.tar.xz member
ar rc pkg-data-xz.deb debian-binary control.tar.gz data.tar.xz
ar t pkg-data-xz.deb
dpkg-deb -c pkg-data-xz.deb
], [], [debian-binary
control.tar.gz
data.tar.xz
drwxr-xr-x root/root         0 1970-01-01 00:00 ./
-rw-r--r-- root/root         5 1970-01-01 00:00 ./file-templ
])

AT_CHECK([
# Test data.tar.bz2 member
ar rc pkg-data-bz2.deb debian-binary control.tar.gz data.tar.bz2
ar t pkg-data-bz2.deb
dpkg-deb -c pkg-data-bz2.deb
], [], [debian-binary
control.tar.gz
data.tar.bz2
drwxr-xr-x root/root         0 1970-01-01 00:00 ./
-rw-r--r-- root/root         5 1970-01-01 00:00 ./file-templ
])

AT_CHECK([
# Test data.tar.lzma member
ar rc pkg-data-lzma.deb debian-binary control.tar.gz data.tar.lzma
ar t pkg-data-lzma.deb
dpkg-deb -c pkg-data-lzma.deb
], [], [debian-binary
control.tar.gz
data.tar.lzma
drwxr-xr-x root/root         0 1970-01-01 00:00 ./
-rw-r--r-- root/root         5 1970-01-01 00:00 ./file-templ
])

AT_CHECK([
# Test non-uniform data.tar/control.tar member compression
ar rc pkg-mixed-comp.deb debian-binary control.tar.xz data.tar.gz
ar t pkg-mixed-comp.deb
# XXX: Ideally we would have no need to strip trailing spaces.
dpkg-deb -I pkg-mixed-comp.deb | sed -e 's/ *$//'
dpkg-deb -c pkg-mixed-comp.deb
], [], [debian-binary
control.tar.xz
data.tar.gz
 new Debian package, version 2.0.
 size 682 bytes: control archive=336 bytes.
     193 bytes,     7 lines      control
 Package: pkg-deb-format
 Version: 0.0-1
 Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
 Architecture: all
 Description: test package - deb format support
drwxr-xr-x root/root         0 1970-01-01 00:00 ./
-rw-r--r-- root/root         5 1970-01-01 00:00 ./file-templ
])

AT_CLEANUP