Mercurial > dotfiles
diff install.py @ 431:e0bb52007402
Add installation of homebrew stuff on Mac.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 01 Apr 2018 22:57:57 -0700 |
parents | 350f7a55ff33 |
children | 06a551d3fbb2 |
line wrap: on
line diff
--- a/install.py Sun Apr 01 22:44:59 2018 -0700 +++ b/install.py Sun Apr 01 22:57:57 2018 -0700 @@ -12,10 +12,13 @@ dotfiles_dir = os.path.abspath(os.path.dirname(__file__)) is_nix = True +is_mac = False is_windows = False if sys.platform == "win32": is_nix = False is_windows = True +if sys.platform == 'darwin': + is_mac = True def _p(*paths, force_unix=False): @@ -70,6 +73,14 @@ return decorator +def only_on_mac(f): + @functools.wraps(f) + def decorator(*args, **kwargs): + if is_mac: + return f(*args, **kwargs) + return decorator + + def only_on_win(f): @functools.wraps(f) def decorator(*args, **kwargs): @@ -244,6 +255,41 @@ clone_hg(url, full_path, force=force) +@only_on_mac +@run_priority(210) +def install_xcode(): + if shutil.which('xcodebuild') is None: + print("Installing XCode") + subprocess.check_call(['xcode-select', '--install']) + subprocess.check_call(['sudo', 'xcodebuild', '-license', 'accept']) + + +@only_on_mac +@run_priority(209) +def install_homebrew(): + if shutil.which('brew') is None: + print("Installing Homebrew and Homebrew Cask") + subprocess.check_call([ + '/usr/bin/ruby', '-e', + "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"]) # NOQA + subprocess.check_call(['brew', 'tap', 'caskroom/fonts']) + + +@only_on_mac +@needs_config +@supports_forcing +@run_priority(208) +def install_mactools(cfg, force=False): + if not cfg.has_section('mactools'): + return + + for name, _ in cfg.items('mactools'): + args = ['brew', 'install', name] + if force: + args.append('--force') + subprocess.check_call(args) + + def main(): print("dotfiles installer") print("python %s" % sys.version)