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. --- bin/dispatch-conf | 2 +- bin/egencache | 2 +- bin/portageq | 2 +- bin/repoman | 2 +- 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 +- 10 files changed, 11 insertions(+), 13 deletions(-) diff --git a/bin/dispatch-conf b/bin/dispatch-conf index 1cad9e011..75e991189 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -85,7 +85,7 @@ class dispatch: confs = [] count = 0 - config_root = os.environ.get("__PORTAGE_TEST_EPREFIX", "/") + config_root = portage.const.EPREFIX or os.sep self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS) if "log-file" in self.options: diff --git a/bin/egencache b/bin/egencache index ba1f18873..532cc034c 100755 --- a/bin/egencache +++ b/bin/egencache @@ -841,7 +841,7 @@ def egencache_main(args): if options.portdir is not None: env['PORTDIR'] = options.portdir - eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX") + eprefix = portage.const.EPREFIX settings = portage.config(config_root=config_root, local_config=False, env=env, _eprefix=eprefix) diff --git a/bin/portageq b/bin/portageq index e1cf1a0f7..5e488d340 100755 --- a/bin/portageq +++ b/bin/portageq @@ -842,7 +842,7 @@ def main(): sys.stderr.write("Run portageq with --help for info\n") sys.stderr.flush() sys.exit(os.EX_USAGE) - eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX") + eprefix = portage.const.EPREFIX eroot = portage.util.normalize_path(sys.argv[2]) if eprefix: root = eroot[:1-len(eprefix)] diff --git a/bin/repoman b/bin/repoman index fc5000f7e..6ea15678d 100755 --- a/bin/repoman +++ b/bin/repoman @@ -95,7 +95,7 @@ os.umask(0o22) # behave incrementally. repoman_incrementals = tuple(x for x in \ portage.const.INCREMENTALS if x != 'ACCEPT_KEYWORDS') -eprefix = os.environ.get("__REPOMAN_TEST_EPREFIX") +eprefix = portage.const.EPREFIX repoman_settings = portage.config(local_config=False, _eprefix=eprefix) repoman_settings.lock() 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