1 |
commit: 8601ea2b80208491b471f37710b35813fd341c28 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat May 7 21:59:54 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat May 7 21:59:54 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8601ea2b |
7 |
|
8 |
doebuild: use EbuildBuildDir for locking |
9 |
|
10 |
EbuildBuildDir also performs safe removal of the category when it is |
11 |
empty, so ebuild.sh/dyn_clean doesn't need to do it anymore. This |
12 |
fixes a race condition if one process is trying to remove the category |
13 |
directory while another one is trying to create it for |
14 |
PORTAGE_BUILDDIR. |
15 |
|
16 |
--- |
17 |
bin/ebuild.sh | 2 +- |
18 |
pym/portage/package/ebuild/doebuild.py | 15 +++++++++++++-- |
19 |
2 files changed, 14 insertions(+), 3 deletions(-) |
20 |
|
21 |
diff --git a/bin/ebuild.sh b/bin/ebuild.sh |
22 |
index f3349ae..c3cf181 100755 |
23 |
--- a/bin/ebuild.sh |
24 |
+++ b/bin/ebuild.sh |
25 |
@@ -812,7 +812,7 @@ dyn_clean() { |
26 |
# Some kernels, such as Solaris, return EINVAL when an attempt |
27 |
# is made to remove the current working directory. |
28 |
cd "$PORTAGE_BUILDDIR"/../.. |
29 |
- rmdir "$PORTAGE_BUILDDIR" "${PORTAGE_BUILDDIR%/*}" 2>/dev/null |
30 |
+ rmdir "$PORTAGE_BUILDDIR" 2>/dev/null |
31 |
|
32 |
true |
33 |
} |
34 |
|
35 |
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py |
36 |
index 1c04822..f83a1e3 100644 |
37 |
--- a/pym/portage/package/ebuild/doebuild.py |
38 |
+++ b/pym/portage/package/ebuild/doebuild.py |
39 |
@@ -566,8 +566,19 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, |
40 |
use_cache, mydbapi) |
41 |
|
42 |
if mydo in clean_phases: |
43 |
- return _spawn_phase(mydo, mysettings, |
44 |
- fd_pipes=fd_pipes, returnpid=returnpid) |
45 |
+ builddir_lock = None |
46 |
+ if not returnpid and \ |
47 |
+ 'PORTAGE_BUILDIR_LOCKED' not in mysettings: |
48 |
+ builddir_lock = EbuildBuildDir( |
49 |
+ scheduler=PollScheduler().sched_iface, |
50 |
+ settings=mysettings) |
51 |
+ builddir_lock.lock() |
52 |
+ try: |
53 |
+ return _spawn_phase(mydo, mysettings, |
54 |
+ fd_pipes=fd_pipes, returnpid=returnpid) |
55 |
+ finally: |
56 |
+ if builddir_lock is not None: |
57 |
+ builddir_lock.unlock() |
58 |
|
59 |
restrict = set(mysettings.get('PORTAGE_RESTRICT', '').split()) |
60 |
# get possible slot information from the deps file |