1 |
Author: zmedico |
2 |
Date: 2008-10-24 00:07:21 +0000 (Fri, 24 Oct 2008) |
3 |
New Revision: 11723 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/__init__.py |
7 |
Log: |
8 |
When populating the fake $DISTDIR inside doebuild(), reuse existing symlinks |
9 |
when possible, instead of recreating the whole directory from scratch. |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/portage/__init__.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/portage/__init__.py 2008-10-23 17:19:09 UTC (rev 11722) |
15 |
+++ main/trunk/pym/portage/__init__.py 2008-10-24 00:07:21 UTC (rev 11723) |
16 |
@@ -5656,24 +5656,31 @@ |
17 |
mysettings["PORTAGE_ACTUAL_DISTDIR"] = orig_distdir |
18 |
edpath = mysettings["DISTDIR"] = \ |
19 |
os.path.join(mysettings["PORTAGE_BUILDDIR"], "distdir") |
20 |
- if os.path.exists(edpath): |
21 |
+ portage.util.ensure_dirs(edpath, uid=portage_uid, mode=0755) |
22 |
+ |
23 |
+ # Remove any unexpected files or directories. |
24 |
+ for x in os.listdir(edpath): |
25 |
+ symlink_path = os.path.join(edpath, x) |
26 |
+ st = os.lstat(symlink_path) |
27 |
+ if x in alist and stat.S_ISLNK(st.st_mode): |
28 |
+ continue |
29 |
+ if stat.S_ISDIR(st.st_mode): |
30 |
+ shutil.rmtree(symlink_path) |
31 |
+ else: |
32 |
+ os.unlink(symlink_path) |
33 |
+ |
34 |
+ # Check for existing symlinks and recreate if necessary. |
35 |
+ for x in alist: |
36 |
+ symlink_path = os.path.join(edpath, x) |
37 |
+ target = os.path.join(orig_distdir, x) |
38 |
try: |
39 |
- if os.path.isdir(edpath) and not os.path.islink(edpath): |
40 |
- shutil.rmtree(edpath) |
41 |
- else: |
42 |
- os.unlink(edpath) |
43 |
+ link_target = os.readlink(symlink_path) |
44 |
except OSError: |
45 |
- print "!!! Failed reseting ebuild distdir path, " + edpath |
46 |
- raise |
47 |
- os.mkdir(edpath) |
48 |
- apply_secpass_permissions(edpath, uid=portage_uid, mode=0755) |
49 |
- try: |
50 |
- for file in alist: |
51 |
- os.symlink(os.path.join(orig_distdir, file), |
52 |
- os.path.join(edpath, file)) |
53 |
- except OSError: |
54 |
- print "!!! Failed symlinking in '%s' to ebuild distdir" % file |
55 |
- raise |
56 |
+ os.symlink(target, symlink_path) |
57 |
+ else: |
58 |
+ if link_target != target: |
59 |
+ os.unlink(symlink_path) |
60 |
+ os.symlink(target, symlink_path) |
61 |
|
62 |
#initial dep checks complete; time to process main commands |