Commit 9a2415db authored by Julien Muchembled's avatar Julien Muchembled

Remove slapos.recipe.cmmi way of having conditional sections

It was broken because it conflicts with buildout,
which has similar feature.
parent d6fe5d64
...@@ -214,29 +214,6 @@ Supported options ...@@ -214,29 +214,6 @@ Supported options
both ``environment-section`` and ``environment`` are provided the values from both ``environment-section`` and ``environment`` are provided the values from
the former will be overridden by the latter allowing per-part customization. the former will be overridden by the latter allowing per-part customization.
The recipe uses separated part to support custom options in different
platforms. These platform's part has a pattern "part:platform" or
"part:platform:arch".
arch could be 'x86', 'amd64', 'ia64' ... which equals
platform.machine().
platform could be 'linux', 'cygwin', 'macos', 'sunos', 'freebsd',
'netbsd', 'unixware' ... which equals a formatted sys.platform.
For example::
[bzip2]
recipe = slapos.recipe.cmmi
[bzip2:cygwin]
patches = cygwin-bzip2-1.0.6.src.patch
All the options in the [part:platform] have high priority level.
The recipe first searches the exact match, if no found. Ignore arch
and search again, if still found nothing. Use no platform part.
Additionally, the recipe honors the ``download-cache`` option set Additionally, the recipe honors the ``download-cache`` option set
in the ``[buildout]`` section and stores the downloaded files under in the ``[buildout]`` section and stores the downloaded files under
it. If the value is not set a directory called ``downloads`` will be it. If the value is not set a directory called ``downloads`` will be
...@@ -632,46 +609,6 @@ shell command in the corresponding stage. ...@@ -632,46 +609,6 @@ shell command in the corresponding stage.
package: Executing post-install package: Executing post-install
Finished. Finished.
Building in multi-platforms
===========================
The recipe can specify build options for each platform. For example,
>>> write('buildout.cfg',
... """
... [buildout]
... newest = false
... parts = package
...
... [package]
... recipe = slapos.recipe.cmmi
... url = file://%s
... pre-configure = echo "Configure in common platform"
... post-install = echo "Finished."
...
... [package:cygwin]
... pre-configure = echo "Configure in the CYGWIN platform"
... pre-install = echo "Installing in the CYGWIN"
... post-install = echo -n "CYGWIN " && ${package:post-install}
... """ % package_path)
In the linux, the recipe gets the options from part 'package', there
are only ``pre-configure`` and ``post-install``. the output will be
#>>> print(system(buildout))
Uninstalling package.
Installing package.
package: Executing pre-configure
Configure part: Configure in common platform
configure --prefix=/sample_buildout/parts/package
building package
installing package
package: Executing post-install
Finished.
In the cygwin, the recipe merges the options in the parts 'package'
and 'package:cygwin'.
Union prefix Union prefix
============ ============
......
...@@ -8,7 +8,6 @@ import stat ...@@ -8,7 +8,6 @@ import stat
import subprocess import subprocess
import sys import sys
from hashlib import md5 from hashlib import md5
from platform import machine as platform_machine
import pkg_resources import pkg_resources
import zc.buildout import zc.buildout
from zc.buildout import UserError from zc.buildout import UserError
...@@ -40,12 +39,6 @@ class Recipe(object): ...@@ -40,12 +39,6 @@ class Recipe(object):
self.buildout = buildout self.buildout = buildout
self.name = name self.name = name
self.logger = logging.getLogger(self.name) self.logger = logging.getLogger(self.name)
# Merge options if there is a matched platform section
platform_options = buildout.get(
"%s:%s:%s" % (name, sys.platform, self.get_machine()),
buildout.get("%s:%s" % (name, sys.platform)))
if platform_options is not None:
options.update(platform_options)
environment_section = options.get('environment-section') environment_section = options.get('environment-section')
self.environ = ( self.environ = (
...@@ -145,37 +138,6 @@ class Recipe(object): ...@@ -145,37 +138,6 @@ class Recipe(object):
sig = zc.buildout.buildout._dists_sig(pkg_resources.working_set.resolve([req])) sig = zc.buildout.buildout._dists_sig(pkg_resources.working_set.resolve([req]))
return ' '.join(sig) return ' '.join(sig)
def get_platform(self):
# Get value of sys.platform
for platform in ['linux', 'cygwin', 'beos', 'darwin', 'atheos', 'osf1',
'netbsd', 'openbsd', 'freebsd', 'unixware', 'sunos']:
if sys.platform.startswith(platform):
return platform
return sys.platform
def get_machine(self):
arch = platform_machine()
# i?86-*-* : x86
if arch in ('i386', 'i586', 'i686'):
return 'x86'
# x86_64-*-* : amd64
elif arch == 'x86_64':
return 'amd64'
# ia64-*-* : ia64
# and others
return arch
def get_platform_options(self):
platform_part = self.get_platform() + '-' + self.name
part_list = [part for part in self.buildout if part.endswith(platform_part)]
if part_list[:1]:
arch_prefix = self.get_machine() + '-'
for part in part_list:
if part.startswith(arch_prefix):
return self.buildout[part]
else:
return self.buildout.get(platform_part)
def download_file(self, url): def download_file(self, url):
download = zc.buildout.download.Download( download = zc.buildout.download.Download(
self.buildout['buildout'], hash_name=True) self.buildout['buildout'], hash_name=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment