Remove $PORTAGE_BUILDDIR locking from portage.pkgmerge() and use
authorZac Medico <zmedico@gentoo.org>
Wed, 2 Jul 2008 08:21:20 +0000 (08:21 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 2 Jul 2008 08:21:20 +0000 (08:21 -0000)
an instance of EbuildBuildDir instead.

svn path=/main/trunk/; revision=10892

pym/_emerge/__init__.py
pym/portage/__init__.py

index a2dc88b1a867a781c4dade3c2a66160cdf144b39..225a4c4d6c12e95b0befa2e86c126491122a6f4c 100644 (file)
@@ -2124,12 +2124,18 @@ class Binpkg(SlotObject):
                short_msg = "emerge: (%s of %s) %s Merge Binary" % \
                        (pkg_count.curval, pkg_count.maxval, pkg.cpv)
                logger.log(msg, short_msg=short_msg)
-               merge = BinpkgMerge(find_blockers=find_blockers,
-                       ldpath_mtimes=ldpath_mtimes, pkg=pkg, pretend=opts.pretend,
-                       pkg_path=pkg_path, settings=settings)
-               retval = merge.execute()
-               if retval != os.EX_OK:
-                       return retval
+
+               build_dir = EbuildBuildDir(pkg=pkg, settings=settings)
+               try:
+                       build_dir.lock()
+                       merge = BinpkgMerge(find_blockers=find_blockers,
+                               ldpath_mtimes=ldpath_mtimes, pkg=pkg, pretend=opts.pretend,
+                               pkg_path=pkg_path, settings=settings)
+                       retval = merge.execute()
+                       if retval != os.EX_OK:
+                               return retval
+               finally:
+                       build_dir.unlock()
                return os.EX_OK
 
 class BinpkgFetcher(Task):
index 6cba85bf78b951fa3f154e4a010c4dd58dee54ab..5fe2b41f3afe7db48821af9747c464023717957f 100644 (file)
@@ -6589,8 +6589,6 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
                return 1
 
        tbz2_lock = None
-       builddir_lock = None
-       catdir_lock = None
        mycat = None
        mypkg = None
        did_merge_phase = False
@@ -6622,11 +6620,6 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
                catdir_lock = portage.locks.lockdir(catdir)
                portage.util.ensure_dirs(catdir,
                        uid=portage_uid, gid=portage_gid, mode=070, mask=0)
-               builddir_lock = portage.locks.lockdir(builddir)
-               try:
-                       portage.locks.unlockdir(catdir_lock)
-               finally:
-                       catdir_lock = None
                try:
                        shutil.rmtree(builddir)
                except (IOError, OSError), e:
@@ -6678,7 +6671,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
                mysettings.pop("PORTAGE_BINPKG_FILE", None)
                if tbz2_lock:
                        portage.locks.unlockfile(tbz2_lock)
-               if builddir_lock:
+               if True:
                        if not did_merge_phase:
                                # The merge phase handles this already.  Callers don't know how
                                # far this function got, so we have to call elog_process() here
@@ -6692,21 +6685,6 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
-                       portage.locks.unlockdir(builddir_lock)
-                       try:
-                               if not catdir_lock:
-                                       # Lock catdir for removal if empty.
-                                       catdir_lock = portage.locks.lockdir(catdir)
-                       finally:
-                               if catdir_lock:
-                                       try:
-                                               os.rmdir(catdir)
-                                       except OSError, e:
-                                               if e.errno not in (errno.ENOENT,
-                                                       errno.ENOTEMPTY, errno.EEXIST):
-                                                       raise
-                                               del e
-                                       portage.locks.unlockdir(catdir_lock)
 
 def deprecated_profile_check():
        if not os.access(DEPRECATED_PROFILE_FILE, os.R_OK):