Mercurial > hg > config
annotate python/install_config.py @ 129:83bc1e6e5b54
part of a dream realized
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 18 Mar 2011 11:33:56 -0700 |
parents | 84a37735cd88 |
children | c61997cf17b0 |
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 | |
6 | 10 import sys |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
11 HOME=os.environ['HOME'] |
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
12 os.chdir(HOME) |
1 | 13 |
14 # make the current directory a repository | |
15 import subprocess | |
6 | 16 |
17 commands = [ ['hg', 'init'], | |
18 ['hg', 'pull', SRC], | |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
19 ['hg', 'update', '-C'], |
51 | 20 |
21 # get virtual env | |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
22 ['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'], |
50 | 23 ['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
|
24 |
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
25 # site-specific files |
22
8da594377f18
updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents:
16
diff
changeset
|
26 ['mkdir', '-p', '.subversion'], |
8da594377f18
updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents:
16
diff
changeset
|
27 ['rm', '-f', '.subversion/config'], |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
28 ['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
|
29 ] |
6 | 30 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
31 def execute(*commands): |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
32 for command in commands: |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
33 print ' '.join(command) |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
34 code = subprocess.call(command) |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
35 if code: |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
36 sys.exit(code) |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
37 |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
38 execute(*commands) |
51 | 39 subprocess.call('/bin/echo -e "[paths]\\ndefault = http://k0s.org/hg/config\\ndefault-push = ssh://k0s.org/hg/config" > ~/.hg/hgrc', shell=True) |
1 | 40 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
41 def install_develop(package): |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
42 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
|
43 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
|
44 commands = [ ['virtualenv/virtualenv.py', package], |
44 | 45 ['mkdir', '-p', directory ], |
46 ['hg', 'clone', src, directory] ] | |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
54 # install some python |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
55 install_develop('smartopen') |
6 | 56 |
45
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
57 postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ], |
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
58 ] |
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
59 execute(*postinstall_commands) |
32
f878d9f62211
fix syntax error and actually execute the commands
Jeff Hammel <k0scist@gmail.com>
parents:
31
diff
changeset
|
60 |
45
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
61 |
36
d83f35b9b799
adding xclip package and echo which packages need installation
Jeff Hammel <k0scist@gmail.com>
parents:
34
diff
changeset
|
62 # - ubuntu packages to install: |
64
84a37735cd88
add graphviz to list of desired packages
Jeff Hammel <jhammel@mozilla.com>
parents:
51
diff
changeset
|
63 PACKAGES="unison fluxbox antiword xclip graphviz" |
43 | 64 print "Ensure the following packages are installed:" |
65 print "sudo apt-get install $PACKAGES" |