Page
Library
Module
Module type
Parameter
Class
Class type
Source
A library for reading metadata from RPM packages (supports version 3.0 and partially 4.0), providing an Angstrom parser and a simple interface for accessing values.
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.
module SelectNameOnly = struct
include Rpmfile.Selector.All
let select_header_tag = function
| 1000 (* name *) -> true
| _ -> false
end
module _ = Rpmfile.Reader (SelectNameOnly)
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
For integer representation, native int is used by default, which is theoretically sufficient on 64-bit systems. Otherwise, use manual decoding of the value.
odig
Related
The project is stable, but the library could be more complete. I look forward to your pull requests! If you encounter a bug, then please create an issue.