Molecule:

- generate ISO md5 file automatically


git-svn-id: http://svn.sabayonlinux.org/projects/molecule/trunk@3190 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
lxnay
2009-03-15 17:13:54 +00:00
parent 624a3acdde
commit 4c07da0ffd
2 changed files with 22 additions and 0 deletions
+11
View File
@@ -509,6 +509,17 @@ class IsoHandler(GenericHandlerInterface):
_("built ISO image"),self.dest_iso,
)
)
if os.path.isfile(self.dest_iso) and os.access(self.dest_iso,os.R_OK):
self.Output.updateProgress("[%s|%s] %s: %s" % (
blue("IsoHandler"),darkred(self.spec_name),
_("generating md5 for"),self.dest_iso,
)
)
digest = molecule.utils.md5sum(self.dest_iso)
md5file = self.dest_iso+".md5"
with open(md5file,"w") as f:
f.write("%s %s\n" % (os.path.basename(self.dest_iso),digest,))
f.flush()
return 0
+11
View File
@@ -85,3 +85,14 @@ def remove_path_sandbox(path, sandbox_env):
def get_random_number():
return abs(hash(os.urandom(2)))%99999
def md5sum(filepath):
import hashlib
m = hashlib.md5()
readfile = open(filepath)
block = readfile.read(1024)
while block:
m.update(block)
block = readfile.read(1024)
readfile.close()
return m.hexdigest()