From 64688c0382ee6e252e342395d287cb7e776c49b7 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Fri, 10 Oct 2014 04:00:19 -0700 Subject: [PATCH] Get rid of tasks.sh Bump emacs.d for emacs jedi stuff --- .gitmodules | 2 +- README.md | 2 +- dotfiles/emacs.d | 2 +- dotfiles/lib/shellrc/python.sh | 53 -------------- resources/bootstrapping.sh | 5 -- resources/everything.sh | 4 -- setup.sh | 127 --------------------------------- web_start.sh => start.sh | 19 ++++- tasks/__init__.py | 56 +++++++++++++++ tasks/linux.py | 14 ++++ tasks/osx.py | 60 ++++++++++++++++ tasks/util.py | 12 ++++ 12 files changed, 163 insertions(+), 193 deletions(-) delete mode 100644 dotfiles/lib/shellrc/python.sh delete mode 100644 resources/bootstrapping.sh delete mode 100644 resources/everything.sh delete mode 100755 setup.sh rename web_start.sh => start.sh (64%) mode change 100755 => 100644 create mode 100644 tasks/__init__.py create mode 100644 tasks/linux.py create mode 100644 tasks/osx.py create mode 100644 tasks/util.py diff --git a/.gitmodules b/.gitmodules index 5bc4a2f6..dd6b5661 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "dotfiles/emacs.d"] path = dotfiles/emacs.d - url = git@github.com:IvanMalison/.emacs.d.git + url = https://github.com/IvanMalison/.emacs.d.git [submodule "dotfiles/vim/bundle/vundle"] path = dotfiles/vim/bundle/vundle url = https://github.com/gmarik/Vundle.vim.git diff --git a/README.md b/README.md index 2b541544..13c20859 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ dotfiles To get started run: -``curl https://raw.githubusercontent.com/IvanMalison/dotfiles/master/web_start.sh | sh /dev/stdin`` +``curl https://raw.githubusercontent.com/IvanMalison/dotfiles/master/start.sh | sh /dev/stdin`` diff --git a/dotfiles/emacs.d b/dotfiles/emacs.d index bb180725..251dbaed 160000 --- a/dotfiles/emacs.d +++ b/dotfiles/emacs.d @@ -1 +1 @@ -Subproject commit bb1807256fd065252eb8c90d2f291e07d042262e +Subproject commit 251dbaed92e52ad5b7322b50cd0b403d2e61ce6c diff --git a/dotfiles/lib/shellrc/python.sh b/dotfiles/lib/shellrc/python.sh deleted file mode 100644 index 41fbab61..00000000 --- a/dotfiles/lib/shellrc/python.sh +++ /dev/null @@ -1,53 +0,0 @@ -function install_python_packages() { - easy_install pip - ESSENTIAL=(ipdb ipython virtualenv) - FOR_EDITOR=(jedi pyflakes) - USEFUL=( - Flask - ddg - ouimeaux - readline - simplejson - tox - numpy - ) - OPTIND=1 - while getopts "uea" OPTCHAR; - do - case $OPTCHAR in - u) - sudo pip install $USEFUL - ;; - e) - sudo pip install $FOR_EDITOR - ;; - a) - sudo pip install $FOR_EDITOR - sudo pip install $USEFUL - install_pygame - install_powerline - ;; - h) - echo " --u Install useful but non essential python. --e Install editor python packages. --a Install all python utilities." - ;; - esac - done - sudo pip install $ESSENTIAL -} - -function install_pygame() { - sudo pip install numpy - brew install sdl sdl_image sdl_mixer sdl_ttf portmidi - /usr/local/share/python/pip install hg+http://bitbucket.org/pygame/pygame -} - -function install_powerline() { - hash pip 2>/dev/null || sudo easy_install pip - if test -z $(pip show Powerline | grep Location | awk '{print $2}'); - then - sudo pip install --user git+git://github.com/Lokaltog/powerline - fi -} diff --git a/resources/bootstrapping.sh b/resources/bootstrapping.sh deleted file mode 100644 index 4e8e307e..00000000 --- a/resources/bootstrapping.sh +++ /dev/null @@ -1,5 +0,0 @@ -readlink_command='readlink' -command -v greadlink > /dev/null && readlink_command="greadlink" -function dotfiles_abspath() { - echo "$(${readlink_command} -f "$BASH_SOURCE" | xargs dirname | xargs dirname)" -} diff --git a/resources/everything.sh b/resources/everything.sh deleted file mode 100644 index 2f15ad29..00000000 --- a/resources/everything.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -cd "dirname $BASH_SOURCE" -source brew.sh -source npm.sh diff --git a/setup.sh b/setup.sh deleted file mode 100755 index d4c48834..00000000 --- a/setup.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env bash -cd `dirname $BASH_SOURCE` && source resources/bootstrapping.sh -source dotfiles/lib/shellrc/functions.sh -source dotfiles/lib/shellrc/brew.sh -source dotfiles/lib/shellrc/python.sh -source dotfiles/lib/shellrc/vim.sh -source resources/osx.sh -DOTFILES_DIRECTORY="$(dotfiles_abspath)/dotfiles" - - -function symlink_dotfiles() { - local overwrite='' - OPTIND=1 - while getopts "o" OPTCHAR; - do - case $OPTCHAR in - o) - overwrite='yes' - ;; - esac - done - cd $DOTFILES_DIRECTORY - [ -a ~/.dotfiles-backups ] && mv ~/.dotfiles-backups ~/.dotfiles-backups.old - mkdir ~/.dotfiles-backups - for filename in *; do - local link_destination="$HOME/.$filename" - local link_target=$(${readlink_command} -f $filename) - echo "linking $link_destination to $link_target" - # Using only test -e doesn't work here because it will return - # false if the destination of the symbolic link at does not exist. - test -e $link_destination || test -L $link_destination && test $overwrite && mv $link_destination ~/.dotfiles-backups && ln -si $link_target $link_destination - done - [ -a ~/.dotfiles-backups.old ] && mv ~/.dotfiles-backups.old ~/.dotfiles-backups/.dotfiles-backups -} - - -function apt-get() { - INSTALL="sudo apt-get -y install" - $INSTALL zsh - $INSTALL tmux - $INSTALL emacs24-nox - $INSTALL nmap - $INSTALL python2.7 - $INSTALL python-pip python-dev -} - -function setup_help() { - echo "setup Usage: --a Install apt-get packages. --o Run OSX configuration commands. --s Symlink dotfiles to home directory. --b Install brew packages. --p Install python packages. --v Setup vim. --e Do absolutely everything with the most aggresive options. --h display this help message." -} - -function get_command_line_tools() { - hash gcc 2> /dev/null || xcode-select --install -} - -function setup() { - if [[ $# -eq 0 ]] ; then - setup_help - exit 0 - fi - while getopts "acosbpev" OPTCHAR; - do - local real_opt_ind=$OPTIND - case $OPTCHAR in - a) - source resources/apt-get.sh - ;; - b) - get_command_line_tools - if get_brew; then - do_the_brew_help - read -p "Enter flags for brew package installation: -" - [[ $REPLY[0] != '-' ]] && REPLY="-$REPLY" - do_the_brew $REPLY - fi - ;; - o) - sudo -v - osx_config - ;; - s) - symlink_dotfiles -o - ;; - p) - install_python_packages -h - read -p "Enter flags for python package installation" - if [[ $REPLY[0] != '-' ]]; then - REPLY="-$REPLY" - fi - install_python_packages $REPLY - ;; - e) - case $(uname) in - Darwin) - get_command_line_tools - get_brew && do_the_brew -au - osx_config - ;; - Linux) - apt-get - ;; - esac - install_python_packages -a - symlink_dotfiles - vimstall - ;; - v) - vimstall - ;; - h) - setup_help - return - ;; - esac - OPTIND=$real_opt_ind - done -} - -setup $@ diff --git a/web_start.sh b/start.sh old mode 100755 new mode 100644 similarity index 64% rename from web_start.sh rename to start.sh index 35175be6..7c98b004 --- a/web_start.sh +++ b/start.sh @@ -1,8 +1,17 @@ #!/bin/bash +function fedora() { + yum install make automake gcc gcc-c++ kernel-devel + yum install + yum install python-pip +} + + function debian() { hash apt-get &>/dev/null || (echo 'apt-get is missing.' && exit) sudo apt-get -y install build-essential sudo apt-get -y install git + sudo apt-get -y install python + sudo apt-get install python-pip } function brew_for_multiple_users() { @@ -23,14 +32,21 @@ function osx() { brew_for_multiple_users brew update brew install git + brew install python + easy_install pip } function go() { + while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & git clone https://github.com/IvanMalison/dotfiles.git cd dotfiles - ./setup.sh -e + sudo pip install dotfiles + sudo pip install invoke + invoke setup } +while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & + case `uname` in 'Darwin') osx @@ -39,4 +55,5 @@ case `uname` in debian ;; esac + go diff --git a/tasks/__init__.py b/tasks/__init__.py new file mode 100644 index 00000000..fdc89fd8 --- /dev/null +++ b/tasks/__init__.py @@ -0,0 +1,56 @@ +import os +import sys + +from invoke import Collection, ctask + +from . import osx +from . import linux +from .util import DOTFILES_DIRECTORY, RESOURCES_DIRECTORY + + +ns = Collection() +ns.add_collection(osx) +ns.add_collection(linux) + + +@ctask(default=True) +def setup(ctx): + ctx.config['run']['pty'] = False + ctx.config['run']['warn'] = True + if 'darwin' in sys.platform: + osx.all(ctx) + else: + linux.all(ctx) + dotfiles(ctx, '') + install_python_libraries(ctx) + + + +@ctask +def dotfiles(ctx, flags): + ctx.run('hash dotfiles || sudo pip install dotfiles') + return ctx.run('dotfiles -sR{1} {0}'.format(DOTFILES_DIRECTORY, flags)) + + +@ctask +def install_python_libraries(ctx): + ctx.run('sudo pip install -r {0}'.format( + os.path.join(RESOURCES_DIRECTORY, 'requirements.txt') + )) + +@ctask +def install_npm_libraries(ctx): + ctx.run('source {0}'.format( + os.path.join(RESOURCES_DIRECTORY, 'npm.sh') + )) + + +@ctask +def vimstall(ctx): + ctx.run('vim +BundleInstall! +q +q') + + +ns.add_task(dotfiles) +ns.add_task(setup) +ns.add_task(install_python_libraries) +ns.add_task(vimstall) diff --git a/tasks/linux.py b/tasks/linux.py new file mode 100644 index 00000000..90b97350 --- /dev/null +++ b/tasks/linux.py @@ -0,0 +1,14 @@ +from invoke import ctask + + +@ctask(default=True) +def all(ctx): + apt_get(ctx) + + +linux_pacakges = ('zsh', 'tmux', 'emacs24-nox', 'nmap', 'scala', 'sbt') +@ctask +def apt_get(ctx): + install_command = 'sudo apt-get -y install' + for package in linux_pacakges: + ctx.run('{0} {1}'.format(install_command, package), pty=False) diff --git a/tasks/osx.py b/tasks/osx.py new file mode 100644 index 00000000..12bc0f4d --- /dev/null +++ b/tasks/osx.py @@ -0,0 +1,60 @@ +import os + +from invoke import ctask + +from .util import RESOURCES_DIRECTORY, command_exists + + +@ctask(default=True) +def all(ctx): + get_command_line_tools(ctx) + get_brew(ctx) + brew_install(ctx) + brew_cask(ctx) + osx_config(ctx) + + +ESSENTIAL = ( + "emacs", "tmux", "python --with-brewed-openssl", "htop", "greadlink", "zsh", "make", + "macvim --override-system-vim --custom-system-icons --with-features=huge " + "--enable-rubyinterp --enable-pythoninterp --enable-perlinterp --enable-cscope" +) +BASICS=( + "findutils", "coreutils", "binutils", "diffutils", "ed --default-names", + "gawk", "gnu-indent --default-names", "gnu-sed --default-names", + "gnu-tar --default-names", "gnu-which --default-names", "gnutls --default-names", + "grep --default-names", "gzip", "watch", "wdiff --with-gettext", "wget --enable-iri" +) +SHOULD_INSTALL = ( + "nmap", "readline", "netcat", "reattach-to-user-namespace", "daemonize", + "ngrep", "gist", "gawk", "pstree", "ack", "hub", "tig", "heroku", "scala", + "sbt", "node", "npm" +) +MISC = ("file-formula", "less", "openssh --with-brewed-openssl", + "perl518", "rsync", "svn", "unzip") + +CASKS = ('alfred', 'caffeine', 'flux', 'google-chrome', 'iterm2', 'spotify', 'vlc',) +@ctask +def osx_config(ctx): + ctx.run('source {0}; osx_config'.format(os.path.join(RESOURCES_DIRECTORY, 'osx.sh'))) + +@ctask +def brew_cask(ctx): + ctx.run('brew install caskroom/cask/brew-cask') + for cask in CASKS: + ctx.run('brew cask install {0}'.format(cask)) + +@ctask +def get_brew(ctx): + if not command_exists('brew'): + ctx.run('ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"') + +@ctask +def brew_install(ctx): + for package_name in ESSENTIAL + BASICS + SHOULD_INSTALL + MISC: + ctx.run('brew install {0}'.format(package_name)) + +@ctask +def get_command_line_tools(ctx): + if not command_exists('gcc'): + ctx.run('xcode-select --install') diff --git a/tasks/util.py b/tasks/util.py new file mode 100644 index 00000000..67a82574 --- /dev/null +++ b/tasks/util.py @@ -0,0 +1,12 @@ +import os + +from invoke import run + + +REPO_DIRECTORY = os.path.dirname(os.path.dirname(__file__)) +DOTFILES_DIRECTORY = os.path.join(REPO_DIRECTORY, 'dotfiles') +RESOURCES_DIRECTORY = os.path.join(REPO_DIRECTORY, 'resources') + + +def command_exists(command, run=run): + return run("hash {0}".format(command), warn=True, hide=True).exited == 0