Commit 47bf55f2 authored by Łukasz Nowak's avatar Łukasz Nowak

Implement more of compatibility with known recipes.

Squashed commit of the following:

commit 2d7dc0b3
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 17:22:13 2011 +0200

    Explain more about patches.

commit d5df4cdc
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 17:18:55 2011 +0200

    Provide better looking patches.

commit c6befb05
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 17:15:32 2011 +0200

    Support make-command and make-options.

    Fix configure-command.

commit d2212cb7
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 17:04:05 2011 +0200

    Allow to override configure command.

commit 4321b38a
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:56:49 2011 +0200

    Share applyPatchList with in base class.

commit 4a2ea3b3
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:56:29 2011 +0200

    Support no md5sum.

commit 2cd36cb7
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:56:16 2011 +0200

    Show how to patch.

commit 8cd9ea9c
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:53:45 2011 +0200

    Allow options per patch.

commit 84fea623
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:48:47 2011 +0200

    Allow patching.

commit 8934eb92
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:30:46 2011 +0200

    Allow to keep directories in case of error.

    Default is to remove.

commit 74d0b2bd
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:24:49 2011 +0200

    Allow to have a=b=c, where a is key and b=c is value.

commit 034c2381
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:17:07 2011 +0200

    Another typo.

commit f5abcde0
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:15:44 2011 +0200

    Follow fixed typo.

commit 5b950e26
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:14:35 2011 +0200

    Extract does not need md5sum.

commit 6f725632
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:14:14 2011 +0200

    Pass md5sum directly.

commit 9f42d22a
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:13:53 2011 +0200

    Allow to pass empty md5sum.

commit c91fafb1
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:13:15 2011 +0200

    Fix typos.

commit 8919378d
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:12:31 2011 +0200

    Fix examples.
