annotate python/install_config.py @ 43:ff7f771a9baf

oops
author Jeff Hammel <k0scist@gmail.com>
date Fri, 26 Mar 2010 13:56:34 -0700
parents 8cf361926883
children fc4b830a61e8 069a739d88ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
2 """
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
3 installs config to a user's home directory
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
4 this can be done with
16
57298ea7a7f1 fix string for how to install
k0s <k0scist@gmail.com>
parents: 14
diff changeset
5 curl http://k0s.org/hg/config/raw-file/tip/python/install_config.py | python
1
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
6 """
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
7
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
8 SRC='http://k0s.org/hg/config'
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
9 import os
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
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
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
13
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
14 # make the current directory a repository
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
15 import subprocess
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
16
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
17 commands = [ ['hg', 'init'],
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
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'],
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
20 ['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'],
14
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
21
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
22 # site-specific files
22
8da594377f18 updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents: 16
diff changeset
23 ['mkdir', '-p', '.subversion'],
8da594377f18 updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents: 16
diff changeset
24 ['rm', '-f', '.subversion/config'],
14
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
25 ['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
26 ]
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
27
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
28 def execute(*commands):
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
29 for command in commands:
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
30 print ' '.join(command)
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
31 code = subprocess.call(command)
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
32 if code:
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
33 sys.exit(code)
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
34
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
35 execute(*commands)
1
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
36
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
37 def install_develop(package):
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
38 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
39 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
40 commands = [ ['virtualenv/virtualenv.py', 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
41 ['mkdir', 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
42 ['hg', 'clone', src, '%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
43 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
44 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
45 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
46 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
47 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
48 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
49
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
50 # install some python
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
51 install_develop('smartopen')
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
52
32
f878d9f62211 fix syntax error and actually execute the commands
Jeff Hammel <k0scist@gmail.com>
parents: 31
diff changeset
53 postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ] ]
f878d9f62211 fix syntax error and actually execute the commands
Jeff Hammel <k0scist@gmail.com>
parents: 31
diff changeset
54
f878d9f62211 fix syntax error and actually execute the commands
Jeff Hammel <k0scist@gmail.com>
parents: 31
diff changeset
55 execute(*postinstall_commands)
33
8e5746ef15fe add note about installing ubuntu packages
Jeff Hammel <k0scist@gmail.com>
parents: 32
diff changeset
56
8e5746ef15fe add note about installing ubuntu packages
Jeff Hammel <k0scist@gmail.com>
parents: 32
diff changeset
57 # TODO:
36
d83f35b9b799 adding xclip package and echo which packages need installation
Jeff Hammel <k0scist@gmail.com>
parents: 34
diff changeset
58 # - ubuntu packages to install:
d83f35b9b799 adding xclip package and echo which packages need installation
Jeff Hammel <k0scist@gmail.com>
parents: 34
diff changeset
59 PACKAGES="unison fluxbox antiword xclip"
43
Jeff Hammel <k0scist@gmail.com>
parents: 42
diff changeset
60 print "Ensure the following packages are installed:"
Jeff Hammel <k0scist@gmail.com>
parents: 42
diff changeset
61 print "sudo apt-get install $PACKAGES"