summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-09-23 10:28:09 +0000
committerZac Medico <zmedico@gentoo.org>2006-09-23 10:28:09 +0000
commita61d4ff691133ca34ff86262635757116c6aa4ec (patch)
treee13790a5660178865ae8ca82621fecb643c4da24
parentce313966c95b66a64e3c1d2287eeceb34b0dca84 (diff)
downloadportage-a61d4ff691133ca34ff86262635757116c6aa4ec.tar.gz
portage-a61d4ff691133ca34ff86262635757116c6aa4ec.tar.bz2
portage-a61d4ff691133ca34ff86262635757116c6aa4ec.zip
Lock PORTAGE_BUILDDIR all the way through prerm, unmerge, and postrm.
svn path=/main/trunk/; revision=4514
-rw-r--r--pym/portage.py110
1 files changed, 60 insertions, 50 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 2b9f532ca..b158b291c 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -5742,42 +5742,73 @@ class dblink:
ldpath_mtimes=None):
"""The caller must ensure that lockdb() and unlockdb() are called
before and after this method."""
- global dircache
- dircache={}
+
+ # Now, don't assume that the name of the ebuild is the same as the
+ # name of the dir; the package may have been moved.
+ myebuildpath = None
+ mystuff = listdir(self.dbdir, EmptyOnError=1)
+ for x in mystuff:
+ if x.endswith(".ebuild"):
+ myebuildpath = os.path.join(self.dbdir, x)
+ break
self.settings.load_infodir(self.dbdir)
+ if myebuildpath:
+ retval = doebuild_environment(myebuildpath, "prerm", self.myroot,
+ self.settings, 0, 0, self.vartree.dbapi)
+ if retval != os.EX_OK:
+ sys.exit(retval)
+ portage_util.ensure_dirs(
+ os.path.dirname(self.settings["PORTAGE_BUILDDIR"]),
+ gid=portage_gid, mode=070, mask=02)
+ builddir_lock = None
+ try:
+ builddir_lock = portage_locks.lockdir(
+ self.settings["PORTAGE_BUILDDIR"])
+
+ if myebuildpath:
+ # Eventually, we'd like to pass in the saved ebuild env here...
+ retval = doebuild(myebuildpath, "prerm", self.myroot,
+ self.settings, cleanup=cleanup, use_cache=0,
+ mydbapi=self.vartree.dbapi, tree="vartree",
+ vartree=self.vartree)
+ # XXX: Decide how to handle failures here.
+ if retval != os.EX_OK:
+ writemsg("!!! FAILED prerm: %s\n" % retval, noiselevel=-1)
+ sys.exit(123)
+
+ self._unmerge_pkgfiles(pkgfiles)
+
+ if myebuildpath:
+ retval = doebuild(myebuildpath, "postrm", self.myroot,
+ self.settings, use_cache=0, tree="vartree",
+ mydbapi=self.vartree.dbapi, vartree=self.vartree)
+
+ # process logs created during pre/postrm
+ elog_process(self.mycpv, self.settings)
+
+ # XXX: Decide how to handle failures here.
+ if retval != os.EX_OK:
+ writemsg("!!! FAILED postrm: %s\n" % retval, noiselevel=-1)
+ sys.exit(123)
+ doebuild(myebuildpath, "cleanrm", self.myroot, self.settings,
+ tree="vartree", mydbapi=self.vartree.dbapi,
+ vartree=self.vartree)
- if not pkgfiles:
- writemsg_stdout("No package files given... Grabbing a set.\n")
- pkgfiles=self.getcontents()
+ finally:
+ if builddir_lock:
+ portage_locks.unlockdir(builddir_lock)
- # Now, don't assume that the name of the ebuild is the same as the
- # name of the dir; the package may have been moved.
- myebuildpath=None
+ env_update(target_root=self.myroot, prev_mtimes=ldpath_mtimes)
- # We should use the environement file if possible,
- # as it has all sourced files already included.
- # XXX: Need to ensure it doesn't overwrite any important vars though.
- if os.access(self.dbdir+"/environment.bz2", os.R_OK):
- spawn("bzip2 -d "+self.dbdir+"/environment.bz2",self.settings,free=1)
+ def _unmerge_pkgfiles(self, pkgfiles):
- if not myebuildpath:
- mystuff=listdir(self.dbdir,EmptyOnError=1)
- for x in mystuff:
- if x[-7:]==".ebuild":
- myebuildpath=self.dbdir+"/"+x
- break
+ global dircache
+ dircache={}
- #do prerm script
- if myebuildpath and os.path.exists(myebuildpath):
- # Eventually, we'd like to pass in the saved ebuild env here...
- a = doebuild(myebuildpath, "prerm", self.myroot, self.settings,
- cleanup=cleanup, use_cache=0, tree="vartree",
- mydbapi=self.vartree.dbapi, vartree=self.vartree)
- # XXX: Decide how to handle failures here.
- if a != 0:
- writemsg("!!! FAILED prerm: "+str(a)+"\n", noiselevel=-1)
- sys.exit(123)
+ if not pkgfiles:
+ writemsg_stdout("No package files given... Grabbing a set.\n")
+ pkgfiles=self.getcontents()
if pkgfiles:
mykeys=pkgfiles.keys()
@@ -5891,27 +5922,6 @@ class dblink:
#remove self from vartree database so that our own virtual gets zapped if we're the last node
self.vartree.zap(self.mycpv)
- #do original postrm
- if myebuildpath and os.path.exists(myebuildpath):
- # XXX: This should be the old config, not the current one.
- # XXX: Use vardbapi to load up env vars.
- a = doebuild(myebuildpath, "postrm", self.myroot, self.settings,
- use_cache=0, tree="vartree", mydbapi=self.vartree.dbapi,
- vartree=self.vartree)
-
- # process logs created during pre/postrm
- elog_process(self.mycpv, self.settings)
-
- # XXX: Decide how to handle failures here.
- if a != 0:
- writemsg("!!! FAILED postrm: "+str(a)+"\n", noiselevel=-1)
- sys.exit(123)
- doebuild(myebuildpath, "cleanrm", self.myroot, self.settings,
- tree="vartree", mydbapi=self.vartree.dbapi,
- vartree=self.vartree)
-
- env_update(target_root=self.myroot, prev_mtimes=ldpath_mtimes)
-
def isowner(self,filename,destroot):
""" check if filename is a new file or belongs to this package
(for this or a previous version)"""