Make abipkgdiff compare tar archives containing binaries
authorDodji Seketeli <dodji@redhat.com>
Sat, 22 Aug 2015 11:59:18 +0000 (13:59 +0200)
committerDodji Seketeli <dodji@redhat.com>
Sat, 22 Aug 2015 12:32:20 +0000 (14:32 +0200)
commit585fc4c33cd317a6d8ef50d6db27b246f8943f20
treeb2a9aa8c2dea17d9697858001953598a93ecdc41
parentfca8506ab937462bec535cdd47890aff2ec26a94
Make abipkgdiff compare tar archives containing binaries

This patch adds support for comparing the ABI of binaries contained in
a tar archive.

If the archive is compressed with gzip, bzip2, lzip, lzma or xz, then
abipkgdiff recognizes the usual relevant file extensions and lets the
GNU tar program handle the decompression.

If the archive is not compressed, abipkgdiff recognizes the UStar
(Uniform Standard Tape ARchive) format, even if the archive file name
doesn't end with the .tar extension, and lets the GNU tar program
handle the extraction.  If the file ends up with the .tar extension
anyway (even if it's not in the UStar format, abipkgdiff lets the GNU
tar program handle its extraction.

* config.h.in (WITH_TAR): New configuration preprocessor macro.
* configure.ac: Add a new --enable-tar option.  It's turned on
automatically if the tar program is found in the PATH.  Adjust the
build configuration report to add the tar archive support.
* include/abg-tools-utils.h (string_ends_with): Declare new
function.
(enum file_type): Add a new FILE_TYPE_TAR enumerator.
* src/abg-tools-utils.cc (string_ends_with): Define new function.
(operator<<(ostream&, file_type)): Serialize the new FILE_TYPE_TAR
enumerator.
(guess_file_type): Detect UStar format file by reading its magic
number.  Detect compressed tar files based on the file path
extension.
* tools/abipkgdiff.cc (extract_tar): Define new function.
(extract_package): Handle tar packages.
(main): Handle tar archives.
* tools/abidiff.cc (main): Handle the new FILE_TYPE_TAR
enumerator.
* tools/abilint.cc (main): Likewise.
* tests/data/test-diff-pkg/tarpkg-0-dir{1,2}.ta{,r,.bz2, gz}: New
test input tarballs.
* tests/data/test-diff-pkg/tarpkg-0-report-0.txt: New test output
reference.
* tests/data/Makefile.am: Add the new test data file above to
source distribution.
* tests/test-diff-pkg.cc (in_out_specs): Add new tests cases.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 files changed:
config.h.in
configure.ac
include/abg-tools-utils.h
src/abg-tools-utils.cc
tests/data/Makefile.am
tests/data/test-diff-pkg/tarpkg-0-dir1.ta [new file with mode: 0644]
tests/data/test-diff-pkg/tarpkg-0-dir1.tar [new file with mode: 0644]
tests/data/test-diff-pkg/tarpkg-0-dir1.tar.bz2 [new file with mode: 0644]
tests/data/test-diff-pkg/tarpkg-0-dir1.tar.gz [new file with mode: 0644]
tests/data/test-diff-pkg/tarpkg-0-dir2.ta [new file with mode: 0644]
tests/data/test-diff-pkg/tarpkg-0-dir2.tar [new file with mode: 0644]
tests/data/test-diff-pkg/tarpkg-0-dir2.tar.bz2 [new file with mode: 0644]
tests/data/test-diff-pkg/tarpkg-0-dir2.tar.gz [new file with mode: 0644]
tests/data/test-diff-pkg/tarpkg-0-report-0.txt [new file with mode: 0644]
tests/test-diff-pkg.cc
tools/abidiff.cc
tools/abilint.cc
tools/abipkgdiff.cc