linkmap: check for access before locking vardbapi
authorZac Medico <zmedico@gentoo.org>
Sun, 8 May 2011 05:02:38 +0000 (22:02 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 8 May 2011 05:02:38 +0000 (22:02 -0700)
pym/portage/util/_dyn_libs/LinkageMapELF.py

index 31aacbbf27cc2e098aaa3c9d34477c79ed2dcbed..11e32b6b9d083b9c2594a1761bac6a5110643fe4 100644 (file)
@@ -183,7 +183,9 @@ class LinkageMapELF(object):
                                lines.append((include_file, line))
 
                aux_keys = [self._needed_aux_key]
-               self._dbapi.lock()
+               can_lock = os.access(os.path.dirname(self._dbapi._dbroot), os.W_OK)
+               if can_lock:
+                       self._dbapi.lock()
                try:
                        for cpv in self._dbapi.cpv_all():
                                if exclude_pkgs is not None and cpv in exclude_pkgs:
@@ -193,7 +195,8 @@ class LinkageMapELF(object):
                                for line in self._dbapi.aux_get(cpv, aux_keys)[0].splitlines():
                                        lines.append((needed_file, line))
                finally:
-                       self._dbapi.unlock()
+                       if can_lock:
+                               self._dbapi.unlock()
 
                # have to call scanelf for preserved libs here as they aren't 
                # registered in NEEDED.ELF.2 files