Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rpm: query the RPM architecture
Query the RPM library for the current architecture of RPM, storing it
for later use, and printing it to the debug output.
  • Loading branch information
ptoscano committed Apr 12, 2019
1 parent de07577 commit e57e988
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/librpm-c.c
Expand Up @@ -132,6 +132,16 @@ supermin_rpm_vercmp (value av, value bv)
return Val_int (rpmvercmp (String_val (av), String_val (bv)));
}

value
supermin_rpm_get_arch (value unit)
{
const char *str;

rpmGetArchInfo (&str, NULL);

return caml_copy_string (str);
}

value
supermin_rpm_open (value debugv)
{
Expand Down
1 change: 1 addition & 0 deletions src/librpm.ml
Expand Up @@ -20,6 +20,7 @@ external rpm_is_available : unit -> bool = "supermin_rpm_is_available" "noalloc"

external rpm_version : unit -> string = "supermin_rpm_version"
external rpm_vercmp : string -> string -> int = "supermin_rpm_vercmp" "noalloc"
external rpm_get_arch : unit -> string = "supermin_rpm_get_arch"

type t

Expand Down
3 changes: 3 additions & 0 deletions src/librpm.mli
Expand Up @@ -28,6 +28,9 @@ val rpm_version : unit -> string
val rpm_vercmp : string -> string -> int
(** Compare two RPM version strings using RPM version compare rules. *)

val rpm_get_arch : unit -> string
(** The current main RPM architecture. *)

type t
(** The librpm handle. *)

Expand Down
8 changes: 6 additions & 2 deletions src/ph_rpm.ml
Expand Up @@ -64,7 +64,7 @@ let ibm_powerkvm_detect () =
with Unix_error _ -> false

let settings = ref no_settings
let rpm_major, rpm_minor = ref 0, ref 0
let rpm_major, rpm_minor, rpm_arch = ref 0, ref 0, ref ""
let zypper_major, zypper_minor, zypper_patch = ref 0, ref 0, ref 0
let t = ref None

Expand Down Expand Up @@ -93,7 +93,11 @@ let rec rpm_init s =
if !settings.debug >= 1 then
printf "supermin: rpm: detected RPM version %d.%d\n" major minor;

t := Some (rpm_open ~debug:!settings.debug)
t := Some (rpm_open ~debug:!settings.debug);

rpm_arch := rpm_get_arch ();
if !settings.debug >= 1 then
printf "supermin: rpm: detected RPM architecture %s\n" !rpm_arch

and opensuse_init s =
rpm_init s;
Expand Down

0 comments on commit e57e988

Please sign in to comment.