Example #1
0
def tmux_install():
    if yesno('own_tmux', 'Compile tmux from source?', None):
        need_installpkg(
            apt=('libevent-dev', 'ncurses-dev'),
            brew=('automake', 'libevent'),
        )
        tmux = InstallFromSource('https://github.com/tmux/tmux.git',
                                 '~/src/tmux.git')
        tmux.select_tag('2.7')
        tmux.compile_cmd([
            # distclean will always fail if there's nothing to clean
            ['bash', '-c', 'make distclean || :'],
            ['sh', 'autogen.sh'],
            ['./configure'],
            ['make'],
        ])
        tmux.symlink('tmux', '~/bin/tmux')
        tmux.symlink('tmux.1', '~/man/man1/tmux.1')
        run(tmux)
    else:
        try:
            # install tmux using brew or apt-get ...
            installpkg('tmux')
        except Exception:
            print("-" * 50)
            print(
                "Compiling `tmux` failed - do you need to install automake or gcc?"
            )  # noqa
            print("-" * 50)
            raise
Example #2
0
def install_fedora_copr():
    if not allow_installing_stuff:
        return False

    if not haveexecutable('yum'):
        return False

    copr_url = 'https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/repo/epel-7/carlwgeorge-ripgrep-epel-7.repo'
    if not yesno('allow_fedora_copr', 'Add fedora COPR repo on this host?',
                 None):
        return False

    # enable the repo
    installpkg('yum-utils')
    execute(['sudo', 'yum-config-manager', '--add-repo=' + copr_url],
            stdout="TTY")
    return True
Example #3
0
def fzf_install():
    if not yesno('install_fzf', 'Install fzf?', want_full):
        return

    if haveexecutable('brew') and allow_installing_stuff:
        installpkg('fzf')
        brewpath = execute(['brew', '--prefix'],
                           stdout=True)[1].decode('utf-8').strip()
        if brewpath == '/opt/homebrew':
            # brew puts the fzf files into versioned folders, so all we can do
            # is glob and sort (which isn't perfect because it would need to be
            # a semver-compatible sort) and pick the first one
            fzf_path = execute(
                [
                    'bash', '-c',
                    f'echo {brewpath}/Cellar/fzf/* | sort -r | head -n 1'
                ],
                stdout=True,
            )[1].decode('utf-8').strip()
        else:
            # this is how it was on my old mac
            fzf_path = brewpath + '/opt/fzf'
    else:
        # do it the long way
        import os.path
        fzf_repo = os.path.expanduser('~/src/fzf.git')
        fzf_install = InstallFromSource('https://github.com/junegunn/fzf.git',
                                        fzf_repo)
        fzf_install.select_tag('0.17.3')
        fzf_install.compile_cmd([
            ['./install', '--bin'],
        ])
        fzf_install.symlink('bin/fzf', '~/bin/fzf')
        run(fzf_install)
        execute(['./install', '--bin'], cwd=fzf_repo, stdout='TTY')
        fzf_path = fzf_repo

    lineinfile('~/.bashrc', 'source {}/shell/completion.bash'.format(fzf_path))
    lineinfile('~/.bashrc',
               'source {}/shell/key-bindings.bash'.format(fzf_path))
    if wantzsh():
        lineinfile('~/.zshrc',
                   'source {}/shell/completion.zsh'.format(fzf_path))
        lineinfile('~/.zshrc',
                   'source {}/shell/key-bindings.zsh'.format(fzf_path))
Example #4
0
def install_pyenv():
    if not yesno('want_pyenv', 'Git clone pyenv to ~/.pyenv?', default=None):
        return

    gitclone = InstallFromSource('https://github.com/pyenv/pyenv.git',
                                 '~/.pyenv')
    gitclone.select_branch('master')
    run(gitclone)

    gitclone2 = InstallFromSource('https://github.com/pyenv/pyenv-virtualenv',
                                  '~/.pyenv/plugins/pyenv-virtualenv')
    gitclone2.select_branch('master')
    run(gitclone2)

    # NOTE: on ubuntu you'll need to install libffi-dev
    if IS_UBUNTU:
        installpkg('libffi-dev', apt='libffi-dev')
        installpkg('pkgconf', apt='pkgconf')
