Support up to two --wp options for abipkgdiff
authorDodji Seketeli <dodji@redhat.com>
Tue, 11 Jul 2017 16:06:50 +0000 (18:06 +0200)
committerDodji Seketeli <dodji@redhat.com>
Wed, 12 Jul 2017 08:40:15 +0000 (10:40 +0200)
The user should be able to specify one white list package per kernel
package on the command line.  That means the user should be able to
say:

    --wp whitelist-pkg1 --wp whitelist-pkg2

on the command line.

This patch adds support for that.

* doc/manuals/abipkgdiff.rst: Update the documentation to say that
--wp can be provided twice, but not more than that.
* tools/abipkgdiff.cc (options::kabi_whitelist_packages): Rename
kabi_whitelist_package to this, and make be of vector<string>
type.
(package::erase_extraction_directories): Erase the white list
package extracted data.
(maybe_handle_kabi_whitelist_pkg, parse_command_line): Adjust.
(main): Make sure there is no more than 2 --wp on the command
line.  Associate a white list package to each kernel package on
the command line.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
doc/manuals/abipkgdiff.rst
tools/abipkgdiff.cc

index 05c378da82f718be109a14daa9b0d359a56eb8b5..606b6ae6b177bfddfd3647192e11f61921363af3 100644 (file)
@@ -221,6 +221,10 @@ Options
     that white list will not be considered by the ABI comparison
     process.
 
+    Note that this option can be provided twice (not mor than twice),
+    specifying one white list package for each Linux Kernel package
+    that is provided on the command line.
+
     If this option is not provided -- thus if no white list is
     provided -- then the ABI of all publicly defined and exported
     functions and global variables by the Linux Kernel binaries are
index df1b96610a148724dc333d8582d41b0ac2278aa3..a632c055d492e1c4f3cbbaa9dfbdadde247593b0 100644 (file)
@@ -149,7 +149,6 @@ public:
   string       debug_package2;
   string       devel_package1;
   string       devel_package2;
-  string       kabi_whitelist_package;
   size_t       num_workers;
   bool         verbose;
   bool         drop_private_types;
@@ -166,6 +165,7 @@ public:
   bool         show_added_binaries;
   bool         fail_if_no_debug_info;
   bool         show_identical_binaries;
+  vector<string> kabi_whitelist_packages;
   vector<string> suppression_paths;
   vector<string> kabi_whitelist_paths;
   suppressions_type kabi_suppressions;
@@ -513,6 +513,8 @@ public:
       debug_info_package()->erase_extraction_directory(opts);
     if (devel_package())
       devel_package()->erase_extraction_directory(opts);
+    if (kabi_whitelist_package())
+      kabi_whitelist_package()->erase_extraction_directory(opts);
   }
 }; // end class package.
 
@@ -1346,7 +1348,7 @@ get_kabi_whitelists_from_arch_under_dir(const string& dir,
 static bool
 maybe_handle_kabi_whitelist_pkg(const package& pkg, options &opts)
 {
-  if (opts.kabi_whitelist_package.empty()
+  if (opts.kabi_whitelist_packages.empty()
       || !opts.kabi_whitelist_paths.empty()
       || !pkg.kabi_whitelist_package())
     return false;
@@ -2302,7 +2304,8 @@ parse_command_line(int argc, char* argv[], options& opts)
              opts.wrong_option = argv[i];
              return true;
            }
-         opts.kabi_whitelist_package = make_path_absolute(argv[j]).get();
+         opts.kabi_whitelist_packages.push_back
+           (make_path_absolute(argv[j]).get());
          ++i;
        }
       else if (!strcmp(argv[i], "--help")
@@ -2367,6 +2370,14 @@ main(int argc, char* argv[])
              | abigail::tools_utils::ABIDIFF_ERROR);
     }
 
+  if (opts.kabi_whitelist_packages.size() > 2)
+    {
+      emit_prefix("abipkgdiff", cerr)
+       << "no more than 2 Linux kernel white list packages can be provided\n";
+      return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
+             | abigail::tools_utils::ABIDIFF_ERROR);
+    }
+
   if (opts.display_usage)
     {
       display_usage(argv[0], cout);
@@ -2437,12 +2448,20 @@ main(int argc, char* argv[])
                                "devel_package2",
                                /*pkg_kind=*/package::KIND_DEVEL)));
 
-  if (!opts.kabi_whitelist_package.empty())
-    first_package->kabi_whitelist_package
-      (package_sptr(new package
-                   (opts.kabi_whitelist_package,
-                    "kabi_whitelist_package",
-                    /*pkg_kind=*/package::KIND_KABI_WHITELISTS)));
+  if (!opts.kabi_whitelist_packages.empty())
+    {
+      first_package->kabi_whitelist_package
+       (package_sptr(new package
+                     (opts.kabi_whitelist_packages[0],
+                      "kabi_whitelist_package1",
+                      /*pkg_kind=*/package::KIND_KABI_WHITELISTS)));
+      if (opts.kabi_whitelist_packages.size() >= 2)
+       second_package->kabi_whitelist_package
+         (package_sptr(new package
+                       (opts.kabi_whitelist_packages[1],
+                        "kabi_whitelist_package2",
+                        /*pkg_kind=*/package::KIND_KABI_WHITELISTS)));
+    }
 
   string package_name;
   switch (first_package->type())