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

Implement more of compatibility with known recipes.

Squashed commit of the following:

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

    Explain more about patches.

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

    Provide better looking patches.

commit c6befb0568e21d95ee2b9e96a0490dadf96b7c06
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 d2212cb7fa4e7d31af671b33b32fdf97094f7e6e
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 17:04:05 2011 +0200

    Allow to override configure command.

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

    Share applyPatchList with in base class.

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

    Support no md5sum.

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

    Show how to patch.

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

    Allow options per patch.

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

    Allow patching.

commit 8934eb92f100e5f7916bdea0bffd65287cee7558
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 74d0b2bd41a827646a1a1fb851f0dbe8185a4965
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 034c238125fd040c39c87afce6ea4aa6150ed059
Author: Łukasz Nowak <luke@nexedi.com>
Date:   Tue Sep 6 16:17:07 2011 +0200

    Another typo.

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

    Follow fixed typo.

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

    Extract does not need md5sum.

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

    Pass md5sum directly.

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

    Allow to pass empty md5sum.

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

    Fix typos.

commit 8919378ddc44169af07426a5cce6aa55b064f9c9
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