Example #5
0
def homely_dev():
    if not yesno("create_homely_venv",
                 "Create ~/playground-homely virtualenv?", False):
        return

    venv = environ['HOME'] + '/playground-homely'

    # create container dir
    mkdir(venv)
    checkout = join(venv, 'homely.git')

    # create the virtualenv if it doesn't already exist
    if not exists(join(venv, 'bin')):
        execute(['virtualenv', '--python=python3', venv], stdout="TTY")

    # check out homely.git repo if it isn't there yet
    if not exists(checkout):
        execute(['git', 'clone', '[email protected]:phodge/homely.git', checkout],
                stdout="TTY")

    # need to install editable version of homely.git in both virtualenvs
    venv_pip = venv + '/bin/pip'

    execute([venv_pip, 'install', '--editable', checkout])
    mypips(venv_pip)

    # install all dev requirements
    execute(
        [venv_pip, 'install', '-r',
         join(checkout, 'requirements_dev.txt')])

    if wantjerjerrod():
        # register the playground with jerjerrod
        jerjerrod_addline('WORKSPACE', venv, ignore=["py2venv"])

    # we may want to install pandoc to make the slides, but
    if yesno('homley_want_pandoc',
             'Install pandoc to create slides?',
             recommended=True):
        from homely.install import installpkg
        installpkg('pandoc')
Example #6
0
def ubuntu_install_devilspie2():
    """
    Install devilspie2 under Ubuntu.

    devilspie2 can "pin" apps like Rhythmbox or Spotify, causing them to move across all
    desktops/workspaces. This means I don't accidentally flip to another desktop/workspace when I
    go to play some music or respond to a chat message.
    """
    question = 'Install devilspie2 to manage window sticky bits?'
    if not yesno('want_devilspie2', question, default=True):
        return

    installpkg('devilspie2', apt='devilspie2', brew=None)

    symlink('devilspie2', '~/.config/devilspie2')

    with writefile('~/.config/autostart/devilspie2.desktop') as f:
        f.write("[Desktop Entry]\n")
        f.write("Type=Application\n")
        f.write("Name=devilspie2\n")
        f.write("Exec=/usr/bin/devilspie2\n")
        f.write("Comment=devilspie2 - react to gnome window events\n")
        f.write("X-GNOME-Autostart-enabled=true\n")
Example #7
0
def search_tools():
    if yesno('install_ack', 'Install ack?', False):
        installpkg('ack', apt='ack-grep')

    if want_silver_searcher():
        installpkg('ag', yum='the_silver_searcher', apt='silversearcher-ag')

    if yesno('install_ripgrep', 'Install ripgrep?', True):
        yum = False
        if haveexecutable('yum') and install_fedora_copr():
            yum = 'ripgrep'
        installpkg('ripgrep', yum=yum)
Example #8
0
def tools():
    if yesno('install_with', 'Install `with` utility?', want_full):
        withutil = InstallFromSource('https://github.com/mchav/with',
                                     '~/src/with.git')
        withutil.symlink('with', '~/bin/with')
        withutil.select_branch('master')
        run(withutil)

    if yesno('install_universal_ctags', 'Install Universal Ctags?', want_full):
        need_installpkg(apt=('autoconf', 'g++'))
        mkdir('~/bin')
        if haveexecutable('brew'):
            # install with homebrew
            execute(['brew', 'tap', 'universal-ctags/universal-ctags'])
            execute(['brew', 'install', '--HEAD', 'universal-ctags'])
        else:
            uc = InstallFromSource('https://github.com/universal-ctags/ctags',
                                   '~/src/universal-ctags.git')
            uc.select_branch('master')
            uc.compile_cmd([
                ['./autogen.sh'],
                ['./configure'],
                ['make'],
            ])
            uc.symlink('ctags', '~/bin/ctags')
            run(uc)
    elif allow_installing_stuff and yesno('install_ctags', 'Install `ctags`?',
                                          want_full):
        installpkg('ctags')
    if allow_installing_stuff and yesno('install_patch', 'Install patch?',
                                        want_full):
        installpkg('patch')

    if allow_installing_stuff and yesno('install_tidy',
                                        'Install tidy cli tool?', want_full):
        installpkg('tidy')

    # on OSX we want to install gnu utils (brew install coreutils findutils)
    # and put /usr/local/opt/coreutils/libexec/gnubin in PATH
    if IS_OSX and haveexecutable('brew') and allow_installing_stuff:
        if yesno('brew_install_coreutils',
                 'Install gnu utils?',
                 default=want_full):
            brew_list = set(
                execute(['brew', 'list'],
                        stdout=True)[1].decode('utf-8').splitlines())
            install = [
                pkg for pkg in ('coreutils', 'findutils')
                if pkg not in brew_list
            ]
            if len(install):
                execute(['brew', 'install'] + install)
Example #9
0
def need_installpkg(*, apt=None, brew=None, yum=None):
    if not allow_installing_stuff:
        what = apt or brew or yum
        raise Exception(
            "Can't install {} when only doing minimal config".format(what))

    if haveexecutable('apt-get'):
        for name in apt or []:
            installpkg(name, brew=False, yum=False, port=False)
    if haveexecutable('brew'):
        for name in brew or []:
            installpkg(name, apt=False, yum=False, port=False)
    if haveexecutable('yum'):
        for name in yum or []:
            installpkg(name, apt=False, brew=False, port=False)
