[ann] rpmfile 0.8.0+ library

Hello,

I am pleased to announce the next major version of my library for reading RPM packages, powered by Angstrom.

# #require "rpmfile";;

# let pkg = 
    In_channel.with_open_bin 
      "hello-2.12.2-2.fc43.x86_64.rpm" 
      Rpmfile.Reader.of_channel
    |> Result.get_ok;;

# Rpmfile.View.name pkg;;
- : string = "hello"

# Rpmfile.View.vendor pkg;;
- : string = "Fedora Project"

# Rpmfile.View.version pkg;;
- : string = "2.12.2"

This release has broken the previous API and made it simpler and more compact.

Added capture of the payload of the RPM package body. But it is not effective enough.

# pkg.payload;;
- : string option = None

You can implement this functionality manually using Lwt and angstrom-lwt-unix or something else.

(* examples/extract_payload_by_lwt.ml *)

let default_tags_selector =
  Rpmfile.Reader.
    {
      predicate_signature_tag = Fun.const true;
      predicate_header_tag = Fun.const true;
    }

let pkg_parser =
  Rpmfile.Reader.make_package_parser ~capture_payload:false
    ~tags_selector:default_tags_selector

let () =
  let open Lwt.Syntax in
  Lwt_main.run
  @@
  let* ic = Lwt_io.open_file ~mode:Input "hello.rpm" in
  let* _pkg =
    let* b, r = Angstrom_lwt_unix.parse pkg_parser ic in
    let+ _ = Lwt_io.set_position ic (Int64.of_int b.off) in
    Result.get_ok r
  in
  let* payload = Lwt_io.read ic in

  (* ... *)

:pie:

1 Like