From bd8514843e2dac56c59a566b335c89d486ad894b Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 9 Dec 2011 22:02:01 -0800 Subject: Use portage.const.EPREFIX more. --- pym/portage/__init__.py | 2 ++ pym/portage/const.py | 4 ---- pym/portage/data.py | 2 +- pym/portage/dispatch_conf.py | 4 ++-- pym/portage/tests/repoman/test_simple.py | 2 +- pym/portage/util/env_update.py | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) (limited to 'pym') diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 27353a1e8..bdfb4e29d 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -505,6 +505,8 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None): if env is None: env = os.environ eprefix = env.get("__PORTAGE_TEST_EPREFIX") + if eprefix is None: + eprefix = portage.const.EPREFIX settings = config(config_root=config_root, target_root=target_root, env=env, _eprefix=eprefix) settings.lock() diff --git a/pym/portage/const.py b/pym/portage/const.py index 5003b155c..553dfc534 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -154,10 +154,6 @@ if "__PORTAGE_TEST_EPREFIX" in os.environ: if EPREFIX: EPREFIX = os.path.normpath(EPREFIX) -elif EPREFIX: - # Propagate the constant to other portage code which uses this variable. - os.environ["__PORTAGE_TEST_EPREFIX"] = EPREFIX - # =========================================================================== # END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT # =========================================================================== diff --git a/pym/portage/data.py b/pym/portage/data.py index fe390a130..53af6b966 100644 --- a/pym/portage/data.py +++ b/pym/portage/data.py @@ -82,7 +82,7 @@ def _get_global(k): secpass = 0 if uid == 0: secpass = 2 - elif "__PORTAGE_TEST_EPREFIX" in os.environ: + elif portage.const.EPREFIX: secpass = 2 #Discover the uid and gid of the portage user/group try: diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py index abd3ac141..7f407fffe 100644 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@ -39,8 +39,8 @@ def diffstatusoutput_len(cmd): return (1, 1) def read_config(mandatory_opts): - eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX", "/") - config_path = os.path.join(eprefix, "etc/dispatch-conf.conf") + eprefix = portage.const.EPREFIX + config_path = os.path.join(eprefix or os.sep, "etc/dispatch-conf.conf") loader = KeyValuePairFileLoader(config_path, None) opts, errors = loader.load() if not opts: diff --git a/pym/portage/tests/repoman/test_simple.py b/pym/portage/tests/repoman/test_simple.py index 6c8a61c5b..b3186d7b4 100644 --- a/pym/portage/tests/repoman/test_simple.py +++ b/pym/portage/tests/repoman/test_simple.py @@ -184,7 +184,7 @@ class SimpleRepomanTestCase(TestCase): pythonpath = PORTAGE_PYM_PATH + pythonpath env = { - "__REPOMAN_TEST_EPREFIX" : eprefix, + "__PORTAGE_TEST_EPREFIX" : eprefix, "DISTDIR" : distdir, "GENTOO_COMMITTER_NAME" : committer_name, "GENTOO_COMMITTER_EMAIL" : committer_email, diff --git a/pym/portage/util/env_update.py b/pym/portage/util/env_update.py index 7879ed9aa..e8507b3f7 100644 --- a/pym/portage/util/env_update.py +++ b/pym/portage/util/env_update.py @@ -50,7 +50,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, target_root = portage.settings["ROOT"] target_eroot = portage.settings['EROOT'] else: - eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX", "") + eprefix = portage.const.EPREFIX target_eroot = os.path.join(target_root, eprefix.lstrip(os.sep)) target_eroot = target_eroot.rstrip(os.sep) + os.sep -- cgit v1.2.3-1-g7c22