summaryrefslogtreecommitdiffstats
path: root/pym/portage/__init__.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-10-24 00:07:21 +0000
committerZac Medico <zmedico@gentoo.org>2008-10-24 00:07:21 +0000
commit4911690cfc977ff22da143dd9af987be400a2dec (patch)
tree0a17e2ba183e8c04a77150c04dba956b81e82586 /pym/portage/__init__.py
parentdd5b4ab092e9ed6c22bbe2f235b919747bf4a4ef (diff)
downloadportage-4911690cfc977ff22da143dd9af987be400a2dec.tar.gz
portage-4911690cfc977ff22da143dd9af987be400a2dec.tar.bz2
portage-4911690cfc977ff22da143dd9af987be400a2dec.zip
When populating the fake $DISTDIR inside doebuild(), reuse existing symlinks
when possible, instead of recreating the whole directory from scratch. svn path=/main/trunk/; revision=11723
Diffstat (limited to 'pym/portage/__init__.py')
-rw-r--r--pym/portage/__init__.py39
1 files changed, 23 insertions, 16 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d55054e47..3ec0f08d7 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -5656,24 +5656,31 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
mysettings["PORTAGE_ACTUAL_DISTDIR"] = orig_distdir
edpath = mysettings["DISTDIR"] = \
os.path.join(mysettings["PORTAGE_BUILDDIR"], "distdir")
- if os.path.exists(edpath):
+ portage.util.ensure_dirs(edpath, uid=portage_uid, mode=0755)
+
+ # Remove any unexpected files or directories.
+ for x in os.listdir(edpath):
+ symlink_path = os.path.join(edpath, x)
+ st = os.lstat(symlink_path)
+ if x in alist and stat.S_ISLNK(st.st_mode):
+ continue
+ if stat.S_ISDIR(st.st_mode):
+ shutil.rmtree(symlink_path)
+ else:
+ os.unlink(symlink_path)
+
+ # Check for existing symlinks and recreate if necessary.
+ for x in alist:
+ symlink_path = os.path.join(edpath, x)
+ target = os.path.join(orig_distdir, x)
try:
- if os.path.isdir(edpath) and not os.path.islink(edpath):
- shutil.rmtree(edpath)
- else:
- os.unlink(edpath)
+ link_target = os.readlink(symlink_path)
except OSError:
- print "!!! Failed reseting ebuild distdir path, " + edpath
- raise
- os.mkdir(edpath)
- apply_secpass_permissions(edpath, uid=portage_uid, mode=0755)
- try:
- for file in alist:
- os.symlink(os.path.join(orig_distdir, file),
- os.path.join(edpath, file))
- except OSError:
- print "!!! Failed symlinking in '%s' to ebuild distdir" % file
- raise
+ os.symlink(target, symlink_path)
+ else:
+ if link_target != target:
+ os.unlink(symlink_path)
+ os.symlink(target, symlink_path)
#initial dep checks complete; time to process main commands