[Libguestfs] [PATCH 1/5] mllib: compute checksum of file inside tar
Pino Toscano
ptoscano at redhat.com
Mon Nov 7 13:14:56 UTC 2016
On Friday, 4 November 2016 14:52:49 CET Tomáš Golembiovský wrote:
> Signed-off-by: Tomáš Golembiovský <tgolembi at 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 =
In this case, do not set a default value to the optional argument, so
you can later check whether it was actually set. Optional arguments
are handled as 'a option. So ...
> 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
... this case be:
let cmd =
match tar with
| None ->
sprintf "%s %s" prog (Filename.quote filename)
| Some tar ->
sprintf "tar xOf %s %s | %s"
(Filename.quote tar) (Filename.quote filename) prog in
Thanks,
--
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20161107/199a7490/attachment.sig>
More information about the Libguestfs
mailing list