From: Eric Edgar Date: Thu, 21 Apr 2005 17:45:31 +0000 (+0000) Subject: Add support to clear the autoresume flags and improve the purge code to clean the... X-Git-Tag: CATALYST_2_0_6_916~761 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bc1172d901cff66098ca852acde48778379f3212;p=catalyst.git Add support to clear the autoresume flags and improve the purge code to clean the chroot, and pkg/kern cache git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@622 d1e1f19c-881f-0410-ab34-b69fee027534 --- diff --git a/ChangeLog b/ChangeLog index ad457ff0..44bd72c4 100644 --- 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 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 catalyst, modules/catalyst_support.py, modules/generic_stage_target.py, diff --git a/catalyst b/catalyst index 95955e17..59562df2 100755 --- 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 @@ -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() diff --git a/modules/catalyst_support.py b/modules/catalyst_support.py index c20e298e..3c22bfd1 100644 --- a/modules/catalyst_support.py +++ b/modules/catalyst_support.py @@ -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") diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py index 1fa6f604..07570317 100644 --- a/modules/generic_stage_target.py +++ b/modules/generic_stage_target.py @@ -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