comparison install.py @ 417:6dbef23ca6bd

Update subrepos if they're already cloned.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 21 Jan 2018 12:50:45 -0800
parents 222b477ad678
children 350f7a55ff33
comparison
equal deleted inserted replaced
416:222b477ad678 417:6dbef23ca6bd
183 'source "gpg2 -dq %s |"' % _p('mutt/variables.gpg'), 183 'source "gpg2 -dq %s |"' % _p('mutt/variables.gpg'),
184 'source "%s"' % _p('mutt/muttrc'), 184 'source "%s"' % _p('mutt/muttrc'),
185 'source "%s"' % _p('lib/mutt/mutt-colors-solarized/' 185 'source "%s"' % _p('lib/mutt/mutt-colors-solarized/'
186 'mutt-colors-solarized-dark-256.muttrc') 186 'mutt-colors-solarized-dark-256.muttrc')
187 ]) 187 ])
188 188
189 189
190 def _on_error_try_make_readable(func, path, exc_info): 190 def _on_error_try_make_readable(func, path, exc_info):
191 if not os.access(path, os.W_OK): 191 if not os.access(path, os.W_OK):
192 os.chmod(path, stat.S_IWUSR) 192 os.chmod(path, stat.S_IWUSR)
193 func(path) 193 func(path)
194 else: 194 else:
196 196
197 197
198 def clone_git(url, path, force=False): 198 def clone_git(url, path, force=False):
199 if os.path.isdir(path): 199 if os.path.isdir(path):
200 if not force: 200 if not force:
201 print("Skipping git clone of %s -- directory exists" % path) 201 print("git pull origin master %s" % path)
202 subprocess.check_call(['git', 'pull', 'origin', 'master'],
203 cwd=path)
202 return 204 return
203 else: 205 else:
204 print("Deleting existing: %s" % path) 206 print("Deleting existing: %s" % path)
205 shutil.rmtree(path, onerror=_on_error_try_make_readable) 207 shutil.rmtree(path, onerror=_on_error_try_make_readable)
206 208
210 212
211 213
212 def clone_hg(url, path, force=False): 214 def clone_hg(url, path, force=False):
213 if os.path.isdir(path): 215 if os.path.isdir(path):
214 if not force: 216 if not force:
215 print("Skipping hg clone of %s -- directory exists" % path) 217 print("hg pull -u %s" % path)
218 subprocess.check_call(['hg', 'pull', '-u'], cwd=path)
216 return 219 return
217 else: 220 else:
218 print("Deleting existing: %s" % path) 221 print("Deleting existing: %s" % path)
219 shutil.rmtree(path, onerror=_on_error_try_make_readable) 222 shutil.rmtree(path, onerror=_on_error_try_make_readable)
220 223
256 if not an.startswith('install_'): 259 if not an.startswith('install_'):
257 continue 260 continue
258 261
259 name = an[len('install_'):] 262 name = an[len('install_'):]
260 mod_names.append(name) 263 mod_names.append(name)
261 264
262 # See if we have any local install script. 265 # See if we have any local install script.
263 local_mod = None 266 local_mod = None
264 local_install_py = os.path.join(dotfiles_dir, 'local', 267 local_install_py = os.path.join(dotfiles_dir, 'local',
265 'local_install.py') 268 'local_install.py')
266 if os.path.isfile(local_install_py): 269 if os.path.isfile(local_install_py):