parent 3bad2372
......@@ -19,10 +19,10 @@ Example buildout::
[zlib]
# Use standard configure, make, make install way
recipe = slapos.cookbook:build
recipe = slapos.recipe.build:cmmi
url = http://prdownloads.sourceforge.net/libpng/zlib-1.2.5.tar.gz?download
md5sum = c735eab2d659a96e5a594c9e8541ad63
slapos_promisee =
slapos_promise =
directory:include
file:include/zconf.h
file:include/zlib.h
......@@ -39,13 +39,13 @@ Example buildout::
file:share/man/man3/zlib.3
[file]
recipe = slapos.cookbook:buildcmmi
recipe = slapos.recipe.build:cmmi
url = ftp://ftp.astron.com/pub/file/file-5.04.tar.gz
md5sum = accade81ff1cc774904b47c72c8aeea0
environment =
CPPFLAGS=-I${zlib:location}/include
LDFLAGS=-L${zlib:location}/lib -Wl,-rpath -Wl,${zlib:location}/lib
slapos_promisee =
slapos_promise =
directory:bin
dynlib:bin/file linked:libz.so.1,libc.so.6,libmagic.so.1 rpath:${zlib:location}/lib,!/lib
directory:include
......@@ -70,7 +70,7 @@ Example buildout::
[somethingelse]
# default way with using script
recipe = slapos.cookbook:build
recipe = slapos.recipe.build
url_0 = http://host/path/file.tar.gz
md5sum = 9631070eac74f92a812d4785a84d1b4e
script =
......@@ -79,12 +79,41 @@ Example buildout::
unpack(%(url_0), strip_path=True)
execute('make')
execute('make install DEST=%(location)s')
slapos_promisee =
slapos_promise =
...
[with_patches]
recipe = slapos.recipe.build:cmmi
md5sum = 1b845a983a50b8dec0169ac48479eacc
url = http://downloads.sourceforge.net/project/w3m/w3m/w3m-0.5.3/w3m-0.5.3.tar.gz
configure-options =
--disable-nls
--disable-image
--disable-dict
--disable-xface
--disable-mouse
--disable-nntp
--disable-help-cgi
--disable-external-uri-loader
--disable-w3mmailer
# default patch options
patch-options =
-p1
# patches can be local files, then can have (optional) md5sum, they can have
# own options added
patches =
/path/to/local/file
/path/to/local/file2 75422a6f7f671b3a6d9add6724cc0945
http://downloaded/ 75422a6f7f671b3a6d9add6724cc0945
http://download/ uNkNoWn -p8
http://downloaded2/ 75422a6f7f671b3a6d9add6724cc0945 -p2
[multiarchitecture]
recipe = slapos.recipe.build
slapos_promisee =
slapos_promise =
...
x86 = http://host/path/x86.zip
x86-64 = http://host/path/x64.zip
......@@ -98,7 +127,7 @@ TODO:
* add linking suport, buildout definition:
slapos_link = <relative/path> [optional-path
slapos_link = <relative/path> [optional-path]
can be used as::
......
......@@ -102,6 +102,8 @@ def guessPlatform():
return target
TRUE_LIST = ('y', 'on', 'yes', 'true', '1')
class Script:
"""Free script building system"""
def _checkPromise(self, promise_key, location):
......@@ -163,7 +165,7 @@ class Script:
raise zc.buildout.UserError('Promise not met, found issues:\n %s' %
' '.join([q + '\n' for q in promise_problem_list]))
def download(self, url, md5sum):
def download(self, url, md5sum=None):
download = zc.buildout.download.Download(self.buildout['buildout'],
hash_name=True, cache=self.buildout['buildout'].get('download-cache'))
path, is_temp = download(url, md5sum=md5sum)
......@@ -247,7 +249,11 @@ class Script:
self.options[k] = self.options.get(k, '').strip()
self.options['script'] = self.options.get('script', self.script) % \
self.options
if self.options.get('keep-on-error', '').strip().lower() in TRUE_LIST:
self.logger.debug('Keeping directories in case of errors')
self.keep_on_error = True
else:
self.keep_on_error = False
def getEnvironment(self):
# prepare cool dictionary
wanted_env = {}
......@@ -259,7 +265,7 @@ class Script:
raise zc.buildout.UserError('Line %r in environment is incorrect' %
line)
key, value = line.split('=')
key, value = line.split('=', 1)
key = key.strip()
value = value.strip()
if key in wanted_env:
......@@ -293,8 +299,11 @@ class Script:
finally:
for d in self.cleanup_dir_list:
if os.path.exists(d):
self.logger.debug('Cleanup directory %r' % d)
shutil.rmtree(d)
if not self.keep_on_error:
self.logger.debug('Cleanup directory %r' % d)
shutil.rmtree(d)
else:
self.logger.info('Left directory %r as requested' % d)
return [self.options['location']]
......@@ -316,25 +325,60 @@ class Script:
self.logger.debug('Cleanup directory %r' % d)
shutil.rmtree(d)
def applyPatchList(self, patch_string, patch_options=None, patch_binary=None, cwd=None):
if patch_string is not None:
if patch_options is None:
patch_options = []
else:
patch_options = patch_options.split(' ')
if patch_binary is None:
patch_binary = 'patch'
kwargs = dict()
if cwd is not None:
kwargs['cwd'] = cwd
for patch in patch_string.splitlines():
patch = patch.strip()
if patch:
if ' ' in patch:
patch, md5sum = patch.split(' ', 1)
md5sum = md5sum.strip()
if md5sum.lower() == 'unknown':
md5sum = None
else:
md5sum = None
if md5sum is not None and ' ' in md5sum:
md5sum, patch_options = md5sum.split(' ', 1)
patch_options = patch_options.split(' ')
kwargs['stdin'] = open(self.download(patch, md5sum))
self.logger.info('Applying patch %r' % patch)
call([patch_binary] + patch_options, **kwargs)
class Cmmi(Script):
"""Simple configure-make-make-insall compatible with hexagonit.recipe.cmmi
"""Simple configure-make-make-install compatible with hexagonit.recipe.cmmi
Compatibility on parameter level, without bug-to-bug, hack-to-hack"""
Compatibility on parameter level"""
script = """
url = self.download(self.options['url']
md5sum = self.options.get('md5sum')
extract_dir = self.extract(url, md5sum)
url = self.download(self.options['url'], self.options.get('md5sum'))
extract_dir = self.extract(url)
workdir = guessworkdir(extract_dir)
configure_command = ["./configure", "--prefix=%(location)s"]
configure_command.extend(%(configure-options)r.split())
self.logger.info('Configuring with: %%s' %% configure_command)
configure_command = self.options.get('configure-command')
if configure_command is None or configure_command.lower() == 'None':
configure_command = ["./configure", "--prefix=%(location)s"] + %(configure-options)r.split()
else:
configure_command = configure_command.split(' ')
self.logger.info('Configuring with: %%r' %% ' '.join(configure_command))
self.applyPatchList(self.options.get('patches'), self.options.get('patch-options'), self.options.get('patch-binary'), workdir)
call(configure_command, cwd=workdir, env=env)
self.logger.info('Building')
call("make", cwd=workdir, env=env)
self.logger.info('Installing')
call(["make", "install"], cwd=workdir, env=env)
make_command = [self.options.get('make-binary', "make")]
make_options = self.options.get('make-options')
if make_options is not None:
make_command.extend(make_options.split(' '))
self.logger.info('Building with %%r' %% ' '.join(make_command))
call(make_command, cwd=workdir, env=env)
make_command.append('install')
self.logger.info('Installing with %%r' %% ' '.join(make_command))
call(make_command + ['install'], cwd=workdir, env=env)
"""
def __init__(self, buildout, name, options):
......
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