Mercurial > hg > config
changeset 218:e4221e45d6c1
update install script
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 06 Apr 2012 16:41:05 -0700 |
parents | 4ad8bce17e85 |
children | 4390ca34912c |
files | python/install_config.py python/which.py |
diffstat | 2 files changed, 36 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/python/install_config.py Thu Apr 05 13:34:36 2012 -0700 +++ b/python/install_config.py Fri Apr 06 16:41:05 2012 -0700 @@ -6,6 +6,8 @@ """ SRC='http://k0s.org/hg/config' + +import imp import os import subprocess import sys @@ -19,10 +21,6 @@ ['hg', 'pull', SRC], ['hg', 'update', '-C'], - # get virtual env - ['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'], - ['ln', '-s', HOME + '/virtualenv/virtualenv.py', HOME + '/bin/'], - # site-specific files ['mkdir', '-p', '.subversion'], ['rm', '-f', '.subversion/config'], @@ -39,8 +37,19 @@ execute(*commands) +# get the which command +sys.path.append(os.path.join(HOME, 'python')) +from which import which + + # make a (correct) .hg/hgrc file for $HOME -subprocess.call('/bin/echo -e "[paths]\\ndefault = http://k0s.org/hg/config\\ndefault-push = ssh://k0s.org/hg/config" > ~/.hg/hgrc', shell=True) +hgrc = """[paths] +default = http://k0s.org/hg/config +default-push = ssh://k0s.org/hg/config +""" +f = file('.hg/hgrc', 'w') +f.write(hgrc) +f.close() def install_develop(package): src = 'http://k0s.org/hg/%s' % package @@ -54,21 +63,29 @@ command = ['../../bin/python', 'setup.py', 'develop'] execute(command) os.chdir(old_directory) - -# install some python -install_develop('smartopen') -install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first + +# do git stuff +git = which('git') +if git: + # get virtual env + virtualenv_commands = [['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'], + ['ln', '-s', HOME + '/virtualenv/virtualenv.py', HOME + '/bin/']] + execute(*virtualenv_commands) -postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ], - ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ], - ] -execute(*postinstall_commands) + # setup git's global ignore, since git is silly about this + # and doesn't look for the file in the right place + execute(['git', 'config', '--global', 'core.excludesfile', os.path.join(HOME, '.gitignore')]) + # install some python + install_develop('smartopen') + install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first + + postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ], + ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ], + ] + execute(*postinstall_commands) # - ubuntu packages to install: PACKAGES="mercurial unison fluxbox antiword xclip graphviz python-dev python-lxml curl arandr" print "Ensure the following packages are installed:" -print "sudo apt-get install $PACKAGES" - -# setup git's global ignore, since git is silly about this and doesn't look for the file in the right place -subprocess.call('if which git; then git config --global core.excludesfile ~/.gitignore; fi', shell=True) +print "sudo apt-get install %s" % PACKAGES
--- a/python/which.py Thu Apr 05 13:34:36 2012 -0700 +++ b/python/which.py Fri Apr 06 16:41:05 2012 -0700 @@ -3,7 +3,7 @@ import os import sys -def findInPath(fileName, path=os.environ['PATH']): +def which(fileName, path=os.environ['PATH']): """python equivalent of which; should really be in the stdlib""" dirs = path.split(os.pathsep) for dir in dirs: @@ -14,4 +14,4 @@ if __name__ == '__main__': for i in sys.argv[1:]: - print findInPath(i) + print which(i)