diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-05-23 20:40:20 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-05-23 20:40:20 +0000 |
commit | fa216dc7b5a9d147d356f8458c52e99f975e7da3 (patch) | |
tree | 72bd3ab6983c41661e41b7c30fecbcc0a5860949 /bin/repoman | |
parent | 251599fe919add04678e2d8bda1dc181d83b6de6 (diff) | |
download | portage-fa216dc7b5a9d147d356f8458c52e99f975e7da3.tar.gz portage-fa216dc7b5a9d147d356f8458c52e99f975e7da3.tar.bz2 portage-fa216dc7b5a9d147d356f8458c52e99f975e7da3.zip |
Use device number and i-node number (like os.path.samefile does) to check if the current directory is inside a given overlay. This solves issues with path comparison and symlinks. (trunk r6558:6559)
svn path=/main/branches/2.1.2/; revision=6605
Diffstat (limited to 'bin/repoman')
-rwxr-xr-x | bin/repoman | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/bin/repoman b/bin/repoman index 556872a02..36097550c 100755 --- a/bin/repoman +++ b/bin/repoman @@ -409,13 +409,28 @@ if "PWD" in os.environ and os.environ["PWD"] != mydir and \ # the current working directory (from the shell). mydir = os.environ["PWD"] mydir = normalize_path(mydir) +path_ids = set() +p = mydir +s = None +while True: + s = os.stat(p) + path_ids.add((s.st_dev, s.st_ino)) + if p == "/": + break + p = os.path.dirname(p) if mydir[-1] != "/": mydir += "/" for overlay in repoman_settings["PORTDIR_OVERLAY"].split(): + overlay = os.path.realpath(overlay) + try: + s = os.stat(overlay) + except OSError: + continue + overlay_id = (s.st_dev, s.st_ino) if overlay[-1] != "/": overlay += "/" - if mydir.startswith(overlay): + if overlay_id in path_ids: portdir_overlay = overlay subdir = mydir[len(overlay):] if subdir and subdir[-1] != "/": @@ -424,6 +439,8 @@ for overlay in repoman_settings["PORTDIR_OVERLAY"].split(): portdir = portdir_overlay break +del p, s, path_ids + if not portdir_overlay: if (repoman_settings["PORTDIR"] + os.path.sep).startswith(mydir): portdir_overlay = repoman_settings["PORTDIR"] |