From 4911690cfc977ff22da143dd9af987be400a2dec Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 24 Oct 2008 00:07:21 +0000 Subject: 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 --- pym/portage/__init__.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'pym/portage/__init__.py') 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 -- cgit v1.2.3-1-g7c22