From 84d405e6f79a04a6d2bfc4713dd80d48453d983a Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 21 Mar 2013 13:31:14 -0700 Subject: [PATCH] Use realpath(__file__) to locate whole portage. Use realpath(__file__) so that python module symlinks in site-packages are followed back to the real location of the whole portage installation. --- pym/portage/const.py | 4 +++- pym/portage/tests/bin/setup_env.py | 12 +++++------- pym/portage/tests/runTests | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pym/portage/const.py b/pym/portage/const.py index fdd33e63c..93556a02b 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -58,7 +58,9 @@ DEPCACHE_PATH = "/var/cache/edb/dep" GLOBAL_CONFIG_PATH = "/usr/share/portage/config" # these variables are not used with target_root or config_root -PORTAGE_BASE_PATH = os.path.join(os.sep, os.sep.join(__file__.split(os.sep)[:-3])) +# NOTE: Use realpath(__file__) so that python module symlinks in site-packages +# are followed back to the real location of the whole portage installation. +PORTAGE_BASE_PATH = os.path.join(os.sep, os.sep.join(os.path.realpath(__file__).split(os.sep)[:-3])) PORTAGE_BIN_PATH = PORTAGE_BASE_PATH + "/bin" PORTAGE_PYM_PATH = PORTAGE_BASE_PATH + "/pym" LOCALE_DATA_PATH = PORTAGE_BASE_PATH + "/locale" # FIXME: not used diff --git a/pym/portage/tests/bin/setup_env.py b/pym/portage/tests/bin/setup_env.py index 1f8554e42..42a0e5676 100644 --- a/pym/portage/tests/bin/setup_env.py +++ b/pym/portage/tests/bin/setup_env.py @@ -1,19 +1,17 @@ # setup_env.py -- Make sure bin subdir has sane env for testing -# Copyright 2007-2011 Gentoo Foundation +# Copyright 2007-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import tempfile from portage import os from portage import shutil +from portage.const import PORTAGE_BIN_PATH +from portage.const import PORTAGE_PYM_PATH from portage.tests import TestCase from portage.process import spawn -basepath = os.path.join(os.path.dirname(os.path.dirname( - os.path.abspath(__file__))), - "..", "..", "..") -bindir = os.path.join(basepath, "bin") -pymdir = os.path.join(basepath, "pym") +bindir = PORTAGE_BIN_PATH basedir = None env = None @@ -37,7 +35,7 @@ def binTestsInit(): env["PF"] = "portage-tests-0.09-r1" env["PATH"] = bindir + ":" + os.environ["PATH"] env["PORTAGE_BIN_PATH"] = bindir - env["PORTAGE_PYM_PATH"] = pymdir + env["PORTAGE_PYM_PATH"] = PORTAGE_PYM_PATH env["PORTAGE_INST_UID"] = str(os.getuid()) env["PORTAGE_INST_GID"] = str(os.getgid()) env["DESTTREE"] = "/usr" diff --git a/pym/portage/tests/runTests b/pym/portage/tests/runTests index b0069698b..60bcf31b7 100755 --- a/pym/portage/tests/runTests +++ b/pym/portage/tests/runTests @@ -29,7 +29,7 @@ os.environ["PORTAGE_GRPNAME"] = grp.getgrgid(os.getgid()).gr_name # Insert our parent dir so we can do shiny import "tests" # This line courtesy of Marienz and Pkgcore ;) -sys.path.insert(0, osp.dirname(osp.dirname(osp.dirname(osp.abspath(__file__))))) +sys.path.insert(0, osp.dirname(osp.dirname(osp.dirname(osp.realpath(__file__))))) import portage portage._internal_caller = True -- 2.26.2