Add support for .deb files to abipkgdiff

This lets abipkgdiff compare debian binary packages.

The patch contains test cases for debian package with split debug info
that is referenced by the build-id scheme.  These test cases come from
the bug report https://sourceware.org/bugzilla/show_bug.cgi?id=18792,
more particularly from the attachment
https://sourceware.org/bugzilla/attachment.cgi?id=8516.

	* include/abg-tools-utils.h (file_type): Add FILE_TYPE_DEB.
	* tools/abipkgdiff.cc (extract_deb): New.
	(extract_package, main): Handle FILE_TYPE_DEB.
	* src/abg-tools-utils.cc (operator<<): Handle FILE_TYPE_DEB.
	(guess_file_type): Detect FILE_TYPE_DEB.
	* tools/abidiff.cc (main): Handle FILE_TYPE_DEB.
	* tools/abilint.cc (main): Handle FILE_TYPE_DEB.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb:
	Input debian debug info package; to be compared by the test
	harness runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb:
	Input debian package; to be compared by the test harness
	runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb:
	Input debug info package
	* tests/data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb:
	Input debian package; to be compared by the test harness
	runtestdiffpkg.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt:
	Reference output for the comparison of the packages above.
	* tests/data/Makefile.am: Add the new files above to the source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the input packages
	above to the set of files to be compared by this test harness.

Signed-off-by: Matthias Klose <doko@debian.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Matthias Klose 2015-08-07 10:48:17 +02:00 committed by Dodji Seketeli
parent 393fe3166b
commit 4df0a4d952
12 changed files with 157 additions and 5 deletions

View File

@ -115,6 +115,8 @@ enum file_type
FILE_TYPE_RPM,
/// An SRPM (.src.rpm) file
FILE_TYPE_SRPM,
/// An DEB (.deb) binary file
FILE_TYPE_DEB,
};
/// Exit status for abidiff and abicompat tools.

View File

@ -471,6 +471,9 @@ operator<<(ostream& output,
case FILE_TYPE_SRPM:
repr = "SRPM file type";
break;
case FILE_TYPE_DEB:
repr = "Debian binary file type";
break;
}
output << repr;
@ -485,8 +488,8 @@ operator<<(ostream& output,
file_type
guess_file_type(istream& in)
{
const unsigned BUF_LEN = 13;
const unsigned NB_BYTES_TO_READ = 12;
const unsigned BUF_LEN = 25;
const unsigned NB_BYTES_TO_READ = 24;
char buf[BUF_LEN];
memset(buf, 0, BUF_LEN);
@ -511,7 +514,12 @@ guess_file_type(istream& in)
&& buf[4] == 'c'
&& buf[5] == 'h'
&& buf[6] == '>')
return FILE_TYPE_AR;
{
if (strstr(buf, "debian-binary"))
return FILE_TYPE_DEB;
else
return FILE_TYPE_AR;
}
if (buf[0] == '<'
&& buf[1] == 'a'

View File

@ -818,5 +818,9 @@ test-diff-pkg/test-rpm-report-1.txt \
test-diff-pkg/test-rpm-report-2.txt \
test-diff-pkg/test-rpm-report-3.txt \
test-diff-pkg/test-rpm-report-4.txt \
test-diff-pkg/test-rpm-report-5.txt
test-diff-pkg/test-rpm-report-5.txt \
test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb \
test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt \
test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb \
test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb \
test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb

View File

@ -0,0 +1,65 @@
================ changes of 'libsigc-2.0.so.0.0.0'===============
Functions changes summary: 1 Removed, 2 Changed (15 filtered out), 1 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 Removed function:
'method void std::_List_base<sigc::slot_base, std::allocator<sigc::slot_base> >::_M_clear()' {_ZNSt10_List_baseIN4sigc9slot_baseESaIS1_EE8_M_clearEv}
1 Added function:
'method void std::__cxx11::_List_base<sigc::slot_base, std::allocator<sigc::slot_base> >::_M_clear()' {_ZNSt7__cxx1110_List_baseIN4sigc9slot_baseESaIS2_EE8_M_clearEv}
2 functions with some indirect sub-type change:
[C]'method sigc::connection::connection(const sigc::connection&)' has some indirect sub-type changes:
parameter 1 of type 'const sigc::connection&' has sub-type changes:
in referenced type 'const sigc::connection':
in unqualified underlying type 'struct sigc::connection':
1 data member change:
type of 'sigc::slot_base* sigc::connection::slot_' changed:
in pointed to type 'class sigc::slot_base':
1 data member change:
type of 'sigc::slot_base::rep_type* sigc::slot_base::rep_' changed:
in pointed to type 'typedef sigc::slot_base::rep_type':
underlying type 'struct sigc::internal::slot_rep' changed:
1 base class change:
'struct sigc::trackable' changed:
1 data member change:
type of 'sigc::internal::trackable_callback_list* sigc::trackable::callback_list_' changed:
in pointed to type 'struct sigc::internal::trackable_callback_list':
type size changed from 192 to 256 bits
2 data member changes:
type of 'sigc::internal::trackable_callback_list::callback_list sigc::internal::trackable_callback_list::callbacks_' changed:
underlying type 'class std::list<sigc::internal::trackable_callback, std::allocator<sigc::internal::trackable_callback> >' changed:
type name changed from 'std::list<sigc::internal::trackable_callback, std::allocator<sigc::internal::trackable_callback> >' to 'std::__cxx11::list<sigc::internal::trackable_callback, std::allocator<sigc::internal::trackable_callback> >'
type size changed from 128 to 192 bits
1 base class deletion:
class std::_List_base<sigc::internal::trackable_callback, std::allocator<sigc::internal::trackable_callback> >
1 base class insertion:
class std::__cxx11::_List_base<sigc::internal::trackable_callback, std::allocator<sigc::internal::trackable_callback> >
'bool sigc::internal::trackable_callback_list::clearing_' offset changed from 128 to 192 (in bits)
[C]'method sigc::internal::signal_impl* sigc::signal_base::impl()' has some indirect sub-type changes:
return type changed:
in pointed to type 'struct sigc::internal::signal_impl':
type size changed from 192 to 256 bits
1 data member change:
type of 'std::list<sigc::slot_base, std::allocator<sigc::slot_base> > sigc::internal::signal_impl::slots_' changed:
type name changed from 'std::list<sigc::slot_base, std::allocator<sigc::slot_base> >' to 'std::__cxx11::list<sigc::slot_base, std::allocator<sigc::slot_base> >'
type size changed from 128 to 192 bits
1 base class deletion:
class std::_List_base<sigc::slot_base, std::allocator<sigc::slot_base> >
1 base class insertion:
class std::__cxx11::_List_base<sigc::slot_base, std::allocator<sigc::slot_base> >
================ end of changes of 'libsigc-2.0.so.0.0.0'===============

View File

@ -113,6 +113,16 @@ static InOutSpec in_out_specs[] =
"data/test-diff-pkg/test-rpm-report-5.txt",
"output/test-diff-pkg/test-rpm-report-5.txt"
},
// Two debian packages.
{
"data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb",
"data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb",
"--fail-no-dbg",
"data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb",
"data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb",
"data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt",
"output/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt"
},
// This should be the last entry.
{0, 0, 0, 0, 0, 0, 0}
};

