Add support for -P/--purgeonly option
authorAndrew Gaffney <agaffney@gentoo.org>
Sat, 29 Nov 2008 02:04:15 +0000 (20:04 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sat, 29 Nov 2008 02:04:15 +0000 (20:04 -0600)
ChangeLog
catalyst
modules/catalyst_support.py
modules/generic_stage_target.py

index 4fc17feff06dbe8ee7676c335772bc0e9cbe089a..3cf534efc5b580687068826edfd55dbbaf4daf88 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 # Copyright 2002-2008 Gentoo Foundation; 2008 Chris Gianelloni, Andrew Gaffney
 # Distributed under the GPL v2
 
+  29 Nov 2008; Andrew Gaffney <agaffney@gentoo.org> catalyst,
+  modules/catalyst_support.py, modules/generic_stage_target.py:
+  Add support for -P/--purgeonly option
+
   31 Oct 2008; Chris Gianelloni <wolf31o2@wolf31o2.org> README:
   Updated README to tell the user where to locate catalyst.conf if not using
   an ebuild. Thanks to Claus Boehmer <Claus.Boehmer@gmx.de> for pointing it
index 969e95d8996c954b3073e8a891bf0c4f9b944966..9883485a2049c383d4bdeb0ab55db0e11e0394e7 100755 (executable)
--- a/catalyst
+++ b/catalyst
@@ -20,16 +20,17 @@ 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 release snapshot"
-       print " -V --version            display version information"
-       print " -v --verbose            verbose output"
+       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 " -P --purgeonly  clear tmp dirs,package cache and autoresume flags and exit"
+       print " -s --snapshot   generate a release snapshot"
+       print " -V --version    display version information"
+       print " -v --verbose    verbose output"
        print
        print "Usage examples:"
        print
@@ -224,7 +225,7 @@ if __name__ == "__main__":
 
        # parse out the command line arguments
        try:
-               opts,args = getopt.getopt(sys.argv[1:], "aphvdc:C:f:FVs:", ["purge","help", "version", "debug",\
+               opts,args = getopt.getopt(sys.argv[1:], "apPhvdc:C:f:FVs:", ["purge", "purgeonly", "help", "version", "debug",\
                        "clear-autoresume", "config=", "cli=", "file=", "fetch", "verbose","snapshot="])
        
        except getopt.GetoptError:
@@ -245,7 +246,8 @@ if __name__ == "__main__":
                print "!!! catalyst: please specify one of either -f or -C\n"
                usage()
                sys.exit(2)
-       run=0   
+
+       run = false
        for o, a in opts:
                if o in ("-h", "--help"):
                        usage()
@@ -256,48 +258,28 @@ if __name__ == "__main__":
                        sys.exit(1)
 
                if o in ("-d", "--debug"):
-                       if len(sys.argv) < 3:
-                               print "!!! catalyst: please specify one of either -f or -C\n"
-                               usage()
-                               sys.exit(2)
-                       else:
-                               conf_values["DEBUG"]="1"
-                               conf_values["VERBOSE"]="1"
+                       conf_values["DEBUG"]="1"
+                       conf_values["VERBOSE"]="1"
 
                if o in ("-c", "--config"):
-                       if len(sys.argv) < 3:
-                               print "!!! catalyst: please specify one of either -f or -C\n"
-                               usage()
-                               sys.exit(2)
-                       else:
-                               myconfig=a
+                       myconfig=a
 
                if o in ("-C", "--cli"):
-                       run=1   
+                       run = true
                        x=sys.argv.index(o)+1
                        while x < len(sys.argv):
                                mycmdline.append(sys.argv[x])
                                x=x+1
                        
                if o in ("-f", "--file"):
-                       run=1   
+                       run = true
                        myspecfile=a
 
                if o in ("-F", "--fetchonly"):
-                       if len(sys.argv) < 3:
-                               print "!!! catalyst: please specify one of either -f or -C\n"
-                               usage()
-                               sys.exit(2)
-                       else:
-                               conf_values["FETCH"]="1"
+                       conf_values["FETCH"]="1"
                        
                if o in ("-v", "--verbose"):
-                       if len(sys.argv) < 3:
-                               print "!!! catalyst: please specify one of either -f or -C\n"
-                               usage()
-                               sys.exit(2)
-                       else:
-                               conf_values["VERBOSE"]="1"
+                       conf_values["VERBOSE"]="1"
 
                if o in ("-s", "--snapshot"):
                        if len(sys.argv) < 3:
@@ -305,25 +287,20 @@ if __name__ == "__main__":
                                usage()
                                sys.exit(2)
                        else:
-                               run=1
+                               run = true
                                mycmdline.append("target=snapshot")
                                mycmdline.append("version_stamp="+a)
                
                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"
+                       conf_values["PURGE"] = "1"
+
+               if o in ("-P", "--purgeonly"):
+                       conf_values["PURGEONLY"] = "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:
+                       conf_values["CLEAR_AUTORESUME"] = "1"
+
+       if not run:
                print "!!! catalyst: please specify one of either -f or -C\n"
                usage()
                sys.exit(2)
index f110c5da5e8cbebe462b180150c1ac19652cbdd7..ab59c5e0120f4338706cf4626b0a2df787da10af 100644 (file)
@@ -215,6 +215,7 @@ valid_config_file_values.append("options")
 valid_config_file_values.append("DEBUG")
 valid_config_file_values.append("VERBOSE")
 valid_config_file_values.append("PURGE")
+valid_config_file_values.append("PURGEONLY")
 valid_config_file_values.append("SNAPCACHE")
 valid_config_file_values.append("snapshot_cache")
 valid_config_file_values.append("hash_function")
index 9be4c41920de6494f48a6f650caee23281dc01ae..88f847b58f13b13d69f773523003c047e0bb2dbc 100644 (file)
@@ -1232,6 +1232,11 @@ class generic_stage_target(generic_target):
 
                if self.settings.has_key("CLEAR_AUTORESUME"):
                        self.clear_autoresume()
+
+               if self.settings.has_key("PURGEONLY"):
+                       self.purge()
+                       return
+
                if self.settings.has_key("PURGE"):
                        self.purge()
 
@@ -1614,7 +1619,7 @@ class generic_stage_target(generic_target):
 
        def purge(self):
                countdown(10,"Purging Caches ...")
-               if self.settings.has_key("PURGE"):
+               if self.settings.has_key("PURGE") or self.settings.has_key("PURGEONLY"):
                        print "clearing autoresume ..."
                        self.clear_autoresume()