Browse files

verify iso md5sum every time not only after iso has been downloaded

  • Loading branch information...
1 parent 7dc0355 commit 2d7d187fae770accd65c280066f0fe2fd8a0b37e Max Horbul committed Apr 20, 2012
Showing with 14 additions and 10 deletions.
  1. +14 −10 lib/veewee/provider/core/helper/iso.rb
View
24 lib/veewee/provider/core/helper/iso.rb
@@ -37,7 +37,7 @@ def download_progress(url,localfile)
:progress_proc => lambda {|s|
pbar.set s if pbar
}) { |src|
- # We assume large 10K files, so this is tempfile object
+ # We assume large 10K files, so this is tempfile object
env.logger.info "#{src.class}"
ui.info "Moving #{src.path} to #{localfile}"
# Force the close of the src stream to release handle before moving
@@ -65,6 +65,17 @@ def hashsum(filename)
return checksum.hexdigest
end
+ def verify_md5sum(full_path)
+ filename = File.basename(full_path)
+ ui.info "Verifying md5 checksum : #{self.iso_md5}"
+ file_md5=hashsum(full_path)
+
+ unless file_md5==self.iso_md5
+ ui.error "The MD5 checksums for file #{filename } do not match: "
+ ui.error "- #{file_md5} (current) vs #{self.iso_md5} (specified)"
+ raise Veewee::Error, "The MD5 checksums for file #{filename } do not match: \n"+ "- #{file_md5} (current) vs #{self.iso_md5} (specified)"
+ end
+ end
def verify_iso(options)
filename=self.iso_file
@@ -123,19 +134,12 @@ def verify_iso(options)
raise Veewee::Error, "The provided iso #{full_path} is not readable"
end
- ui.info "Verifying md5 checksum : #{self.iso_md5}"
- file_md5=hashsum(full_path)
-
- unless file_md5==self.iso_md5
- ui.error "The MD5 checksums for file #{filename } do not match: "
- ui.error "- #{file_md5} (current) vs #{self.iso_md5} (specified)"
- raise Veewee::Error, "The MD5 checksums for file #{filename } do not match: \n"+ "- #{file_md5} (current) vs #{self.iso_md5} (specified)"
- end
-
end
end
+ verify_md5sum(full_path) unless self.iso_md5.nil?
+
end
end #Module

2 comments on commit 2d7d187

@jedi4ever

Thanks, I was actually aware that this didn't work. The reason is because on DVD's the md5 sum could take a while.

So we either need a way to speed up (a flag like --no-md5) or otherwise disable it by default and add (--md5) for explicit verification?

@mhorbul
Owner

I submitted that change because just spent a night to figure out why Centos-5.8 hangs on ISOLINUX screen :)
It was not very bad for me (~1s)
ree-1.8.7-2012.02@chef_repo ~/w/chef-repo basebox-cleanup time md5 iso/CentOS-5.8-x86_64-bin-DVD-1of2.iso
MD5 (iso/CentOS-5.8-x86_64-bin-DVD-1of2.iso) = 83e83376d62f44cf08d57f4bc1089058
md5 iso/CentOS-5.8-x86_64-bin-DVD-1of2.iso 1.13s user 0.26s system 99% cpu 1.388 total

But if you think it might take a while --no-md5 is very good option.

Please sign in to comment.