Bug 1279564 - Move get_state_dir() to own module; r=glandium
We'll be consolidating code from mach_bootstrap.py and mozboot.
We don't want mach_bootstrap.py to import bootstrap.py because it
imports nearly every module under mozboot. So establish a standalone
module with minimal dependencies to hold utility code. Move
get_state_dir() there.
MozReview-Commit-ID: Hw5VB5OZGCi
--- a/python/mozboot/mozboot/bootstrap.py
+++ b/python/mozboot/mozboot/bootstrap.py
@@ -15,16 +15,19 @@ import subprocess
from mozboot.centosfedora import CentOSFedoraBootstrapper
from mozboot.debian import DebianBootstrapper
from mozboot.freebsd import FreeBSDBootstrapper
from mozboot.gentoo import GentooBootstrapper
from mozboot.osx import OSXBootstrapper
from mozboot.openbsd import OpenBSDBootstrapper
from mozboot.archlinux import ArchlinuxBootstrapper
from mozboot.windows import WindowsBootstrapper
+from mozboot.util import (
+ get_state_dir,
+)
APPLICATION_CHOICE = '''
Please choose the version of Firefox you want to build:
%s
Note: (For Firefox for Android)
The Firefox for Android front-end is built using Java, the Android
@@ -132,26 +135,16 @@ DEBIAN_DISTROS = (
'Mint',
'LinuxMint',
'Elementary OS',
'Elementary',
'"elementary OS"',
)
-def get_state_dir():
- """Obtain path to a directory to hold state.
-
- This code is shared with ``mach_bootstrap.py``.
- """
- state_user_dir = os.path.expanduser('~/.mozbuild')
- state_env_dir = os.environ.get('MOZBUILD_STATE_PATH')
- return state_env_dir or state_user_dir
-
-
class Bootstrapper(object):
"""Main class that performs system bootstrap."""
def __init__(self, finished=FINISHED, choice=None, no_interactive=False,
hg_configure=False):
self.instance = None
self.finished = finished
self.choice = choice
new file mode 100644
--- /dev/null
+++ b/python/mozboot/mozboot/util.py
@@ -0,0 +1,12 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import os
+
+
+def get_state_dir():
+ """Obtain path to a directory to hold state."""
+ state_user_dir = os.path.expanduser('~/.mozbuild')
+ state_env_dir = os.environ.get('MOZBUILD_STATE_PATH')
+ return state_env_dir or state_user_dir