SUSE distros all have in common suse in ID_LIKE field. The ID field
could be varying and is even set to 'Dummy' when building the packages.
If the usual values for openSUSE/SLE can't be found in ID, try with
ID_LIKE.
---
src/os_release.ml | 10 +++++++++-
src/os_release.mli | 7 +++++++
src/ph_rpm.ml | 1 +
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/os_release.ml b/src/os_release.ml
index b2de259..daa8b07 100644
--- a/src/os_release.ml
+++ b/src/os_release.ml
@@ -29,6 +29,7 @@ let split sep str =
type os_release = {
id : string;
+ id_like : string list;
}
let data = ref None
@@ -52,6 +53,7 @@ and parse () =
let lines = List.filter (fun s -> s.[0] <> '#') lines in
let id = ref "" in
+ let id_like = ref [] in
List.iter (
fun line ->
@@ -65,10 +67,11 @@ and parse () =
else value in
match field with
| "ID" -> id := value
+ | "ID_LIKE" -> id_like := String.split_on_char ' ' value
| _ -> ()
) lines;
- Some { id = !id; }
+ Some { id = !id; id_like = !id_like }
) else
None
@@ -76,3 +79,8 @@ let get_id () =
match get_data () with
| None -> ""
| Some d -> d.id
+
+let get_id_like () =
+ match get_data () with
+ | None -> []
+ | Some d -> d.id_like
diff --git a/src/os_release.mli b/src/os_release.mli
index 2ae349b..e9f2993 100644
--- a/src/os_release.mli
+++ b/src/os_release.mli
@@ -24,3 +24,10 @@ val get_id : unit -> string
An empty string is returned if the file does not exist or cannot
be read. *)
+
+val get_id_like : unit -> string list
+(** Get the value of the "ID_LIKE" field from the /etc/os-release file
+ on the current system.
+
+ An empty list is returned if the file does not exist, cannot
+ be read or the ID_LIKE field is not defined. *)
diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml
index b0a5eb2..fd87822 100644
--- a/src/ph_rpm.ml
+++ b/src/ph_rpm.ml
@@ -41,6 +41,7 @@ let opensuse_detect () =
Config.rpm <> "no" && Config.rpm2cpio <> "no"
&& rpm_is_available () &&
Config.zypper <> "no" &&
(List.mem (Os_release.get_id ()) [ "opensuse"; "sled";
"sles" ] ||
+ List.mem "suse" (Os_release.get_id_like ()) ||
try (stat "/etc/SuSE-release").st_kind = S_REG with Unix_error _ ->
false)
let mageia_detect () =
--
2.13.2