Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
mllib/checksums.ml | 10 ++++++++--
mllib/checksums.mli | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/mllib/checksums.ml b/mllib/checksums.ml
index dfa8c3a..9fcff2f 100644
--- a/mllib/checksums.ml
+++ b/mllib/checksums.ml
@@ -45,7 +45,7 @@ let of_string csum_type csum_value =
| "sha512" -> SHA512 csum_value
| _ -> invalid_arg csum_type
-let verify_checksum csum filename =
+let verify_checksum csum ?(tar = "") filename =
let prog, csum_ref =
match csum with
| SHA1 c -> "sha1sum", c
@@ -53,7 +53,13 @@ let verify_checksum csum filename =
| SHA512 c -> "sha512sum", c
in
- let cmd = sprintf "%s %s" prog (Filename.quote filename) in
+ let cmd =
+ if tar = "" then
+ sprintf "%s %s" prog (Filename.quote filename)
+ else
+ sprintf "tar xOf %s %s | %s"
+ (Filename.quote tar) (Filename.quote filename) prog
+ in
let lines = external_command cmd in
match lines with
| [] ->
diff --git a/mllib/checksums.mli b/mllib/checksums.mli
index 0074837..2440324 100644
--- a/mllib/checksums.mli
+++ b/mllib/checksums.mli
@@ -29,7 +29,7 @@ val of_string : string -> string -> csum_t
Raise [Invalid_argument] if the checksum type is not known. *)
-val verify_checksum : csum_t -> string -> unit
+val verify_checksum : csum_t -> ?tar:string -> string -> unit
(** Verify the checksum of the file. *)
val verify_checksums : csum_t list -> string -> unit
--
2.10.1