diff --git a/slapos/recipe/erp5/__init__.py b/slapos/recipe/erp5/__init__.py index c8c810efaf101b39d5c666d95c9567b9018f2958..f1a96ecc4d9ac2a1f6c4de3f5e6a572ea15f9c09 100644 --- a/slapos/recipe/erp5/__init__.py +++ b/slapos/recipe/erp5/__init__.py @@ -36,15 +36,6 @@ import zc.recipe.egg import ConfigParser import re -_isurl = re.compile('([a-zA-Z0-9+.-]+)://').match - -# based on Zope2.utilities.mkzopeinstance.write_inituser -def Zope2InitUser(path, username, password): - open(path, 'w').write('') - os.chmod(path, 0600) - open(path, "w").write('%s:{SHA}%s\n' % ( - username,binascii.b2a_base64(hashlib.sha1(password).digest())[:-1])) - class Recipe(BaseSlapRecipe): def getTemplateFilename(self, template_name): return pkg_resources.resource_filename(__name__, @@ -544,77 +535,6 @@ SSLCARevocationPath %(ca_crl)s""" certificate_authority_path=config['ca_dir'] ) - def installERP5(self): - """ - All zope have to share file created by portal_classes - (until everything is integrated into the ZODB). - So, do not request zope instance and create multiple in the same partition. - """ - # Create instance directories - self.erp5_directory = self.createDataDirectory('erp5shared') - # Create init user - password = self.generatePassword() - # XXX Unhardcoded me please - user = 'zope' - Zope2InitUser( - os.path.join(self.erp5_directory, "inituser"), user, password) - - self._createDirectory(self.erp5_directory) - for directory in ( - 'Constraint', - 'Document', - 'Extensions', - 'PropertySheet', - 'import', - 'lib', - 'tests', - 'Products', - 'etc', - ): - self._createDirectory(os.path.join(self.erp5_directory, directory)) - self._createDirectory(os.path.join(self.erp5_directory, 'etc', - 'package-includes')) - - # Symlink to BT5 repositories defined in instance config. - # Those paths will eventually end up in the ZODB, and having symlinks - # inside the XXX makes it possible to reuse such ZODB with another software - # release[ version]. - # Note: this path cannot be used for development, it's really just a - # read-only repository. - repository_path = os.path.join(self.var_directory, "bt5_repository") - if not os.path.isdir(repository_path): - os.mkdir(repository_path) - self.path_list.append(repository_path) - self.bt5_repository_list = [] - append = self.bt5_repository_list.append - for repository in self.options.get('bt5_repository_list', '').split(): - repository = repository.strip() - if not repository: - continue - - if _isurl(repository) and not repository.startswith("file://"): - # XXX: assume it's a valid URL - append(repository) - continue - - if repository.startswith('file://'): - repository = repository.replace('file://', '', '') - - if os.path.isabs(repository): - repo_id = hashlib.sha1(repository).hexdigest() - link = os.path.join(repository_path, repo_id) - if os.path.lexists(link): - if not os.path.islink(link): - raise zc.buildout.UserError( - 'Target link already %r exists but it is not link' % link) - os.unlink(link) - os.symlink(repository, link) - self.logger.debug('Created link %r -> %r' % (link, repository_path)) - # Always provide a URL-Type - append("file://" + link) - - return user, password - def installERP5Site(self, user, password, zope_access, mysql_conf, conversion_server_conf=None, memcached_conf=None, kumo_conf=None, diff --git a/slapos/recipe/generic_zope/__init__.py b/slapos/recipe/generic_zope/__init__.py index b7e48673bed75aef4087546a65ddfa47f02f7ce3..3ba81db9705163f597038795f30ae0ee53ebb8ef 100644 --- a/slapos/recipe/generic_zope/__init__.py +++ b/slapos/recipe/generic_zope/__init__.py @@ -25,15 +25,75 @@ # ############################################################################## from slapos.recipe.librecipe import GenericBaseRecipe +import binascii +import hashlib +import os +import re +import zc.buildout + +_isurl = re.compile('([a-zA-Z0-9+.-]+)://').match + +# based on Zope2.utilities.mkzopeinstance.write_inituser +def Zope2InitUser(path, username, password): + open(path, 'w').write('') + os.chmod(path, 0600) + open(path, "w").write('%s:{SHA}%s\n' % ( + username,binascii.b2a_base64(hashlib.sha1(password).digest())[:-1])) class Recipe(GenericBaseRecipe): def _options(self, options): + options['password'] = self.generatePassword() options['deadlock-password'] = self.generatePassword() def install(self): - """ Install a single Zope instance without ZEO Server. + """ + All zope have to share file created by portal_classes + (until everything is integrated into the ZODB). + So, do not request zope instance and create multiple in the same partition. """ path_list = [] + Zope2InitUser( + os.path.join(self.erp5_directory, "inituser"), self.options['user'], + self.options['password']) + + # Symlink to BT5 repositories defined in instance config. + # Those paths will eventually end up in the ZODB, and having symlinks + # inside the XXX makes it possible to reuse such ZODB with another software + # release[ version]. + # Note: this path cannot be used for development, it's really just a + # read-only repository. + repository_path = os.path.join(self.var_directory, "bt5_repository") + if not os.path.isdir(repository_path): + os.mkdir(repository_path) + path_list.append(repository_path) + self.bt5_repository_list = [] + append = self.bt5_repository_list.append + for repository in self.options.get('bt5_repository_list', '').split(): + repository = repository.strip() + if not repository: + continue + + if _isurl(repository) and not repository.startswith("file://"): + # XXX: assume it's a valid URL + append(repository) + continue + + if repository.startswith('file://'): + repository = repository.replace('file://', '', '') + + if os.path.isabs(repository): + repo_id = hashlib.sha1(repository).hexdigest() + link = os.path.join(repository_path, repo_id) + if os.path.lexists(link): + if not os.path.islink(link): + raise zc.buildout.UserError( + 'Target link already %r exists but it is not link' % link) + os.unlink(link) + os.symlink(repository, link) + self.logger.debug('Created link %r -> %r' % (link, repository_path)) + # Always provide a URL-Type + append("file://" + link) + # Create zope configuration file zope_config = dict( products=self.options['products'], diff --git a/software/erp5/instance-zope.cfg b/software/erp5/instance-zope.cfg index 494cb77e104f534a65fe50eedb41c84f42e435aa..15488d24b46fd0241db462cf975470a0851219e4 100644 --- a/software/erp5/instance-zope.cfg +++ b/software/erp5/instance-zope.cfg @@ -112,13 +112,17 @@ backup = $${rootdirectory:srv}/backup/ [directory] recipe = slapos.cookbook:mkdirectory zodb = $${rootdirectory:srv}/zodb/ -instance = $${rootdirectory:srv}/zope/ +instance = $${rootdirectory:srv}/erp5shared/ instance-etc = $${:instance}/etc +instance-etc-package-include = $${:instance}/etc/package-include instance-Document = $${:instance}/Document instance-PropertySheet = $${:instance}/PropertySheet instance-Products = $${:instance}/Products instance-Extensions = $${:instance}/Extensions instance-Constraint = $${:instance}/Constraint +instance-import = $${:instance}/import +instance-lib = $${:instance}/lib +instance-tests = $${:instance}/tests cron-entries = $${rootdirectory:etc}/cron.d/ crontabs = $${rootdirectory:etc}/crontabs/ cronstamps = $${rootdirectory:etc}/cronstamps/ diff --git a/software/erp5/software.cfg b/software/erp5/software.cfg index 65c2d0b5000624725797ad04d277bdd146911b03..a77dd906ce1b37fe0023a05686613b05d7928e05 100644 --- a/software/erp5/software.cfg +++ b/software/erp5/software.cfg @@ -32,7 +32,7 @@ mode = 0644 [template-zope] recipe = slapos.recipe.template url = ${:_profile_base_location_}/instance-zope.cfg -md5sum = d454beae74f7e52c4c2b3b3a11abcf04 +md5sum = 538533a9b2d916c85380c9cb9388516f output = ${buildout:directory}/template-zope.cfg mode = 0644