diff --git a/setup.py b/setup.py index dfe4aee0702f3a62be9c60184bce42f989f2cf29..791de10deb81997ded7e4be955e542b002f11a1c 100755 --- a/setup.py +++ b/setup.py @@ -62,6 +62,7 @@ setup(name=name, 'generic.onetimeupload = slapos.recipe.generic_onetimeupload:Recipe', 'helloworld = slapos.recipe.helloworld:Recipe', 'generic.cloudooo = slapos.recipe.generic_cloudooo:Recipe', + 'cloudooo.test = slapos.recipe.cloudooo_test:Recipe', 'fontconfig = slapos.recipe.fontconfig:Recipe', 'java = slapos.recipe.java:Recipe', 'kumofs = slapos.recipe.kumofs:Recipe', diff --git a/slapos/recipe/cloudooo_test/__init__.py b/slapos/recipe/cloudooo_test/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..2cb6f6863014f705c83b1037e8f949dc58791bdf --- /dev/null +++ b/slapos/recipe/cloudooo_test/__init__.py @@ -0,0 +1,51 @@ +############################################################################## +# +# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## +from slapos.recipe.librecipe import GenericBaseRecipe +import urlparse + +class Recipe(GenericBaseRecipe): + def install(self): + path_list = [] + common_dict = dict( + prepend_path=self.options['prepend-path'], + ) + common_list = [ + "--paster_path", self.options['ooo-paster'], + self.options['configuration-file'] + ] + run_unit_test_path = self.createPythonScript(self.options['run-unit-test'], + __name__ + '.test.runUnitTest', [dict( + call_list=[self.options['run-unit-test-binary'], + ] + common_list, **common_dict)]) + + path_list.append(run_unit_test_path) + path_list.append(self.createPythonScript(self.options['run-test-suite'], + __name__ + '.test.runTestSuite', [dict( + call_list=[self.options['run-test-suite-binary'], + ], **common_dict)])) + + return path_list diff --git a/slapos/recipe/cloudooo_test/test.py b/slapos/recipe/cloudooo_test/test.py new file mode 100644 index 0000000000000000000000000000000000000000..70baa22f5a42427a24caa9cfd345fcd669e2e1f3 --- /dev/null +++ b/slapos/recipe/cloudooo_test/test.py @@ -0,0 +1,64 @@ +############################################################################## +# +# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## +import os +import sys +def runTestSuite(args): + env = os.environ.copy() + d = args[0] + env['PATH'] = ':'.join([d['prepend_path']] + os.environ['PATH'].split(':')) + # Deal with Shebang size limitation + executable_filepath = d['call_list'][0] + file_object = open(executable_filepath, 'r') + line = file_object.readline() + file_object.close() + argument_list = [] + if line[:2] == '#!': + executable_filepath = line[2:].strip() + argument_list.append(executable_filepath) + argument_list.extend(d['call_list']) + argument_list.extend(sys.argv[1:]) + argument_list.append(env) + os.execle(executable_filepath, *argument_list) + +def runUnitTest(args): + env = os.environ.copy() + d = args[0] + env['PATH'] = ':'.join([d['prepend_path']] + os.environ.get('PATH', '').split(':')) + # Deal with Shebang size limitation + executable_filepath = d['call_list'][0] + file_object = open(executable_filepath, 'r') + line = file_object.readline() + file_object.close() + argument_list = [] + if line[:2] == '#!': + executable_filepath = line[2:].strip() + argument_list.append(executable_filepath) + argument_list.extend(d['call_list']) + argument_list.extend(sys.argv[1:]) + argument_list.append(env) + os.execle(executable_filepath, *argument_list) + diff --git a/slapos/recipe/generic_cloudooo/template/cloudooo.cfg.in b/slapos/recipe/generic_cloudooo/template/cloudooo.cfg.in index 156f7e4aeca9507cc84f90c84c8a8e14e592671f..eb20ecdba41aa8661973024badaf782c4e0f861e 100644 --- a/slapos/recipe/generic_cloudooo/template/cloudooo.cfg.in +++ b/slapos/recipe/generic_cloudooo/template/cloudooo.cfg.in @@ -32,6 +32,9 @@ limit_memory_used = 3000 application_hostname = %(ip)s # OpenOffice Port openoffice_port = %(openoffice_port)s + +# PATH is required for imagemagick and others conversors +env-PATH = %(PATH)s # LD_LIBRARY_PATH passed to OpenOffice env-LD_LIBRARY_PATH = %(LD_LIBRARY_PATH)s env-FONTCONFIG_FILE = %(FONTCONFIG_FILE)s @@ -41,12 +44,30 @@ env-FONTCONFIG_FILE = %(FONTCONFIG_FILE)s # It is used to select the handler that will be used in conversion. # Priority matters, first match take precedence on next lines. mimetype_registry = - application/pdf * pdf application/vnd.oasis.opendocument* * ooo application/vnd.sun.xml* * ooo - text/* * ooo - image/* image/* imagemagick + application/pdf text/* pdf + application/pdf * ooo video/* * ffmpeg + audio/* * ffmpeg + application/x-shockwave-flash * ffmpeg + application/ogg * ffmpeg + application/ogv * ffmpeg + image/png image/jpeg imagemagick + image/png * ooo + image/* image/* imagemagick + text/* * ooo + application/zip * ooo + application/msword * ooo + application/vnd* * ooo + application/x-vnd* * ooo + application/postscript * ooo + application/wmf * ooo + application/csv * ooo + application/x-openoffice-gdimetafile * ooo + application/x-emf * ooo + application/emf * ooo + application/octet* * ooo * application/vnd.oasis.opendocument* ooo [server:main] diff --git a/software/cloudooo/instance-cloudoo.cfg.in b/software/cloudooo/instance-cloudoo.cfg.in index 58b620dd2c312c04fe9e918300dadc812335a6ba..e17ad18db5b2cbf6048540f810271b0fcb055976 100644 --- a/software/cloudooo/instance-cloudoo.cfg.in +++ b/software/cloudooo/instance-cloudoo.cfg.in @@ -4,6 +4,8 @@ parts = publish-cloudooo-connection-information cloudooo-instance + cloudooo-test-runner + eggs-directory = {{ eggs_directory }} develop-eggs-directory = {{ develop_eggs_directory }} offline = true @@ -30,6 +32,7 @@ data-directory = ${directory:cloudooo-data} environment = LD_LIBRARY_PATH = {{ parameter_dict['file'] }}/lib:{{ parameter_dict['fontconfig'] }}/lib:{{ parameter_dict['freetype'] }}/lib:{{ parameter_dict['libICE'] }}/lib:{{ parameter_dict['libpng12'] }}/lib:{{ parameter_dict['libSM'] }}/lib:{{ parameter_dict['libX11'] }}/lib:{{ parameter_dict['libXau'] }}/lib:{{ parameter_dict['libXdmcp'] }}/lib:{{ parameter_dict['libXext'] }}/lib:{{ parameter_dict['libxcb'] }}/lib:{{ parameter_dict['libXrender'] }}/lib:{{ parameter_dict['zlib'] }}/lib FONTCONFIG_FILE = ${fontconfig-instance:conf-path} + PATH = ${binary-link:target-directory} # Binary information # cloudooo specific configuration @@ -37,6 +40,19 @@ ooo-binary-path = {{ parameter_dict['libreoffice-bin'] }}/program ooo-paster = {{ bin_directory }}/cloudooo_paster ooo-uno-path = {{ parameter_dict['libreoffice-bin'] }}/basis-link/program +[cloudooo-test-runner] +recipe = slapos.cookbook:cloudooo.test + +prepend-path = ${buildout:bin-directory} +run-unit-test = ${buildout:bin-directory}/runUnitTest +run-test-suite = ${buildout:bin-directory}/runTestSuite + +ooo-paster = ${cloudooo-instance:ooo-paster} +configuration-file = ${cloudooo-instance:configuration-file} + +run-unit-test-binary = {{ bin_directory }}/runCloudoooUnitTest +run-test-suite-binary = {{ bin_directory }}/runCloudoooTestSuite + [fontconfig-instance] recipe = slapos.cookbook:fontconfig conf-path = ${rootdirectory:etc}/font.conf @@ -46,6 +62,22 @@ url-list = {{ json.get('font_url_list', []) | join(' ') }} service-folder = ${basedirectory:services} onetimedownload_path = {{ bin_directory }}/onetimedownload +[binary-link] +recipe = slapos.cookbook:symbolic.link +target-directory = ${rootdirectory:bin} +link-binary = + {{ parameter_dict['coreutils'] }}/bin/basename + {{ parameter_dict['coreutils'] }}/bin/cat + {{ parameter_dict['coreutils'] }}/bin/cp + {{ parameter_dict['coreutils'] }}/bin/ls + {{ parameter_dict['coreutils'] }}/bin/tr + {{ parameter_dict['coreutils'] }}/bin/uname + {{ parameter_dict['imagemagick'] }}/bin/convert + {{ parameter_dict['imagemagick'] }}/bin/identify + {{ parameter_dict['poppler'] }}/bin/pdfinfo + {{ parameter_dict['poppler'] }}/bin/pdftotext + {{ parameter_dict['poppler'] }}/bin/pdftohtml + # rest of parts are candidates for some generic stuff [basedirectory] recipe = slapos.cookbook:mkdirectory @@ -60,3 +92,4 @@ font = ${rootdirectory:srv}/font recipe = slapos.cookbook:mkdirectory etc = ${buildout:directory}/etc srv = ${buildout:directory}/srv +bin = ${buildout:directory}/bin diff --git a/software/cloudooo/instance.cfg.in b/software/cloudooo/instance.cfg.in index 2e4ca32bbf2b201fb2e9f97287c4874b479c03f4..e341a342ebdea59e6b3b9191212579c3db18a309 100644 --- a/software/cloudooo/instance.cfg.in +++ b/software/cloudooo/instance.cfg.in @@ -40,6 +40,9 @@ libXrender = {{ libXrender_location }} zlib = {{ zlib_location }} libreoffice-bin = {{ libreoffice_bin_location }} fonts = {{ fonts_location }} +coreutils = {{ coreutils_location }} +imagemagick = {{ imagemagick_location }} +poppler = {{ poppler_location }} buildout-bin-directory = {{ buildout_bin_directory }} [dynamic-template-cloudooo] diff --git a/software/cloudooo/software.cfg b/software/cloudooo/software.cfg index 8f55779cc32c7bc697445f671bd9c4c1bb50529a..8e63995381fce99516a3f2c9e42eb36e2578debd 100755 --- a/software/cloudooo/software.cfg +++ b/software/cloudooo/software.cfg @@ -68,7 +68,7 @@ context = # XXX: "template.cfg" is hardcoded in instanciation recipe filename = template.cfg template = ${:_profile_base_location_}/instance.cfg.in -md5sum = 5f3efb79caca9f50951bce44e0a0f54a +md5sum = 46a1f4dc69ccf0b42b9d579e34b40df9 extra-context = key buildout_bin_directory buildout:bin-directory key dcron_location dcron:location @@ -93,9 +93,10 @@ extra-context = key poppler_location poppler:location key template_cloudooo template-cloudooo:target key zlib_location zlib:location + key coreutils_location coreutils:location [template-cloudooo] recipe = slapos.recipe.build:download url = ${:_profile_base_location_}/instance-cloudoo.cfg.in -md5sum = ed1c1c1d00a2e12751a4f9da9c165b16 +md5sum = b4692fb5916e997c9766b9d0e1030e6c mode = 640 diff --git a/stack/cloudooo.cfg b/stack/cloudooo.cfg index 2ae13afaf5960d999b765e6e2565fea4f9a805e4..e99a62a30e2d759bbb36b26f618bc80ef2b02981 100755 --- a/stack/cloudooo.cfg +++ b/stack/cloudooo.cfg @@ -28,6 +28,7 @@ extends = ../component/stunnel/buildout.cfg ../component/rdiff-backup/buildout.cfg ../component/dcron/buildout.cfg + ../component/coreutils/buildout.cfg versions = versions @@ -97,9 +98,11 @@ entry-points = main=cloudooo.paster_application:application cloudooo_tester=cloudooo.bin.cloudooo_tester:main runCloudoooUnitTest=cloudooo.tests.runHandlerUnitTest:run + runCloudoooTestSuite=cloudooo.tests.runTestSuite:run scripts = paster=cloudooo_paster runCloudoooUnitTest + runCloudoooTestSuite ugly-depend-on = ${cloudooo:command} ${cloudooo:update-command} [bootstrap2.6]