Add md5 and sha .digests file creation per wolf31o2's feature request
authorEric Edgar <rocket@gentoo.org>
Thu, 1 Dec 2005 19:18:27 +0000 (19:18 +0000)
committerEric Edgar <rocket@gentoo.org>
Thu, 1 Dec 2005 19:18:27 +0000 (19:18 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@922 d1e1f19c-881f-0410-ab34-b69fee027534

ChangeLog
catalyst
files/catalyst.conf
modules/catalyst_support.py
modules/generic_stage_target.py

index bb751eecd13424b3df6252fe0b96c7d6b40b24eb..e754b2aad3908def385720c47b82212f917bba4b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.409 2005/11/30 21:42:19 wolf31o2 Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.410 2005/12/01 19:18:27 rocket Exp $
+
+  01 Dec 2005; Eric Edgar <rocket@gentoo.org> catalyst, files/catalyst.conf,
+  modules/catalyst_support.py, modules/generic_stage_target.py:
+  Add md5 and sha .digests file creation per wolf31o2's feature request
 
   30 Nov 2005; Chris Gianelloni <wolf31o2@gentoo.org> catalyst:
   This is catalyst-2.0_rc2.
index d63566d5afc78005eee793c605ced6d54bc1864f..6253d859cbc16b39b0819323dd9b988f7839d14f 100755 (executable)
--- a/catalyst
+++ b/catalyst
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # Copyright 1999-2005 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.103 2005/11/30 21:42:19 wolf31o2 Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.104 2005/12/01 19:18:27 rocket Exp $
 
 # Maintained in full by:
 # Eric Edgar <rocket@gentoo.org>
@@ -133,6 +133,14 @@ def parse_config(myconfig):
        if myconf.has_key("envscript"):
                print "Envscript support enabled."
                conf_values["ENVSCRIPT"]=myconf["envscript"]
+       
+       if "md5" in string.split(conf_values["options"]):
+               print "MD5 .digests file creation support enabled."
+               conf_values["MD5"]="1"
+       
+       if "sha" in string.split(conf_values["options"]):
+               print "SHA .digests file creation support enabled."
+               conf_values["SHA"]="1"
 
 def import_modules():
        # import catalyst's own modules (i.e. catalyst_support and the arch modules)
index 70d2c487301fcf3eebb0849eccd8c98004f59473..d2b74a2b3576145049fcceffd91ab827d3cb3bf9 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2005 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/files/catalyst.conf,v 1.15 2005/11/30 21:37:58 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/files/catalyst.conf,v 1.16 2005/12/01 19:18:27 rocket Exp $
 
 # Simple desriptions of catalyst settings. Please refer to the online
 # documentation for more information.
@@ -24,6 +24,10 @@ distdir="/usr/portage/distfiles"
 #             the -a option to the catalyst cmdline.  -p will clear the 
 #             autoresume flags as well as your pkgcache and kerncache.
 #             ( This option is not fully tested, bug reports welcome ) 
+#
+# DIGESTS CREATION 
+# md5 = Cræate a .digests file containing the md5 of the output object
+# sha = Cræate a .digests file containing the sha of the output object
 options="pkgcache kerncache seedcache snapcache"
 
 # sharedir specifies where all of the catalyst runtime executables are. Most
index 5a47b336c6790e8571657c1fe1b92040b5715ba3..1986784395b6007691d999b4f35470e6b34a94ec 100644 (file)
@@ -1,8 +1,8 @@
 # Copyright 1999-2005 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.57 2005/10/06 15:45:28 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.58 2005/12/01 19:18:27 rocket Exp $
 
-import sys,string,os,types,re,signal,traceback,md5,time
+import sys,string,os,types,re,signal,traceback,md5,sha,time
 selinux_capable = False
 #userpriv_capable = (os.getuid() == 0)
 #fakeroot_capable = False
@@ -75,7 +75,18 @@ def calc_md5(file):
     print "MD5 (%s) = %s" % (file, md5sum)
     return md5sum
 # calc_md5
-    
+   
+def calc_sha(file):
+    m = sha.new()
+    f = open(file, 'r')
+    for line in f.readlines():
+       m.update(line)
+    f.close()
+    shaval = hexify(m.digest())
+    #shaval = sha.new(file(file).read()).hexdigest() # loads all into memory first
+    print "SHA (%s) = %s" % (file, shaval)
+    return shaval
+   
 def read_from_clst(file):
        line = ''
        myline = ''
@@ -107,6 +118,8 @@ valid_config_file_values.append("CCACHE")
 valid_config_file_values.append("DISTCC")
 valid_config_file_values.append("ENVSCRIPT")
 valid_config_file_values.append("AUTORESUME")
+valid_config_file_values.append("SHA")
+valid_config_file_values.append("MD5")
 valid_config_file_values.append("FETCH")
 valid_config_file_values.append("CLEAR_AUTORESUME")
 valid_config_file_values.append("options")
index cd437063c52925d4b38fe08e2b33d7302b7eea76..719ec3a83587d9c8f9e563234b9cbd29930cffe5 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2005 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.80 2005/11/30 21:37:58 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.81 2005/12/01 19:18:27 rocket Exp $
 
 """
 This class does all of the chroot setup, copying of files, etc. It is
@@ -335,6 +335,7 @@ class generic_stage_target(generic_target):
                        if os.path.isfile(self.settings["source_path"]):
                                if os.path.exists(self.settings["source_path"]):
                                        self.settings["source_path_md5sum"]=calc_md5(self.settings["source_path"])
+                                       self.settings["source_path_sha"]=calc_sha(self.settings["source_path"])
                if os.path.isdir(self.settings["source_path"]):
                        print "Source path set to "+self.settings["source_path"]
                        print "\tIf this is not desired, remove this directory or turn of seedcache in the options of catalyst.conf"
@@ -354,6 +355,7 @@ class generic_stage_target(generic_target):
                self.settings["snapshot_path"]=normpath(self.settings["storedir"]+"/snapshots/portage-"+self.settings["snapshot"]+".tar.bz2")
                if os.path.exists(self.settings["snapshot_path"]):
                        self.settings["snapshot_path_md5sum"]=calc_md5(self.settings["snapshot_path"])
+                       self.settings["snapshot_path_sha"]=calc_sha(self.settings["snapshot_path"])
        
        def set_snapcache_path(self):
                if self.settings.has_key("SNAPCACHE"):
@@ -896,6 +898,21 @@ class generic_stage_target(generic_target):
                
                cmd("tar cjf "+self.settings["target_path"]+" -C "+self.settings["stage_path"]+\
                        " .","Couldn't create stage tarball")
+
+               if self.settings.has_key("MD5") \
+                   and os.path.exists(self.settings["target_path"]):
+                       md5=calc_md5(self.settings["target_path"])
+                       myf=open(self.settings["target_path"]+".digests","w")
+                       myf.write("MD5: "+md5+"\n")
+                       myf.close()
+               
+               if self.settings.has_key("SHA") \
+                   and os.path.exists(self.settings["target_path"]):
+                       sha=calc_sha(self.settings["target_path"])
+                       myf=open(self.settings["target_path"]+".digests","w")
+                       myf.write("SHA: "+sha+"\n")
+                       myf.close()
+
                touch(self.settings["autoresume_path"]+"capture")
 
        def run_local(self):
@@ -1007,6 +1024,21 @@ class generic_stage_target(generic_target):
                        cmd("/bin/bash "+self.settings["controller_file"]+" iso "+\
                                self.settings["iso"],"ISO creation script failed.")
                        touch(self.settings["autoresume_path"]+"create_iso")
+               
+               if self.settings.has_key("MD5") \
+                   and os.path.exists(self.settings["iso"]):
+                       md5=calc_md5(self.settings["iso"])
+                       myf=open(self.settings["iso"]+".digests","w")
+                       myf.write("MD5: "+md5+"\n")
+                       myf.close()
+               
+               if self.settings.has_key("SHA") \
+                   and os.path.exists(self.settings["iso"]):
+                       sha=calc_sha(self.settings["iso"])
+                       myf=open(self.settings["iso"]+".digests","w")
+                       myf.write("SHA: "+sha+"\n")
+                       myf.close()
+
                else:
                        print "WARNING livecd/iso was not defined."
                        print "A CD Image will not be created, skipping create-iso.sh..."