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