forked from rpm-software-management/rpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpmbuild.at
1806 lines (1580 loc) · 49.2 KB
/
rpmbuild.at
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# rpmbuild.at: test rpmbuild
#
# Copyright (C) 2007 Ralf Corsépius <corsepiu@fedoraproject.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
AT_BANNER([RPM build])
# ------------------------------
# Check if rpmbuild -ba *.spec works
AT_SETUP([rpmbuild -ba *.spec])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
run rpmbuild \
-ba "${abs_srcdir}"/data/SPECS/hello.spec
],
[0],
[ignore],
[ignore])
AT_CLEANUP
AT_SETUP([rpmbuild -ba autosetup])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
run rpmbuild \
-ba "${abs_srcdir}"/data/SPECS/hello-auto.spec
],
[0],
[ignore],
[ignore])
AT_CLEANUP
AT_SETUP([rpmbuild -ba autopatch])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
run rpmbuild \
-ba "${abs_srcdir}"/data/SPECS/hello-autopatch.spec
],
[0],
[ignore],
[ignore])
AT_CLEANUP
# ------------------------------
# Check if rpmbuild --rebuild *.src.rpm works
AT_SETUP([rpmbuild --rebuild])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
run rpmbuild \
--rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
],
[0],
[ignore],
[ignore])
AT_CLEANUP
AT_SETUP([rpmbuild --short-circuit -bl])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
run rpmbuild -bi "${abs_srcdir}"/data/SPECS/hello.spec &> /dev/null
run rpmbuild --quiet -bl --short-circuit "${abs_srcdir}"/data/SPECS/hello.spec
],
[0],
[],
[])
AT_CLEANUP
# ------------------------------
# Check if tar unpacking works
AT_SETUP([rpmbuild -tb <tar with bad spec>])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
runroot rpmbuild \
-tb /data/SOURCES/hello-1.0.tar.gz
],
[1],
[ignore],
[error: line 5: Unknown tag: Serial: 1
])
AT_CLEANUP
AT_SETUP([rpmbuild -ts <spec>])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
runroot rpmbuild --quiet -ts /data/SOURCES/hello-2.0.tar.gz
runroot rpm -qpl /build/SRPMS/hello-2.0-1.src.rpm
],
[0],
[hello-2.0.tar.gz
hello.spec
],
[])
AT_CLEANUP
# weird filename survival test
AT_SETUP([rpmbuild package with weird filenames])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
runroot rpmbuild -bb --quiet /data/SPECS/weirdnames.spec
runroot rpm -qpl /build/RPMS/noarch/weirdnames-1.0-1.noarch.rpm
],
[0],
[/opt/!absolutely
/opt/#nocomment
/opt/$talks
/opt/&ground
/opt/(maybe)
/opt/<namehere>
/opt/\.back
/opt/after{all}
/opt/bar"ed
/opt/equals=not
/opt/foo'ed
/opt/index[[this]]
/opt/just space
/opt/perhaps;not
/opt/tee|two
/opt/the * are falling
/opt/to?be
/opt/true:false
/opt/~right
],
[])
AT_CLEANUP
AT_SETUP([rpmbuild package with illegal filenames])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
# XXX current output is not well suited for grab + compare, just ignore
runroot rpmbuild -bb --quiet --with illegal /data/SPECS/weirdnames.spec
],
[1],
[],
[ignore])
AT_CLEANUP
# ------------------------------
# Check if tar build works
# TODO: test that the rpms are actually created...
AT_SETUP([rpmbuild -tb])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
run rpmbuild \
-ta "${RPMDATA}/SOURCES/hello-2.0.tar.gz"
],
[0],
[ignore],
[ignore])
AT_CLEANUP
AT_SETUP([rpmbuild scriptlet -f])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
runroot rpmbuild \
-bb --quiet /data/SPECS/scriptfile.spec
runroot rpm -qp --scripts --triggers --filetriggers \
/build/RPMS/noarch/scriptfile-1-1.noarch.rpm
],
[0],
[preinstall scriptlet (using /bin/sh):
#!/bin/sh
echo one
postuninstall scriptlet (using /bin/sh):
#!/bin/sh
echo two
triggerin scriptlet (using /bin/sh) -- scriptfile
#!/bin/sh
echo one
triggerun scriptlet (using /bin/sh) -- scriptfile
#!/bin/sh
echo two
filetriggerin scriptlet (using /bin/sh) -- /path
#!/bin/sh
echo one
filetriggerin scriptlet (using /bin/sh) -- /path
#!/bin/sh
echo two
transfiletriggerin scriptlet (using /bin/sh) -- /path
#!/bin/sh
echo one
transfiletriggerun scriptlet (using /bin/sh) -- /path
#!/bin/sh
echo two
],
[])
AT_CLEANUP
# ------------------------------
# %attr/%defattr tests
AT_SETUP([rpmbuild %attr and %defattr])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([[
runroot rpmbuild \
-bb --quiet /data/SPECS/attrtest.spec
runroot rpm -qp --qf \
"\n[%{filemodes:perms} %-8{fileusername} %-8{filegroupname} %{filenames}\n]"\
/build/RPMS/noarch/attrtest-1.0-1.noarch.rpm
]],
[0],
[
drwx------ root root /a/dir
-r-------- root root /a/file
drwx------ daemon adm /b/dir
-r-------- daemon adm /b/file
drwxr-x--- root adm /c/dir
-rw-r----- daemon root /c/file
drwxr-x--x daemon bin /d/dir
-rw-r--r-- bin daemon /d/file
drwx------ foo bar /e/dir
-r-------- foo bar /e/file
drwxrwx--- bar foo /f/dir
-rw-rw---- bar foo /f/file
drwx------ adm foo /g/dir
-r-------- bar adm /g/file
drwxr-xr-x foo bar /h/dir
-rw-r--r-- foo bar /h/file
drwxr-x--- adm root /i/dir
-rwsr-xr-x root adm /i/file
drwxrwxrwx zoot zoot /j/dir
--w--w--w- zoot zoot /j/file
],
[])
AT_CLEANUP
AT_SETUP([rpmbuild unpackaged files])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
RPMDB_INIT
runroot rpmbuild \
-bb --quiet --with unpackaged_files /data/SPECS/hlinktest.spec
],
[1],
[],
[error: Installed (but unpackaged) file(s) found:
/toot
Installed (but unpackaged) file(s) found:
/toot
])
AT_CLEANUP
# rpm doesn't detect unpackaged directories but should, really
AT_SETUP([rpmbuild unpackaged directories])
AT_KEYWORDS([build])
AT_XFAIL_IF([test $RPM_XFAIL -ne 0])
RPMDB_INIT
AT_CHECK([
RPMDB_INIT
runroot rpmbuild \
-bb --quiet --with unpackaged_dirs /data/SPECS/hlinktest.spec
],
[1],
[],
[error: Installed (but unpackaged) file(s) found:
/zoo
Installed (but unpackaged) file(s) found:
/zoo
])
AT_CLEANUP
AT_SETUP([rpmbuild glob])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
RPMDB_INIT
runroot rpmbuild -bb --quiet /data/SPECS/globtest.spec
runroot rpm -qp \
--qf "[[%{filemodes:perms} %{filenames}\n]]" \
/build/RPMS/noarch/globtest-1.0-1.noarch.rpm
],
[0],
[-rw-r--r-- /opt/globtest/baf
drwxr-xr-x /opt/globtest/bang
-rw-r--r-- /opt/globtest/bif
drwxr-xr-x /opt/globtest/bing
drwxr-xr-x /opt/globtest/bong
drwxr-xr-x /opt/globtest/foo
-rw-r--r-- /opt/globtest/foo/one
-rw-r--r-- /opt/globtest/foo/three
-rw-r--r-- /opt/globtest/foo/two
lrwxrwxrwx /opt/globtest/linkbad
lrwxrwxrwx /opt/globtest/linkgood
-rw-r--r-- /opt/globtest/weird%name
-rw-r--r-- /opt/globtest/zab
-rw-r--r-- /opt/globtest/zeb
-rw-r--r-- /opt/globtest/zib
],
[warning: absolute symlink: /opt/globtest/linkbad -> /opt/globtest/zub
warning: absolute symlink: /opt/globtest/linkgood -> /opt/globtest/zab
])
AT_CLEANUP
AT_SETUP([rpmbuild prefixpostfix])
AT_KEYWORDS([build])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild -bb --quiet \
/data/SPECS/prefixtest.spec
runroot rpm -qp \
--qf "[[%{filemodes:perms} %{filenames}\n]]" \
/build/RPMS/noarch/prefixtest-1.0-1.noarch.rpm
],
[0],
[-rw-r--r-- /opt/prefixtest/ba
drwxr-xr-x /opt/prefixtest/ban
-rw-r--r-- /opt/prefixtest/bi
drwxr-xr-x /opt/prefixtest/bin
drwxr-xr-x /opt/prefixtest/bon
drwxr-xr-x /opt/prefixtest/foo
-rw-r--r-- /opt/prefixtest/foo/one
-rw-r--r-- /opt/prefixtest/foo/three
-rw-r--r-- /opt/prefixtest/foo/two
lrwxrwxrwx /opt/prefixtest/linkbad
lrwxrwxrwx /opt/prefixtest/linkgood
-rw-r--r-- /opt/prefixtest/weird%name
-rw-r--r-- /opt/prefixtest/zab
-rw-r--r-- /opt/prefixtest/zeb
-rw-r--r-- /opt/prefixtest/zib
],
[warning: absolute symlink: /opt/prefixtest/linkbad -> /opt/prefixtest/zub
warning: absolute symlink: /opt/prefixtest/linkgood -> /opt/prefixtest/zab
])
AT_CLEANUP
# ------------------------------
# Check if weak and reverse requires can be built
AT_SETUP([Weak and reverse requires])
AT_KEYWORDS([build])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild -bb --quiet \
--define "pkg weakdeps" \
--define "recs foo > 1.2.3" \
--define "sugs bar >= 0.1.2" \
--define "sups baz" \
--define "ens zap = 3" \
/data/SPECS/deptest.spec
runroot rpm -qp --recommends /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
runroot rpm -qp --suggests /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
runroot rpm -qp --supplements /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
runroot rpm -qp --enhances /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
],
[0],
[foo > 1.2.3
bar >= 0.1.2
baz
zap = 3
],
[ignore])
AT_CLEANUP
# ------------------------------
# Test BuildRequire functionality
AT_SETUP([Build requires])
AT_KEYWORDS([build])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild -bb --quiet \
--define "pkg buildreq" \
--define "buildreqs foo > 1.2.3" \
/data/SPECS/deptest.spec
],
[11],
[],
[error: Failed build dependencies:
foo > 1.2.3 is needed by deptest-buildreq-1.0-1.noarch
])
AT_CLEANUP
AT_SETUP([Dependency generation 1])
AT_KEYWORDS([build])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild -bb --quiet \
--define "_binary_payload w9.gzdio" \
/data/SPECS/filedep.spec
echo Requires:
runroot rpm -qp --requires /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
echo Provides:
runroot rpm -qp --provides /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
echo Filerequires:
runroot rpm -qp --qf '[["%{FILENAMES}\t%{FILEREQUIRE}"\n]]' /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
echo Fileprovides:
runroot rpm -qp --qf '[["%{FILENAMES}\t%{FILEPROVIDE}"\n]]' /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
],
[0],
[Requires:
/bin/f00f
/bin/sh
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Provides:
filedep = 1.0-1
Filerequires:
"/etc/foo.conf "
"/usr/bin/bar /bin/f00f"
"/usr/bin/foo /bin/sh"
"/usr/share/doc/filedep "
"/usr/share/doc/filedep/README "
Fileprovides:
"/etc/foo.conf "
"/usr/bin/bar "
"/usr/bin/foo "
"/usr/share/doc/filedep "
"/usr/share/doc/filedep/README "
],
[])
AT_CLEANUP
AT_SETUP([Dependency generation 2])
AT_KEYWORDS([build])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild -bb --quiet \
/data/SPECS/shebang.spec
runroot rpm -qp --requires /build/RPMS/noarch/shebang-0.1-1.noarch.rpm|grep -v ^rpmlib
],
[0],
[/bin/blabla
],
[])
AT_CLEANUP
AT_SETUP([Dependency generation 3])
AT_KEYWORDS([build])
AT_CHECK([
RPMDB_INIT
cat << EOF > "${RPMTEST}"/tmp/bad.req
#!/bin/sh
echo 'bad = *'
EOF
chmod a+x "${RPMTEST}"/tmp/bad.req
runroot rpmbuild -bb --quiet \
--define "__script_requires /tmp/bad.req" \
/data/SPECS/shebang.spec
],
[1],
[],
[error: Illegal char '*' (0x2a) in: *
Illegal char '*' (0x2a) in: *
])
AT_CLEANUP
AT_SETUP([Dependency generation 4])
AT_KEYWORDS([build])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild -bb --quiet \
--define '__script_requires() foo(%{basename:%{1}})' \
/data/SPECS/shebang.spec
runroot rpm -qp --requires /build/RPMS/noarch/shebang-0.1-1.noarch.rpm|grep -v ^rpmlib
],
[0],
[foo(shebang)
],
[])
AT_CLEANUP
AT_SETUP([Dependency generation 5])
AT_KEYWORDS([build])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild -bb --quiet \
--define '__script_mime text/plain' \
--undefine '__script_magic' \
/data/SPECS/shebang.spec
runroot rpm -qp --requires /build/RPMS/noarch/shebang-0.1-1.noarch.rpm|grep -v ^rpmlib
],
[0],
[/bin/blabla
],
[])
AT_CLEANUP
AT_SETUP([elf dependencies])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
runroot_other chmod a-x /data/misc/libhello.so
runroot_other ${RPM_CONFIGDIR}/elfdeps -R /data/misc/libhello.so
runroot_other chmod a+x /data/misc/libhello.so
runroot_other ${RPM_CONFIGDIR}/elfdeps -R /data/misc/libhello.so
],
[0],
[libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6()(64bit)
rtld(GNU_HASH)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6()(64bit)
rtld(GNU_HASH)
],
[])
AT_CHECK([
runroot_other chmod a-x /data/misc/libhello.so
runroot_other ${RPM_CONFIGDIR}/elfdeps -P /data/misc/libhello.so
runroot_other chmod a+x /data/misc/libhello.so
runroot_other ${RPM_CONFIGDIR}/elfdeps -P /data/misc/libhello.so
],
[0],
[libhello.so()(64bit)
libhello.so()(64bit)
],
[])
AT_CHECK([
runroot_other chmod a-x /data/misc/helloexe
runroot_other ${RPM_CONFIGDIR}/elfdeps -R /data/misc/helloexe
runroot_other chmod a+x /data/misc/helloexe
runroot_other ${RPM_CONFIGDIR}/elfdeps -R /data/misc/helloexe
],
[0],
[libc.so.6(GLIBC_2.2.5)(64bit)
libhello.so()(64bit)
libc.so.6()(64bit)
rtld(GNU_HASH)
],
[])
AT_CHECK([
runroot_other chmod a-x /data/misc/hellopie
runroot_other ${RPM_CONFIGDIR}/elfdeps -R /data/misc/hellopie
runroot_other chmod a+x /data/misc/hellopie
runroot_other ${RPM_CONFIGDIR}/elfdeps -R /data/misc/hellopie
],
[0],
[libc.so.6(GLIBC_2.2.5)(64bit)
libhello.so()(64bit)
libc.so.6()(64bit)
rtld(GNU_HASH)
],
[])
AT_CLEANUP
# ------------------------------
# Test spec query functionality
AT_SETUP([rpmspec query 1])
AT_KEYWORDS([build])
AT_CHECK([
runroot rpmspec -q \
--define "pkg dep" \
--define "reqs foo > 1.2.3 bar <= 2.3" \
--requires \
/data/SPECS/deptest.spec
],
[0],
[bar <= 2.3
foo > 1.2.3
],
[])
AT_CLEANUP
# ------------------------------
# archive sanity check
AT_SETUP([rpmbuild archive sanity])
AT_KEYWORDS([build])
AT_CHECK([
RPMDB_INIT
runroot rpmbuild \
-bb --quiet /data/SPECS/attrtest.spec
runroot rpm2cpio \
/build/RPMS/noarch/attrtest-1.0-1.noarch.rpm > "${RPMTEST}"/tmp/attrtest.cpio
],
[0],
[],
[])
AT_CLEANUP
# ------------------------------
# Check if rpmbuild creates the minisymtab section in the main hello binary
AT_SETUP([rpmbuild debuginfo minisymtab])
AT_KEYWORDS([build] [debuginfo])
AT_SKIP_IF([$DEBUGINFO_DISABLED])
AT_CHECK([
RPMDB_INIT
# Use macros.debug to generate a debuginfo package.
export CFLAGS="-g"
rundebug rpmbuild --quiet \
--rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
# Extract the main package and inspect the hello binary
# It should contain .gnu_debugdata, but not the full .symtab
rpm2cpio ${RPMTEST}/build/RPMS/*/hello-1.0-1.*.rpm | cpio -diu
test -f ./usr/local/bin/hello || exit 1
readelf -S ./usr/local/bin/hello |\
grep -q .gnu_debugdata; test $? == 0 || exit 1
readelf -S ./usr/local/bin/hello \
| grep -q .symtab; test $? == 1 || exit 1
# And the opposite for the debuginfo package
rpm2cpio ${RPMTEST}/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
| cpio -diu
test -f ./usr/lib/debug/usr/local/bin/hello*.debug || exit 1
readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
| grep -q .gnu_debugdata; test $? == 1 || exit 1
readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
| grep -q .symtab; test $? == 0 || exit 1
],
[0],
[],
[ignore])
AT_CLEANUP
# ------------------------------
# Check if rpmbuild doesn't create the minisymtab section if we keep symtab
# Some package might want to use strip -g to keep the symbol table and only
# but the debug symbols/info in the debuginfo package.
AT_SETUP([rpmbuild debuginfo minisymtab strip -g])
AT_KEYWORDS([build] [debuginfo])
AT_SKIP_IF([$DEBUGINFO_DISABLED])
AT_CHECK([
RPMDB_INIT
# Use macros.debug to generate a debuginfo package.
export CFLAGS="-g"
rundebug rpmbuild --quiet \
--define="_find_debuginfo_opts -g" \
--rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
# Extract the main package and inspect the hello binary
# It should contain .symtab (because of strip -g), so doesn't .gnu_debugdata.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello-1.0-1.*.rpm | cpio -diu
test -f ./usr/local/bin/hello || exit 1
readelf -S ./usr/local/bin/hello \
| grep -q .gnu_debugdata; test $? == 1 || exit 1
readelf -S ./usr/local/bin/hello \
| grep -q .symtab; test $? == 0 || exit 1
# The debuginfo package should contain neither. The .symtab is NOBITS.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
| cpio -diu
test -f ./usr/lib/debug/usr/local/bin/hello*.debug || exit 1
readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
| grep -q .gnu_debugdata; test $? == 1 || exit 1
readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
| grep .symtab | grep -q NOBITS; test $? == 0 || exit 1
],
[0],
[],
[ignore])
AT_CLEANUP
# ------------------------------
# Check if rpmbuild runs dwz and generates a multi file that with shared
# debuginfo. This is simply the hello example with one binary build twice
# so dwz has enough slightly similar debug data.
# Test the case without unique debug file names.
AT_SETUP([rpmbuild debuginfo dwz])
AT_KEYWORDS([build] [debuginfo] [dwz])
AT_SKIP_IF([$DEBUGINFO_DISABLED])
AT_CHECK([
RPMDB_INIT
rundebug rpmbuild --quiet \
--undefine "_unique_debug_names" \
--undefine "_unique_debug_srcs" \
-ba "${abs_srcdir}"/data/SPECS/hello2.spec
# The debuginfo package should contain a .debug file for each binary
# and a dwz multi file that contains the shared debuginfo between them.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
| cpio -diu
hello_file_debug=./usr/lib/debug/usr/local/bin/hello.debug
hello2_file_debug=./usr/lib/debug/usr/local/bin/hello2.debug
hello_multi_file=./usr/lib/debug/.dwz/hello2-1.0-1.*
test -f $hello_file_debug || echo "no hello debug file: $hello_file_debug"
test -f $hello2_file_debug || echo "no hello2 debug file: $hello2_file_debug"
test -f $hello_multi_file || echo "no dwz multi file: $hello_multi_file"
# Make sure the main package binaries contain the correct build-ids
# linking them to the debug packages.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello2-1.0-1.*.rpm \
| cpio -diu
hello_file=./usr/local/bin/hello
hello2_file=./usr/local/bin/hello2
test -f $hello_file || echo "no hello file: $hello_file"
test -f $hello2_file || echo "no hello2 file: $hello2_file"
id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id1debug=$(file $hello_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
# The build-id files should link to the .debug files.
id1file="./usr/lib/debug/.build-id/${id1:0:2}/${id1:2}"
canonid1file=$(readlink -f ${id1file})
canonfile1=$(readlink -f $hello_file)
canonid1debug=$(readlink -f ${id1file}.debug)
canondebug1=$(readlink -f $hello_file_debug)
test "$canonid1file" = "$canonfile1" \
|| echo "canonid1file: $canonid1file != $canonfile1"
test "$canonid1debug" = "$canondebug1" \
|| echo "canonid1debug: $canonid1debug != $canondebug1"
id2file="./usr/lib/debug/.build-id/${id2:0:2}/${id2:2}"
canonid2file=$(readlink -f ${id2file})
canonfile2=$(readlink -f $hello2_file)
canonid2debug=$(readlink -f ${id2file}.debug)
canondebug2=$(readlink -f $hello2_file_debug)
test "$canonid2file" = "$canonfile2" \
|| echo "canonid2: $canonid2file != $canonfile2"
test "$canonid2debug" = "$canondebug2" \
|| echo "canonid2debug: $canonid2debug" != "$canondebug2"
# Both .debug files should point to the dwz multi file.
# It would be nice to also test that they contain the correct dwz build-id
# but that is a bit hard to grep out of the section data.
multiref1=$(readelf --string-dump=.gnu_debugaltlink $hello_file_debug \
| grep '[ 0]' | cut -c13-)
multiref2=$(readelf --string-dump=.gnu_debugaltlink $hello2_file_debug \
| grep '[ 0]' | cut -c13-)
test "$multiref1" = "$multiref2" || echo "multiref: $multiref1 != $multiref2"
canonmultiref=$(readlink -f $(dirname $canondebug1)/$multiref1)
canonmultifile=$(readlink -f $hello_multi_file)
test "$canonmultiref" = "$canonmultifile" \
|| echo "canonmultiref: $canonmultiref" != "$canonmultifile"
],
[0],
[],
[ignore])
AT_CLEANUP
# ------------------------------
# Check that rpmbuild creates no debuginfo when --nodebuginfo is passed
AT_SETUP([rpmbuild no debuginfo])
AT_KEYWORDS([build] [debuginfo])
AT_SKIP_IF([$DEBUGINFO_DISABLED])
AT_CHECK([
RPMDB_INIT
# Use macros.debug to generate a debuginfo package,
# but pass --nodebuginfo to skip it.
export CFLAGS="-g"
rundebug rpmbuild --quiet --nodebuginfo \
--rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
# Extract the main package and inspect the hello binary
# It should not contain .gnu_debugdata, but the full .symtab
rpm2cpio ${RPMTEST}/build/RPMS/*/hello-1.0-1.*.rpm | cpio -diu
test -f ./usr/local/bin/hello || exit 1
readelf -S ./usr/local/bin/hello |\
grep -q .gnu_debugdata; test $? == 1 || exit 1
readelf -S ./usr/local/bin/hello \
| grep -q .symtab; test $? == 0 || exit 1
# And the opposite for the debuginfo package
test ! -e ${RPMTEST}/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm || exit 1
],
[0],
[],
[ignore])
AT_CLEANUP
# ------------------------------
# Check if rpmbuild runs dwz and generates a multi file that with shared
# debuginfo. This is simply the hello example with one binary build twice
# so dwz has enough slightly similar debug data.
# Test with unique debug file names.
AT_SETUP([rpmbuild debuginfo dwz unique debug names])
AT_KEYWORDS([build] [debuginfo] [dwz])
AT_SKIP_IF([$DEBUGINFO_DISABLED])
AT_CHECK([
RPMDB_INIT
rundebug rpmbuild --quiet \
--define "_unique_debug_names 1" \
-ba "${abs_srcdir}"/data/SPECS/hello2.spec
# The debuginfo package should contain a .debug file for each binary
# and a dwz multi file that contains the shared debuginfo between them.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
| cpio -diu
hello_file_debug=./usr/lib/debug/usr/local/bin/hello-*.debug
hello2_file_debug=./usr/lib/debug/usr/local/bin/hello2-*.debug
hello_multi_file=./usr/lib/debug/.dwz/hello2-1.0-1.*
test -f $hello_file_debug || echo "no hello debug file: $hello_file_debug"
test -f $hello2_file_debug || echo "no hello2 debug file: $hello2_file_debug"
test -f $hello_multi_file || echo "no dwz multi file: $hello_multi_file"
# Make sure the main package binaries contain the correct build-ids
# linking them to the debug packages.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello2-1.0-1.*.rpm \
| cpio -diu
hello_file=./usr/local/bin/hello
hello2_file=./usr/local/bin/hello2
test -f $hello_file || echo "no hello file: $hello_file"
test -f $hello2_file || echo "no hello2 file: $hello2_file"
id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id1debug=$(file $hello_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
# The build-id files should link to the .debug files.
id1file="./usr/lib/debug/.build-id/${id1:0:2}/${id1:2}"
canonid1file=$(readlink -f ${id1file})
canonfile1=$(readlink -f $hello_file)
canonid1debug=$(readlink -f ${id1file}.debug)
canondebug1=$(readlink -f $hello_file_debug)
test "$canonid1file" = "$canonfile1" \
|| echo "canonid1file: $canonid1file != $canonfile1"
test "$canonid1debug" = "$canondebug1" \
|| echo "canonid1debug: $canonid1debug != $canondebug1"
id2file="./usr/lib/debug/.build-id/${id2:0:2}/${id2:2}"
canonid2file=$(readlink -f ${id2file})
canonfile2=$(readlink -f $hello2_file)
canonid2debug=$(readlink -f ${id2file}.debug)
canondebug2=$(readlink -f $hello2_file_debug)
test "$canonid2file" = "$canonfile2" \
|| echo "canonid2: $canonid2file != $canonfile2"
test "$canonid2debug" = "$canondebug2" \
|| echo "canonid2debug: $canonid2debug" != "$canondebug2"
# Both .debug files should point to the dwz multi file.
# It would be nice to also test that they contain the correct dwz build-id
# but that is a bit hard to grep out of the section data.
multiref1=$(readelf --string-dump=.gnu_debugaltlink $hello_file_debug \
| grep '[ 0]' | cut -c13-)
multiref2=$(readelf --string-dump=.gnu_debugaltlink $hello2_file_debug \
| grep '[ 0]' | cut -c13-)
test "$multiref1" = "$multiref2" || echo "multiref: $multiref1 != $multiref2"
canonmultiref=$(readlink -f $(dirname $canondebug1)/$multiref1)
canonmultifile=$(readlink -f $hello_multi_file)
test "$canonmultiref" = "$canonmultifile" \
|| echo "canonmultiref: $canonmultiref" != "$canonmultifile"
],
[0],
[],
[ignore])
AT_CLEANUP
# ------------------------------
# Check that an implicit suid binary get included with the suid bit set.
# We explicitly build with all debug.macros to test those helpers.
AT_SETUP([rpmbuild implicit suid binary])
AT_KEYWORDS([build] [debuginfo] [dwz] [suid])
AT_SKIP_IF([$DEBUGINFO_DISABLED])
AT_CHECK([
RPMDB_INIT
# Build a package that has some debuginfo
rundebug rpmbuild --quiet \
-ba "${abs_srcdir}"/data/SPECS/hello2-suid.spec
# Unpack rpm so we can check the included binaries.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello2-1.0-1.*.rpm \
| cpio -diu --quiet
# List all binaries with suid bit set (should be one, hello).
echo "suid:"
find usr -executable -type f -perm /4000
# List all binaries without suid bit set (should also be one, hello2).
echo "no-suid:"
find usr -executable -type f \! -perm /4000
],
[0],
[suid:
usr/local/bin/hello
no-suid:
usr/local/bin/hello2
],
[ignore])
AT_CLEANUP
# ------------------------------
# Check that a GDB index is included when requested.
AT_SETUP([rpmbuild debuginfo gdb index included])
AT_KEYWORDS([build] [debuginfo] [gdb])
AT_SKIP_IF([$DEBUGINFO_DISABLED])
AT_CHECK([
RPMDB_INIT
# Build a package that has some debuginfo
rundebug rpmbuild --quiet \
--define "_include_gdb_index 1" \
-ba "${abs_srcdir}"/data/SPECS/hello2.spec
# Unpack the debuginfo rpms so we can check the .debug files.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
| cpio -diu --quiet
# Check that gdb-add-index has ran and a .gdb_index section has been added
readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
| grep gdb_index | cut -c8-17
],
[0],
[.gdb_index
],
[ignore])
AT_CLEANUP
# ------------------------------
# Check that a GDB index is NOT included when not requested.
AT_SETUP([rpmbuild debuginfo no gdb index included])
AT_KEYWORDS([build] [debuginfo] [gdb])
AT_SKIP_IF([$DEBUGINFO_DISABLED])
AT_CHECK([
RPMDB_INIT
# Build a package that has some debuginfo
rundebug rpmbuild --quiet \
--undefine "_include_gdb_index" \
-ba "${abs_srcdir}"/data/SPECS/hello2.spec
# Unpack the debuginfo rpms so we can check the .debug files.
rpm2cpio ${RPMTEST}/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
| cpio -diu --quiet
# Check that gdb-add-index has not ran and no .gdb_index section has been added
readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
| grep gdb_index | cut -c8-17
],
[0],
[],
[ignore])