rpmfile
A library for reading metadata from RPM packages, providing an Angstrom parser and a simple interface for accessing values.
Usage
Before you can read an RPM package, you must create a Reader
module with a selector (predicate for parsing only necessary tags) passed to it.
module Rpm_reader = Rpmfile.Reader (Rpmfile.Selector.All)
let metadata = Rpm_reader.of_file_exn "hello-2.12.1-1.7.x86_64.rpm"
Rpmfile.summary metadata
(* - : string = "A Friendly Greeting Program" *)
You can also have “direct” access to values by tag using the get
function. Example of getting file sizes:
Rpmfile.get Rpmfile.D.(array int) 1028 metadata
(* int list = [35000; 0; 93787; ...]*)
If there's a retrieval error, the Rpmfile.Not_found
exception will be thrown.
Custom selector
module SelectNameOnly = struct
include Rpmfile.Selector.All
let select_header_tag = function
| 1000 (* name *) -> true
| _ -> false
end
module _ = Rpmfile.Reader (SelectNameOnly)
CLI utility
You can also use rpmfile as a CLI utility to get information about a package, similar to rpm -qi
.
rpmfile hello-2.12.1-1.7.x86_64.rpm
Documentation
Lookup documentation using the odig
:
odig doc rpmfile
References