Commit d6ddf139 authored by Jondy Zhao's avatar Jondy Zhao

Set the value of 'location' as 'share' in case 'share' is not blank

parent ae9f451f
......@@ -37,6 +37,11 @@ Supported options
In share mode, ``promises`` should be set so that recipe can tell
whether the package is installed. Otherwise nohting to do.
If ``share`` is not empty, ``location`` will be set to value of
``share``, and remove trailing '/'. So in case ``share`` is '/',
``location`` will be set to blank. Thus any reference like
"${part:location}/bin" in other parts will get the correct value.
This option is experiment now. Recipe doesn't try to set prefix
with the valule of this opton in the configure or make command,
you should specify them accordingly by yourself.
......@@ -1078,19 +1083,19 @@ Use option ``share`` to install a share pacakge.
... [package]
... recipe = slapos.recipe.cmmi
... url = file://%s/package-0.0.0.tar.gz
... share = /usr/local/bin
... promises = ${:share}/mypackage.exe
... share = /usr/local
... promises = ${:share}/bin/mypackage.exe
... """ % (src,))
>>> print system(buildout)
Uninstalling package.
Uninstalling package-2.
Installing package.
package: Checking whether package is installed at share path: /usr/local/bin
package: Checking whether package is installed at share path: /usr/local
package: could not find promise "/usr/local/bin/mypackage.exe"
package: [ENV] TMP = /sample_buildout/parts/package/tmp
package: Extracting package to /sample_buildout/parts/package__compile__
configure --prefix=/sample_buildout/parts/package
configure --prefix=/usr/local
building package
installing package
package: could not find promise "/usr/local/bin/mypackage.exe"
......
......@@ -30,9 +30,13 @@ class Recipe(object):
self.original_options = options.copy()
options.update(platform_options)
options['location'] = os.path.join(
options['share'] = options.get('share', '').strip()
options['default-location'] = os.path.join(
buildout['buildout']['parts-directory'],
self.name)
share = options['share']
options['location'] = options['default-location'] if share == '' else share.rstrip('/')
prefix = options.get('prefix', '').strip()
if prefix == '':
prefix = self.buildout_prefix = buildout['buildout'].get('prefix', '').strip()
......@@ -44,7 +48,6 @@ class Recipe(object):
options['url'] = options.get('url', '').strip()
options['path'] = options.get('path', '').strip()
options['promises'] = options.get('promises', '')
options['share'] = options.get('share', '').strip()
# Check dependencies, all the dependent parts will be installed first. It
# seems once part is referenced, for example, self.buildout[part], it will
......@@ -71,7 +74,7 @@ class Recipe(object):
raise zc.buildout.UserError('You must provide either "url" or "path".')
if options['url']:
options['compile-directory'] = '%s__compile__' % options['location']
options['compile-directory'] = '%s__compile__' % options['default-location']
else:
options['compile-directory'] = options['path']
......@@ -101,7 +104,7 @@ class Recipe(object):
# environment.
for key in self.environ:
self.environ[key] = self.environ[key] % os.environ
self.environ['TMP'] = os.path.join(options['location'], 'tmp')
self.environ['TMP'] = os.path.join(options['default-location'], 'tmp')
def augmented_environment(self):
"""Returns a dictionary containing the current environment variables
......@@ -286,7 +289,7 @@ class Recipe(object):
current_dir = os.getcwd()
try:
os.mkdir(self.options['location'])
os.mkdir(self.options['default-location'])
except OSError as e:
if e.errno == errno.EEXIST:
pass
......@@ -377,5 +380,5 @@ class Recipe(object):
del self.options['compile-directory']
if self.options['share'] == '':
parts.append(self.options['location'])
parts.append(self.options['default-location'])
return parts
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