supermin/0001-rpm-extend-the-Multiple_matches-exception.patch
2019-01-24 14:43:22 +00:00

90 lines
2.8 KiB
Diff

From 42955541dc3aa8ae3361f3bd6eb0ae338f307545 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Wed, 23 Jan 2019 12:22:19 +0100
Subject: [PATCH 1/2] rpm: extend the Multiple_matches exception
Add the package that raised the issue, so it can be used to provide
better diagnostic.
---
src/librpm-c.c | 15 ++++++++++-----
src/librpm.ml | 4 ++--
src/librpm.mli | 2 +-
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/librpm-c.c b/src/librpm-c.c
index 3bd25a2..75ca4d7 100644
--- a/src/librpm-c.c
+++ b/src/librpm-c.c
@@ -66,10 +66,15 @@ librpm_handle_closed (void)
}
static void
-librpm_raise_multiple_matches (int occurrences)
+librpm_raise_multiple_matches (value pkgv, int occurrences)
{
- caml_raise_with_arg (*caml_named_value ("librpm_multiple_matches"),
- Val_int (occurrences));
+ CAMLparam1 (pkgv);
+
+ value args[] = { pkgv, Val_int (occurrences) };
+ caml_raise_with_args (*caml_named_value ("librpm_multiple_matches"),
+ 2, args);
+
+ CAMLnoreturn;
}
#define Librpm_val(v) (*((struct librpm_data *)Data_custom_val(v)))
@@ -296,7 +301,7 @@ supermin_rpm_pkg_requires (value rpmv, value pkgv)
fflush (stdout);
}
if (count != 1)
- librpm_raise_multiple_matches (count);
+ librpm_raise_multiple_matches (pkgv, count);
h = rpmdbNextIterator (iter);
assert (h != NULL);
@@ -413,7 +418,7 @@ supermin_rpm_pkg_filelist (value rpmv, value pkgv)
fflush (stdout);
}
if (count != 1)
- librpm_raise_multiple_matches (count);
+ librpm_raise_multiple_matches (pkgv, count);
h = rpmdbNextIterator (iter);
assert (h != NULL);
diff --git a/src/librpm.ml b/src/librpm.ml
index 4eeba77..b6f9ff8 100644
--- a/src/librpm.ml
+++ b/src/librpm.ml
@@ -23,7 +23,7 @@ external rpm_vercmp : string -> string -> int = "supermin_rpm_vercmp" "noalloc"
type t
-exception Multiple_matches of int
+exception Multiple_matches of string * int
external rpm_open : ?debug:int -> t = "supermin_rpm_open"
external rpm_close : t -> unit = "supermin_rpm_close"
@@ -49,4 +49,4 @@ external rpm_pkg_whatprovides : t -> string -> string array = "supermin_rpm_pkg_
external rpm_pkg_filelist : t -> string -> rpmfile_t array = "supermin_rpm_pkg_filelist"
let () =
- Callback.register_exception "librpm_multiple_matches" (Multiple_matches 0)
+ Callback.register_exception "librpm_multiple_matches" (Multiple_matches ("", 0))
diff --git a/src/librpm.mli b/src/librpm.mli
index 5229be6..53b4b2c 100644
--- a/src/librpm.mli
+++ b/src/librpm.mli
@@ -31,7 +31,7 @@ val rpm_vercmp : string -> string -> int
type t
(** The librpm handle. *)
-exception Multiple_matches of int
+exception Multiple_matches of string * int
val rpm_open : ?debug:int -> t
(** Open the librpm (transaction set) handle. *)
--
2.20.1