diff --git a/builder-web.opam b/builder-web.opam index 18ceb87..4341386 100644 --- a/builder-web.opam +++ b/builder-web.opam @@ -46,8 +46,8 @@ depends: [ "cmarkit" {>= "0.3.0"} "tar" {>= "3.0.0"} "tar-unix" {>= "3.0.0"} - "owee" - "solo5-elftool" {>= "0.3.0" & < "0.4.0"} + "cachet" + "solo5-elftool" {>= "0.4.0"} "decompress" {>= "1.5.0"} "digestif" {>= "1.2.0"} "uuidm" {>= "0.9.9"} diff --git a/lib/model.ml b/lib/model.ml index 3b3aa66..9380054 100644 --- a/lib/model.ml +++ b/lib/model.ml @@ -59,17 +59,22 @@ let build_artifacts build (module Db : CONN) = List.map snd let solo5_manifest datadir file = - (* inlined from Owee_buf.map_binary *) - let path = Fpath.(to_string (datadir // artifact_path file)) in - let fd = Unix.openfile path [Unix.O_RDONLY] 0 in - let len = Unix.lseek fd 0 Unix.SEEK_END in - let buf = - Bigarray.array1_of_genarray - (Unix.map_file fd Bigarray.int8_unsigned - Bigarray.c_layout false [|len|]) in - Unix.close fd; - (* end of inlined code *) - Solo5_elftool.query_manifest buf |> Result.to_option + let cachet = + let path = Fpath.(to_string (datadir // artifact_path file)) in + let fd = Unix.openfile path [Unix.O_RDONLY] 0 in + let len = Unix.lseek fd 0 Unix.SEEK_END in + let buf = + Bigarray.array1_of_genarray + (Unix.map_file fd Bigarray.char + Bigarray.c_layout false [|len|]) in + Unix.close fd; + let map () ~pos len = + let len = min len (max 0 (Bigarray.Array1.dim buf - pos)) in + Bigarray.Array1.sub buf pos len + in + Cachet.make ~pagesize:8 ~map () + in + Solo5_elftool.query_manifest cachet |> Result.to_option let platforms_of_job id (module Db : CONN) = Db.collect_list Builder_db.Build.get_platforms_for_job id