Example #10
0
def nvim_install():
    if install_nvim_via_apt():
        installpkg('neovim')
        installpkg('python-neovim')
        return

    if (allow_installing_stuff and haveexecutable('brew')
            and yesno('install_nvim_package', 'Install nvim from apt/brew?')):
        installpkg('neovim')
        return

    the_hard_way = yesno('compile_nvim',
                         'Compile/install nvim from source?',
                         recommended=allow_installing_stuff)
    if not the_hard_way:
        raise Exception('No way to install neovim')

    need_installpkg(
        apt=(
            'libtool',
            'libtool-bin',
            'autoconf',
            'automake',
            'cmake',
            'g++',
            'pkg-config',
            'unzip',
            'gettext',
        ),
        yum=('cmake', 'gcc-c++', 'unzip'),
        brew=('cmake', 'libtool', 'gettext'),
    )
    n = InstallFromSource('https://github.com/neovim/neovim.git',
                          '~/src/neovim.git')
    n.select_tag(NVIM_TAG)
    n.compile_cmd([
        ['make', 'distclean'],
        ['make'],
        ['sudo', 'make', 'install'],
    ])
    run(n)
Example #11
0
    'rofi',
    'i3',
    'i3blocks',
    'scrot',
    'compton',
    'zsh',
    'wget',
    'git',
    'xbacklight',
    'vlc',
    'pavucontrol',
    'numlockx',
    'vim',
    'tree',
]

for package in packages:
    installpkg(package)

# Fonts

fonts = [
    'fonts-firacode',
    'fonts-font-awesome',
    'ttf-ancient-fonts',
    'fonts-powerline',
]

for font in fonts:
    installpkg(font)
Example #12
0
want_mercurial = yesno(
    'want_mercurial',
    'Bother with anything mercurial-related?',
    False,
)

want_poetry = yesno(
    'want_python_poetry',
    'Install poetry in $HOME?',
    False,
)

pipx_install_fn = None

if want_full and IS_OSX:
    pipx_install_fn = lambda: installpkg('pipx', brew='pipx')  # noqa: E731


@memoize
def need_installpkg(*, apt=None, brew=None, yum=None):
    if not allow_installing_stuff:
        what = apt or brew or yum
        raise Exception(
            "Can't install {} when only doing minimal config".format(what))

    if haveexecutable('apt-get'):
        for name in apt or []:
            installpkg(name, brew=False, yum=False, port=False)
    if haveexecutable('brew'):
        for name in brew or []:
            installpkg(name, apt=False, yum=False, port=False)
Example #13
0
symlink('_gitignore', '.gitignore')
symlink('_hgignore', '.hgignore')
symlink('_hgrc', '.hgrc')
symlink('_tmux.conf', '.tmux.conf')
symlink('_vimrc', '.vimrc')

# vim_plug_url = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
# download(vim_plug_url, '~/.vim/autoload/plug.vim')

# mkdir('~/.config')
# mkdir('~/.config/nvim')
# mkdir('~/.config/pip')

# symlink('init.vim', '~/.config/nvim/')
# symlink('pip.conf', '~/.config/pip/')

installpkg('ag', yum='the_silver_searcher', apt='silversearcher-ag')
installpkg('tmux')

installpkg('zsh')

oh_my_zsh_url = 'https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh'
install_script = 'oh-my-zsh-install.sh'
download(oh_my_zsh_url, install_script)
home = expanduser('~')
execute(['sh', install_script], cwd=home)

nvm_url = 'https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh'
download(nvm_url, install_script)

Example #14
0
from pathlib import Path
from homely.files import symlink
from homely.system import haveexecutable, execute
from homely.install import installpkg


if haveexecutable('apt'):
    if not haveexecutable('git'):
        installpkg('git')
    if not haveexecutable('curl'):
        installpkg('curl')
    if not haveexecutable('wget'):
        installpkg('wget')
    if not haveexecutable('zsh'):       
        installpkg('zsh')
    if not haveexecutable('vim'):
        installpkg('vim')
    if not haveexecutable('tmux'):
        installpkg('tmux')


omz_dir = Path('~/.oh-my-zsh')
if not omz_dir.is_dir():
    execute(['sh', '-c', "'$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)'")
    
vundle_dir = Path('~/.vim/bundle/Vundle.vim')
if not vundle_dir.is_dir():
    execute(['git','clone','https://github.com/VundleVim/Vundle.vim.git', '~/.vim/bundle/Vundle.vim'])
    execute(['vim','+PluginInstall'])