]> sourceware.org Git - libabigail.git/commitdiff
Add support for .deb files to abipkgdiff
authorMatthias Klose <doko@debian.org>
Fri, 7 Aug 2015 08:48:17 +0000 (10:48 +0200)
committerDodji Seketeli <dodji@redhat.com>
Fri, 14 Aug 2015 11:36:23 +0000 (13:36 +0200)
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>
12 files changed:
include/abg-tools-utils.h
src/abg-tools-utils.cc
tests/data/Makefile.am
tests/data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb [new file with mode: 0644]
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 [new file with mode: 0644]
tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb [new file with mode: 0644]
tests/data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb [new file with mode: 0644]
tests/data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb [new file with mode: 0644]
tests/test-diff-pkg.cc
tools/abidiff.cc
tools/abilint.cc
tools/abipkgdiff.cc

index 14673b80c9c0eb7257b8fe5a4d032eabf7e8309b..43f1312f4085556296c2ef9829728de55f69a2b9 100644 (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.
index c9a6fa125f55edb38c5d234ce39ab382aa7e6a3c..4e7e0f7bdfb1488fb59a4bf99cd56da9768a467f 100644 (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'
index ab347fb59039aa010a8a2438d83f44d3e6922497..3f8ed41c49017c7611b507f89523ef26a7a34208 100644 (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
diff --git a/tests/data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb b/tests/data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb
new file mode 100644 (file)
index 0000000..f2d7562
Binary files /dev/null and b/tests/data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb differ
diff --git a/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 b/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
new file mode 100644 (file)
index 0000000..34a0953
--- /dev/null
@@ -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'===============
+
diff --git a/tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb b/tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb
new file mode 100644 (file)
index 0000000..a6f1454
Binary files /dev/null and b/tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb differ
diff --git a/tests/data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb b/tests/data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb
new file mode 100644 (file)
index 0000000..a4bdb7f
Binary files /dev/null and b/tests/data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb differ
diff --git a/tests/data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb b/tests/data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb
new file mode 100644 (file)
index 0000000..b0c3092
Binary files /dev/null and b/tests/data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb differ
index 5ecd0627753f089eaa491e6ef40f005b52b75048..277de36ffe6897b63a23994f1bd221c6eac4321e 100644 (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}
 };
index b977f0a14233beed2e674e7b182f5166cbb0ff5e..9c706b5bab94a016111662d3d71e17020105ba32 100644 (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)
index 0599d245b3478a339267c6cd008eb1ecbf58d869..47a797cf4bc956d8988048358d185e27f8196325 100644 (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)
index 982a2b51fbc7b205137bb24912d3b4cd7d02e6d8..6c78a370d631dce2b6d88ae7fcb4f9ebcb86f49d 100644 (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;
This page took 0.054293 seconds and 5 git commands to generate.