Bug 1250748 - Remove the 20s countdown timer from mach first run; r?chmanchester draft
authorGregory Szorc <gps@mozilla.com>
Tue, 23 Feb 2016 17:29:38 -0800
changeset 333984 c45bb9c8671d0ae13a69dce56c5d5b52365f54af
parent 333377 a9e33d8c48b5ca93ca1937eba4220f681a0f05ec
child 514788 d4303287d4371b44f995edbc36c1ff6c17fda6e9
push id11411
push usergszorc@mozilla.com
push dateWed, 24 Feb 2016 01:30:11 +0000
reviewerschmanchester
bugs1250748
milestone47.0a1
Bug 1250748 - Remove the 20s countdown timer from mach first run; r?chmanchester Previously on first `mach` run on a system, we'd display a prompt with a 20s countdown timer after which the default state directory (~/.mozbuild) was created. Users had to wait 20s or ctrl+c and make the directory by hand. Either way, they'd have to re-invoke mach to run whatever command they were trying to run. This was annoying. This commit makes the following changes: 1) The countdown timer is replaced with "press RETURN/ENTER to continue" 2) The requirement to re-invoke mach has been removed On first run, people now see a message telling them to press RETURN/ENTER. Then the directory is created and whatever mach command they requested to run is run. While I was here, I also changed the permissions on the newly created directory to match what it was a few lines above. Without, we're relying on umask, which may be permissive. UNIX convention is to use a more restrictive umask insider user directories. So this feels like the right behavior. MozReview-Commit-ID: IodN13xAJ8P
build/mach_bootstrap.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -22,16 +22,18 @@ mach and the build system store shared s
 filesystem. The following directory will be created:
 
   {userdir}
 
 If you would like to use a different directory, hit CTRL+c and set the
 MOZBUILD_STATE_PATH environment variable to the directory you would like to
 use and re-run mach. For this change to take effect forever, you'll likely
 want to export this environment variable from your shell's init scripts.
+
+Press ENTER/RETURN to continue or CTRL+c to abort.
 '''.lstrip()
 
 NO_MERCURIAL_SETUP = '''
 *** MERCURIAL NOT CONFIGURED ***
 
 mach has detected that you have never run `{mach} mercurial-setup`.
 
 Running this command will ensure your Mercurial version control tool is up
@@ -378,35 +380,28 @@ def bootstrap(topsrcdir, mozilla_dir=Non
     def populate_context(context, key=None):
         if key is None:
             return
         if key == 'state_dir':
             state_dir, is_environ = get_state_dir()
             if is_environ:
                 if not os.path.exists(state_dir):
                     print('Creating global state directory from environment variable: %s'
-                        % state_dir)
+                          % state_dir)
                     os.makedirs(state_dir, mode=0o770)
-                    print('Please re-run mach.')
-                    sys.exit(1)
             else:
                 if not os.path.exists(state_dir):
                     print(STATE_DIR_FIRST_RUN.format(userdir=state_dir))
                     try:
-                        for i in range(20, -1, -1):
-                            time.sleep(1)
-                            sys.stdout.write('%d ' % i)
-                            sys.stdout.flush()
+                        sys.stdin.readline()
                     except KeyboardInterrupt:
                         sys.exit(1)
 
                     print('\nCreating default state directory: %s' % state_dir)
-                    os.mkdir(state_dir)
-                    print('Please re-run mach.')
-                    sys.exit(1)
+                    os.makedirs(state_dir, mode=0o770)
 
             return state_dir
 
         if key == 'topdir':
             return topsrcdir
 
         if key == 'pre_dispatch_handler':
             return pre_dispatch_handler