summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-13 06:08:55 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-13 06:08:55 +0000
commit836560e718315bd76865042ae5b88a6ee11c4765 (patch)
treeb5b2eb827a3de4f0af224d9e29766a9b47817e8b
parent4a516031391a94d60924b61e5799469a9602c1c4 (diff)
downloadportage-836560e718315bd76865042ae5b88a6ee11c4765.tar.gz
portage-836560e718315bd76865042ae5b88a6ee11c4765.tar.bz2
portage-836560e718315bd76865042ae5b88a6ee11c4765.zip
In dblink.treewalk(), use os.walk() instead of portage.listdir()
in order to avoid cacheddir() bloat when listing the files to be merged from ${D}. Remove a chdir() call that's no longer needed for the collision-protect symlink code. (trunk r8095:8098) svn path=/main/branches/2.1.2/; revision=8099
-rw-r--r--pym/portage.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/pym/portage.py b/pym/portage.py
index dbc615745..747ae9560 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -7821,6 +7821,9 @@ class dblink:
secondhand is a list of symlinks that have been skipped due to their target
not existing; we will merge these symlinks at a later time.
"""
+
+ srcroot = normalize_path(srcroot).rstrip(os.path.sep) + os.path.sep
+
if not os.path.isdir(srcroot):
writemsg("!!! Directory Not Found: D='%s'\n" % srcroot,
noiselevel=-1)
@@ -7862,21 +7865,30 @@ class dblink:
max_dblnk = dblnk
self._installed_instance = max_dblnk
+ myfilelist = []
+ mylinklist = []
+ def onerror(e):
+ raise
+ for parent, dirs, files in os.walk(srcroot, onerror=onerror):
+ for f in files:
+ file_path = os.path.join(parent, f)
+ file_mode = os.lstat(file_path).st_mode
+ if stat.S_ISREG(file_mode):
+ myfilelist.append(file_path[len(srcroot):])
+ elif stat.S_ISLNK(file_mode):
+ mylinklist.append(file_path[len(srcroot):])
+
+ myfilelist.extend(mylinklist)
+ mysymlinks = mylinklist
+ del mylinklist
+
# check for package collisions
if True:
collision_ignore = set([normalize_path(myignore) for myignore in \
self.settings.get("COLLISION_IGNORE", "").split()])
- myfilelist = listdir(srcroot, recursive=1, filesonly=1, followSymlinks=False)
-
- # the linkcheck only works if we are in srcroot
- mycwd = getcwd()
- os.chdir(srcroot)
- mysymlinks = filter(os.path.islink, listdir(srcroot, recursive=1, filesonly=0, followSymlinks=False))
- myfilelist.extend(mysymlinks)
mysymlinked_directories = [s + os.path.sep for s in mysymlinks]
del mysymlinks
-
stopmerge=False
starttime=time.time()
i=0
@@ -7993,10 +8005,6 @@ class dblink:
print "None of the installed packages claim the above file(s)."
print
sys.exit(1)
- try:
- os.chdir(mycwd)
- except OSError:
- pass
if os.stat(srcroot).st_dev == os.stat(destroot).st_dev:
""" The merge process may move files out of the image directory,
@@ -8227,7 +8235,7 @@ class dblink:
# this is supposed to merge a list of files. There will be 2 forms of argument passing.
if type(stufftomerge)==types.StringType:
#A directory is specified. Figure out protection paths, listdir() it and process it.
- mergelist = listdir(join(srcroot, stufftomerge))
+ mergelist = os.listdir(join(srcroot, stufftomerge))
offset=stufftomerge
else:
mergelist=stufftomerge