Use portage.const.EPREFIX more.
authorZac Medico <zmedico@gentoo.org>
Sat, 10 Dec 2011 06:02:01 +0000 (22:02 -0800)
committerZac Medico <zmedico@gentoo.org>
Sat, 10 Dec 2011 06:02:01 +0000 (22:02 -0800)
bin/dispatch-conf
bin/egencache
bin/portageq
bin/repoman
pym/portage/__init__.py
pym/portage/const.py
pym/portage/data.py
pym/portage/dispatch_conf.py
pym/portage/tests/repoman/test_simple.py
pym/portage/util/env_update.py

index 1cad9e01167629395c562afda39d75e469c01b67..75e991189367e559db732a6a9aa61f80a5e30a60 100755 (executable)
@@ -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:
index ba1f18873909ff60f4e880f813675e543a04b767..532cc034cde7e1c7d92e26823045a442390b990b 100755 (executable)
@@ -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)
index e1cf1a0f7ac7465fd0fe38768f2bc7f23792c306..5e488d340cef9ad5ec33a6cec5687d823e95bcf6 100755 (executable)
@@ -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)]
index fc5000f7eba64a0df34c646e52df062c80d741e1..6ea15678d70d5c6b60931d1e821b39c5ea8218e8 100755 (executable)
@@ -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()
 
index 27353a1e8b2d5ba2efd033b33767b00637d8a943..bdfb4e29d3d99f4cdacdfd7c53b70774b3da33bf 100644 (file)
@@ -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()
index 5003b155c98ed2676207ef2acbe51e3edf67db73..553dfc534381d563930760716b89abb2864c9f26 100644 (file)
@@ -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
 # ===========================================================================
index fe390a1304cfbcfa5d3129ceb223574f9a50d2d4..53af6b9665405fe99b93fd0ffcde36068cb890d3 100644 (file)
@@ -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:
index abd3ac1416d920ff1b642c8f6dd62ce44ff64476..7f407fffed77e72a5df281f549b6c70a3687661a 100644 (file)
@@ -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:
index 6c8a61c5b14469fc2ec876cbc8000d3b15989f54..b3186d7b4781dd8b0d7eb9c1cca269f526cc1d3a 100644 (file)
@@ -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,
index 7879ed9aa0190dab3ffadc30e5c601a8af867a2c..e8507b3f7cf3fd17482d2f334bb40a283a24326f 100644 (file)
@@ -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