From 0bab68e3df2061ce1f4d46a69e3ddeccd7199e0f Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 3 Jul 2009 19:13:59 +0000 Subject: Make --help into an action, and move --help --sync output to the actions section. Thanks to Marat Radchenko for this patch. svn path=/main/trunk/; revision=13766 --- pym/_emerge/help.py | 37 +++++++++++++++++-------------------- pym/_emerge/main.py | 27 ++++++++++++--------------- 2 files changed, 29 insertions(+), 35 deletions(-) (limited to 'pym') diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py index 1f4b5201e..291dd26f2 100644 --- a/pym/_emerge/help.py +++ b/pym/_emerge/help.py @@ -21,17 +21,17 @@ def shorthelp(): print " [ "+green("--reinstall ")+turquoise("changed-use")+" ] [ " + green("--with-bdeps")+" < " + turquoise("y") + " | "+ turquoise("n")+" > ]" print bold("Actions:")+" [ "+green("--depclean")+" | "+green("--list-sets")+" | "+green("--search")+" | "+green("--sync")+" | "+green("--version")+" ]" -def help(myaction,myopts,havecolor=1): +def help(myopts, havecolor=1): # TODO: Implement a wrap() that accounts for console color escape codes. from textwrap import wrap desc_left_margin = 14 desc_indent = desc_left_margin * " " desc_width = 80 - desc_left_margin - 5 - if not myaction and ("--verbose" not in myopts): + if "--verbose" not in myopts: shorthelp() print print " For more help try 'emerge --help --verbose' or consult the man page." - elif not myaction: + else: shorthelp() print print turquoise("Help (this screen):") @@ -195,6 +195,20 @@ def help(myaction,myopts,havecolor=1): print " emerge -S applet" print " emerge -S 'perl.*module'" print + print " "+green("--sync") + print " Tells emerge to update the Portage tree as specified in" + print " The SYNC variable found in /etc/make.conf. By default, SYNC instructs" + print " emerge to perform an rsync-style update with rsync.gentoo.org." + print + print " 'emerge-webrsync' exists as a helper app to emerge --sync, providing a" + print " method to receive the entire portage tree as a tarball that can be" + print " extracted and used. First time syncs would benefit greatly from this." + print + print " "+turquoise("WARNING:") + print " If using our rsync server, emerge will clean out all files that do not" + print " exist on it, including ones that you may have created. The exceptions" + print " to this are the distfiles, local and packages directories." + print print " "+green("--unmerge")+" ("+green("-C")+" short option)" print " "+turquoise("WARNING: This action can remove important packages!") print " Removes all matching packages. This does no checking of" @@ -500,20 +514,3 @@ def help(myaction,myopts,havecolor=1): print " added to EMERGE_DEFAULT_OPTS (see make.conf(5)) and later" print " overridden via the command line." print - elif myaction == "sync": - print - print bold("Usage: ")+turquoise("emerge")+" "+turquoise("--sync") - print - print " 'emerge --sync' tells emerge to update the Portage tree as specified in" - print " The SYNC variable found in /etc/make.conf. By default, SYNC instructs" - print " emerge to perform an rsync-style update with rsync.gentoo.org." - print - print " 'emerge-webrsync' exists as a helper app to emerge --sync, providing a" - print " method to receive the entire portage tree as a tarball that can be" - print " extracted and used. First time syncs would benefit greatly from this." - print - print " "+turquoise("WARNING:") - print " If using our rsync server, emerge will clean out all files that do not" - print " exist on it, including ones that you may have created. The exceptions" - print " to this are the distfiles, local and packages directories." - print diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 087493c4d..697647fdd 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -54,7 +54,7 @@ options=[ "--emptytree", "--fetchonly", "--fetch-all-uri", "--getbinpkg", "--getbinpkgonly", -"--help", "--ignore-default-opts", +"--ignore-default-opts", "--keep-going", "--noconfmem", "--newuse", @@ -203,7 +203,6 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval): if icount > 0: out.einfo("Processed %d info files." % (icount,)) - def display_preserved_libs(vardbapi): MAX_DISPLAY = 3 @@ -274,11 +273,10 @@ def display_preserved_libs(vardbapi): print colorize("WARN", " * ") + " used by %d other files" % (len(consumers) - MAX_DISPLAY) print "Use " + colorize("GOOD", "emerge @preserved-rebuild") + " to rebuild packages using these libraries" - def post_emerge(root_config, myopts, mtimedb, retval): """ Misc. things to run at the end of a merge session. - + Update Info Files Update Config Files Update News Items @@ -347,14 +345,13 @@ def post_emerge(root_config, myopts, mtimedb, retval): portage.locks.unlockdir(vdb_lock) chk_updated_cfg_files(target_root, config_protect) - + display_news_notification(root_config, myopts) if retval in (None, os.EX_OK) or (not "--pretend" in myopts): display_preserved_libs(vardbapi) sys.exit(retval) - def multiple_actions(action1, action2): sys.stderr.write("\n!!! Multiple actions requested... Please choose one only.\n") sys.stderr.write("!!! '%s' or '%s'\n\n" % (action1, action2)) @@ -439,7 +436,7 @@ def parse_opts(tmpcmdline, silent=False): global options, shortmapping actions = frozenset([ - "clean", "config", "depclean", + "clean", "config", "depclean", "help", "info", "list-sets", "metadata", "prune", "regen", "search", "sync", "unmerge", "version", @@ -666,7 +663,7 @@ def expand_set_arguments(myfiles, myaction, root_config): IS_OPERATOR = "/@" DIFF_OPERATOR = "-@" UNION_OPERATOR = "+@" - + for i in range(0, len(myfiles)): if myfiles[i].startswith(SETPREFIX): start = 0 @@ -679,7 +676,7 @@ def expand_set_arguments(myfiles, myaction, root_config): if start > 0 and start < end: namepart = x[:start] argpart = x[start+1:end] - + # TODO: implement proper quoting args = argpart.split(",") options = {} @@ -696,13 +693,13 @@ def expand_set_arguments(myfiles, myaction, root_config): newset += x x = "" myfiles[i] = SETPREFIX+newset - + sets = setconfig.getSets() # display errors that occured while loading the SetConfig instance for e in setconfig.errors: print colorize("BAD", "Error during set creation: %s" % e) - + # emerge relies on the existance of sets with names "world" and "system" required_sets = ("world", "system") missing_sets = [] @@ -870,9 +867,9 @@ def config_protect_check(trees): writemsg_level(msg, level=logging.WARN, noiselevel=-1) def profile_check(trees, myaction, myopts): - if myaction in ("info", "sync"): + if myaction in ("help", "info", "sync"): return os.EX_OK - elif "--version" in myopts or "--help" in myopts: + elif "--version" in myopts: return os.EX_OK for root, root_trees in trees.iteritems(): if root_trees["root_config"].settings.profiles: @@ -1082,8 +1079,8 @@ def emerge_main(): settings.profile_path, settings["CHOST"], trees[settings["ROOT"]]["vartree"].dbapi) return 0 - elif "--help" in myopts: - _emerge.help.help(myaction, myopts, portage.output.havecolor) + elif myaction == "help": + _emerge.help.help(myopts, portage.output.havecolor) return 0 if "--debug" in myopts: -- cgit v1.2.3-1-g7c22