summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid James <davidjames@google.com>2010-08-13 13:39:17 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-31 17:48:21 -0700
commitcb27c41a2d03209f07bc12f85c991537270dbb0e (patch)
tree94af354f35e02bee6fc69d86d9e50317e208d53f
parentb3bbf815e986dc9ac8c24116a6ed1ef912108722 (diff)
downloadportage-cb27c41a2d03209f07bc12f85c991537270dbb0e.tar.gz
portage-cb27c41a2d03209f07bc12f85c991537270dbb0e.tar.bz2
portage-cb27c41a2d03209f07bc12f85c991537270dbb0e.zip
Update portage to create directories atomically.
Portage should use the ensure_dirs function instead of os.makedirs to create directories, because this function ensures atomicity. It prevents failures when more than one process tries to create the same directory. This fixes a crash bug reported by msb: [...] File "/usr/lib64/portage/pym/portage/dbapi/vartree.py", line 3258, in _merge self.vartree.dbapi._bump_mtime(self.mycpv) File "/usr/lib64/portage/pym/portage/dbapi/vartree.py", line 152, in _bump_mtime os.makedirs(catdir) File "/usr/lib64/portage/pym/portage/__init__.py", line 210, in __call__ rval = self._func(*wrapped_args, **wrapped_kwargs) File "/usr/lib64/python2.6/os.py", line 157, in makedirs mkdir(name, mode) OSError: [Errno 17] File exists: '/home/msb/trunk/src/build/images/x86-generic/0.8.63.2010_08_03_1844-a1/rootfs//var/db/pkg/x11-proto' BUG=chromium-os:5366 TEST=build_packages && build_image Review URL: http://codereview.chromium.org/3113014
-rw-r--r--pym/portage/dbapi/vartree.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index bec7aa1b4..923e96297 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -179,7 +179,7 @@ class vardbapi(dbapi):
for x in (catdir, base):
os.utime(x, t)
except OSError:
- os.makedirs(catdir)
+ ensure_dirs(catdir)
def cpv_exists(self, mykey):
"Tells us whether an actual ebuild exists on disk (no masking)"
@@ -198,7 +198,7 @@ class vardbapi(dbapi):
def cpv_inject(self, mycpv):
"injects a real package into our on-disk database; assumes mycpv is valid and doesn't already exist"
- os.makedirs(self.getpath(mycpv))
+ ensure_dirs(self.getpath(mycpv))
counter = self.counter_tick(mycpv=mycpv)
# write local package counter so that emerge clean does the right thing
write_atomic(self.getpath(mycpv, filename="COUNTER"), str(counter))
@@ -239,7 +239,7 @@ class vardbapi(dbapi):
moves += 1
if not os.path.exists(self.getpath(mynewcat)):
#create the directory
- os.makedirs(self.getpath(mynewcat))
+ ensure_dirs(self.getpath(mynewcat))
newpath = self.getpath(mynewcpv)
if os.path.exists(newpath):
#dest already exists; keep this puppy where it is.
@@ -2846,7 +2846,7 @@ class dblink(object):
self._eerror("preinst", lines)
if not os.path.exists(self.dbcatdir):
- os.makedirs(self.dbcatdir)
+ ensure_dirs(self.dbcatdir)
otherversions = []
for v in self.vartree.dbapi.cp_list(self.mysplit[0]):