2003-10-03 05:53:28 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
'''
|
2011-04-09 03:10:29 +00:00
|
|
|
Usage: upgrade [options] project_root
|
2004-11-24 19:17:50 +00:00
|
|
|
Options:
|
2009-06-10 22:38:33 +00:00
|
|
|
--srcdir default: current directory
|
2012-12-14 09:05:49 +00:00
|
|
|
--web_only copy only web (PHP) files
|
|
|
|
--server_only copy everything except web files
|
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
|
|
|
|
2011-04-09 03:10:29 +00:00
|
|
|
If project_root is an absolute path, it's the project root.
|
|
|
|
Otherwise the project root is HOME/projects/project_root.
|
|
|
|
|
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():
|
2011-04-09 03:10:29 +00:00
|
|
|
print "Usage: upgrade [--web_only | --server_only] [--srcdir DIR] project_root"
|
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:
|
2011-04-09 03:10:29 +00:00
|
|
|
opts, args = getopt.getopt(sys.argv[1:], '', ['help', 'web_only', 'server_only', 'srcdir='])
|
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('~')
|
|
|
|
|
2008-01-01 18:07:13 +00:00
|
|
|
options.web_only = False
|
2009-12-31 02:37:16 +00:00
|
|
|
options.server_only = False
|
2009-06-10 22:38:33 +00:00
|
|
|
options.srcdir = None
|
2004-11-24 19:17:50 +00:00
|
|
|
|
|
|
|
for o,a in opts:
|
|
|
|
if o == '--help': usage()
|
2007-12-28 05:23:52 +00:00
|
|
|
elif o == '--web_only': options.web_only = True
|
2009-12-31 02:37:16 +00:00
|
|
|
elif o == '--server_only': options.server_only = True
|
2009-06-10 22:38:33 +00:00
|
|
|
elif o == '--srcdir': options.srcdir = a
|
2004-11-24 19:17:50 +00:00
|
|
|
else:
|
|
|
|
raise SystemExit('internal error o=%s'%o)
|
|
|
|
|
|
|
|
if len(args) == 1:
|
2011-04-09 03:10:29 +00:00
|
|
|
if os.path.isabs(args[0]):
|
|
|
|
INSTALL_DIR = args[0]
|
|
|
|
else:
|
|
|
|
INSTALL_DIR = os.path.join(home, 'projects', args[0])
|
2004-11-24 19:17:50 +00:00
|
|
|
else:
|
|
|
|
syntax_error('No project name')
|
|
|
|
|
2009-06-10 22:38:33 +00:00
|
|
|
if not options.srcdir:
|
|
|
|
for dir in ('.', '..'):
|
|
|
|
if os.path.exists(os.path.join(dir, 'html', 'project.sample', 'project.inc')):
|
|
|
|
options.srcdir = dir
|
|
|
|
if not options.srcdir:
|
|
|
|
syntax_error('Not running in the source directory and --srcdir was not specified')
|
|
|
|
|
2004-11-24 19:17:50 +00:00
|
|
|
if not tools.query_noyes("Overwrite files in "+INSTALL_DIR):
|
|
|
|
raise SystemExit
|
2004-11-02 22:33:41 +00:00
|
|
|
|
2008-11-24 23:16:40 +00:00
|
|
|
if not options.web_only:
|
2010-03-29 22:28:20 +00:00
|
|
|
if os.system('cd '+INSTALL_DIR+'; ./bin/stop'):
|
2008-11-24 23:16:40 +00:00
|
|
|
raise SystemExit("Couldn't stop project!")
|
2003-10-03 05:53:28 +00:00
|
|
|
|
|
|
|
print "Upgrading files... "
|
|
|
|
|
|
|
|
options.install_method = 'copy'
|
|
|
|
init()
|
2009-12-31 02:37:16 +00:00
|
|
|
install_boinc_files(INSTALL_DIR, not options.server_only, not options.web_only)
|
2003-10-03 05:53:28 +00:00
|
|
|
|
|
|
|
print "Upgrading files... done"
|
2010-09-04 22:13:27 +00:00
|
|
|
print "Finding SVN revision"
|
2003-10-28 00:41:03 +00:00
|
|
|
|
2010-09-04 22:13:27 +00:00
|
|
|
print "Updating translations"
|
2009-03-24 21:24:57 +00:00
|
|
|
try:
|
2009-06-11 17:25:01 +00:00
|
|
|
os.system('cd '+INSTALL_DIR+'/html/ops; ./update_translations.php -d 1')
|
2009-03-24 21:24:57 +00:00
|
|
|
except:
|
|
|
|
print '''Couldn't install translation files'''
|
|
|
|
|
2010-08-11 20:08:13 +00:00
|
|
|
opt = '';
|
|
|
|
if options.server_only:
|
|
|
|
opt = ' --server'
|
|
|
|
if options.web_only:
|
|
|
|
opt = ' --web'
|
|
|
|
|
2012-11-02 22:38:54 +00:00
|
|
|
print "Checking for DB updates"
|
2010-08-11 20:08:13 +00:00
|
|
|
os.system('cd '+INSTALL_DIR+'/html/ops; ./upgrade_db.php'+opt)
|
2008-10-08 16:48:11 +00:00
|
|
|
|
2009-12-16 22:35:08 +00:00
|
|
|
if os.path.exists(INSTALL_DIR+'/html/project/project_news.inc'):
|
|
|
|
print '''\
|
|
|
|
|
|
|
|
html/project/project_news.inc is deprecated.
|
|
|
|
Run html/ops/news_convert.php to convert project news to forum format.
|
|
|
|
'''
|
|
|
|
|
2008-11-24 23:16:40 +00:00
|
|
|
if not options.web_only:
|
|
|
|
print "Run `bin/start' to restart the project."
|