Merged from trunk -r15292:15298
authorFabian Groffen <grobian@gentoo.org>
Sun, 31 Jan 2010 09:44:08 +0000 (09:44 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sun, 31 Jan 2010 09:44:08 +0000 (09:44 -0000)
   | 15293   | Fix: change os.mkdir to os.makedirs in case of there are     |
   | volkmar | more than one directory depth missing. According to          |
   |         | docs.python.org, permissions may be not respected with       |
   |         | os.makedirs... with some systems.                            |

   | 15294   | Avoid NameError when cwd is $FILESDIR. Thanks to Christian   |
   | zmedico | Ruppert <idl0r@g.o> for reporting.                           |

   | 15295   | Bug #302764 - Inside __iter__, only recurse 1 deep, in order |
   | zmedico | to avoid iteration over entries from another nested cache    |
   |         | instance. This can happen if the user nests an overlay       |
   |         | inside /usr/portage/local. Thanks to Vlastimil Babka         |
   |         | <caster@g.o> for this patch.                                 |

   | 15296   | Make __iter__ use list.pop() instead of pop(0), for greater  |
   | zmedico | efficiency.                                                  |

   | 15297   | In __iter__, handle OSError from lstat in case a cache entry |
   | zmedico | disappears.                                                  |

   | 15298   | Reverting r15293, it was actually not needed.                |
   | volkmar |                                                              |

svn path=/main/branches/prefix/; revision=15302

bin/repoman
pym/portage/cache/flat_hash.py

index 54b466348d67adc16815576ec41c16c722f321e5..3edb2b1ee8aa92facf89a19218b1c00baaadf24b 100755 (executable)
@@ -748,6 +748,12 @@ elif repolevel==3:
                caterror(catdir)
        scanlist.append(catdir+"/"+reposplit[-1])
        repo_subdir = scanlist[-1] + os.sep
+else:
+       msg = 'Repoman is unable to determine PORTDIR or PORTDIR_OVERLAY' + \
+               ' from the current working directory'
+       logging.critical(msg)
+       sys.exit(1)
+
 repo_subdir_len = len(repo_subdir)
 scanlist.sort()
 
index 93411580584f943c5c767fd95b2efa8cb09f259d..b014f170d5b6424015b3179fbce282ed87695122 100644 (file)
@@ -120,24 +120,32 @@ class database(fs_template.FsBased):
 
        def __iter__(self):
                """generator for walking the dir struct"""
-               dirs = [self.location]
+               dirs = [(0, self.location)]
                len_base = len(self.location)
-               while len(dirs):
+               while dirs:
+                       depth, dir_path = dirs.pop()
                        try:
-                               dir_list = os.listdir(dirs[0])
+                               dir_list = os.listdir(dir_path)
                        except OSError as e:
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
-                               dirs.pop(0)
                                continue
                        for l in dir_list:
                                if l.endswith(".cpickle"):
                                        continue
-                               p = os.path.join(dirs[0],l)
-                               st = os.lstat(p)
+                               p = os.path.join(dir_path, l)
+                               try:
+                                       st = os.lstat(p)
+                               except OSError:
+                                       # Cache entry disappeared.
+                                       continue
                                if stat.S_ISDIR(st.st_mode):
-                                       dirs.append(p)
+                                       # Only recurse 1 deep, in order to avoid iteration over
+                                       # entries from another nested cache instance. This can
+                                       # happen if the user nests an overlay inside
+                                       # /usr/portage/local as in bug #302764.
+                                       if depth < 1:
+                                               dirs.append((depth+1, p))
                                        continue
                                yield p[len_base+1:]
-                       dirs.pop(0)