From: Andrew Gaffney Date: Sat, 29 Nov 2008 02:04:15 +0000 (-0600) Subject: Add support for -P/--purgeonly option X-Git-Tag: CATALYST_2_0_6_916~65 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=89d280dd72b50588ce5070d89b025a6c6d0b427d;p=catalyst.git Add support for -P/--purgeonly option --- diff --git a/ChangeLog b/ChangeLog index 4fc17fef..3cf534ef 100644 --- 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 catalyst, + modules/catalyst_support.py, modules/generic_stage_target.py: + Add support for -P/--purgeonly option + 31 Oct 2008; Chris Gianelloni README: Updated README to tell the user where to locate catalyst.conf if not using an ebuild. Thanks to Claus Boehmer for pointing it diff --git a/catalyst b/catalyst index 969e95d8..9883485a 100755 --- 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) diff --git a/modules/catalyst_support.py b/modules/catalyst_support.py index f110c5da..ab59c5e0 100644 --- a/modules/catalyst_support.py +++ b/modules/catalyst_support.py @@ -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") diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py index 9be4c419..88f847b5 100644 --- a/modules/generic_stage_target.py +++ b/modules/generic_stage_target.py @@ -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()