[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 1/2] v2v: ova: fix checking of the manifest file



The regular expression for parsing the manifest line was wrong. There is
a mandatory space between '=' and the hash.

Another problem was that only the first line of the manifest file was
actually processed.

Also added some debugging info and warning to catch problems with
parsing.

Signed-off-by: Tomáš Golembiovský <tgolembi redhat com>
---
 v2v/input_ova.ml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 4f848e2..513fe30 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -133,9 +133,10 @@ object
 
     (* Read any .mf (manifest) files and verify sha1. *)
     let mf = find_files exploded ".mf" in
-    let rex = Str.regexp "SHA1(\\(.*\\))=\\([0-9a-fA-F]+\\)\r?" in
+    let rex = Str.regexp "SHA1(\\(.*\\))= \\([0-9a-fA-F]+\\)\r?" in
     List.iter (
       fun mf ->
+        debug "Processing manifest %s" mf;
         let mf_folder = Filename.dirname mf in
         let chan = open_in mf in
         let rec loop () =
@@ -156,6 +157,11 @@ object
               debug "sha1 of %s matches expected checksum %s" disk expected
             | _::_ -> error (f_"cannot parse output of sha1sum command")
           )
+          else
+            warning (f_"Unable to parse line from manifest file. Line is \"%s\"")
+              (String.replace line "\r" "")
+          ;
+          loop ()
         in
         (try loop () with End_of_file -> ());
         close_in chan
-- 
2.10.0




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]