Mercurial > hg > config
comparison python/install_config.py @ 131:52cf3e146a4c
make the install script slightly nicer
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Tue, 22 Mar 2011 17:47:42 -0700 |
| parents | c61997cf17b0 |
| children | 40b670219789 |
comparison
equal
deleted
inserted
replaced
| 130:c61997cf17b0 | 131:52cf3e146a4c |
|---|---|
| 5 curl http://k0s.org/hg/config/raw-file/tip/python/install_config.py | python | 5 curl http://k0s.org/hg/config/raw-file/tip/python/install_config.py | python |
| 6 """ | 6 """ |
| 7 | 7 |
| 8 SRC='http://k0s.org/hg/config' | 8 SRC='http://k0s.org/hg/config' |
| 9 import os | 9 import os |
| 10 import subprocess | |
| 10 import sys | 11 import sys |
| 12 | |
| 13 # go home | |
| 11 HOME=os.environ['HOME'] | 14 HOME=os.environ['HOME'] |
| 12 os.chdir(HOME) | 15 os.chdir(HOME) |
| 13 | 16 |
| 14 # make the current directory a repository | 17 commands = [ # make the home directory a repository |
| 15 import subprocess | 18 ['hg', 'init'], |
| 16 | |
| 17 commands = [ ['hg', 'init'], | |
| 18 ['hg', 'pull', SRC], | 19 ['hg', 'pull', SRC], |
| 19 ['hg', 'update', '-C'], | 20 ['hg', 'update', '-C'], |
| 20 | 21 |
| 21 # get virtual env | 22 # get virtual env |
| 22 ['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'], | 23 ['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'], |
| 27 ['rm', '-f', '.subversion/config'], | 28 ['rm', '-f', '.subversion/config'], |
| 28 ['ln', '-s', os.path.join(HOME, '.subversion_config/config'), os.path.join(HOME, '.subversion/config')], | 29 ['ln', '-s', os.path.join(HOME, '.subversion_config/config'), os.path.join(HOME, '.subversion/config')], |
| 29 ] | 30 ] |
| 30 | 31 |
| 31 def execute(*commands): | 32 def execute(*commands): |
| 33 """execute a series of commands""" | |
| 32 for command in commands: | 34 for command in commands: |
| 33 print ' '.join(command) | 35 print ' '.join(command) |
| 34 code = subprocess.call(command) | 36 code = subprocess.call(command) |
| 35 if code: | 37 if code: |
| 36 sys.exit(code) | 38 sys.exit(code) |
| 37 | 39 |
| 38 execute(*commands) | 40 execute(*commands) |
| 41 | |
| 42 # make a (correct) .hg/hgrc file for $HOME | |
| 39 subprocess.call('/bin/echo -e "[paths]\\ndefault = http://k0s.org/hg/config\\ndefault-push = ssh://k0s.org/hg/config" > ~/.hg/hgrc', shell=True) | 43 subprocess.call('/bin/echo -e "[paths]\\ndefault = http://k0s.org/hg/config\\ndefault-push = ssh://k0s.org/hg/config" > ~/.hg/hgrc', shell=True) |
| 40 | 44 |
| 41 def install_develop(package): | 45 def install_develop(package): |
| 42 src = 'http://k0s.org/hg/%s' % package | 46 src = 'http://k0s.org/hg/%s' % package |
| 43 directory = '%s/src/%s' % (package, package) | 47 directory = '%s/src/%s' % (package, package) |
| 51 execute(command) | 55 execute(command) |
| 52 os.chdir(old_directory) | 56 os.chdir(old_directory) |
| 53 | 57 |
| 54 # install some python | 58 # install some python |
| 55 install_develop('smartopen') | 59 install_develop('smartopen') |
| 56 install_develop('silvermirror') | 60 install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first |
| 57 | 61 |
| 58 postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ], | 62 postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ], |
| 63 ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ], | |
| 59 ] | 64 ] |
| 60 execute(*postinstall_commands) | 65 execute(*postinstall_commands) |
| 61 | 66 |
| 62 | 67 |
| 63 # - ubuntu packages to install: | 68 # - ubuntu packages to install: |
| 64 PACKAGES="unison fluxbox antiword xclip graphviz" | 69 PACKAGES="unison fluxbox antiword xclip graphviz python-dev" |
| 65 print "Ensure the following packages are installed:" | 70 print "Ensure the following packages are installed:" |
| 66 print "sudo apt-get install $PACKAGES" | 71 print "sudo apt-get install $PACKAGES" |
