From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QOcZk-0006Kq-DJ for garchives@archives.gentoo.org; Mon, 23 May 2011 21:22:08 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7ECAA1C150; Mon, 23 May 2011 21:22:00 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3B2FF1C150 for ; Mon, 23 May 2011 21:22:00 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C7FBC1B4027 for ; Mon, 23 May 2011 21:21:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2FFEA80505 for ; Mon, 23 May 2011 21:21:59 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <342d33e12301708623454743da3aa0455f890c89.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/unmerge.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 342d33e12301708623454743da3aa0455f890c89 Date: Mon, 23 May 2011 21:21:59 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 8cc8cc3c788aa23024ca49e80bc0e254 commit: 342d33e12301708623454743da3aa0455f890c89 Author: Zac Medico gentoo org> AuthorDate: Mon May 23 21:21:43 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon May 23 21:21:43 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D342d33e1 unmerge: split out _unmerge_display() function This will be useful for adding asynchronous support to the PackageUninstall class, since it will be able to call _unmerge_display() for the display portion, and then do the actual unmerge asynchronously. --- pym/_emerge/unmerge.py | 64 +++++++++++++++++++++++++++++++++---------= ------ 1 files changed, 44 insertions(+), 20 deletions(-) diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py index 5331744..0b02b32 100644 --- a/pym/_emerge/unmerge.py +++ b/pym/_emerge/unmerge.py @@ -20,21 +20,20 @@ from _emerge.UninstallFailure import UninstallFailure from _emerge.userquery import userquery from _emerge.countdown import countdown =20 -def unmerge(root_config, myopts, unmerge_action, - unmerge_files, ldpath_mtimes, autoclean=3D0, - clean_world=3D1, clean_delay=3D1, ordered=3D0, raise_on_error=3D0, - scheduler=3DNone, writemsg_level=3Dportage.util.writemsg_level): +def _unmerge_display(root_config, myopts, unmerge_action, + unmerge_files, clean_delay=3D1, ordered=3D0, + writemsg_level=3Dportage.util.writemsg_level): + """ + Returns a tuple of (returncode, pkgmap) where returncode is + os.EX_OK is no errors occur, and 1 otherwise. + """ =20 - if clean_world: - clean_world =3D myopts.get('--deselect') !=3D 'n' quiet =3D "--quiet" in myopts - enter_invalid =3D '--ask-enter-invalid' in myopts settings =3D root_config.settings sets =3D root_config.sets vartree =3D root_config.trees["vartree"] candidate_catpkgs=3D[] global_unmerge=3D0 - xterm_titles =3D "notitles" not in settings.features out =3D portage.output.EOutput() pkg_cache =3D {} db_keys =3D list(vartree.dbapi._aux_cache_keys) @@ -87,14 +86,12 @@ def unmerge(root_config, myopts, unmerge_action, syslist.append(mycp) syslist =3D frozenset(syslist) =09 - mysettings =3D portage.config(clone=3Dsettings) -=09 if not unmerge_files: if unmerge_action =3D=3D "unmerge": print() print(bold("emerge unmerge") + " can only be used with specific pack= age names") print() - return 0 + return 1, {} else: global_unmerge =3D 1 =09 @@ -108,7 +105,7 @@ def unmerge(root_config, myopts, unmerge_action, #we've got command-line arguments if not unmerge_files: print("\nNo packages to unmerge have been provided.\n") - return 0 + return 1, {} for x in unmerge_files: arg_parts =3D x.split('/') if x[0] not in [".","/"] and \ @@ -124,7 +121,7 @@ def unmerge(root_config, myopts, unmerge_action, # ebuild and we're in "unmerge" mode, so it's ok. if not os.path.exists(x): print("\n!!! The path '"+x+"' doesn't exist.\n") - return 0 + return 1, {} =09 absx =3D os.path.abspath(x) sp_absx =3D absx.split("/") @@ -135,14 +132,13 @@ def unmerge(root_config, myopts, unmerge_action, sp_absx_len =3D len(sp_absx) =09 vdb_path =3D os.path.join(settings["EROOT"], portage.VDB_PATH) - vdb_len =3D len(vdb_path) =09 sp_vdb =3D vdb_path.split("/") sp_vdb_len =3D len(sp_vdb) =09 if not os.path.exists(absx+"/CONTENTS"): print("!!! Not a valid db dir: "+str(absx)) - return 0 + return 1, {} =09 if sp_absx_len <=3D sp_vdb_len: # The Path is shorter... so it can't be inside the vdb. @@ -150,7 +146,7 @@ def unmerge(root_config, myopts, unmerge_action, print(absx) print("\n!!!",x,"cannot be inside "+ \ vdb_path+"; aborting.\n") - return 0 + return 1, {} =09 for idx in range(0,sp_vdb_len): if idx >=3D sp_absx_len or sp_vdb[idx] !=3D sp_absx[idx]: @@ -158,7 +154,7 @@ def unmerge(root_config, myopts, unmerge_action, print(absx) print("\n!!!", x, "is not inside "+\ vdb_path+"; aborting.\n") - return 0 + return 1, {} =09 print("=3D"+"/".join(sp_absx[sp_vdb_len:])) candidate_catpkgs.append( @@ -285,13 +281,13 @@ def unmerge(root_config, myopts, unmerge_action, numselected =3D len(all_selected) if global_unmerge and not numselected: portage.writemsg_stdout("\n>>> No outdated packages were found on you= r system.\n") - return 0 + return 1, {} =09 if not numselected: portage.writemsg_stdout( "\n>>> No packages selected for removal by " + \ unmerge_action + "\n") - return 0 + return 1, {} finally: if vdb_lock: vartree.dbapi.flush_cache() @@ -407,7 +403,7 @@ def unmerge(root_config, myopts, unmerge_action, writemsg_level( "\n>>> No packages selected for removal by " + \ unmerge_action + "\n") - return 0 + return 1, {} =20 # Unmerge order only matters in some cases if not ordered: @@ -492,6 +488,34 @@ def unmerge(root_config, myopts, unmerge_action, " and " + colorize("GOOD", "'omitted'") + \ " packages will not be removed.\n\n") =20 + return os.EX_OK, pkgmap + +def unmerge(root_config, myopts, unmerge_action, + unmerge_files, ldpath_mtimes, autoclean=3D0, + clean_world=3D1, clean_delay=3D1, ordered=3D0, raise_on_error=3D0, + scheduler=3DNone, writemsg_level=3Dportage.util.writemsg_level): + """ + Returns 1 if successful, otherwise 0. + """ + + if clean_world: + clean_world =3D myopts.get('--deselect') !=3D 'n' + + rval, pkgmap =3D _unmerge_display(root_config, myopts, + unmerge_action, unmerge_files, + clean_delay=3Dclean_delay, ordered=3Dordered, + writemsg_level=3Dportage.util.writemsg_level) + + if rval !=3D os.EX_OK: + return 0 + + enter_invalid =3D '--ask-enter-invalid' in myopts + vartree =3D root_config.trees["vartree"] + sets =3D root_config.sets + settings =3D root_config.settings + mysettings =3D portage.config(clone=3Dsettings) + xterm_titles =3D "notitles" not in settings.features + if "--pretend" in myopts: #we're done... return return 0