38
38
class MainSoftware(object):
39
39
"""Placeholder to represent the main software instead of an addon location.
41
Should just have a singleton instance: :data:`main_software`,
42
whose meaning depends on the concrete recipe class using it.
44
For example, in :class:`anybox.recipe.openerp.server.ServerRecipe`,
45
:data:`main_software` represents the OpenObject server or the OpenERP
46
standard distribution.
51
58
"""Base class for other recipes.
53
60
It implements notably fetching of the main software part plus addons.
54
The ``sources`` attributes is a dict storing how to fetch the main software
55
part and specified addons. It has the following structure:
57
local path -> (type, location_spec, options).
59
where local path is the ``main_software`` object for the main software
60
part, and otherwise a local path to an addons container.
65
- one of the supported vcs
67
location_spec is, depending on the type, a tuple specifying how to
68
fetch : (url, None), or (vcs_url, vcs_revision) or None
70
addons options are typically used to specify that the addons directory
71
is actually a subdir of the specified one.
62
The :attr:`sources` attribute is a ``dict`` storing how to fetch the main
63
software part and the specified addons, with the following structure:
65
``local path -> (type, location_spec, options)``, in which:
67
:local path: is either the :data:`main_software` singleton
68
(see :class:`MainSoftware`) or a local path to an
74
* one of the supported vcs
76
:location_spec: is, depending on the type, a tuple specifying how
79
``(url, None)``, or ``(vcs_url, vcs_revision)``
81
:addons options: are typically used to specify that the addons
82
directory is actually a subdir of the specified one.
84
VCS support classes (see
85
:mod:`anybox.recipe.openerp.vcs`) can implemented their
164
179
self.parse_revisions(options)
166
181
def parse_version(self):
167
"""Set the main software in ``sources`` and related attributes.
182
"""Set the main software in :attr:`sources` and related attributes.
169
184
self.version_wanted = self.options.get('version')
170
185
if self.version_wanted is None:
438
453
os.putenv('PYTHONPATH', pythonpath_bak)
440
455
def parse_addons(self, options):
441
"""Parse the addons options into the ``sources`` attribute.
456
"""Parse the addons options into :attr:`sources`.
443
See ``BaseRecipe`` docstring for details about the ``sources`` dict.
458
See :class:`BaseRecipe` for the structure of :attr:`sources`.
446
461
for line in options.get('addons', '').split(os.linesep):
462
477
self.sources[addons_dir] = (loc_type, location_spec, options)
464
479
def parse_revisions(self, options):
465
"""Parse revisions options and update the ``sources`` attribute.
480
"""Parse revisions options and update :attr:`sources`.
467
It is assumed that ``sources`` has already been populated, and
468
notably has a main_software part.
482
It is assumed that :attr:`sources` has already been populated, and
483
notably has a :data:`main_software` entry.
469
484
This allows for easy fixing of revisions in an extension buildout
486
See :class:`BaseRecipe` for the structure of :attr:`sources`.
471
488
for line in options.get('revisions', '').split(os.linesep):
472
489
# GR inline comment should have not gone through, but sometimes
507
524
def retrieve_addons(self):
508
"""Parse the addons option line, download and return a list of paths.
525
"""Peform all lookup and downloads specified in :attr:`sources`.
510
syntax: repo_type repo_url repo_dir repo_rev [options]
511
or an absolute or relative path
512
options are themselves in the key=value form
527
See :class:`BaseRecipe` for the structure of :attr:`sources`.
514
529
self.addons_paths = []
515
530
for local_dir, source_spec in self.sources.items():
623
638
logger.info("No need to re-download %s", self.archive_path)
625
640
def retrieve_main_software(self):
626
"""install server, webclient or gtkclient."""
641
"""Lookup or fetch the main software.
643
See :class:`MainSoftware` and :class:`BaseRecipe` for explanations.
628
646
source = self.sources[main_software]
629
647
type_spec = source[0]
751
769
def dump_nightly_latest_version(self):
752
770
"""After download/analysis of 'nightly latest', give equivalent spec.
754
return ' '.join((self.nightly_series, 'nightly', self.nightly_version))
772
return ' '.join(('nightly', self.nightly_series, self.nightly_version))
756
774
def freeze_to(self, out_config_path):
757
775
"""Create an extension buildout freezing current revisions & versions.
1142
1160
base_addons = join(self.openerp_dir, 'openerp', 'addons')
1143
1161
if os.path.exists(base_addons):
1144
self.addons_paths.append(base_addons)
1162
self.addons_paths.insert(0, base_addons)
1146
1164
if check_existence:
1147
1165
for path in self.addons_paths: