Mercurial > hg > config
annotate python/install_config.py @ 180:f52486ceadee
handle defunct processes
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 08 Nov 2011 17:11:35 -0800 |
parents | 492ec7e2d46e |
children | e4221e45d6c1 |
rev | line source |
---|---|
1 | 1 #!/usr/bin/env python |
2 """ | |
3 installs config to a user's home directory | |
4 this can be done with | |
16 | 5 curl http://k0s.org/hg/config/raw-file/tip/python/install_config.py | python |
1 | 6 """ |
7 | |
8 SRC='http://k0s.org/hg/config' | |
9 import os | |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
10 import subprocess |
6 | 11 import sys |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
12 |
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
13 # go home |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
14 HOME=os.environ['HOME'] |
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
15 os.chdir(HOME) |
1 | 16 |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
17 commands = [ # make the home directory a repository |
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
18 ['hg', 'init'], |
6 | 19 ['hg', 'pull', SRC], |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
20 ['hg', 'update', '-C'], |
51 | 21 |
22 # get virtual env | |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
23 ['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'], |
174 | 24 ['ln', '-s', HOME + '/virtualenv/virtualenv.py', HOME + '/bin/'], |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
25 |
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
26 # site-specific files |
22
8da594377f18
updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents:
16
diff
changeset
|
27 ['mkdir', '-p', '.subversion'], |
8da594377f18
updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents:
16
diff
changeset
|
28 ['rm', '-f', '.subversion/config'], |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
29 ['ln', '-s', os.path.join(HOME, '.subversion_config/config'), os.path.join(HOME, '.subversion/config')], |
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
30 ] |
6 | 31 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
32 def execute(*commands): |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
33 """execute a series of commands""" |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
34 for command in commands: |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
35 print ' '.join(command) |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
36 code = subprocess.call(command) |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
37 if code: |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
38 sys.exit(code) |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
39 |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
40 execute(*commands) |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
41 |
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
42 # make a (correct) .hg/hgrc file for $HOME |
51 | 43 subprocess.call('/bin/echo -e "[paths]\\ndefault = http://k0s.org/hg/config\\ndefault-push = ssh://k0s.org/hg/config" > ~/.hg/hgrc', shell=True) |
1 | 44 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
45 def install_develop(package): |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
46 src = 'http://k0s.org/hg/%s' % package |
41
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
47 directory = '%s/src/%s' % (package, package) |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
48 commands = [ ['virtualenv/virtualenv.py', package], |
44 | 49 ['mkdir', '-p', directory ], |
50 ['hg', 'clone', src, directory] ] | |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
51 execute(*commands) |
41
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
52 old_directory = os.getcwd() |
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
53 os.chdir(directory) |
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
54 command = ['../../bin/python', 'setup.py', 'develop'] |
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
55 execute(command) |
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
56 os.chdir(old_directory) |
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
57 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
58 # install some python |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
59 install_develop('smartopen') |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
60 install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first |
6 | 61 |
45
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
62 postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ], |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
63 ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ], |
45
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
64 ] |
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
65 execute(*postinstall_commands) |
32
f878d9f62211
fix syntax error and actually execute the commands
Jeff Hammel <k0scist@gmail.com>
parents:
31
diff
changeset
|
66 |
45
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
67 |
36
d83f35b9b799
adding xclip package and echo which packages need installation
Jeff Hammel <k0scist@gmail.com>
parents:
34
diff
changeset
|
68 # - ubuntu packages to install: |
174 | 69 PACKAGES="mercurial unison fluxbox antiword xclip graphviz python-dev python-lxml curl arandr" |
43 | 70 print "Ensure the following packages are installed:" |
71 print "sudo apt-get install $PACKAGES" | |
137
e12176a453e4
note git global ignore silliness
Jeff Hammel <jhammel@mozilla.com>
parents:
132
diff
changeset
|
72 |
e12176a453e4
note git global ignore silliness
Jeff Hammel <jhammel@mozilla.com>
parents:
132
diff
changeset
|
73 # setup git's global ignore, since git is silly about this and doesn't look for the file in the right place |
e12176a453e4
note git global ignore silliness
Jeff Hammel <jhammel@mozilla.com>
parents:
132
diff
changeset
|
74 subprocess.call('if which git; then git config --global core.excludesfile ~/.gitignore; fi', shell=True) |