From 32d5fd3a9134c6f3b4de79fa96e52377d87aca45 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 25 Feb 2010 22:28:00 +0000 Subject: [PATCH] Move merge and unmerge functions to the vartree module. svn path=/main/trunk/; revision=15468 --- pym/portage/__init__.py | 34 +--------------------------------- pym/portage/dbapi/vartree.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 005055a62..a49244e5d 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -86,7 +86,7 @@ try: 'portage.dbapi.dep_expand:dep_expand', 'portage.dbapi.porttree:close_portdbapi_caches,FetchlistDict,' + \ 'portagetree,portdbapi', - 'portage.dbapi.vartree:vardbapi,vartree,dblink', + 'portage.dbapi.vartree:dblink,merge,unmerge,vardbapi,vartree', 'portage.dbapi.virtual:fakedbapi', 'portage.dep', 'portage.dep:best_match_to_list,dep_getcpv,dep_getkey,' + \ @@ -616,38 +616,6 @@ def _movefile(src, dest, **kwargs): raise portage.exception.PortageException( "mv '%s' '%s'" % (src, dest)) -def merge(mycat, mypkg, pkgloc, infloc, myroot, mysettings, myebuild=None, - mytree=None, mydbapi=None, vartree=None, prev_mtimes=None, blockers=None, - scheduler=None): - if not os.access(myroot, os.W_OK): - writemsg(_("Permission denied: access('%s', W_OK)\n") % myroot, - noiselevel=-1) - return errno.EACCES - mylink = dblink(mycat, mypkg, myroot, mysettings, treetype=mytree, - vartree=vartree, blockers=blockers, scheduler=scheduler) - return mylink.merge(pkgloc, infloc, myroot, myebuild, - mydbapi=mydbapi, prev_mtimes=prev_mtimes) - -def unmerge(cat, pkg, myroot, mysettings, mytrimworld=1, vartree=None, - ldpath_mtimes=None, scheduler=None): - mylink = dblink(cat, pkg, myroot, mysettings, treetype="vartree", - vartree=vartree, scheduler=scheduler) - vartree = mylink.vartree - try: - mylink.lockdb() - if mylink.exists(): - vartree.dbapi.plib_registry.load() - vartree.dbapi.plib_registry.pruneNonExisting() - retval = mylink.unmerge(trimworld=mytrimworld, cleanup=1, - ldpath_mtimes=ldpath_mtimes) - if retval == os.EX_OK: - mylink.delete() - return retval - return os.EX_OK - finally: - vartree.dbapi.linkmap._clear_cache() - mylink.unlockdb() - auxdbkeys = ( 'DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI', 'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION', diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index fbbe8176e..0ccc4ddd4 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -4473,6 +4473,38 @@ class dblink(object): "Is this a regular package (does it have a CATEGORY file? A dblink can be virtual *and* regular)" return os.path.exists(os.path.join(self.dbdir, "CATEGORY")) +def merge(mycat, mypkg, pkgloc, infloc, myroot, mysettings, myebuild=None, + mytree=None, mydbapi=None, vartree=None, prev_mtimes=None, blockers=None, + scheduler=None): + if not os.access(myroot, os.W_OK): + writemsg(_("Permission denied: access('%s', W_OK)\n") % myroot, + noiselevel=-1) + return errno.EACCES + mylink = dblink(mycat, mypkg, myroot, mysettings, treetype=mytree, + vartree=vartree, blockers=blockers, scheduler=scheduler) + return mylink.merge(pkgloc, infloc, myroot, myebuild, + mydbapi=mydbapi, prev_mtimes=prev_mtimes) + +def unmerge(cat, pkg, myroot, mysettings, mytrimworld=1, vartree=None, + ldpath_mtimes=None, scheduler=None): + mylink = dblink(cat, pkg, myroot, mysettings, treetype="vartree", + vartree=vartree, scheduler=scheduler) + vartree = mylink.vartree + try: + mylink.lockdb() + if mylink.exists(): + vartree.dbapi.plib_registry.load() + vartree.dbapi.plib_registry.pruneNonExisting() + retval = mylink.unmerge(trimworld=mytrimworld, cleanup=1, + ldpath_mtimes=ldpath_mtimes) + if retval == os.EX_OK: + mylink.delete() + return retval + return os.EX_OK + finally: + vartree.dbapi.linkmap._clear_cache() + mylink.unlockdb() + def write_contents(contents, root, f): """ Write contents to any file like object. The file will be left open. -- 2.26.2