Commit 772a4579 authored by Julien Muchembled's avatar Julien Muchembled

Small clean-up

parent 2b2df332
......@@ -31,9 +31,9 @@ class Recipe(object):
self.name = name
log = logging.getLogger(self.name)
# Merge options if there is a matched platform section
platform_options = self.buildout.get(
platform_options = buildout.get(
"%s:%s:%s" % (name, sys.platform, self.get_machine()),
self.buildout.get("%s:%s" % (name, sys.platform)))
buildout.get("%s:%s" % (name, sys.platform)))
if platform_options is None:
self.original_options = options
else:
......@@ -43,7 +43,8 @@ class Recipe(object):
shared = ((options.get('shared', '').lower() == 'true') and
buildout['buildout'].get('shared-part-list', None))
if shared:
self._signature = slapos.recipe.downloadunpacked.Signature('.slapos.recipe.cmmi.signature')
self._signature = slapos.recipe.downloadunpacked.Signature(
'.slapos.recipe.cmmi.signature')
buildout_directory = buildout['buildout']['directory']
profile_base_location = options.get('_profile_base_location_', '')
for k, v in sorted(options.items()):
......@@ -52,24 +53,22 @@ class Recipe(object):
v = v.replace(profile_base_location, '${:_profile_base_location_}')
self._signature.update(k, v)
shared_parts = [part.strip().rstrip('/')
for part in buildout['buildout']['shared-part-list'].splitlines()
if part.strip()]
for shared in shared_parts:
shared = os.path.join(os.path.join(shared, self.name), self._signature.hexdigest())
if os.path.exists(shared):
break
else:
shared = os.path.join(os.path.join(shared_parts[-1], self.name), self._signature.hexdigest())
log.info('shared directory %s set for %s', shared, self.name)
signature_digest = self._signature.hexdigest()
for x in shared.splitlines():
x = x.strip().rstrip('/')
if x:
shared = os.path.join(os.path.join(x, self.name),
signature_digest)
if os.path.exists(shared):
break
log.info('shared at %s', shared)
else:
shared = ''
options['shared'] = shared
default_location = options['default-location'] = os.path.join(
location = options['location'] = shared or os.path.join(
buildout['buildout']['parts-directory'],
self.name) if shared == '' else shared
options['location'] = options['default-location']
self.name)
prefix = options.get('prefix', '').strip()
if prefix == '':
......@@ -78,7 +77,7 @@ class Recipe(object):
self.buildout_prefix = ''
else:
self.buildout_prefix = ''
options['prefix'] = options['location'] if prefix == '' else prefix
options['prefix'] = prefix or location
options['url'] = options.get('url', '').strip()
options['path'] = options.get('path', '').strip()
options['promises'] = options.get('promises', '')
......@@ -108,13 +107,13 @@ class Recipe(object):
raise zc.buildout.UserError('You must provide either "url" or "path".')
if options['url']:
options['compile-directory'] = '%s__compile__' % options['default-location']
options['compile-directory'] = location + '__compile__'
else:
options['compile-directory'] = options['path']
for k, v in list(options.items()):
if '@@LOCATION@@' in v:
options[k] = v.replace('@@LOCATION@@', default_location)
options[k] = v.replace('@@LOCATION@@', location)
self.environ = {}
self.original_environment = os.environ.copy()
......@@ -123,7 +122,7 @@ class Recipe(object):
if environment_section and environment_section in buildout:
# Use environment variables from the designated config section.
self.environ.update(buildout[environment_section])
for variable in self.options.get('environment', '').splitlines():
for variable in options.get('environment', '').splitlines():
if variable.strip():
try:
key, value = variable.split('=', 1)
......@@ -138,7 +137,7 @@ class Recipe(object):
self.environ['CXXFLAGS'] = '-I%s/include %s' % (self.buildout_prefix, self.environ.get('CXXFLAGS', ''))
self.environ['LDFLAGS'] = '-L%s/lib %s' % (self.buildout_prefix, self.environ.get('LDFLAGS', ''))
if self.options.get('configure-command', '').strip() == 'cygport':
if options.get('configure-command') == 'cygport':
self.environ.setdefault('CYGCONF_PREFIX', options['prefix'])
# Extrapolate the environment variables using values from the current
......@@ -324,15 +323,14 @@ class Recipe(object):
compile_dir = self.options['path']
current_dir = os.getcwd()
location = self.options['default-location']
location = self.options['location']
# Clean the install directory if it already exists as it is
# a remain from a previous failed installation
if os.path.exists(location):
shutil.rmtree(location)
os.mkdir(location)
os.chdir(compile_dir)
try:
os.chdir(compile_dir)
try:
# We support packages that either extract contents to the $PWD
# or alternatively have a single directory.
......
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