View File

@ -551,6 +551,8 @@ main(int argc, char* argv[])
break;
case abigail::tools_utils::FILE_TYPE_SRPM:
break;
case abigail::tools_utils::FILE_TYPE_DEB:
break;
}
switch (t2_type)
@ -583,6 +585,8 @@ main(int argc, char* argv[])
break;
case abigail::tools_utils::FILE_TYPE_SRPM:
break;
case abigail::tools_utils::FILE_TYPE_DEB:
break;
}
if (!t1 && !c1)

View File

@ -227,6 +227,8 @@ main(int argc, char* argv[])
break;
case abigail::tools_utils::FILE_TYPE_SRPM:
break;
case abigail::tools_utils::FILE_TYPE_DEB:
break;
}
if (!tu && !corp)

View File

@ -417,6 +417,47 @@ extract_rpm(const string& package_path,
return true;
}
/// Extract an Debian binary package.
///
/// @param package_path the path to the package to extract.
///
/// @param extracted_package_dir_path the path where to extract the
/// package to.
///
/// @return true upon successful completion, false otherwise.
static bool
extract_deb(const string& package_path,
const string& extracted_package_dir_path)
{
if (verbose)
cerr << "Extracting package "
<< package_path
<< "to "
<< extracted_package_dir_path
<< " ...";
string cmd = "test -d " +
extracted_package_dir_path +
" && rm -rf " + extracted_package_dir_path;
system(cmd.c_str());
cmd = "mkdir -p " + extracted_package_dir_path + " && dpkg -x " +
package_path + " " + extracted_package_dir_path;
if (system(cmd.c_str()))
{
if (verbose)
cerr << " FAILED\n";
return false;
}
if (verbose)
cerr << " DONE\n";
return true;
}
/// Erase the temporary directories created for the extraction of two
/// packages.
///
@ -464,6 +505,14 @@ extract_package(const package& package)
}
return true;
break;
case abigail::tools_utils::FILE_TYPE_DEB:
if (!extract_deb(package.path(), package.extracted_dir_path()))
{
cerr << "Error while extracting package" << package.path() << "\n";
return false;
}
return true;
break;
default:
return false;
}
@ -1044,6 +1093,14 @@ main(int argc, char* argv[])
}
break;
case abigail::tools_utils::FILE_TYPE_DEB:
if (!(second_package->type() == abigail::tools_utils::FILE_TYPE_DEB))
{
cerr << opts.package2 << " should be an DEB file\n";
return 1;
}
break;
default:
cerr << opts.package1 << " should be a valid package file \n";
return 1;