# HG changeset patch # User Emilio Cobos Alvarez # Date 1534801270 -7200 # Node ID 4b7383b27f89dcb1732b27f6d68f1684f36ff377 # Parent 4c5792051e029fd9092f0f61683d0c46f5f9ce13 Bug 1484485: Create state dir and install node / stylo stuff in bootstrap's non-interactive mode. r=ted The state directory is in $HOME by default, so should be fine to just create it if we get --no-interactive I think. Differential Revision: https://phabricator.services.mozilla.com/D3838 diff --git a/python/mozboot/mozboot/bootstrap.py b/python/mozboot/mozboot/bootstrap.py --- a/python/mozboot/mozboot/bootstrap.py +++ b/python/mozboot/mozboot/bootstrap.py @@ -291,53 +291,54 @@ class Bootstrapper(object): # We can't easily import mach_bootstrap.py because the bootstrapper may # run in self-contained mode and only the files in this directory will # be available. We /could/ refactor parts of mach_bootstrap.py to be # part of this directory to avoid the code duplication. def try_to_create_state_dir(self): state_dir, _ = get_state_dir() if not os.path.exists(state_dir): + should_create_state_dir = True if not self.instance.no_interactive: choice = self.instance.prompt_int( prompt=STATE_DIR_INFO.format(statedir=state_dir), low=1, high=2) - if choice == 1: - print('Creating global state directory: %s' % state_dir) - os.makedirs(state_dir, mode=0o770) + should_create_state_dir = choice == 1 + + # This directory is by default in $HOME, or overridden via an env + # var, so we probably shouldn't gate it on --no-system-changes. + if should_create_state_dir: + print('Creating global state directory: %s' % state_dir) + os.makedirs(state_dir, mode=0o770) state_dir_available = os.path.exists(state_dir) return state_dir_available, state_dir def maybe_install_private_packages_or_exit(self, state_dir, state_dir_available, have_clone, checkout_root): - # Install the clang packages needed for developing stylo, as well - # as the version of NodeJS that we currently support. - if not self.instance.no_interactive: - # The best place to install our packages is in the state directory - # we have. If the user doesn't have one, we need them to re-run - # bootstrap and create the directory. - # - # XXX Android bootstrap just assumes the existence of the state - # directory and writes the NDK into it. Should we do the same? - if not state_dir_available: - print(STYLO_NODEJS_DIRECTORY_MESSAGE.format(statedir=state_dir)) - sys.exit(1) + # Install the clang packages needed for building the style system, as + # well as the version of NodeJS that we currently support. - if not have_clone: - print(STYLE_NODEJS_REQUIRES_CLONE) - sys.exit(1) + # The best place to install our packages is in the state directory + # we have. We should have created one above in non-interactive mode. + if not state_dir_available: + print(STYLO_NODEJS_DIRECTORY_MESSAGE.format(statedir=state_dir)) + sys.exit(1) - self.instance.state_dir = state_dir - self.instance.ensure_stylo_packages(state_dir, checkout_root) - self.instance.ensure_node_packages(state_dir, checkout_root) + if not have_clone: + print(STYLE_NODEJS_REQUIRES_CLONE) + sys.exit(1) + + self.instance.state_dir = state_dir + self.instance.ensure_stylo_packages(state_dir, checkout_root) + self.instance.ensure_node_packages(state_dir, checkout_root) def bootstrap(self): if self.choice is None: # Like ['1. Firefox for Desktop', '2. Firefox for Android Artifact Mode', ...]. labels = ['%s. %s' % (i + 1, name) for (i, (name, _)) in enumerate(APPLICATIONS_LIST)] prompt = APPLICATION_CHOICE % '\n'.join(labels) prompt_choice = self.instance.prompt_int(prompt=prompt, low=1, high=len(APPLICATIONS)) name, application = APPLICATIONS_LIST[prompt_choice-1]