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():
|
|
|
|
print "Usage: upgrade [--project_root] 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:
|
2004-12-27 22:49:25 +00:00
|
|
|
opts, args = getopt.getopt(sys.argv[1:], '', ['help', 'project_root='])
|
|
|
|
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')
|
|
|
|
|
|
|
|
for o,a in opts:
|
|
|
|
if o == '--help': usage()
|
|
|
|
elif o == '--project_root': options.project_root = a
|
|
|
|
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()
|
2004-11-02 22:33:41 +00:00
|
|
|
install_boinc_files(INSTALL_DIR)
|
2003-10-03 05:53:28 +00:00
|
|
|
|
|
|
|
print "Upgrading files... done"
|
2004-11-24 19:17:50 +00:00
|
|
|
print "You may need to do database upgrades also."
|
|
|
|
print "(see html/ops/db_update.php)"
|
2007-02-13 21:41:07 +00:00
|
|
|
print "Run `bin/start' to restart the project."
|
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'''
|
|
|
|
|
2004-11-24 19:17:50 +00:00
|
|
|
#if os.system(os.path.join(INSTALL_DIR,'bin/start')):
|
|
|
|
# raise SystemExit("Couldn't start BOINC!")
|