diff --git a/checkin_notes b/checkin_notes index 56d8fe6b9b..23dfa14cef 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5264,3 +5264,19 @@ David 10 June 2009 tools/ update_versions + +David 10 June 2009 + - make_project and upgrade: add --srcdir option so you + can run these commands from any directory + (mostly from Gabor Gombas; added a fix for svnversion) + + configure.ac + py/Boinc/ + boinc_path_config.py.in + database.py + setup_project.py + test/ + testbase.py + tools/ + make_project + upgrade diff --git a/configure.ac b/configure.ac index 47d1caa20c..7a90dc4540 100644 --- a/configure.ac +++ b/configure.ac @@ -274,7 +274,6 @@ AC_SUBST([BOINC_MAJOR_VERSION]) AC_SUBST([BOINC_MINOR_VERSION]) AC_SUBST([TOP_BUILD_DIR], [`pwd`]) -AC_SUBST([TOP_SOURCE_DIR], [`(cd \`dirname "$0"\` && pwd)`]) ## commented this out to turn all maintainer-mode features ON by default, ## such as automatic reconfiguring on changes in Makefile.am's and configure.ac diff --git a/py/Boinc/boinc_path_config.py.in b/py/Boinc/boinc_path_config.py.in index ee6e1eb153..fc5fa962d9 100644 --- a/py/Boinc/boinc_path_config.py.in +++ b/py/Boinc/boinc_path_config.py.in @@ -9,9 +9,4 @@ import sys, os TOP_BUILD_DIR = "@TOP_BUILD_DIR@" -TOP_SOURCE_DIR = "@TOP_SOURCE_DIR@" -TOP_SOURCE_DIR = os.environ.get('TOP_SOURCE_DIR') or TOP_SOURCE_DIR - -sys.path.insert(0, os.path.join(TOP_SOURCE_DIR, 'py')) -if TOP_BUILD_DIR != TOP_SOURCE_DIR: - sys.path.insert(0, os.path.join(TOP_BUILD_DIR, 'py')) +sys.path.insert(0, os.path.join(TOP_BUILD_DIR, 'py')) diff --git a/py/Boinc/database.py b/py/Boinc/database.py index 64c96c8390..f76d5be766 100644 --- a/py/Boinc/database.py +++ b/py/Boinc/database.py @@ -257,7 +257,7 @@ def _execute_sql_script(cursor, filename): if not query: continue cursor.execute(query) -def create_database(config = None, drop_first = False): +def create_database(srcdir, config = None, drop_first = False): ''' creates a new database. ''' import boinc_path_config config = config or configxml.default_config().config @@ -267,9 +267,8 @@ def create_database(config = None, drop_first = False): cursor.execute("drop database if exists %s"%config.db_name) cursor.execute("create database %s"%config.db_name) cursor.execute("use %s"%config.db_name) - schema_path = os.path.join(boinc_path_config.TOP_SOURCE_DIR, 'db') for file in ['schema.sql', 'constraints.sql']: - _execute_sql_script(cursor, os.path.join(schema_path, file)) + _execute_sql_script(cursor, os.path.join(srcdir, 'db', file)) cursor.close() # alias diff --git a/py/Boinc/setup_project.py b/py/Boinc/setup_project.py index 2e01bb36c6..a6078e719e 100644 --- a/py/Boinc/setup_project.py +++ b/py/Boinc/setup_project.py @@ -168,7 +168,7 @@ def account_file_name(url): return 'account_' + _url_to_filename(url) + '.xml' def srcdir(*dirs): - return apply(os.path.join,(boinc_path_config.TOP_SOURCE_DIR,)+dirs) + return apply(os.path.join,(options.srcdir,)+dirs) def builddir(*dirs): return apply(os.path.join,(boinc_path_config.TOP_BUILD_DIR,)+dirs) @@ -486,7 +486,6 @@ class Project: self.dir('html/user/rss_main.php')) install(srcdir('html/ops', 'sample_server_status.php'), self.dir('html/user/server_status.php')) - install(srcdir('html/languages/project_specific_translations/sample_en.po'), self.dir('html/languages/project_specific_translations/en.po')) install(srcdir('tools/project.xml'), self.dir('project.xml')) if not self.production: install(srcdir('test/uc_result'), self.dir('templates/uc_result')) @@ -520,6 +519,7 @@ class Project: verbose_echo(1, "Setting up database") database.create_database( + srcdir = options.srcdir, config = self.config.config, drop_first = options.drop_db_first ) diff --git a/test/testbase.py b/test/testbase.py index 04dd251596..8d12e5b235 100644 --- a/test/testbase.py +++ b/test/testbase.py @@ -26,7 +26,8 @@ def test_init(): options.have_init_t = True if not os.path.exists('testbase.py'): - os.chdir(os.path.join(boinc_path_config.TOP_SOURCE_DIR,'test')) + # automake sets the srcdir env. variable if srcdir != builddir + os.chdir(os.path.join(os.getenv('srcdir'),'test')) if not os.path.exists('testbase.py'): raise SystemExit('Could not find testbase.py anywhere') diff --git a/tools/make_project b/tools/make_project index 7e7da86ae9..5a88528b70 100755 --- a/tools/make_project +++ b/tools/make_project @@ -35,6 +35,7 @@ Misc options: --drop_db_first drop database first (from prev installation) --test_app install test application --web_only install web files, no executables (for Bossa, Bolt) + --srcdir where to find the source files (default: current directory) Dir-options: --project_root default: HOME/projects/PROJECT @@ -76,6 +77,7 @@ try: 'no_query', 'test_app', 'web_only', + 'srcdir=', 'user_name=', 'drop_db_first', 'delete_prev_inst', @@ -100,6 +102,7 @@ options.no_query = False options.test_app = False options.web_only = False options.delete_prev_inst = False +options.srcdir = None for o,a in opts: if o == '-h' or o == '--help': usage() @@ -108,6 +111,7 @@ for o,a in opts: elif o == '--no_query': options.no_query = True elif o == '--test_app': options.test_app = True elif o == '--web_only': options.web_only = True + elif o == '--srcdir': options.srcdir = a elif o == '--user_name': options.user_name = a elif o == '--drop_db_first': options.drop_db_first = True elif o == '--delete_prev_inst': options.delete_prev_inst = True @@ -131,6 +135,13 @@ elif len(args) == 1: else: syntax_error('Need one or two arguments') +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') + opt_repls = {'PROJECT':project_shortname, 'PROJECT_ops':project_shortname+'_ops', 'PROJECT_cgi':project_shortname+'_cgi'} @@ -270,14 +281,17 @@ t.disabled = 1 project.config.write() + svn_version_file = proot+'/local.revision' try: - os.system('/bin/sh -c /usr/bin/svnversion > '+svn_version_file) + cmd = '/bin/sh -c \'/usr/bin/svnversion ' + options.srcdir + '\' > '+svn_version_file + os.system(cmd) except: print '''Couldn't find svnversion''' try: - os.system('/bin/sh -c /usr/bin/svnversion > '+proot+'/db_revision') + cmd = '/bin/sh -c \'/usr/bin/svnversion ' + options.srcdir + '\' > '+proot+'/db_revision' + os.system(cmd) except: print '''Couldn't find svnversion''' diff --git a/tools/upgrade b/tools/upgrade index f4e79d086f..7bde7306b6 100755 --- a/tools/upgrade +++ b/tools/upgrade @@ -6,6 +6,7 @@ Usage: upgrade [options] project_name Options: --project_root default: HOME/projects/ + --srcdir default: current directory Copy source/build files to a project tree, overwriting what's already there. @@ -19,14 +20,14 @@ from Boinc.setup_project import * import os, getopt def usage(): - print "Usage: upgrade [--project_root] [--web_only] project_name" + print "Usage: upgrade [--project_root] [--web_only] [--srcdir DIR] project_name" raise SystemExit def syntax_error(str): raise SystemExit('%s; See "%s --help" for help\n' % (str, sys.argv[0])) try: - opts, args = getopt.getopt(sys.argv[1:], '', ['help', 'project_root=', 'web_only']) + opts, args = getopt.getopt(sys.argv[1:], '', ['help', 'project_root=', 'web_only', 'srcdir=']) except getopt.GetoptError, e: syntax_error(e) @@ -34,11 +35,13 @@ home = os.path.expanduser('~') options.project_root = os.path.join(home, 'projects') options.web_only = False +options.srcdir = None for o,a in opts: if o == '--help': usage() elif o == '--project_root': options.project_root = a elif o == '--web_only': options.web_only = True + elif o == '--srcdir': options.srcdir = a else: raise SystemExit('internal error o=%s'%o) @@ -47,6 +50,13 @@ if len(args) == 1: else: syntax_error('No project name') +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') + INSTALL_DIR = os.path.join(options.project_root, project_shortname) if not tools.query_noyes("Overwrite files in "+INSTALL_DIR):