Some OVA files generated by VMware have a *.mf file which contains
checksums for files which don't exist in the OVA. Ignore these
checksums.
Thanks: Nisim Simsolo.
---
builder/builder.ml | 3 +++
common/mltools/checksums.ml | 28 +++++++++++++++++++++-------
common/mltools/checksums.mli | 2 ++
v2v/input_ova.ml | 9 ++++++++-
4 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/builder/builder.ml b/builder/builder.ml
index 83c7aefed..2ed7cb97a 100644
--- a/builder/builder.ml
+++ b/builder/builder.ml
@@ -318,6 +318,9 @@ let main () =
| Checksums.Mismatched_checksum (csum, csum_actual) ->
error (f_"%s checksum of template did not match the expected checksum!\n
found checksum: %s\n expected checksum: %s\nTry:\n - Use the ‘-v’ option and look for
earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one
has tampered with the website or your network!")
(Checksums.string_of_csum_t csum) csum_actual (Checksums.string_of_csum
csum)
+ | Checksums.Missing_file ->
+ error (f_"%s: template not downloaded or deleted. You may have run
‘virt-builder --delete-cache’ in parallel.")
+ template
)
| { Index.checksums = None } ->
diff --git a/common/mltools/checksums.ml b/common/mltools/checksums.ml
index 4dd69e734..fdeae1dff 100644
--- a/common/mltools/checksums.ml
+++ b/common/mltools/checksums.ml
@@ -30,6 +30,7 @@ type csum_t =
type csum_result =
| Good_checksum
| Mismatched_checksum of csum_t * string
+ | Missing_file
let string_of_csum_t = function
| SHA1 _ -> "sha1"
@@ -72,18 +73,31 @@ let compute_checksum csum_type ?tar filename =
let csum_str = fst (String.split " " line) in
of_string csum_type csum_str
+(* Check if the direct file exists or if it exists in the tarball. *)
+let file_exists ?tar filename =
+ match tar with
+ | None -> Sys.file_exists filename
+ | Some tar ->
+ let cmd =
+ sprintf "tar tf %s %s >/dev/null 2>&1" (quote tar) (quote
filename) in
+ Sys.command cmd = 0
+
let verify_checksum csum ?tar filename =
- let csum_type = string_of_csum_t csum in
- let csum_actual = compute_checksum csum_type ?tar filename in
- if csum = csum_actual then
- Good_checksum
- else
- Mismatched_checksum (csum, string_of_csum csum_actual)
+ if not (file_exists ?tar filename) then
+ Missing_file
+ else (
+ let csum_type = string_of_csum_t csum in
+ let csum_actual = compute_checksum csum_type ?tar filename in
+ if csum = csum_actual then
+ Good_checksum
+ else
+ Mismatched_checksum (csum, string_of_csum csum_actual)
+ )
let verify_checksums checksums filename =
List.fold_left (
fun acc c ->
match acc with
| Good_checksum -> verify_checksum c filename
- | Mismatched_checksum _ as acc -> acc
+ | (Mismatched_checksum _|Missing_file) as acc -> acc
) Good_checksum checksums
diff --git a/common/mltools/checksums.mli b/common/mltools/checksums.mli
index d45b29dfd..533e399bf 100644
--- a/common/mltools/checksums.mli
+++ b/common/mltools/checksums.mli
@@ -25,6 +25,8 @@ type csum_result =
| Good_checksum
(* expected checksum, actual checksum. *)
| Mismatched_checksum of csum_t * string
+ (* referenced file does not exist *)
+ | Missing_file
val of_string : string -> string -> csum_t
(** [of_string type value] returns the [csum_t] for the specified
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 59dbe6f5f..f23a1f2a9 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -234,7 +234,14 @@ object
| Checksums.Good_checksum -> ()
| Checksums.Mismatched_checksum (_, actual) ->
error (f_"checksum of disk %s does not match manifest %s (actual
%s(%s) = %s, expected %s(%s) = %s)")
- disk mf mode disk actual mode disk expected;
+ disk mf mode disk actual mode disk expected
+ | Checksums.Missing_file ->
+ (* RHBZ#1570407: Some OVA files generated by VMware
+ * reference non-existent components in the *.mf file.
+ * Generate a warning and ignore it.
+ *)
+ warning (f_"%s has a checksum for non-existent file %s
(ignored)")
+ mf disk
)
else
warning (f_"unable to parse line from manifest file: %S")
line;
--
2.16.2