2003-10-03 05:53:28 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
'''
|
2004-11-24 19:17:50 +00:00
|
|
|
Usage: upgrade [options] project_name
|
|
|
|
Options:
|
|
|
|
--project_root default: HOME/projects/
|
2004-11-02 22:33:41 +00:00
|
|
|
|
2004-11-24 19:17:50 +00:00
|
|
|
Copy source/build files to a project tree,
|
|
|
|
overwriting what's already there.
|
|
|
|
Run it in the source directory (tools/upgrade).
|
2004-11-02 22:33:41 +00:00
|
|
|
|
2003-10-03 05:53:28 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
import boinc_path_config
|
2004-09-07 20:56:08 +00:00
|
|
|
from Boinc import boinc_project_path, tools
|
2003-10-03 05:53:28 +00:00
|
|
|
from Boinc.setup_project import *
|
2004-11-24 19:17:50 +00:00
|
|
|
import os, getopt
|
2003-10-03 05:53:28 +00:00
|
|
|
|
2004-11-24 19:17:50 +00:00
|
|
|
def usage():
|
2007-12-28 05:23:52 +00:00
|
|
|
print "Usage: upgrade [--project_root] [--web_only] project_name"
|
2004-09-07 20:56:08 +00:00
|
|
|
raise SystemExit
|
|
|
|
|
2004-11-24 19:17:50 +00:00
|
|
|
def syntax_error(str):
|
|
|
|
raise SystemExit('%s; See "%s --help" for help\n' % (str, sys.argv[0]))
|
|
|
|
|
|
|
|
try:
|
2007-12-28 05:23:52 +00:00
|
|
|
opts, args = getopt.getopt(sys.argv[1:], '', ['help', 'project_root=', 'web_only'])
|
2004-12-27 22:49:25 +00:00
|
|
|
except getopt.GetoptError, e:
|
2004-11-24 19:17:50 +00:00
|
|
|
syntax_error(e)
|
|
|
|
|
|
|
|
home = os.path.expanduser('~')
|
|
|
|
|
|
|
|
options.project_root = os.path.join(home, 'projects')
|
2008-01-01 18:07:13 +00:00
|
|
|
options.web_only = False
|
2004-11-24 19:17:50 +00:00
|
|
|
|
|
|
|
for o,a in opts:
|
|
|
|
if o == '--help': usage()
|
|
|
|
elif o == '--project_root': options.project_root = a
|
2007-12-28 05:23:52 +00:00
|
|
|
elif o == '--web_only': options.web_only = True
|
2004-11-24 19:17:50 +00:00
|
|
|
else:
|
|
|
|
raise SystemExit('internal error o=%s'%o)
|
|
|
|
|
|
|
|
if len(args) == 1:
|
|
|
|
project_shortname = args[0]
|
|
|
|
else:
|
|
|
|
syntax_error('No project name')
|
|
|
|
|
|
|
|
INSTALL_DIR = os.path.join(options.project_root, project_shortname)
|
|
|
|
|
|
|
|
if not tools.query_noyes("Overwrite files in "+INSTALL_DIR):
|
|
|
|
raise SystemExit
|
2004-11-02 22:33:41 +00:00
|
|
|
|
|
|
|
if os.system(os.path.join(INSTALL_DIR,'bin/stop')):
|
2004-11-24 19:17:50 +00:00
|
|
|
raise SystemExit("Couldn't stop project!")
|
2003-10-03 05:53:28 +00:00
|
|
|
|
|
|
|
print "Upgrading files... "
|
|
|
|
|
|
|
|
options.install_method = 'copy'
|
|
|
|
init()
|
2007-12-28 05:23:52 +00:00
|
|
|
install_boinc_files(INSTALL_DIR, options.web_only)
|
2003-10-03 05:53:28 +00:00
|
|
|
|
|
|
|
print "Upgrading files... done"
|
2003-10-28 00:41:03 +00:00
|
|
|
|
2007-05-01 21:21:13 +00:00
|
|
|
svn_version_file = INSTALL_DIR+'/local.revision'
|
|
|
|
try:
|
|
|
|
os.system('/bin/sh -c /usr/bin/svnversion > '+svn_version_file)
|
|
|
|
except:
|
|
|
|
print '''Couldn't find svnversion'''
|
|
|
|
|
2008-11-11 23:45:55 +00:00
|
|
|
os.system('cd '+INSTALL_DIR+'/html/ops; ./upgrade_db.php')
|
2008-10-08 16:48:11 +00:00
|
|
|
|
|
|
|
print "Run `bin/start' to restart the project."
|