[2/4 anaconda] Drop ROOT_PATH, add a method to set it
Brian C. Lane
bcl at redhat.com
Wed Jun 25 18:32:11 UTC 2014
Drop the global ROOT_PATH, moving it to iutil._root_path and add the
setTargetPhysicalRoot method to change it. All users should use either
getTargetPhysicalRoot or getSysroot depending on their needs.
---
pyanaconda/constants.py | 5 -----
pyanaconda/iutil.py | 24 +++++++++++++++++-------
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
index 4f9b64a..24fcb3c 100644
--- a/pyanaconda/constants.py
+++ b/pyanaconda/constants.py
@@ -22,8 +22,6 @@
import string
from pyanaconda.i18n import N_
-import os
-
# Use -1 to indicate that the selinux configuration is unset
SELINUX_DEFAULT = -1
@@ -55,9 +53,6 @@ DD_RPMS = "/tmp/DD-*"
TRANSLATIONS_UPDATE_DIR="/tmp/updates/po"
ANACONDA_CLEANUP = "anaconda-cleanup"
-# This is a legacy variable; new code should use iutil.getSysroot()
-# or iutil.getTargetPhysicalRoot().
-ROOT_PATH = os.environ.get("ANACONDA_ROOT_PATH", "/mnt/sysimage")
MOUNT_DIR = "/mnt/install"
DRACUT_REPODIR = "/run/install/repo"
DRACUT_ISODIR = "/run/install/source"
diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py
index 9604460..f2b28a9 100644
--- a/pyanaconda/iutil.py
+++ b/pyanaconda/iutil.py
@@ -34,7 +34,7 @@ from Queue import Queue, Empty
from urllib import quote, unquote
from pyanaconda.flags import flags
-from pyanaconda.constants import DRACUT_SHUTDOWN_EJECT, ROOT_PATH, TRANSLATIONS_UPDATE_DIR, UNSUPPORTED_HW
+from pyanaconda.constants import DRACUT_SHUTDOWN_EJECT, TRANSLATIONS_UPDATE_DIR, UNSUPPORTED_HW
from pyanaconda.regexes import URL_PARSE
from pyanaconda.i18n import _
@@ -52,9 +52,11 @@ def augmentEnv():
})
return env
+_root_path = "/mnt/sysimage"
+
def getTargetPhysicalRoot():
"""Returns the path to the "physical" storage root, traditionally /mnt/sysimage.
-
+
This may be distinct from the sysroot, which could be a
chroot-type subdirectory of the physical root. This is used for
example by all OSTree-based installations.
@@ -64,13 +66,21 @@ def getTargetPhysicalRoot():
# target is never mounted anywhere else. This API call just
# allows us to have a clean "git grep ROOT_PATH" in other parts of
# the code.
- return ROOT_PATH
+ return _root_path
+
+def setTargetPhysicalRoot(path):
+ """Change the physical root path
-_sysroot = ROOT_PATH
+ :param string path: Path to use instead of /mnt/sysimage/
+ """
+ global _root_path
+ _root_path = path
+
+_sysroot = _root_path
def getSysroot():
"""Returns the path to the target OS installation.
-
+
For ordinary package-based installations, this is the same as the
target root.
"""
@@ -100,10 +110,10 @@ def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None, log_ou
if env_prune is None:
env_prune = []
- # Transparently redirect callers requesting root=ROOT_PATH to the
+ # Transparently redirect callers requesting root=_root_path to the
# configured system root.
target_root = root
- if target_root == ROOT_PATH:
+ if target_root == _root_path:
target_root = getSysroot()
def chroot():
--
1.9.3
More information about the anaconda-patches
mailing list