class DeliveranceProject(Project): """ Install Deliverance/DeliveranceVHoster """ name = 'deliverance' title = 'Install Deliverance/DeliveranceVHoster' settings = [ Setting('spec', default='requirements/deliverance-req.txt', help='Specification of packages to install'), Setting( 'openplans_hooks_repo', default='https://svn.openplans.org/svn/build/openplans_hooks/trunk', help='SVN location of openplans_hooks'), Setting('port', default='{{env.base_port+int(config.port_offset)}}', help='Port to install Deliverance on'), Setting('port_offset', default='0', help='Offset from base_port for Deliverance'), Setting('host', default='localhost', help='Host to serve on'), Setting('force_ssl', inherit_config=('general', 'force_ssl'), default='False', help='Redirect ssl-only paths to https'), Setting( 'default_rules_repo', default= '{{project.req_settings.get("rules_repo", "https://svn.openplans.org/svn/build/rules/openplans")}}', help='Default svn location of deliverance rules', ) ] actions = [ tasks.SaveSetting('Save force_ssl setting', {'force_ssl': '{{config.force_ssl}}'}), tasks.VirtualEnv(), tasks.InstallSpec('Install Deliverance', '{{config.spec}}'), tasks.TestLxml('{{env.base_path}}/deliverance'), tasks.SvnCheckout('Checkout openplans_hooks', '{{config.openplans_hooks_repo}}', '{{project.name}}/src/openplans_hooks'), tasks.SvnCheckout('Checkout default rules', '{{config.default_rules_repo}}', '{{env.var}}/deliverance/default_rules'), tasks.InstallPasteConfig( path='deliverance/src/deliverancevhoster/fassembler_config.ini_tmpl' ), tasks.InstallPasteStartup(), tasks.InstallSupervisorConfig(), tasks.SaveURI(path='/', theme=False), ] depends_on_projects = ['fassembler:topp']
class BuildBotProject(Project): """Buildbot base project class""" files_dir = os.path.join(os.path.dirname(__file__), 'buildbot-files') skel_dir = os.path.join(files_dir, 'skel') depends_on_projects = ['fassembler:topp'] hostname, platform, version = get_host_info() buildslave_dirname = 'buildslave' settings = [ Setting( 'buildbot_url', inherit_config=('general', 'buildbot_url'), default='http://buildbot.socialplanning.org', help='Public URL of the buildbot web page', ), Setting('spec', default='requirements/buildbot-req.txt', help='Specification of packages to install'), Setting('buildmaster_host', default='localhost', help='Host the buildmaster runs on'), Setting('baseport', default='{{env.base_port}}', help="Base port"), Setting( 'child_baseport', default='{{env.base_port + 1000}}', help= "Base port for applications built by the bots. There are multiple builders, so choose a number where you have a few hundred ports free after that!" ), # It kind of sucks that the master config is in charge of this. Setting( 'buildmaster_private_port', default='{{env.base_port+int(config.buildmaster_private_offset)}}', help="Port to run the private buildmaster on (force build allowed)" ), Setting('buildmaster_private_offset', default='20', help="Offset from base_port for the private build master."), Setting( 'buildmaster_public_port', default='{{env.base_port+int(config.buildmaster_public_offset)}}', help= "Port to run the public buildmaster on (force build disallowed)"), Setting('buildmaster_public_offset', default='21', help="Offset from base_port for the public build master."), Setting('buildslave_port', default='{{env.base_port+int(config.buildslave_port_offset)}}', help="Port build slaves connect to the master on"), Setting( 'buildslave_port_offset', default='22', help='Offset from base_port for the build slave connect port.'), Setting('buildbot_passwd', help="Password for buildslaves to connect to master."), Setting( 'buildslave_dir', default='{{project.buildslave_dirname}}', help="Subdirectory to put the buildslave in. Must be relative"), Setting( 'basedir', default='build', help='Subdirectory where slave will build stuff.', ), Setting('editwarning', default=editwarning, help='Text to warn people about editing generated files.'), ] actions = [ tasks.VirtualEnv(), tasks.InstallSpec('Install buildbot dependencies', '{{config.spec}}'), tasks.SaveSetting('Save buildbot settings', {'buildbot_url': '{{config.buildbot_url}}'}, section='general'), ]
class BrainpowerProject(Project): """Brainpower base project class""" name = 'brainpower' title = 'Installs Brainpower' depends_on_projects = ['fassembler:topp'] def get_req_setting(self, setting): return self.req_settings.get(setting, '') settings = [ Setting( 'port_offset', default='11', help='Port offset from base_port to run the dev django server on'), Setting('port', default='{{env.base_port+int(config.port_offset)}}', help="Port to run the dev django server on"), Setting('db_engine', default='mysql', help="Engine to use for django's database"), Setting('db_host', default='', help="Database host"), Setting('db_username', default='root', help="Database user"), Setting('db_password', default='', help="Database password"), Setting('db_root_password', default='', help="Database root password"), Setting('db_name', default='brainpower', help="Database name"), Setting('test_db_name', default='brainpower_test', help="Scratch database name for tests"), Setting( 'secret_key', default= '{{maker.ask_password("Enter secret key for Django or press enter for a random one")}}', help="Django's secret key"), Setting('spec', default='requirements/brainpower-req.txt', help='Specification of packages to install'), Setting( 'django_tarball_url', default='{{project.get_req_setting("django_tarball_url")}}', help='Where to download the django source', ), Setting( 'django_tarball_version', default='{{project.get_req_setting("django_tarball_version")}}', help='Version of Django to install', ), Setting( 'python', default='{{project.build_properties.get("virtualenv_python")}}', help='Where our Python gets installed', ), Setting( 'flunc', default= '{{project.build_properties.get("virtualenv_bin_path") + "/flunc"}}', help="Where our Flunc executable is installed.", ) ] actions = [ tasks.VirtualEnv(), tasks.InstallSpec('Install brainpower dependencies', '{{config.spec}}'), InstallDjango(), tasks.CheckMySQLDatabase('Check main brainpower database exists'), tasks.CheckMySQLDatabase('Check test brainpower database exists', db_name='{{config.test_db_name}}'), tasks.SaveSetting('Save brainpower settings', { 'django_tarball_version': '{{config.django_tarball_version}}', 'django_tarball_url': '{{config.django_tarball_url}}', 'dev_port': '{{config.port}}', 'python': '{{config.python}}', 'flunc': '{{config.flunc}}', 'db_engine': '{{config.db_engine}}', 'db_username': '******', 'db_password': '******', 'db_host': '{{config.db_host}}', 'db_name': '{{config.db_name}}', 'secret_key': '{{config.secret_key}}', }, section='brainpower'), tasks.Script('Initialize brainpower database', ['brainpower/bin/manage.py', 'syncdb', '--noinput']), # Order of arguments matters here! Watch out for # django bug http://code.djangoproject.com/ticket/7595 tasks.Script('Initialize brainpower test database', [ 'brainpower/bin/manage.py', 'syncdb', '--settings=brainpower.test_settings', '--noinput' ]), tasks.EnsureFile( 'Copy mod_python handler to bin directory', dest= '{{project.build_properties["virtualenv_bin_path"]}}/brainpower_handler.py', content_path= '{{project.build_properties["virtualenv_path"]}}/src/brainpower/brainpower_handler.py', executable=True, ), MediaLinks('Link media directories into {{task.htdocs}}.'), ]
class WordPressProject(Project, ApacheMixin): """ Install WordPress """ name = 'wordpress' title = 'Install WordPress' required_modules = ('mime', 'dir', 'rewrite') settings = [ Setting('port', default='{{env.base_port+int(config.port_offset)}}', help="Port to install Apache/WordPress on"), Setting('port_offset', default='3', help='Offset from base_port for Apache/WordPress'), Setting('host', default='localhost', help='Interface/host to serve Apache/WordPress on'), Setting('wordpress_repo', default='{{project.req_settings.get("wordpress_repo", \ "https://svn.github.com/socialplanning/opencore-wordpress-mu")}}', help='Location of WordPress MU repository'), Setting( 'wordpress_scripts_repo', default= 'https://svn.github.com/socialplanning/opencore-wordpress-mu-scripts', help='Location of scripts for WordPress'), Setting('apache_exec', default='{{project.apache_exec()}}', help='Location of apache executable'), Setting('apache_module_dir', default='{{project.apache_module_dir()}}', help='Location of apache modules'), Setting('php_cgi_exec', default='{{project.php_cgi_exec()}}', help='Location of php cgi executable'), Setting('server_admin', default='{{env.environ["USER"]}}@{{env.fq_hostname}}', help='Server admin for Apache'), Setting( 'db_name', default= '{{env.config.getdefault("general", "db_prefix", "")}}wordpress', help='Database name'), Setting('db_username', default='wordpress', help='Database user'), Setting('db_password', default='wordpress', help='Database password'), Setting('db_host', default='localhost', help='Database host'), Setting('db_root_password', default='{{env.db_root_password}}', help='Database root password'), Setting( 'topp_wordpress_theme', default= '{{project.req_settings.get("topp_wordpress_theme", "openplans")}}', help='Theme for wordpress (template option)'), ] skel_dir = os.path.join(os.path.dirname(__file__), 'wordpress-files', 'skel') actions = [ tasks.SaveSetting( 'Save the wordpress theme (template)', {'topp_wordpress_theme': '{{config.topp_wordpress_theme}}'}, section='applications'), CheckPHP('{{config.php_cgi_exec}}'), CheckApache(('mime', 'dir', 'rewrite', 'php')), tasks.CopyDir('Create layout', skel_dir, './'), tasks.SvnCheckout('Checkout wordpress-mu', '{{config.wordpress_repo}}', '{{env.base_path}}/wordpress/src/wordpress-mu'), tasks.SvnCheckout('Checkout scripts', '{{config.wordpress_scripts_repo}}', '{{env.base_path}}/wordpress/src/scripts'), tasks.EnsureFile( 'Fill in wp-config.php', '{{env.base_path}}/wordpress/src/wordpress-mu/wp-config.php', content_path= '{{env.base_path}}/wordpress/src/wordpress-mu/wp-config.php_tmpl', svn_add=False, overwrite=True), tasks.InstallSupervisorConfig(), tasks.EnsureDir('Create var subdirectory', '{{env.var}}/wordpress'), tasks.CheckMySQLDatabase('Check database'), tasks.Script('Setup database tables', [ '{{config.php_cgi_exec}}', '-f', 'dbsetup.php', '{{project.secret()}}' ], cwd='{{env.base_path}}/wordpress/src/wordpress-mu'), tasks.SaveURI(path='/blog'), DeleteExtraWPSiteRows(db='{{config.db_name}}', user='******', passwd='{{config.db_password}}'), ] depends_on_projects = ['fassembler:topp'] depends_on_executables = [('httpd', 'apache2')] def secret(self): f = open(self.environ.config.get('general', 'topp_secret_filename'), 'rb') c = f.read() f.close() return c
class ToppProject(Project): """ Create the basic layout used at TOPP for a set of applications. """ name = 'topp' title = 'TOPP (openplans.org) Standard File Layout' project_base_dir = os.path.join(os.path.dirname(__file__), 'topp-files') settings = [ Setting('requirements_svn_repo', inherit_config=('general', 'requirements_svn_repo'), default='https://svn.socialplanning.org/svn/build/requirements/openplans/trunk', help="Location where requirement files will be found for all builds"), Setting('requirements_use_wget', default='0'), Setting('base_port', inherit_config=('general', 'base_port'), help='The base port to use for application (each application is an offset from this port)'), Setting('var', default='{{env.base_path}}/var', inherit_config=('general', 'var'), help='The location where persistent files (persistent across builds) are kept'), Setting('etc_svn_repo', inherit_config=('general', 'etc_repository'), default='https://svn.openplans.org/config/', help='Parent directory where the configuration that will go in etc/ comes from'), Setting('etc_svn_subdir', default='{{env.hostname}}-{{os.path.basename(env.base_path)}}', inherit_config=('general', 'etc_svn_subdir'), help='svn subdirectory where data configuration is kept (will be created if necessary)'), Setting('db_prefix', default='{{re.sub(r"\W+", "_", os.path.basename(env.base_path))}}_', inherit_config=('general', 'db_prefix'), help='The prefix to use for all database names'), Setting('find_links', default='http://dist.socialplanning.org/eggs', help='Custom locations for distutils and easy_install to look in'), Setting('projtxt', default='{{project.req_settings.get("projtxt", "project")}}', help='Displayed name for opencore project/group'), Setting('projprefs', default='{{project.req_settings.get("projprefs", "Preferences")}}', help='Displayed name for opencore project/group settings'), Setting('localbuild', inherit_config=('general', 'localbuild'), default='False', help="Specifies whether this is a single developer's build"), Setting('num_extra_zopes', inherit_config=('general', 'num_extra_zopes'), default='0', help="How many additional Zope instances (besides the primary instance) are deployed in this stack"), Setting('spec', default='requirements/fassembler-req.txt', help="Requirements profile for any add-on packages to install in " \ "the Fassembler environment, providing additional build projects"), ] actions = [ CheckBasePorts(), tasks.CopyDir('Create layout', os.path.join(project_base_dir, 'base-layout'), './'), DeleteBuildIniIfNecessary(), tasks.SvnCheckout('Check out etc/', '{{config.etc_svn_subdir}}', 'etc/', base_repository='{{config.etc_svn_repo}}', on_create_set_props={'svn:ignore': 'projects.txt\n'}, create_if_necessary=True), tasks.FetchRequirements('check out requirements/', '{{config.requirements_svn_repo}}', 'requirements'), EnvironRefresh(), tasks.SaveSetting('Save var setting', {'var': '{{os.path.abspath(config.var)}}'}), tasks.SaveSetting('Save settings', {'base_port': '{{config.base_port}}', 'topp_secret_filename': '{{env.var}}/secret.txt', 'admin_info_filename': '{{env.var}}/admin.txt', 'find_links': '{{config.find_links}}', 'db_prefix': '{{config.db_prefix}}', 'requirements_svn_repo': '{{config.requirements_svn_repo}}', 'projtxt': '{{config.projtxt}}', 'projprefs': '{{config.projprefs}}', 'etc_svn_subdir': '{{config.etc_svn_subdir}}', 'localbuild': '{{config.localbuild}}', 'num_extra_zopes': '{{config.num_extra_zopes}}', }, overwrite=True, validators={ 'db_prefix': validate_db_prefix, 'num_extra_zopes': validate_num_extra_zopes }, ), tasks.SaveSetting( 'Save google maps API key settings', {'openplans.org': 'ABQIAAAAPg0JzaavflEP5HFbvAW11BTB3-H4wTAao1hskyzZKyTqTR1AJRQIyIkPAwUg3Qm5pFsqk78fbsrjDQ', 'localhost': 'ABQIAAAACgq_R1LiJejH1-2eRRyQvBTwM0brOpm-All5BF6PoaKBxRWWERRkYcknpt7YAYi-YjtUb5J69-e2Hg', 'nohost': 'bogus_key_used_for_tests', 'dev.nycstreets.org': 'ABQIAAAACgq_R1LiJejH1-2eRRyQvBQ42FaFWNur_4XCSEHkUOZhqT-5LhT80_6nqiuC2nvOrzbvOLN0PC7grg', 'dev.yourstreets.org': 'ABQIAAAACgq_R1LiJejH1-2eRRyQvBQbz6J6EYtXVUBa7BucdbOEH1SrphRUT2-E4Pe2M5U4iDeS9qzQXHoT1A', }, section='google_maps_keys', overwrite=False), tasks.EnsureDir('Make sure var directory exists', '{{env.var}}', svn_add=False), tasks.EnsureFile('Write OpenCore shared secret to var/secret.txt if it does not exist', '{{env.var}}/secret.txt', '{{env.random_string(40)}}', overwrite=False), EnsureAdminFile('Write Zope administrator login to var/admin.txt if it does not exist'), tasks.VirtualEnv(path='fassembler', never_create_virtualenv=True), tasks.InstallSpecIfPresent('Install Fassembler add-on packages', '{{config.spec}}'), ]
class CabochonProject(Project): """ Install Cabochon """ depends_on_projects = ['fassembler:topp'] name = 'cabochon' title = 'Install Cabochon' settings = [ Setting('use_pip', default='1', help="Whether to install with pip or easy_install"), Setting( 'db_sqlobject', default= 'mysql://{{config.db_username}}:{{config.db_password}}@{{config.db_host}}/{{config.db_name}}?charset=utf8', help='Full SQLObject connection string for database'), Setting('db_username', default='cabochon', help='Database connection username'), Setting('db_password', default='cabochon', help='Database connection password'), Setting('db_host', default='localhost', help='Host where database is running'), Setting( 'db_name', default= '{{env.config.getdefault("general", "db_prefix", "")}}cabochon', help='Name of database'), Setting( 'db_test_sqlobject', default= 'mysql://{{config.db_username}}:{{config.db_password}}@{{config.db_host}}/{{config.db_test_name}}', help='Full SQLObject connection string for test database'), Setting('db_test_name', default='cabochon_test', help='Name of the test database'), Setting('db_root_password', default='{{env.db_root_password}}', help='Database root password'), #Setting('cabochon_repo', # default='https://svn.openplans.org/svn/Cabochon/trunk', # help='svn location to install Cabochon from'), Setting('port', default='{{env.base_port+int(config.port_offset)}}', help='Port to install Cabochon on'), Setting('port_offset', default='6', help='Offset from base_port for Cabochon'), Setting('host', default='localhost', help='Host to serve on'), Setting('spec', default='requirements/cabochon-req.txt', help='Specification of packages to install'), Setting('cabochon_user_info', default='{{env.var}}/cabochon-password.txt', help='The cabochon admin user info'), ] actions = [ tasks.VirtualEnv(), tasks.InstallSpec('Install Cabochon', '{{config.spec}}'), tasks.InstallPasteConfig( path='cabochon/src/cabochon/fassembler_config.ini_tmpl'), tasks.InstallPasteStartup(), tasks.InstallSupervisorConfig(), tasks.CheckMySQLDatabase('Check database exists'), tasks. Script('Run setup-app', [ 'paster', 'setup-app', '{{env.base_path}}/etc/{{project.name}}/{{project.name}}.ini#cabochon' ], use_virtualenv=True, cwd='{{env.base_path}}/{{project.name}}/src/{{project.name}}'), tasks.EnsureFile('Write cabochon_user_info.txt if necessary', '{{config.cabochon_user_info}}', 'cabochon:{{env.random_string(12, "alphanumeric")}}', overwrite=False), tasks.SaveSetting( 'save setting', {'cabochon_user_info': '{{config.cabochon_user_info}}'}), tasks.SaveURI(path='/', public=False), ] depends_on_projects = ['fassembler:topp'] depends_on_executables = ['mysql_config']