Add support to clear the autoresume flags and improve the purge code to clean the...
authorEric Edgar <rocket@gentoo.org>
Thu, 21 Apr 2005 17:45:31 +0000 (17:45 +0000)
committerEric Edgar <rocket@gentoo.org>
Thu, 21 Apr 2005 17:45:31 +0000 (17:45 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@622 d1e1f19c-881f-0410-ab34-b69fee027534

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

index ad457ff05444fadb0e15bbb8e1022b5a1640484c..44bd72c408fe92d723ae18b7e6ddea0f433a044f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.234 2005/04/21 14:45:09 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.235 2005/04/21 17:45:31 rocket Exp $
+
+  21 Apr 2005; Eric Edgar <rocket@gentoo.org> catalyst,
+  modules/catalyst_support.py, modules/generic_stage_target.py:
+  Add support to clear the autoresume flags and improve the purge code to
+  clean the chroot, and pkg/kern cache
 
   21 Apr 2005; Eric Edgar <rocket@gentoo.org> catalyst,
   modules/catalyst_support.py, modules/generic_stage_target.py,
index 95955e17ce254bd8394c2d2583e36f17a531f478..59562df20b6b64f0313c2966abcf7d516b677c1c 100755 (executable)
--- a/catalyst
+++ b/catalyst
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.73 2005/04/21 14:45:09 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.74 2005/04/21 17:45:31 rocket Exp $
 
 # Maintained in full by:
 # Eric Edgar <rocket@gentoo.org>
@@ -17,12 +17,14 @@ conf_values={}
 
 def usage():
        print "Usage catalyst [options] [-C variable=value...] [ -s identifier]"
+       print " -a --clear_autoresume   clear autoresume flags"
        print " -c --config             use specified configuration file"
        print " -C --cli                catalyst commandline (MUST BE LAST OPTION)"
        print " -d --debug              enable debugging"
        print " -f --file               read specfile"
        print " -F --fetchonly          fetch files only"
        print " -h --help               print this help message"
+       print " -p --purge              clear tmp dirs,package cache and autoresume flags"
        print " -s --snapshot           generate a Portage snapshot"
        print " -v --version            display version information"
        print " -V --verbose            verbose output"
@@ -116,6 +118,11 @@ def parse_config(myconfig):
                print "Purge support enabled."
                conf_values["PURGE"]="1"
        
+       if "clear_autoresume" in string.split(conf_values["options"]):
+               print "Cleaning autoresume flags support enabled."
+               conf_values["CLEAR_AUTORESUME"]="1"
+       
+       
        if myconf.has_key("envscript"):
                print "Envscript support enabled."
                conf_values["ENVSCRIPT"]=myconf["envscript"]
@@ -175,8 +182,13 @@ def build_target(addlargs, targetmap):
                        raise CatalystError,"Target \""+addlargs["target"]+"\" not available."
                
                mytarget=targetmap[addlargs["target"]](conf_values, addlargs)
+               
+               if conf_values.has_key("CLEAR_AUTORESUME"):
+                   mytarget.clear_autoresume()
+               
                if conf_values.has_key("PURGE"):
                    mytarget.purge()
+               
                mytarget.run()
 
        except CatalystError:
@@ -198,8 +210,8 @@ if __name__ == "__main__":
 
        # parse out the command line arguments
        try:
-               opts,args = getopt.getopt(sys.argv[1:], "xhvdc:C:f:FVs:", ["purge","help", "version", "debug",\
-                       "config=", "cli=", "file=", "fetch", "verbose","snapshot="])
+               opts,args = getopt.getopt(sys.argv[1:], "apxhvdc:C:f:FVs:", ["purge","help", "version", "debug",\
+                       "clear_autoresume", "config=", "cli=", "file=", "fetch", "verbose","snapshot="])
        
        except getopt.GetoptError:
                usage()
@@ -280,8 +292,21 @@ if __name__ == "__main__":
                        else:
                                mycmdline.append("target=snapshot")
                                mycmdline.append("version_stamp="+a)
-               if o in ("--purge"):
+               
+               if o in ("-p", "--purge"):
+                       if len(sys.argv) < 3:
+                               print "!!! catalyst: please specify one of either -f or -C\n"
+                               usage()
+                               sys.exit(2)
+                       else:
                                conf_values["PURGE"]="1"
+               if o in ("-a", "--clear_autoresume"):
+                       if len(sys.argv) < 3:
+                               print "!!! catalyst: please specify one of either -f or -C\n"
+                               usage()
+                               sys.exit(2)
+                       else:
+                               conf_values["CLEAR_AUTORESUME"]="1"
        if run != 1:
                print "!!! catalyst: please specify one of either -f or -C\n"
                usage()
index c20e298e9b43ededcdc65549fa35eb96d70c7827..3c22bfd1c64931033cb99457481780246f933d83 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 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.40 2005/04/21 14:45:09 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.41 2005/04/21 17:45:31 rocket Exp $
 
 import sys,string,os,types,re,signal,traceback,md5
 # a function to turn a string of non-printable characters into a string of
@@ -56,6 +56,7 @@ 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("CLEAR_AUTORESUME")
 valid_config_file_values.append("options")
 valid_config_file_values.append("DEBUG")
 valid_config_file_values.append("VERBOSE")
index 1fa6f604cb66b0b83f8a9eea9739e1f868e1a243..0757031700f31f43201d234038c127290eab367f 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 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.35 2005/04/21 14:45:09 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.36 2005/04/21 17:45:31 rocket Exp $
 
 """
 This class does all of the chroot setup, copying of files, etc. It is
@@ -99,7 +99,6 @@ class generic_stage_target(generic_target):
                # This should be first to be set as other set_ options depend on this
                self.set_spec_prefix()
                
-               
                # define all of our core variables
                self.set_target_profile()
                self.set_target_subpath()
@@ -428,10 +427,8 @@ class generic_stage_target(generic_target):
                    print "Setting up directories..."
                    self.mount_safety_check()
                
-                   if os.path.exists(self.settings["chroot_path"]):
-                           cmd("rm -rf "+self.settings["chroot_path"],\
-                                   "Could not remove existing directory: "+self.settings["chroot_path"])
-                       
+                   self.clear_chroot()
+
                    if not os.path.exists(self.settings["chroot_path"]+"/tmp"):
                            os.makedirs(self.settings["chroot_path"]+"/tmp",1777)
                        
@@ -793,23 +790,7 @@ class generic_stage_target(generic_target):
                        elif type(self.settings[x])==types.ListType:
                                os.environ[varname]=string.join(self.settings[x])
        
-       def purge(self):
-               if self.settings.has_key("PKGCACHE"):
-                   print "purging the pkgcache ..."
-
-                   myemp=self.settings["pkgcache_path"]
-                   if not os.path.isdir(myemp):
-                       print myemp,"not a directory or does not exist, skipping 'pkgcache purge' operation."
-                   else:
-                       print "Emptying directory",myemp
-                       # stat the dir, delete the dir, recreate the dir and set
-                       # the proper perms and ownership
-                       mystat=os.stat(myemp)
-                       shutil.rmtree(myemp)
-                       os.makedirs(myemp,0755)
-                   
        def run(self):
-               
                for x in self.settings["action_sequence"]:
                        print "Running action sequence: "+x
                        try:
@@ -1002,3 +983,41 @@ class generic_stage_target(generic_target):
                except CatalystError:
                        self.unbind()
                        raise CatalystError,"build aborting due to livecd_update error."
+
+       def clear_chroot(self):
+               myemp=self.settings["chroot_path"]
+               if not os.path.isdir(myemp):
+                   print myemp,"not a directory or does not exist, skipping 'chroot purge' operation."
+               else:
+                   print "Emptying directory",myemp
+                   # stat the dir, delete the dir, recreate the dir and set
+                   # the proper perms and ownership
+                   mystat=os.stat(myemp)
+                   shutil.rmtree(myemp)
+                   os.makedirs(myemp,0755)
+       
+       def clear_packages(self):
+           if self.settings.has_key("PKGCACHE"):
+               print "purging the pkgcache ..."
+
+               myemp=self.settings["pkgcache_path"]
+               if not os.path.isdir(myemp):
+                   print myemp,"not a directory or does not exist, skipping 'pkgcache purge' operation."
+               else:
+                   print "Emptying directory",myemp
+                   # stat the dir, delete the dir, recreate the dir and set
+                   # the proper perms and ownership
+                   mystat=os.stat(myemp)
+                   shutil.rmtree(myemp)
+                   os.makedirs(myemp,0755)
+       
+       def purge(self):
+           if self.settings.has_key("PURGE"):
+               print "clearing autoresume ..."
+               self.clear_autoresume
+               
+               print "clearing chroot ..."
+               self.clear_chroot
+               
+               print "clearing package cache ..."
+               self.clear_packages