comparison python/install_config.py @ 218:e4221e45d6c1

update install script
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 06 Apr 2012 16:41:05 -0700
parents 492ec7e2d46e
children 4390ca34912c
comparison
equal deleted inserted replaced
217:4ad8bce17e85 218:e4221e45d6c1
4 this can be done with 4 this can be done with
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
10 import imp
9 import os 11 import os
10 import subprocess 12 import subprocess
11 import sys 13 import sys
12 14
13 # go home 15 # go home
16 18
17 commands = [ # make the home directory a repository 19 commands = [ # make the home directory a repository
18 ['hg', 'init'], 20 ['hg', 'init'],
19 ['hg', 'pull', SRC], 21 ['hg', 'pull', SRC],
20 ['hg', 'update', '-C'], 22 ['hg', 'update', '-C'],
21
22 # get virtual env
23 ['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'],
24 ['ln', '-s', HOME + '/virtualenv/virtualenv.py', HOME + '/bin/'],
25 23
26 # site-specific files 24 # site-specific files
27 ['mkdir', '-p', '.subversion'], 25 ['mkdir', '-p', '.subversion'],
28 ['rm', '-f', '.subversion/config'], 26 ['rm', '-f', '.subversion/config'],
29 ['ln', '-s', os.path.join(HOME, '.subversion_config/config'), os.path.join(HOME, '.subversion/config')], 27 ['ln', '-s', os.path.join(HOME, '.subversion_config/config'), os.path.join(HOME, '.subversion/config')],
37 if code: 35 if code:
38 sys.exit(code) 36 sys.exit(code)
39 37
40 execute(*commands) 38 execute(*commands)
41 39
40 # get the which command
41 sys.path.append(os.path.join(HOME, 'python'))
42 from which import which
43
44
42 # make a (correct) .hg/hgrc file for $HOME 45 # make a (correct) .hg/hgrc file for $HOME
43 subprocess.call('/bin/echo -e "[paths]\\ndefault = http://k0s.org/hg/config\\ndefault-push = ssh://k0s.org/hg/config" > ~/.hg/hgrc', shell=True) 46 hgrc = """[paths]
47 default = http://k0s.org/hg/config
48 default-push = ssh://k0s.org/hg/config
49 """
50 f = file('.hg/hgrc', 'w')
51 f.write(hgrc)
52 f.close()
44 53
45 def install_develop(package): 54 def install_develop(package):
46 src = 'http://k0s.org/hg/%s' % package 55 src = 'http://k0s.org/hg/%s' % package
47 directory = '%s/src/%s' % (package, package) 56 directory = '%s/src/%s' % (package, package)
48 commands = [ ['virtualenv/virtualenv.py', package], 57 commands = [ ['virtualenv/virtualenv.py', package],
52 old_directory = os.getcwd() 61 old_directory = os.getcwd()
53 os.chdir(directory) 62 os.chdir(directory)
54 command = ['../../bin/python', 'setup.py', 'develop'] 63 command = ['../../bin/python', 'setup.py', 'develop']
55 execute(command) 64 execute(command)
56 os.chdir(old_directory) 65 os.chdir(old_directory)
57
58 # install some python
59 install_develop('smartopen')
60 install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first
61 66
62 postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ], 67 # do git stuff
63 ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ], 68 git = which('git')
64 ] 69 if git:
65 execute(*postinstall_commands) 70 # get virtual env
71 virtualenv_commands = [['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'],
72 ['ln', '-s', HOME + '/virtualenv/virtualenv.py', HOME + '/bin/']]
73 execute(*virtualenv_commands)
66 74
75 # setup git's global ignore, since git is silly about this
76 # and doesn't look for the file in the right place
77 execute(['git', 'config', '--global', 'core.excludesfile', os.path.join(HOME, '.gitignore')])
78
79 # install some python
80 install_develop('smartopen')
81 install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first
82
83 postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ],
84 ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ],
85 ]
86 execute(*postinstall_commands)
67 87
68 # - ubuntu packages to install: 88 # - ubuntu packages to install:
69 PACKAGES="mercurial unison fluxbox antiword xclip graphviz python-dev python-lxml curl arandr" 89 PACKAGES="mercurial unison fluxbox antiword xclip graphviz python-dev python-lxml curl arandr"
70 print "Ensure the following packages are installed:" 90 print "Ensure the following packages are installed:"
71 print "sudo apt-get install $PACKAGES" 91 print "sudo apt-get install %s" % PACKAGES
72
73 # setup git's global ignore, since git is silly about this and doesn't look for the file in the right place
74 subprocess.call('if which git; then git config --global core.excludesfile ~/.gitignore; fi', shell=True)