Commit 12a26264 authored by Jondy Zhao's avatar Jondy Zhao Committed by Cédric de Saint Martin

Add option 'promises'

parent 864e286f
...@@ -158,6 +158,14 @@ Supported options ...@@ -158,6 +158,14 @@ Supported options
compile directory is stored in ``options['compile-directory']``. compile directory is stored in ``options['compile-directory']``.
Accepted values are ``true`` or ``false``, defaults to ``false``. Accepted values are ``true`` or ``false``, defaults to ``false``.
``promises``
List the pathes and files should be existed after install part. The
file or path must be absolute path. One line one item
If any item doesn't exist, the recipe shows a warning message. The
default value is empty.
``dependencies`` ``dependencies``
List all the depended parts: List all the depended parts:
...@@ -279,7 +287,7 @@ Let's create a buildout to build and install the package. ...@@ -279,7 +287,7 @@ Let's create a buildout to build and install the package.
>>> write('buildout.cfg', >>> write('buildout.cfg',
... """ ... """
... [buildout] ... [buildout]
... newest = false ... newest = true
... parts = package ... parts = package
... ...
... [package] ... [package]
...@@ -298,6 +306,33 @@ default build options. ...@@ -298,6 +306,33 @@ default build options.
building package building package
installing package installing package
Check option "promises"
>>> write('buildout.cfg',
... """
... [buildout]
... newest = false
... parts = packagex
...
... [packagex]
... recipe = slapos.recipe.cmmi
... url = file://%s/package-0.0.0.tar.gz
... promises = /usr/bin/myfoo
... """ % src)
This will download, extract and build our demo package with the
default build options.
>>> print system(buildout)
Uninstalling package.
Installing packagex.
packagex: [ENV] TMP = /sample_buildout/parts/packagex/tmp
packagex: Extracting package to /sample_buildout/parts/packagex__compile__
configure --prefix=/sample_buildout/parts/packagex
building package
installing package
packagex: could not find promise "/usr/bin/myfoo"
As we can see the configure script was called with the ``--prefix`` As we can see the configure script was called with the ``--prefix``
option by default followed by calls to ``make`` and ``make install``. option by default followed by calls to ``make`` and ``make install``.
......
...@@ -43,6 +43,7 @@ class Recipe(object): ...@@ -43,6 +43,7 @@ class Recipe(object):
options['prefix'] = options['location'] if prefix == '' else prefix options['prefix'] = options['location'] if prefix == '' else prefix
options['url'] = options.get('url', '').strip() options['url'] = options.get('url', '').strip()
options['path'] = options.get('path', '').strip() options['path'] = options.get('path', '').strip()
options['promises'] = options.get('promises', '')
# Check dependencies, all the dependent parts will be installed first. It # Check dependencies, all the dependent parts will be installed first. It
# seems once part is referenced, for example, self.buildout[part], it will # seems once part is referenced, for example, self.buildout[part], it will
...@@ -180,6 +181,15 @@ class Recipe(object): ...@@ -180,6 +181,15 @@ class Recipe(object):
raise zc.buildout.UserError('System error') raise zc.buildout.UserError('System error')
return files.split() return files.split()
def check_promises(self):
result = True
log = logging.getLogger(self.name)
for path in self.options['promises'].splitlines():
if not os.path.exists(path):
result = False
log.warning('could not find promise "%s"' % path)
return result
def call_script(self, script): def call_script(self, script):
"""This method is copied from z3c.recipe.runscript. """This method is copied from z3c.recipe.runscript.
...@@ -342,6 +352,9 @@ class Recipe(object): ...@@ -342,6 +352,9 @@ class Recipe(object):
os.chdir(current_dir) os.chdir(current_dir)
shutil.rmtree(tmp_path) shutil.rmtree(tmp_path)
# Check promises
self.check_promises()
if self.options['url']: if self.options['url']:
if self.options.get('keep-compile-dir', if self.options.get('keep-compile-dir',
self.buildout['buildout'].get('keep-compile-dir', '')).lower() in ('true', 'yes', '1', 'on'): self.buildout['buildout'].get('keep-compile-dir', '')).lower() in ('true', 'yes', '1', 'on'):
......
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