Mercurial > hg > config
annotate python/install_config.py @ 228:4d97b4043f84
fucking hg
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 20 Jun 2012 17:06:43 -0700 |
parents | 4390ca34912c |
children | 761e7dfc675e |
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' | |
218 | 9 |
10 import imp | |
1 | 11 import os |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
12 import subprocess |
6 | 13 import sys |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
14 |
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
15 # go home |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
16 HOME=os.environ['HOME'] |
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
17 os.chdir(HOME) |
1 | 18 |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
19 commands = [ # make the home directory a repository |
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
20 ['hg', 'init'], |
6 | 21 ['hg', 'pull', SRC], |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
22 ['hg', 'update', '-C'], |
51 | 23 |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
24 # site-specific files |
22
8da594377f18
updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents:
16
diff
changeset
|
25 ['mkdir', '-p', '.subversion'], |
8da594377f18
updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents:
16
diff
changeset
|
26 ['rm', '-f', '.subversion/config'], |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
27 ['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
|
28 ] |
6 | 29 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
30 def execute(*commands): |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
31 """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
|
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) |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
39 |
218 | 40 # get the which command |
41 sys.path.append(os.path.join(HOME, 'python')) | |
42 from which import which | |
43 | |
44 | |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
45 # make a (correct) .hg/hgrc file for $HOME |
218 | 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() | |
1 | 53 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
54 def install_develop(package): |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
55 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
|
56 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
|
57 commands = [ ['virtualenv/virtualenv.py', package], |
44 | 58 ['mkdir', '-p', directory ], |
59 ['hg', 'clone', src, directory] ] | |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 os.chdir(old_directory) |
218 | 66 |
67 # do git stuff | |
68 git = which('git') | |
69 if git: | |
70 # get virtual env | |
219 | 71 virtualenv_commands = [['git', 'clone', 'https://github.com/pypa/virtualenv.git'], |
218 | 72 ['ln', '-s', HOME + '/virtualenv/virtualenv.py', HOME + '/bin/']] |
73 execute(*virtualenv_commands) | |
6 | 74 |
218 | 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')]) | |
32
f878d9f62211
fix syntax error and actually execute the commands
Jeff Hammel <k0scist@gmail.com>
parents:
31
diff
changeset
|
78 |
218 | 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) | |
45
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
87 |
36
d83f35b9b799
adding xclip package and echo which packages need installation
Jeff Hammel <k0scist@gmail.com>
parents:
34
diff
changeset
|
88 # - ubuntu packages to install: |
174 | 89 PACKAGES="mercurial unison fluxbox antiword xclip graphviz python-dev python-lxml curl arandr" |
43 | 90 print "Ensure the following packages are installed:" |
218 | 91 print "sudo apt-get install %s" % PACKAGES |