comparison python/install_config.py @ 595:4b79ee6c8539

STUB: python/install_config.py
author Jeff Hammel <k0scist@gmail.com>
date Sun, 26 Jan 2014 22:06:06 -0800
parents 98ccb704e241
children fd50f457185c
comparison
equal deleted inserted replaced
594:98ccb704e241 595:4b79ee6c8539
11 # ln -s /home/jhammel/web/sync.ini /home/jhammel/.silvermirror 11 # ln -s /home/jhammel/web/sync.ini /home/jhammel/.silvermirror
12 # - handle cases where config is autogenerated BUT you still want 12 # - handle cases where config is autogenerated BUT you still want
13 # to have some base (e.g. .gkrellm2/user_config) 13 # to have some base (e.g. .gkrellm2/user_config)
14 # - scp k0s.org:~/web/sync.ini ~/.silvermirror 14 # - scp k0s.org:~/web/sync.ini ~/.silvermirror
15 # - make idempotent 15 # - make idempotent
16 # - step to install (and setup) firefox
16 17
17 # imports 18 # imports
18 import imp 19 import imp
19 import optparse 20 import optparse
20 import os 21 import os
72 return cls.__name__ 73 return cls.__name__
73 __str__ = name 74 __str__ = name
74 def __call__(self): 75 def __call__(self):
75 execute(*self.commands) 76 execute(*self.commands)
76 77
78
77 class Command(object): 79 class Command(object):
78 """require a command""" 80 """require a command"""
81
82 #@require(Virtualenv)
83 class InstallVirtualenv(Step):
84 """ABC for installing packages in a virtualenv"""
85 # TODO: move install_develop sctuff to here
86
79 87
80 ### process steps 88 ### process steps
81 89
82 class InitializeRepository(Step): 90 class InitializeRepository(Step):
83 """make the home directory a repository""" 91 """make the home directory a repository"""
94 default = http://k0s.org/hg/config 102 default = http://k0s.org/hg/config
95 default-push = ssh://k0s.org/hg/config 103 default-push = ssh://k0s.org/hg/config
96 """ 104 """
97 with file('.hg/hgrc', 'w') as f: 105 with file('.hg/hgrc', 'w') as f:
98 f.write(hgrc) 106 f.write(hgrc)
107
99 def __call__(self): 108 def __call__(self):
100 Step.__call__(self) 109 Step.__call__(self)
101 self.write_hgrc() 110 self.write_hgrc()
102 111
103 # get the which command 112 # get the which command
105 from which import which 114 from which import which
106 115
107 #@requires(Command('git')) 116 #@requires(Command('git'))
108 class ConfigureGit(Step): 117 class ConfigureGit(Step):
109 """configure git""" 118 """configure git"""
110 commands = [['git', 'config', '--global', 'core.excludesfile', os.path.join(HOME, '.gitignore')]] 119 commands = [
120 # setup git's global ignore, since git is silly about this
121 # and doesn't look for the file in the right place
122 ['git', 'config', '--global', 'core.excludesfile', os.path.join(HOME, '.gitignore')]
123 ]
111 124
112 #@requires(Command('git')) 125 #@requires(Command('git'))
113 class InstallVirtualenv(Step): 126 class InstallVirtualenv(Step):
114 commands = [['git', 'clone', 'https://github.com/pypa/virtualenv.git'], 127 commands = [['git', 'clone', 'https://github.com/pypa/virtualenv.git'],
115 ['ln', '-s', 128 ['ln', '-s',
116 os.path.join(HOME, 'virtualenv/virtualenv.py'), 129 os.path.join(HOME, 'virtualenv/virtualenv.py'),
117 os.path.join(HOME, 'bin', 'virtualenv.py')] 130 os.path.join(HOME, 'bin', 'virtualenv.py')]
118 ] 131 ]
119 132
120 class InstallKWare(Step): 133 class InstallKWare(In):
121 """install k0s.ware""" 134 """install k0s.ware"""
135 # TODO
136 # from legacy
137 # # install some python
138 # install_develop('smartopen')
139 # install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first
140
141 # postinstall_commands = [['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ],
142 # ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ],
143 # ]
144 # execute(*postinstall_commands)
145
122 146
123 class DebianPackages(Step): 147 class DebianPackages(Step):
124 """ubuntu packages to install""" 148 """ubuntu packages to install"""
125 # TODO: actually install packages 149 # TODO: actually install packages
126 150
157 181
158 # do git stuff 182 # do git stuff
159 git = which('git') 183 git = which('git')
160 if git: 184 if git:
161 185
162 # setup git's global ignore, since git is silly about this
163 # and doesn't look for the file in the right place
164
165 # install some python
166 install_develop('smartopen')
167 install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first
168
169 postinstall_commands = [['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ],
170 ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ],
171 ]
172 execute(*postinstall_commands)
173 else: 186 else:
174 print "git not installed" 187 print "git not installed"
175 188
176 189
177 ### CLI 190 ### CLI