For bug #157393, fix up ebuild path normalization so that it's compatible with portdb...
authorZac Medico <zmedico@gentoo.org>
Thu, 7 Dec 2006 08:56:49 +0000 (08:56 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 7 Dec 2006 08:56:49 +0000 (08:56 -0000)
svn path=/main/trunk/; revision=5201

bin/ebuild

index 0860f089b5f983774e683a9af7c12ea9a0ac090c..91cd94a45c0b0f99c9e5f5dcdd0e208d23d3719c 100755 (executable)
@@ -38,7 +38,20 @@ if portage.settings["NOCOLOR"] in ("yes","true") or not sys.stdout.isatty():
        import output
        output.nocolor()
 
-ebuild = os.path.realpath(pargs.pop(0))
+ebuild = pargs.pop(0)
+if not os.path.isabs(ebuild):
+       mycwd = os.getcwd()
+       # Try to get the non-canonical path from the PWD evironment variable, since
+       # the canonical path returned from os.getcwd() may may be unusable in
+       # cases where the directory stucture is built from symlinks.
+       if "PWD" in os.environ and os.environ["PWD"] != mycwd and \
+               os.path.realpath(os.environ["PWD"]) == mycwd:
+               mycwd = portage.normalize_path(os.environ["PWD"])
+       ebuild = os.path.join(mycwd, ebuild)
+# portdbapi uses the canonical path for the base of the portage tree, but
+# subdirectories of the base can be built from symlinks (like crossdev does).
+ebuild_portdir = os.path.realpath(os.path.dirname(os.path.dirname(ebuild)))
+ebuild = os.path.join(ebuild_portdir, *ebuild.split(os.path.sep)[-2:])
 
 if not os.path.exists(ebuild):
        print "'%s' does not exist." % ebuild
@@ -66,7 +79,7 @@ else:
 
        portage_ebuild = portage.portdb.findname(cpv)
 
-       if not portage_ebuild or os.path.realpath(portage_ebuild) != ebuild:
+       if not portage_ebuild or portage_ebuild != ebuild:
                overlay = "/".join(ebuild_split[:-2])
                os.environ["PORTDIR_OVERLAY"] = os.environ.get("PORTDIR_OVERLAY","") + " " + overlay
                print "Appending %s to PORTDIR_OVERLAY..." % overlay
@@ -74,7 +87,7 @@ else:
                reload(portage)
                portage_ebuild = portage.portdb.findname(cpv)
 
-               if not portage_ebuild or os.path.realpath(portage_ebuild) != ebuild:
+               if not portage_ebuild or portage_ebuild != ebuild:
                        print "!!! %s does not seem to have a valid PORTDIR structure." % overlay
                        sys.exit(1)