fix msm-plugin.c svace issue: make sure dupPath is not NULL before strchr()
[platform/upstream/rpm.git] / tests / rpmbuild.at
1 #    rpmbuild.at: test rpmbuild
2 #
3 #    Copyright (C) 2007  Ralf Corsépius <corsepiu@fedoraproject.org>
4 #
5 #    This program is free software; you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License as published by
7 #    the Free Software Foundation; either version 2 of the License, or
8 #    (at your option) any later version.
9 #
10 #    This program is distributed in the hope that it will be useful,
11 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #    GNU General Public License for more details.
14 #
15 #    You should have received a copy of the GNU General Public License
16 #    along with this program; if not, write to the Free Software
17 #    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
19 AT_BANNER([RPM build])
20
21 # ------------------------------
22 # Check if rpmbuild -ba *.spec works
23 AT_SETUP([rpmbuild -ba *.spec])
24 AT_KEYWORDS([build])
25 AT_CHECK([
26 rm -rf ${TOPDIR}
27 AS_MKDIR_P(${TOPDIR}/SOURCES)
28
29 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
30
31 run rpmbuild \
32   -ba "${abs_srcdir}"/data/SPECS/hello.spec
33 ],
34 [0],
35 [ignore],
36 [ignore])
37 AT_CLEANUP
38
39 # ------------------------------
40 # Check if rpmbuild --rebuild *.src.rpm works
41 AT_SETUP([rpmbuild --rebuild])
42 AT_KEYWORDS([build])
43 AT_CHECK([
44 rm -rf ${TOPDIR}
45
46 run rpmbuild \
47   --rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
48 ],
49 [0],
50 [ignore],
51 [ignore])
52 AT_CLEANUP
53
54 AT_SETUP([rpmbuild --short-circuit -bl])
55 AT_KEYWORDS([build])
56 AT_CHECK([
57 rm -rf ${TOPDIR}
58 AS_MKDIR_P(${TOPDIR}/SOURCES)
59
60 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
61
62 run rpmbuild -bi "${abs_srcdir}"/data/SPECS/hello.spec &> /dev/null
63 run rpmbuild --quiet -bl --short-circuit "${abs_srcdir}"/data/SPECS/hello.spec
64 ],
65 [0],
66 [],
67 [])
68 AT_CLEANUP
69
70 # ------------------------------
71 # Check if tar unpacking works
72 AT_SETUP([rpmbuild -tb <tar with bad spec>])
73 AT_KEYWORDS([build])
74 AT_CHECK([
75 rm -rf ${TOPDIR}
76
77 run rpmbuild \
78   -tb "${RPMDATA}/SOURCES/hello-1.0.tar.gz"
79 ],
80 [1],
81 [ignore],
82 [error: line 5: Unknown tag: Serial:    1
83 ])
84 AT_CLEANUP
85
86 # ------------------------------
87 # Check if tar build works
88 # TODO: test that the rpms are actually created...
89 AT_SETUP([rpmbuild -tb])
90 AT_KEYWORDS([build])
91 AT_CHECK([
92 rm -rf ${TOPDIR}
93
94 run rpmbuild \
95   -ta "${RPMDATA}/SOURCES/hello-2.0.tar.gz"
96 ],
97 [0],
98 [ignore],
99 [ignore])
100 AT_CLEANUP
101
102 # ------------------------------
103 # %attr/%defattr tests
104 AT_SETUP([rpmbuild %attr and %defattr])
105 AT_KEYWORDS([build])
106 AT_CHECK([[
107 rm -rf ${TOPDIR}
108
109 runroot rpmbuild \
110   -bb --quiet /data/SPECS/attrtest.spec
111
112 runroot rpm -qp --qf \
113   "\n[%{filemodes:perms} %-8{fileusername} %-8{filegroupname} %{filenames}\n]"\
114   /build/RPMS/noarch/attrtest-1.0-1.noarch.rpm
115 ]],
116 [0],
117 [
118 drwx------ root     root     /a/dir
119 -r-------- root     root     /a/file
120 drwx------ daemon   adm      /b/dir
121 -r-------- daemon   adm      /b/file
122 drwxr-x--- root     adm      /c/dir
123 -rw-r----- daemon   root     /c/file
124 drwxr-x--x daemon   bin      /d/dir
125 -rw-r--r-- bin      daemon   /d/file
126 drwx------ foo      bar      /e/dir
127 -r-------- foo      bar      /e/file
128 drwxrwx--- bar      foo      /f/dir
129 -rw-rw---- bar      foo      /f/file
130 drwx------ adm      foo      /g/dir
131 -r-------- bar      adm      /g/file
132 drwxr-xr-x foo      bar      /h/dir
133 -rw-r--r-- foo      bar      /h/file
134 drwxr-x--- adm      root     /i/dir
135 -rwsr-xr-x root     adm      /i/file
136 drwxrwxrwx zoot     zoot     /j/dir
137 --w--w--w- zoot     zoot     /j/file
138 ],
139 [])
140 AT_CLEANUP
141
142 # ------------------------------
143 # hardlink tests
144 AT_SETUP([rpmbuild hardlink])
145 AT_KEYWORDS([build])
146 AT_CHECK([
147 RPMDB_CLEAR
148 RPMDB_INIT
149 rm -rf ${TOPDIR}
150
151 runroot rpmbuild \
152   -bb --quiet /data/SPECS/hlinktest.spec
153
154 runroot rpm -i /build/RPMS/noarch/hlinktest-1.0-1.noarch.rpm
155
156 runroot rpm -q --qf "[[%{filenlinks} %{filenames}\n]]%{longsize}\n" hlinktest
157 runroot rpm -V --nouser --nogroup hlinktest
158 ls -i "${RPMTEST}"/foo/hello* | awk {'print $1'} | sort -u | wc -l
159
160 ],
161 [0],
162 [2 /foo/aaaa
163 1 /foo/copyllo
164 4 /foo/hello
165 4 /foo/hello-bar
166 4 /foo/hello-foo
167 4 /foo/hello-world
168 2 /foo/zzzz
169 87
170 1
171 ],
172 [])
173 AT_CLEANUP
174
175 AT_SETUP([rpmbuild unpackaged files])
176 AT_KEYWORDS([build])
177 AT_CHECK([
178 RPMDB_CLEAR
179 RPMDB_INIT
180 rm -rf ${TOPDIR}
181
182 runroot rpmbuild \
183   -bb --quiet --with unpackaged_files /data/SPECS/hlinktest.spec
184 ],
185 [1],
186 [],
187 [error: Installed (but unpackaged) file(s) found:
188    /toot
189     Installed (but unpackaged) file(s) found:
190    /toot
191 ])
192 AT_CLEANUP
193
194 # rpm doesn't detect unpackaged directories but should, really
195 AT_SETUP([rpmbuild unpackaged directories])
196 AT_KEYWORDS([build])
197 AT_XFAIL_IF([test $RPM_XFAIL -ne 0])
198 AT_CHECK([
199 RPMDB_CLEAR
200 RPMDB_INIT
201 rm -rf ${TOPDIR}
202
203 runroot rpmbuild \
204   -bb --quiet --with unpackaged_dirs /data/SPECS/hlinktest.spec
205 ],
206 [1],
207 [],
208 [error: Installed (but unpackaged) file(s) found:
209    /zoo
210     Installed (but unpackaged) file(s) found:
211    /zoo
212 ])
213 AT_CLEANUP
214
215 AT_SETUP([rpmbuild glob])
216 AT_KEYWORDS([build])
217 AT_CHECK([
218 RPMDB_CLEAR
219 RPMDB_INIT
220 rm -rf ${TOPDIR}
221
222 runroot rpmbuild -bb --quiet /data/SPECS/globtest.spec
223 runroot rpm -qp \
224         --qf "[[%{filemodes:perms} %{filenames}\n]]" \
225         /build/RPMS/noarch/globtest-1.0-1.noarch.rpm
226 ],
227 [0],
228 [-rw-r--r-- /opt/globtest/baf
229 drwxr-xr-x /opt/globtest/bang
230 -rw-r--r-- /opt/globtest/bif
231 drwxr-xr-x /opt/globtest/bing
232 drwxr-xr-x /opt/globtest/bong
233 drwxr-xr-x /opt/globtest/foo
234 -rw-r--r-- /opt/globtest/foo/one
235 -rw-r--r-- /opt/globtest/foo/three
236 -rw-r--r-- /opt/globtest/foo/two
237 lrwxrwxrwx /opt/globtest/linkbad
238 lrwxrwxrwx /opt/globtest/linkgood
239 -rw-r--r-- /opt/globtest/weird%name
240 -rw-r--r-- /opt/globtest/zab
241 -rw-r--r-- /opt/globtest/zeb
242 -rw-r--r-- /opt/globtest/zib
243 ],
244 [])
245 AT_CLEANUP
246
247 AT_SETUP([rpmbuild prefixpostfix])
248 AT_KEYWORDS([build])
249 AT_CHECK([
250 RPMDB_CLEAR
251 RPMDB_INIT
252 rm -rf ${TOPDIR}
253
254 runroot rpmbuild -bb --quiet \
255         /data/SPECS/prefixtest.spec
256 runroot rpm -qp \
257         --qf "[[%{filemodes:perms} %{filenames}\n]]" \
258         /build/RPMS/noarch/prefixtest-1.0-1.noarch.rpm
259 ],
260 [0],
261 [-rw-r--r-- /opt/prefixtest/ba
262 drwxr-xr-x /opt/prefixtest/ban
263 -rw-r--r-- /opt/prefixtest/bi
264 drwxr-xr-x /opt/prefixtest/bin
265 drwxr-xr-x /opt/prefixtest/bon
266 drwxr-xr-x /opt/prefixtest/foo
267 -rw-r--r-- /opt/prefixtest/foo/one
268 -rw-r--r-- /opt/prefixtest/foo/three
269 -rw-r--r-- /opt/prefixtest/foo/two
270 lrwxrwxrwx /opt/prefixtest/linkbad
271 lrwxrwxrwx /opt/prefixtest/linkgood
272 -rw-r--r-- /opt/prefixtest/weird%name
273 -rw-r--r-- /opt/prefixtest/zab
274 -rw-r--r-- /opt/prefixtest/zeb
275 -rw-r--r-- /opt/prefixtest/zib
276 ],
277 [])
278 AT_CLEANUP
279
280 # ------------------------------
281 # Check if weak and reverse requires can be built
282 AT_SETUP([Weak and reverse requires])
283 AT_KEYWORDS([build])
284 AT_CHECK([
285
286 runroot rpmbuild -bb --quiet \
287         --define "pkg weakdeps" \
288         --define "recs foo > 1.2.3" \
289         --define "sugs bar >= 0.1.2" \
290         --define "sups baz" \
291         --define "ens zap = 3" \
292           /data/SPECS/deptest.spec
293
294 runroot rpm -qp --recommends /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
295 runroot rpm -qp --suggests /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
296 runroot rpm -qp --supplements /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
297 runroot rpm -qp --enhances /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
298 ],
299 [0],
300 [foo > 1.2.3
301 bar >= 0.1.2
302 baz
303 zap = 3
304 ],
305 [ignore])
306 AT_CLEANUP
307
308 # ------------------------------
309 # Test BuildRequire functionality
310 AT_SETUP([Build requires])
311 AT_KEYWORDS([build])
312 AT_CHECK([
313
314 runroot rpmbuild -bb --quiet \
315                 --define "pkg buildreq" \
316                 --define "buildreqs foo > 1.2.3" \
317                 /data/SPECS/deptest.spec
318 ],
319 [1],
320 [],
321 [error: Failed build dependencies:
322         foo > 1.2.3 is needed by deptest-buildreq-1.0-1.noarch
323 ])
324 AT_CLEANUP
325
326 AT_SETUP([Dependency generation])
327 AT_KEYWORDS([build])
328 AT_CHECK([
329
330 runroot rpmbuild -bb --quiet \
331                 /data/SPECS/filedep.spec
332 echo Requires:
333 runroot rpm  -qp --requires /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
334 echo Provides:
335 runroot rpm -qp --provides /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
336 echo Filerequires:
337 runroot rpm -qp --qf '[["%{FILENAMES}\t%{FILEREQUIRE}"\n]]' /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
338 echo Fileprovides:
339 runroot rpm -qp --qf '[["%{FILENAMES}\t%{FILEPROVIDE}"\n]]' /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
340 ],
341 [0],
342 [Requires:
343 /bin/f00f
344 /bin/sh
345 rpmlib(CompressedFileNames) <= 3.0.4-1
346 rpmlib(FileDigests) <= 4.6.0-1
347 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
348 Provides:
349 filedep = 1.0-1
350 Filerequires:
351 "/etc/foo.conf  "
352 "/usr/bin/bar   /bin/f00f"
353 "/usr/bin/foo   /bin/sh"
354 "/usr/share/doc/filedep "
355 "/usr/share/doc/filedep/README  "
356 Fileprovides:
357 "/etc/foo.conf  "
358 "/usr/bin/bar   "
359 "/usr/bin/foo   "
360 "/usr/share/doc/filedep "
361 "/usr/share/doc/filedep/README  "
362 ],
363 [])
364 AT_CLEANUP
365
366
367 # ------------------------------
368 # Test spec query functionality
369 AT_SETUP([rpmspec query 1])
370 AT_KEYWORDS([build])
371 AT_CHECK([
372
373 runroot rpmspec -q \
374                 --define "pkg dep" \
375                 --define "reqs foo > 1.2.3 bar <= 2.3" \
376                 --requires \
377                 /data/SPECS/deptest.spec
378 ],
379 [0],
380 [bar <= 2.3
381 foo > 1.2.3
382 ],
383 [])
384
385 AT_CLEANUP
386
387 # ------------------------------
388 # archive sanity check
389 AT_SETUP([rpmbuild archive sanity])
390 AT_KEYWORDS([build])
391 AT_CHECK([
392 rm -rf ${TOPDIR}
393
394 runroot rpmbuild \
395   -bb --quiet /data/SPECS/attrtest.spec
396
397 runroot rpm2cpio \
398   /build/RPMS/noarch/attrtest-1.0-1.noarch.rpm > /tmp/attrtest.cpio
399 ],
400 [0],
401 [],
402 [])
403 AT_CLEANUP
404
405 # ------------------------------
406 # Check if rpmbuild creates the minisymtab section in the main hello binary
407 AT_SETUP([rpmbuild debuginfo minisymtab])
408 AT_KEYWORDS([build] [debuginfo])
409 AT_CHECK([
410 rm -rf ${TOPDIR}
411
412 # Use macros.debug to generate a debuginfo package.
413 export CFLAGS="-g"
414 rundebug rpmbuild --quiet \
415   --rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
416
417 # Extract the main package and inspect the hello binary
418 # It should contain .gnu_debugdata, but not the full .symtab
419 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm | cpio -diu
420 test -f ./usr/local/bin/hello || exit 1
421 readelf -S ./usr/local/bin/hello |\
422    grep -q .gnu_debugdata; test $? == 0 || exit 1
423 readelf -S ./usr/local/bin/hello \
424   | grep -q .symtab; test $? == 1 || exit 1
425
426 # And the opposite for the debuginfo package
427 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
428   | cpio -diu
429 test -f ./usr/lib/debug/usr/local/bin/hello*.debug || exit 1
430 readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
431   | grep -q .gnu_debugdata; test $? == 1 || exit 1
432 readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
433   | grep -q .symtab; test $? == 0 || exit 1
434 ],
435 [0],
436 [],
437 [ignore])
438 AT_CLEANUP
439
440 # ------------------------------
441 # Check if rpmbuild doesn't create the minisymtab section if we keep symtab
442 # Some package might want to use strip -g to keep the symbol table and only
443 # but the debug symbols/info in the debuginfo package.
444 AT_SETUP([rpmbuild debuginfo minisymtab strip -g])
445 AT_KEYWORDS([build] [debuginfo])
446 AT_CHECK([
447 rm -rf ${TOPDIR}
448
449 # Use macros.debug to generate a debuginfo package.
450 export CFLAGS="-g"
451 rundebug rpmbuild --quiet \
452   --define="_find_debuginfo_opts -g" \
453   --rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
454
455 # Extract the main package and inspect the hello binary
456 # It should contain .symtab (because of strip -g), so doesn't .gnu_debugdata.
457 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm | cpio -diu
458 test -f ./usr/local/bin/hello || exit 1
459 readelf -S ./usr/local/bin/hello \
460   | grep -q .gnu_debugdata; test $? == 1 || exit 1
461 readelf -S ./usr/local/bin/hello \
462   | grep -q .symtab; test $? == 0 || exit 1
463
464 # The debuginfo package should contain neither. The .symtab is NOBITS.
465 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
466   | cpio -diu
467 test -f ./usr/lib/debug/usr/local/bin/hello*.debug || exit 1
468 readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
469   | grep -q .gnu_debugdata; test $? == 1 || exit 1
470 readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
471   | grep .symtab | grep -q NOBITS; test $? == 0 || exit 1
472 ],
473 [0],
474 [],
475 [ignore])
476 AT_CLEANUP
477
478 # ------------------------------
479 # Check if rpmbuild runs dwz and generates a multi file that with shared
480 # debuginfo. This is simply the hello example with one binary build twice
481 # so dwz has enough slightly similar debug data.
482 # Test the case without unique debug file names.
483 AT_SETUP([rpmbuild debuginfo dwz])
484 AT_KEYWORDS([build] [debuginfo] [dwz])
485 AT_CHECK([
486 rm -rf ${TOPDIR}
487 AS_MKDIR_P(${TOPDIR}/SOURCES)
488
489 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
490
491 rundebug rpmbuild --quiet \
492   --undefine "_unique_debug_names" \
493   --undefine "_unique_debug_srcs" \
494   -ba "${abs_srcdir}"/data/SPECS/hello2.spec
495
496 # The debuginfo package should contain a .debug file for each binary
497 # and a dwz multi file that contains the shared debuginfo between them.
498 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
499   | cpio -diu
500
501 hello_file_debug=./usr/lib/debug/usr/local/bin/hello.debug
502 hello2_file_debug=./usr/lib/debug/usr/local/bin/hello2.debug
503 hello_multi_file=./usr/lib/debug/.dwz/hello2-1.0-1.*
504 test -f $hello_file_debug || echo "no hello debug file: $hello_file_debug"
505 test -f $hello2_file_debug || echo "no hello2 debug file: $hello2_file_debug"
506 test -f $hello_multi_file || echo "no dwz multi file: $hello_multi_file"
507
508 # Make sure the main package binaries contain the correct build-ids
509 # linking them to the debug packages.
510 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
511   | cpio -diu
512 hello_file=./usr/local/bin/hello
513 hello2_file=./usr/local/bin/hello2
514 test -f $hello_file || echo "no hello file: $hello_file"
515 test -f $hello2_file || echo "no hello2 file: $hello2_file"
516
517 id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
518 id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
519 id1debug=$(file $hello_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
520 id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
521 idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
522
523 test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
524 test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
525
526 # The build-id files should link to the .debug files.
527 id1file="./usr/lib/debug/.build-id/${id1:0:2}/${id1:2}"
528 canonid1file=$(readlink -f ${id1file})
529 canonfile1=$(readlink -f $hello_file)
530 canonid1debug=$(readlink -f ${id1file}.debug)
531 canondebug1=$(readlink -f $hello_file_debug)
532
533 test "$canonid1file" = "$canonfile1" \
534   || echo "canonid1file: $canonid1file != $canonfile1"
535 test "$canonid1debug" = "$canondebug1" \
536   || echo "canonid1debug: $canonid1debug != $canondebug1"
537
538 id2file="./usr/lib/debug/.build-id/${id2:0:2}/${id2:2}"
539 canonid2file=$(readlink -f ${id2file})
540 canonfile2=$(readlink -f $hello2_file)
541 canonid2debug=$(readlink -f ${id2file}.debug)
542 canondebug2=$(readlink -f $hello2_file_debug)
543
544 test "$canonid2file" = "$canonfile2" \
545   || echo "canonid2: $canonid2file != $canonfile2"
546 test "$canonid2debug" = "$canondebug2" \
547   || echo "canonid2debug: $canonid2debug" != "$canondebug2"
548
549 # Both .debug files should point to the dwz multi file.
550 # It would be nice to also test that they contain the correct dwz build-id
551 # but that is a bit hard to grep out of the section data.
552 multiref1=$(readelf --string-dump=.gnu_debugaltlink $hello_file_debug \
553   | grep '[     0]' | cut -c13-)
554 multiref2=$(readelf --string-dump=.gnu_debugaltlink $hello2_file_debug \
555   | grep '[     0]' | cut -c13-)
556
557 test "$multiref1" = "$multiref2" || echo "multiref: $multiref1 != $multiref2"
558
559 canonmultiref=$(readlink -f $(dirname $canondebug1)/$multiref1)
560 canonmultifile=$(readlink -f $hello_multi_file)
561
562 test "$canonmultiref" = "$canonmultifile" \
563   || echo "canonmultiref: $canonmultiref" != "$canonmultifile"
564 ],
565 [0],
566 [],
567 [ignore])
568 AT_CLEANUP
569
570 # ------------------------------
571 # Check if rpmbuild runs dwz and generates a multi file that with shared
572 # debuginfo. This is simply the hello example with one binary build twice
573 # so dwz has enough slightly similar debug data.
574 # Test with unique debug file names.
575 AT_SETUP([rpmbuild debuginfo dwz unique debug names])
576 AT_KEYWORDS([build] [debuginfo] [dwz])
577 AT_CHECK([
578 rm -rf ${TOPDIR}
579 AS_MKDIR_P(${TOPDIR}/SOURCES)
580
581 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
582
583 rundebug rpmbuild --quiet \
584   --define "_unique_debug_names 1" \
585   -ba "${abs_srcdir}"/data/SPECS/hello2.spec
586
587 # The debuginfo package should contain a .debug file for each binary
588 # and a dwz multi file that contains the shared debuginfo between them.
589 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
590   | cpio -diu
591
592 hello_file_debug=./usr/lib/debug/usr/local/bin/hello-*.debug
593 hello2_file_debug=./usr/lib/debug/usr/local/bin/hello2-*.debug
594 hello_multi_file=./usr/lib/debug/.dwz/hello2-1.0-1.*
595 test -f $hello_file_debug || echo "no hello debug file: $hello_file_debug"
596 test -f $hello2_file_debug || echo "no hello2 debug file: $hello2_file_debug"
597 test -f $hello_multi_file || echo "no dwz multi file: $hello_multi_file"
598
599 # Make sure the main package binaries contain the correct build-ids
600 # linking them to the debug packages.
601 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
602   | cpio -diu
603 hello_file=./usr/local/bin/hello
604 hello2_file=./usr/local/bin/hello2
605 test -f $hello_file || echo "no hello file: $hello_file"
606 test -f $hello2_file || echo "no hello2 file: $hello2_file"
607
608 id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
609 id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
610 id1debug=$(file $hello_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
611 id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
612 idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
613
614 test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
615 test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
616
617 # The build-id files should link to the .debug files.
618 id1file="./usr/lib/debug/.build-id/${id1:0:2}/${id1:2}"
619 canonid1file=$(readlink -f ${id1file})
620 canonfile1=$(readlink -f $hello_file)
621 canonid1debug=$(readlink -f ${id1file}.debug)
622 canondebug1=$(readlink -f $hello_file_debug)
623
624 test "$canonid1file" = "$canonfile1" \
625   || echo "canonid1file: $canonid1file != $canonfile1"
626 test "$canonid1debug" = "$canondebug1" \
627   || echo "canonid1debug: $canonid1debug != $canondebug1"
628
629 id2file="./usr/lib/debug/.build-id/${id2:0:2}/${id2:2}"
630 canonid2file=$(readlink -f ${id2file})
631 canonfile2=$(readlink -f $hello2_file)
632 canonid2debug=$(readlink -f ${id2file}.debug)
633 canondebug2=$(readlink -f $hello2_file_debug)
634
635 test "$canonid2file" = "$canonfile2" \
636   || echo "canonid2: $canonid2file != $canonfile2"
637 test "$canonid2debug" = "$canondebug2" \
638   || echo "canonid2debug: $canonid2debug" != "$canondebug2"
639
640 # Both .debug files should point to the dwz multi file.
641 # It would be nice to also test that they contain the correct dwz build-id
642 # but that is a bit hard to grep out of the section data.
643 multiref1=$(readelf --string-dump=.gnu_debugaltlink $hello_file_debug \
644   | grep '[     0]' | cut -c13-)
645 multiref2=$(readelf --string-dump=.gnu_debugaltlink $hello2_file_debug \
646   | grep '[     0]' | cut -c13-)
647
648 test "$multiref1" = "$multiref2" || echo "multiref: $multiref1 != $multiref2"
649
650 canonmultiref=$(readlink -f $(dirname $canondebug1)/$multiref1)
651 canonmultifile=$(readlink -f $hello_multi_file)
652
653 test "$canonmultiref" = "$canonmultifile" \
654   || echo "canonmultiref: $canonmultiref" != "$canonmultifile"
655 ],
656 [0],
657 [],
658 [ignore])
659 AT_CLEANUP
660
661 # ------------------------------
662 # Check that old style gnu_debuglink CRC checksums are correct even after
663 # using dwz to compress the debuginfo files.
664 AT_SETUP([rpmbuild debuginfo dwz gnu_debuglink crc])
665 AT_KEYWORDS([build] [debuginfo])
666 AT_CHECK([
667 rm -rf ${TOPDIR}
668 AS_MKDIR_P(${TOPDIR}/SOURCES)
669
670 # Build a package that
671 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
672
673 rundebug rpmbuild --quiet \
674   -ba "${abs_srcdir}"/data/SPECS/hello2.spec
675
676 # Unpack the main and debuginfo rpms so we can check binaries and .debug files.
677 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
678   | cpio -diu
679 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
680   | cpio -diu
681
682 # Check that dwz has ran and a multi file has been produced
683 test -f ./usr/lib/debug/.dwz/hello2-1.0-1.* || exit 1
684
685 # Run sepdbugcrcfix on the binaries, both should have correct CRC already.
686 ${abs_top_builddir}/sepdebugcrcfix ./usr/lib/debug \
687   ./usr/local/bin/hello ./usr/local/bin/hello2 | grep CRC32 | cut -f2 -d:
688 ],
689 [0],
690 [ Updated 0 CRC32s, 2 CRC32s did match.
691 ],
692 [ignore])
693 AT_CLEANUP
694
695 # ------------------------------
696 # Check that an implicit suid binary get included with the suid bit set.
697 # We explicitly build with all debug.macros to test those helpers.
698 AT_SETUP([rpmbuild implicit suid binary])
699 AT_KEYWORDS([build] [debuginfo] [dwz] [suid])
700 AT_CHECK([
701 rm -rf ${TOPDIR}
702 AS_MKDIR_P(${TOPDIR}/SOURCES)
703
704 # Build a package that has some debuginfo
705 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
706
707 rundebug rpmbuild --quiet \
708   -ba "${abs_srcdir}"/data/SPECS/hello2-suid.spec
709
710 # Unpack rpm so we can check the included binaries.
711 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
712   | cpio -diu --quiet
713
714 # List all binaries with suid bit set (should be one, hello).
715 echo "suid:"
716 find usr -executable -type f -perm /4000
717 # List all binaries without suid bit set (should also be one, hello2).
718 echo "no-suid:"
719 find usr -executable -type f \! -perm /4000
720 ],
721 [0],
722 [suid:
723 usr/local/bin/hello
724 no-suid:
725 usr/local/bin/hello2
726 ],
727 [ignore])
728 AT_CLEANUP
729
730 # ------------------------------
731 # Check that a GDB index is included when requested.
732 AT_SETUP([rpmbuild debuginfo gdb index included])
733 AT_KEYWORDS([build] [debuginfo] [gdb])
734 AT_CHECK([
735 rm -rf ${TOPDIR}
736 AS_MKDIR_P(${TOPDIR}/SOURCES)
737
738 # Build a package that has some debuginfo
739 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
740
741 rundebug rpmbuild --quiet \
742   --define "_include_gdb_index 1" \
743   -ba "${abs_srcdir}"/data/SPECS/hello2.spec
744
745 # Unpack the debuginfo rpms so we can check the .debug files.
746 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
747   | cpio -diu --quiet
748
749 # Check that gdb-add-index has ran and a .gdb_index section has been added
750 readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
751   | grep gdb_index | cut -c8-17
752 ],
753 [0],
754 [.gdb_index
755 ],
756 [ignore])
757 AT_CLEANUP
758
759 # ------------------------------
760 # Check that a GDB index is NOT included when not requested.
761 AT_SETUP([rpmbuild debuginfo no gdb index included])
762 AT_KEYWORDS([build] [debuginfo] [gdb])
763 AT_CHECK([
764 rm -rf ${TOPDIR}
765 AS_MKDIR_P(${TOPDIR}/SOURCES)
766
767 # Build a package that has some debuginfo
768 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
769
770 rundebug rpmbuild --quiet \
771   --undefine "_include_gdb_index" \
772   -ba "${abs_srcdir}"/data/SPECS/hello2.spec
773
774 # Unpack the debuginfo rpms so we can check the .debug files.
775 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
776   | cpio -diu --quiet
777
778 # Check that gdb-add-index has not ran and no .gdb_index section has been added
779 readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
780   | grep gdb_index | cut -c8-17
781 ],
782 [0],
783 [],
784 [ignore])
785 AT_CLEANUP
786
787 # ------------------------------
788 # Check that a debug source is in a "unique" directory when requested.
789 AT_SETUP([rpmbuild debuginfo unique debug src dir])
790 AT_KEYWORDS([build] [debuginfo])
791 AT_CHECK([
792 rm -rf ${TOPDIR}
793 AS_MKDIR_P(${TOPDIR}/SOURCES)
794
795 # Build a package that has some debuginfo
796 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
797
798 # Note that the spec defines hello2 as name, but the source is hello-1.0.
799 # Disable dwz to make debuginfo path rewrite checking easier.
800 rundebug rpmbuild --quiet \
801   --undefine "_find_debuginfo_dwz_opts" \
802   --define "_unique_debug_srcs 1" \
803   -ba "${abs_srcdir}"/data/SPECS/hello2.spec
804
805 # Unpack the debuginfo rpms so we can check the .debug files.
806 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
807   | cpio -diu --quiet
808
809 # Check that the source path is "unique"
810 # Drop the final arch prefix to make the test arch-independent.
811 ls ./usr/src/debug/ | cut -f1,2 -d\.
812
813 # Check that the source path has been rewritten in the .debug file.
814 # Drop the final arch prefix to make the test arch-independent.
815 readelf --debug-dump=info ./usr/lib/debug/usr/local/bin/hello2*.debug \
816   | grep comp_dir | sed -e 's/\t$//' | cut -f5- -d/ | cut -f1,2 -d\.
817 ],
818 [0],
819 [hello2-1.0-1
820 hello2-1.0-1
821 ],
822 [ignore])
823 AT_CLEANUP
824
825 # ------------------------------
826 # Check that a debug source is NOT in a "unique" directory when not requested.
827 # It will be in the "build directory" name under /usr/src/debug.
828 AT_SETUP([rpmbuild debuginfo no unique debug src dir])
829 AT_KEYWORDS([build] [debuginfo])
830 AT_CHECK([
831 rm -rf ${TOPDIR}
832 AS_MKDIR_P(${TOPDIR}/SOURCES)
833
834 # Build a package that has some debuginfo
835 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
836
837 # Note that the spec defines hello2 as name, but the source is hello-1.0.
838 # Disable dwz to make debuginfo path rewrite checking easier.
839 rundebug rpmbuild --quiet \
840   --undefine "_find_debuginfo_dwz_opts" \
841   --undefine "_unique_debug_srcs" \
842   -ba "${abs_srcdir}"/data/SPECS/hello2.spec
843
844 # Unpack the debuginfo rpms so we can check the .debug files.
845 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
846   | cpio -diu --quiet
847
848 # Check that the source path is "unique"
849 ls ./usr/src/debug/
850
851 # Check that the source path has been rewritten in the .debug file.
852 readelf --debug-dump=info ./usr/lib/debug/usr/local/bin/hello2*.debug \
853   | grep comp_dir | sed -e 's/\t$//' | cut -f5- -d/
854 ],
855 [0],
856 [hello-1.0
857 hello-1.0
858 ],
859 [ignore])
860 AT_CLEANUP
861
862 # ------------------------------
863 # Check that defining _debugsource_packages creates -debugsource package
864 AT_SETUP([rpmbuild debugsource])
865 AT_KEYWORDS([build] [debuginfo] [debugsource])
866 AT_CHECK([
867 rm -rf ${TOPDIR}
868 AS_MKDIR_P(${TOPDIR}/SOURCES)
869
870 # Build a package that has some debuginfo
871 cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
872
873 rundebug rpmbuild --quiet \
874   --define "_debugsource_packages 1" \
875   -ba "${abs_srcdir}"/data/SPECS/hello2.spec
876
877 # Unpack the debugsource rpm so we can check the sources are there.
878 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debugsource-1.0-1.*.rpm \
879   | cpio -diu --quiet
880
881 # Check that hello.c is there.
882 ls ./usr/src/debug/hello2-1.0*/
883
884 # The debuginfo package should recommend the debugsource package (ignore arch).
885 echo -n "Recommends: "
886 run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
887 ],
888 [0],
889 [hello.c
890 Recommends: hello2-debugsource(ignore-arch) = 1.0-1
891 ],
892 [ignore])
893 AT_CLEANUP
894
895 # ------------------------------
896 # Check that defining _debugsource_packages creates -debugsource package
897 # even if %install changes the working directory (debugsources.list
898 # should be in expected build dir).
899 AT_SETUP([rpmbuild debugsource debugsources.list path])
900 AT_KEYWORDS([build] [debuginfo] [debugsource])
901 AT_CHECK([
902 rm -rf ${TOPDIR}
903 AS_MKDIR_P(${TOPDIR}/SOURCES)
904
905 # Setup sources
906 cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
907
908 rundebug rpmbuild --quiet \
909   --define "_debugsource_packages 1" \
910   -ba "${abs_srcdir}"/data/SPECS/hello-cd.spec
911
912 # Unpack the debuginfo rpms so we can check the sources are there.
913 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debugsource-1.0-1.*.rpm \
914   | cpio -diu --quiet
915
916 # Check that hello.c is there.
917 ls ./usr/src/debug/test-1.0*/
918 ],
919 [0],
920 [hello.c
921 ],
922 [ignore])
923 AT_CLEANUP
924
925 # ------------------------------
926 # Check that undefining _debuginfo_subpackages creates one single -debuginfo.
927 AT_SETUP([rpmbuild debuginfo subpackages single])
928 AT_KEYWORDS([build] [debuginfo] [debugsubpackage])
929 AT_CHECK([
930 rm -rf ${TOPDIR}
931 AS_MKDIR_P(${TOPDIR}/SOURCES)
932
933 # Setup sources
934 cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
935
936 rundebug rpmbuild --quiet \
937   --undefine "_unique_debug_names" \
938   --undefine "_unique_debug_srcs" \
939   --undefine "_debugsource_packages" \
940   --undefine "_debuginfo_subpackages" \
941   -ba "${abs_srcdir}"/data/SPECS/test-subpackages.spec
942
943 # Check that there is just one debuginfo package.
944 ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
945
946 # Which contains hello.debug
947 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
948   | cpio -diu --quiet
949 # Extract the debug name from the exe (.gnu_debuglink section, first string)
950 debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
951
952 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
953   | cpio -diu --quiet
954 if test -f ./usr/lib/debug/bin/$debug_name; then
955   echo "hello debug exists"
956 else
957   echo "No hello: $debug_name"
958 fi
959 ],
960 [0],
961 [1
962 hello debug exists
963 ],
964 [ignore])
965 AT_CLEANUP
966
967 # ------------------------------
968 # Check that defining _debuginfo_subpackages creates multiple -debuginfos.
969 AT_SETUP([rpmbuild debuginfo subpackages multiple])
970 AT_KEYWORDS([build] [debuginfo] [debugsubpackage])
971 AT_CHECK([
972 rm -rf ${TOPDIR}
973 AS_MKDIR_P(${TOPDIR}/SOURCES)
974
975 # Setup sources
976 cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
977
978 rundebug rpmbuild --quiet \
979   --undefine "_unique_debug_names" \
980   --undefine "_unique_debug_srcs" \
981   --undefine "_debugsource_packages" \
982   --define "_debuginfo_subpackages 1" \
983   -ba "${abs_srcdir}"/data/SPECS/test-subpackages.spec
984
985 # Check that there are 3 debuginfo packages.
986 ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
987
988 # First contains hello.debug
989 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
990   | cpio -diu --quiet
991 # Extract the debug name from the exe (.gnu_debuglink section, first string)
992 debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
993
994 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
995   | cpio -diu --quiet
996 if test -f ./usr/lib/debug/bin/$debug_name; then
997   echo "hello debug exists"
998 else
999   echo "No hello: $debug_name"
1000 fi
1001
1002 # Second contains hello2.debug
1003 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
1004   | cpio -diu --quiet
1005 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1006 debug_name=$(readelf -p .gnu_debuglink ./bin/hello2 | grep hello | cut -c13-)
1007
1008 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
1009   | cpio -diu --quiet
1010 if test -f ./usr/lib/debug/bin/$debug_name; then
1011   echo "hello2 debug exists"
1012 else
1013   echo "No hello2: $debug_name"
1014 fi
1015
1016 # No debugsource package, so sources are in the main debuginfo package.
1017 # Make sure it is recommended.
1018 echo -n "Recommends: "
1019 run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
1020
1021 # Third contains hello3.debug
1022 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-1.0-1.*.rpm \
1023   | cpio -diu --quiet
1024 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1025 debug_name=$(readelf -p .gnu_debuglink ./bin/hello3 | grep hello | cut -c13-)
1026
1027 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm \
1028   | cpio -diu --quiet
1029 if test -f ./usr/lib/debug/bin/$debug_name; then
1030   echo "hello3 debug exists"
1031 else
1032   echo "No hello3: $debug_name"
1033 fi
1034
1035 # No debugsource package, so sources are in the main debuginfo package.
1036 # Make sure it is recommended.
1037 echo -n "Recommends: "
1038 run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
1039 ],
1040 [0],
1041 [3
1042 hello debug exists
1043 hello2 debug exists
1044 Recommends: test-debuginfo(ignore-arch) = 1.0-1
1045 hello3 debug exists
1046 Recommends: test-debuginfo(ignore-arch) = 1.0-1
1047 ],
1048 [ignore])
1049 AT_CLEANUP
1050 # ------------------------------
1051 # Check that defining _debuginfo_subpackages creates multiple -debuginfos.
1052 # With unique debug and source names
1053 AT_SETUP([rpmbuild debuginfo subpackages multiple unique])
1054 AT_KEYWORDS([build] [debuginfo] [debugsubpackage])
1055 AT_CHECK([
1056 rm -rf ${TOPDIR}
1057 AS_MKDIR_P(${TOPDIR}/SOURCES)
1058
1059 # Setup sources
1060 cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
1061
1062 rundebug rpmbuild --quiet \
1063   --define "_unique_debug_names 1" \
1064   --define "_unique_debug_srcs 1" \
1065   --undefine "_debugsource_packages" \
1066   --define "_debuginfo_subpackages 1" \
1067   -ba "${abs_srcdir}"/data/SPECS/test-subpackages.spec
1068
1069 # Check that there are 3 debuginfo packages.
1070 ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
1071
1072 # First contains hello.debug
1073 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
1074   | cpio -diu --quiet
1075 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1076 debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
1077
1078 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
1079   | cpio -diu --quiet
1080 if test -f ./usr/lib/debug/bin/$debug_name; then
1081   echo "hello debug exists"
1082 else
1083   echo "No hello: $debug_name"
1084 fi
1085
1086 # Second contains hello2.debug
1087 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
1088   | cpio -diu --quiet
1089 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1090 debug_name=$(readelf -p .gnu_debuglink ./bin/hello2 | grep hello | cut -c13-)
1091
1092 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
1093   | cpio -diu --quiet
1094 if test -f ./usr/lib/debug/bin/$debug_name; then
1095   echo "hello2 debug exists"
1096 else
1097   echo "No hello2: $debug_name"
1098 fi
1099
1100 # No debugsource package, so sources are in the main debuginfo package.
1101 # Make sure it is recommended.
1102 echo -n "Recommends: "
1103 run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
1104
1105 # Third contains hello3.debug
1106 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-1.0-1.*.rpm \
1107   | cpio -diu --quiet
1108 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1109 debug_name=$(readelf -p .gnu_debuglink ./bin/hello3 | grep hello | cut -c13-)
1110
1111 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm \
1112   | cpio -diu --quiet
1113 if test -f ./usr/lib/debug/bin/$debug_name; then
1114   echo "hello3 debug exists"
1115 else
1116   echo "No hello3: $debug_name"
1117 fi
1118
1119 # No debugsource package, so sources are in the main debuginfo package.
1120 # Make sure it is recommended.
1121 echo -n "Recommends: "
1122 run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
1123 ],
1124 [0],
1125 [3
1126 hello debug exists
1127 hello2 debug exists
1128 Recommends: test-debuginfo(ignore-arch) = 1.0-1
1129 hello3 debug exists
1130 Recommends: test-debuginfo(ignore-arch) = 1.0-1
1131 ],
1132 [ignore])
1133 AT_CLEANUP
1134 # ------------------------------
1135 # Check that defining _debuginfo_subpackages creates multiple -debuginfos.
1136 # Unique with debugsources.
1137 AT_SETUP([rpmbuild debuginfo subpackages multiple unique debugsource])
1138 AT_KEYWORDS([build] [debuginfo] [debugsubpackage] [debugsource])
1139 AT_CHECK([
1140 rm -rf ${TOPDIR}
1141 AS_MKDIR_P(${TOPDIR}/SOURCES)
1142
1143 # Setup sources
1144 cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
1145
1146 rundebug rpmbuild --quiet \
1147   --define "_unique_debug_names 1" \
1148   --define "_unique_debug_srcs 1" \
1149   --define "_debugsource_packages 1" \
1150   --define "_debuginfo_subpackages 1" \
1151   -ba "${abs_srcdir}"/data/SPECS/test-subpackages.spec
1152
1153 # Check that there are 3 debuginfo packages.
1154 ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
1155
1156 # First contains hello.debug
1157 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
1158   | cpio -diu --quiet
1159 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1160 debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
1161
1162 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
1163   | cpio -diu --quiet
1164 if test -f ./usr/lib/debug/bin/$debug_name; then
1165   echo "hello debug exists"
1166 else
1167   echo "No hello: $debug_name"
1168 fi
1169
1170 # Sources are in debugsource package. Make sure it is recommended.
1171 echo -n "Recommends: "
1172 run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
1173
1174 # Second contains hello2.debug
1175 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
1176   | cpio -diu --quiet
1177 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1178 debug_name=$(readelf -p .gnu_debuglink ./bin/hello2 | grep hello | cut -c13-)
1179
1180 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
1181   | cpio -diu --quiet
1182 if test -f ./usr/lib/debug/bin/$debug_name; then
1183   echo "hello2 debug exists"
1184 else
1185   echo "No hello2: $debug_name"
1186 fi
1187
1188 # Sources are in debugsource package. Make sure it is recommended.
1189 echo -n "Recommends: "
1190 run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
1191
1192 # Third contains hello3.debug
1193 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-1.0-1.*.rpm \
1194   | cpio -diu --quiet
1195 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1196 debug_name=$(readelf -p .gnu_debuglink ./bin/hello3 | grep hello | cut -c13-)
1197
1198 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm \
1199   | cpio -diu --quiet
1200 if test -f ./usr/lib/debug/bin/$debug_name; then
1201   echo "hello3 debug exists"
1202 else
1203   echo "No hello3: $debug_name"
1204 fi
1205
1206 # Sources are in debugsource package. Make sure it is recommended.
1207 echo -n "Recommends: "
1208 run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
1209 ],
1210 [0],
1211 [3
1212 hello debug exists
1213 Recommends: test-debugsource(ignore-arch) = 1.0-1
1214 hello2 debug exists
1215 Recommends: test-debugsource(ignore-arch) = 1.0-1
1216 hello3 debug exists
1217 Recommends: test-debugsource(ignore-arch) = 1.0-1
1218 ],
1219 [ignore])
1220 AT_CLEANUP
1221
1222 # ------------------------------
1223 # Check that defining _debuginfo_subpackages works with excluded files.
1224 AT_SETUP([rpmbuild debuginfo subpackages multiple excluded])
1225 AT_KEYWORDS([build] [debuginfo] [debugsubpackage] [debugsource])
1226 AT_CHECK([
1227 rm -rf ${TOPDIR}
1228 AS_MKDIR_P(${TOPDIR}/SOURCES)
1229
1230 # Setup sources
1231 cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
1232
1233 rundebug rpmbuild --quiet \
1234   --define "_unique_debug_names 1" \
1235   --define "_unique_debug_srcs 1" \
1236   --define "_debugsource_packages 1" \
1237   --define "_debuginfo_subpackages 1" \
1238   -ba "${abs_srcdir}"/data/SPECS/test-subpackages-exclude.spec
1239
1240 # Check that there are 2 debuginfo packages.
1241 ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
1242
1243 # First contains hello.debug
1244 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
1245   | cpio -diu --quiet
1246 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1247 debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
1248
1249 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
1250   | cpio -diu --quiet
1251 if test -f ./usr/lib/debug/bin/$debug_name; then
1252   echo "hello debug exists"
1253 else
1254   echo "No hello: $debug_name"
1255 fi
1256
1257 # Second contains hello2.debug but NOT hello3.debug
1258 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
1259   | cpio -diu --quiet
1260 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1261 debug_name=$(readelf -p .gnu_debuglink ./bin/hello2 | grep hello | cut -c13-)
1262
1263 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
1264   | cpio -diu --quiet
1265 if test -f ./usr/lib/debug/bin/$debug_name; then
1266   echo "hello2 debug exists"
1267 else
1268   echo "No hello2: $debug_name"
1269 fi
1270
1271 if test -f ./usr/lib/debug/bin/hello3*; then
1272   echo "hello3 debug exists"
1273 else
1274   echo "No hello3 debug"
1275 fi
1276 ],
1277 [0],
1278 [2
1279 hello debug exists
1280 hello2 debug exists
1281 No hello3 debug
1282 ],
1283 [ignore])
1284 AT_CLEANUP
1285
1286 # ------------------------------
1287 # Check that defining _debuginfo_subpackages works with RemovePathPostfixes.
1288 AT_SETUP([rpmbuild debuginfo subpackages multiple excluded])
1289 AT_KEYWORDS([build] [debuginfo] [debugsubpackage] [debugsource])
1290 AT_CHECK([
1291 rm -rf ${TOPDIR}
1292 AS_MKDIR_P(${TOPDIR}/SOURCES)
1293
1294 # Setup sources
1295 cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
1296
1297 rundebug rpmbuild --quiet \
1298   --define "_unique_debug_names 1" \
1299   --define "_unique_debug_srcs 1" \
1300   --define "_debugsource_packages 1" \
1301   --define "_debuginfo_subpackages 1" \
1302   -ba "${abs_srcdir}"/data/SPECS/test-subpackages-pathpostfixes.spec
1303
1304 # Check that there are 2 debuginfo packages.
1305 ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
1306
1307 # First contains hello.debug
1308 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
1309   | cpio -diu --quiet
1310 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1311 debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
1312
1313 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
1314   | cpio -diu --quiet
1315 if test -f ./usr/lib/debug/bin/$debug_name; then
1316   echo "hello debug exists"
1317 else
1318   echo "No hello: $debug_name"
1319 fi
1320
1321 # remove it, we are going to check the other debuginfo package.
1322 rm ./bin/hello
1323 rm ./usr/lib/debug/bin/$debug_name
1324 orig_debugname=$debugname
1325
1326 # Second contains hello.foobar.debug but NOT hello.debug
1327 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
1328   | cpio -diu --quiet
1329 # Extract the debug name from the exe (.gnu_debuglink section, first string)
1330 debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
1331
1332 rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
1333   | cpio -diu --quiet
1334 if test -f ./usr/lib/debug/bin/$debug_name; then
1335   echo "hello.foobar debug exists"
1336 else
1337   echo "No hello2: $debug_name"
1338 fi
1339
1340 if test -f ./usr/lib/debug/bin/$orig_debugname; then
1341   echo "$orig_debugname exists"
1342 else
1343   echo "No hello.debug"
1344 fi
1345 ],
1346 [0],
1347 [2
1348 hello debug exists
1349 hello.foobar debug exists
1350 No hello.debug
1351 ],
1352 [ignore])
1353 AT_CLEANUP